RetryTestViewModel.cs 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  1. using AutoMapper;
  2. using BizService;
  3. using Microsoft.Extensions.Logging;
  4. using Model.Dto;
  5. using Model.Entities;
  6. using Newtonsoft.Json;
  7. using PLCTool.Common;
  8. using PLCTool.Events;
  9. using Prism.Commands;
  10. using Prism.Events;
  11. using Prism.Mvvm;
  12. using Prism.Services.Dialogs;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Collections.ObjectModel;
  16. using System.ComponentModel;
  17. using System.Configuration;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. using System.Windows;
  22. namespace PLCTool.ViewModels.BusinessManageViewModel
  23. {
  24. public class RetryTestViewModel : BindableBase, IDialogAware
  25. {
  26. private readonly IDialogService _dialog;
  27. private readonly IEventAggregator _aggregator;
  28. private readonly IOptionConfigService _optionConfigService;
  29. private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
  30. private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
  31. private readonly IBizTestRecordService _iBizTestRecordService;
  32. private readonly IBizTestRecordDtlService _iBizTestRecordDtlService;
  33. private readonly IMapper _mapper;
  34. private readonly ILogger _logger;
  35. private List<OptionConfigDto> _optionConfigs;
  36. private DateTime startTime = DateTime.Now;
  37. private DateTime endTime = DateTime.Now;
  38. private int testStatus = 0; //测试状态
  39. private int testResult = 0; //测试结果
  40. private long schId = 0; //方案ID
  41. private long globalSchDetailId = 0; //测试方案明细ID
  42. private long globalDeviceId = 0; //设备ID
  43. private BizTestRecordDtlDto bizTestRecordDtlDto = new BizTestRecordDtlDto(); //测试方案明细表
  44. private const string TestMode = "重新测试";
  45. private int defaultDelayTime = Convert.ToInt32(ConfigurationManager.AppSettings["DelayTime"]);
  46. private int delayTime;
  47. public RetryTestViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, ILogger logger)
  48. {
  49. _dialog = dialog;
  50. _aggregator = aggregator;
  51. _optionConfigService = optionConfigService;
  52. _basicPlcTestSchemeService = basicPlcTestSchemeService;
  53. _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
  54. _iBizTestRecordDtlService = iBizTestRecordDtlService;
  55. _iBizTestRecordService = iBizTestRecordService;
  56. _mapper = mapper;
  57. _logger = logger;
  58. CloseCommand = new DelegateCommand(Close);
  59. StartCommand = new DelegateCommand<object>(Start);
  60. PreviousCommand = new DelegateCommand<object>(Previous);
  61. NextCommand = new DelegateCommand<object>(Next);
  62. DoneCommand = new DelegateCommand<object>(Done);
  63. ItemChangeCommand = new DelegateCommand(ItemChange);
  64. BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
  65. InConList = new ObservableCollection<BasPlcItemConfigDto>();
  66. OutConList = new ObservableCollection<BasPlcItemConfigDto>();
  67. GetConfigOption();
  68. }
  69. /// <summary>
  70. /// 选中测试项
  71. /// </summary>
  72. private void ItemChange()
  73. {
  74. var findDtlMsg = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.FirstOrDefault(X => X.item_name == SelectItem);
  75. if (findDtlMsg != null)
  76. {
  77. int id = Convert.ToInt32(findDtlMsg.scheme_dtl_id);
  78. // 根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
  79. globalSchDetailId = id;
  80. GetDetailInfo(id);
  81. }
  82. }
  83. #region idialog接口实现
  84. public string Title { set; get; } = "手动测试";
  85. public event Action<IDialogResult> RequestClose;
  86. public bool CanCloseDialog()
  87. {
  88. return true;
  89. }
  90. public void OnDialogClosed()
  91. {
  92. }
  93. public void OnDialogOpened(IDialogParameters parameters)
  94. {
  95. //编辑
  96. var getMsg = parameters.GetValues<long>("Key");
  97. ///值不为空,表示修改
  98. if (getMsg != null)
  99. {
  100. foreach (var item in getMsg)
  101. {
  102. //测试方案号
  103. schId = item;
  104. var schDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId).OrderBy(x => x.sort).ThenBy(x => x.scheme_dtl_id).ToList();
  105. //不合格项目集合
  106. List<bas_plc_test_scheme_dtl> reTrysList = new List<bas_plc_test_scheme_dtl>();
  107. //查找不合格项目
  108. foreach (var sch in schDtls)
  109. {
  110. long dtlId = sch.scheme_dtl_id;
  111. var dtlResult = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(dtlId)?.OrderByDescending(x => x.start_test_time)?.ToArray();
  112. if ((dtlResult != null) && (dtlResult.Length != 0))
  113. {
  114. //时间最新的结果 ,不通过
  115. if (dtlResult[0].test_result == 0)
  116. {
  117. SchItems.Add(sch.item_name);
  118. reTrysList.Add(sch);
  119. }
  120. }
  121. }
  122. //默认显示第一个测试项的信息
  123. if (reTrysList.Count != 0)
  124. {
  125. int id = Convert.ToInt32(reTrysList[0].scheme_dtl_id);
  126. globalSchDetailId = id;
  127. // 根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
  128. GetDetailInfo(id);
  129. SelectItemIndex = 0;
  130. }
  131. }
  132. }
  133. //获取设备id
  134. var getDes = parameters.GetValues<long>("Key2");
  135. if (getDes != null)
  136. {
  137. foreach (var item in getDes)
  138. {
  139. globalDeviceId = item;
  140. }
  141. }
  142. }
  143. /// <summary>
  144. /// 发送log之界面显示
  145. /// </summary>
  146. /// <param name="msg"></param>
  147. private void SendLogToDis(string msg)
  148. {
  149. _aggregator.GetEvent<LogEvent>().Publish(new LogMessage
  150. {
  151. LogTime = DateTime.Now,
  152. LogMsg = msg
  153. });
  154. }
  155. /// <summary>
  156. /// //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
  157. /// </summary>
  158. /// <param name="id"></param>
  159. private void GetDetailInfo(int schDetailId)
  160. {
  161. //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
  162. var findEntity = _basicPlcTestSchemeDtlService.Find(schDetailId);
  163. var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
  164. if (findresult != null)
  165. {
  166. //根据方案id 在方案表中查找方案名 设备名
  167. schId = findresult.SchemeId.Value; //方案id,方便下一步查找
  168. int intSchId = Convert.ToInt32(findresult.SchemeId);
  169. var findSch = _basicPlcTestSchemeService.Find(intSchId);
  170. if (findSch != null)
  171. {
  172. ScheduleName = findSch.scheme_name;
  173. DeviceKindName = findSch.devicekind_name;
  174. }
  175. TestName = findresult.ItemName;
  176. SelectTest = findresult.ItemType;
  177. //测试时间
  178. if (findresult.ItemTime == 0)
  179. {
  180. delayTime = defaultDelayTime;
  181. }
  182. else
  183. {
  184. delayTime = findresult.ItemTime;
  185. }
  186. //前置项解析
  187. string preconStr = findresult.Precondition.ToString();
  188. if (!string.IsNullOrEmpty(preconStr))
  189. {
  190. JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
  191. BeforeSelectJudge = preconditionModel.ItemType;
  192. SelectLogic = preconditionModel.ItemLogical;
  193. BeforeDetail = preconditionModel.Description;
  194. BeforeConList.Clear();
  195. foreach (var detail in preconditionModel.DetailInfo)
  196. {
  197. BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
  198. basPlcItemConfigDto.Id = detail.Id;
  199. basPlcItemConfigDto.PlcItem = detail.PlcItem;
  200. basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
  201. basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
  202. basPlcItemConfigDto.PlcValue = detail.PlcValue;
  203. basPlcItemConfigDto.Remark = detail.Remark;
  204. BeforeConList.Add(basPlcItemConfigDto);
  205. }
  206. }
  207. //输入项解析
  208. string inStr = findresult.Action.ToString();
  209. if (!string.IsNullOrEmpty(inStr))
  210. {
  211. JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
  212. SelectInJudge = inModel.ItemType;
  213. InSelectLogic = inModel.ItemLogical;
  214. InDetail = inModel.Description;
  215. InConList.Clear();
  216. foreach (var detail in inModel.DetailInfo)
  217. {
  218. BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
  219. basPlcItemConfigDto.Id = detail.Id;
  220. basPlcItemConfigDto.PlcItem = detail.PlcItem;
  221. basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
  222. basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
  223. basPlcItemConfigDto.PlcValue = detail.PlcValue;
  224. basPlcItemConfigDto.Remark = detail.Remark;
  225. InConList.Add(basPlcItemConfigDto);
  226. }
  227. }
  228. //输出项解析
  229. string outStr = findresult.JudgementResult.ToString();
  230. if (!string.IsNullOrEmpty(outStr))
  231. {
  232. JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
  233. SelectOutJudge = outModel.ItemType;
  234. OutSelectLogic = outModel.ItemLogical;
  235. OutDetail = outModel.Description;
  236. OutConList.Clear();
  237. foreach (var detail in outModel.DetailInfo)
  238. {
  239. BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
  240. basPlcItemConfigDto.Id = detail.Id;
  241. basPlcItemConfigDto.PlcItem = detail.PlcItem;
  242. basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
  243. basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
  244. basPlcItemConfigDto.PlcValue = detail.PlcValue;
  245. basPlcItemConfigDto.Remark = detail.Remark;
  246. OutConList.Add(basPlcItemConfigDto);
  247. }
  248. }
  249. }
  250. }
  251. #endregion
  252. #region 私有发方法
  253. /// <summary>
  254. /// 增加或更新测试记录
  255. /// </summary>
  256. private void AddTestRecord()
  257. {
  258. //记录记录主表中是否有这个方案的记录,没有则添加
  259. var findRecord = _iBizTestRecordService.FindRecorddByDeviceIdAndSchname(globalDeviceId, ScheduleName);
  260. if (findRecord == null)
  261. {
  262. //状态status 没有赋值
  263. BizTestRecordDto bizTestRecordDto = new BizTestRecordDto();
  264. bizTestRecordDto.RecordName = ScheduleName + "_Record";
  265. bizTestRecordDto.SchemeName = ScheduleName;
  266. bizTestRecordDto.DeviceId = globalDeviceId;
  267. bizTestRecordDto.Tester = Appsession.UserName;
  268. bizTestRecordDto.StartTestTime = startTime;
  269. bizTestRecordDto.FinishTestTime = endTime;
  270. bizTestRecordDto.CreateBy = Appsession.UserName;
  271. bizTestRecordDto.CreateTime = DateTime.Now;
  272. bizTestRecordDto.UpdateBy = Appsession.UserName;
  273. bizTestRecordDto.UpdateTime = DateTime.Now;
  274. var testRecord = _mapper.Map<BizTestRecordDto, biz_test_record>(bizTestRecordDto);
  275. _iBizTestRecordService.Add(testRecord);
  276. }
  277. }
  278. /// <summary>
  279. /// 获取记录明细
  280. /// </summary>
  281. private void AddDtltRecord(long schDetailId)
  282. {
  283. //查找record ID
  284. long recordId = 0;
  285. var findRecordID = _iBizTestRecordService.FindRecorddByDeviceIdAndSchname(globalDeviceId, ScheduleName);
  286. if (findRecordID != null)
  287. {
  288. recordId = findRecordID.record_id;
  289. }
  290. testStatus = 99;//测试状态赋值为99
  291. //状态status 没有赋值
  292. DateTime finishTime = DateTime.Now;
  293. bizTestRecordDtlDto.RecordId = recordId;
  294. bizTestRecordDtlDto.SchemeDtlId = schDetailId;
  295. bizTestRecordDtlDto.StartTestTime = startTime;
  296. bizTestRecordDtlDto.FinishTestTime = endTime;
  297. bizTestRecordDtlDto.TestMode = TestMode;
  298. bizTestRecordDtlDto.Status = testStatus;
  299. bizTestRecordDtlDto.TestResult = GetTestResult();
  300. bizTestRecordDtlDto.CreateBy = Appsession.UserName;
  301. bizTestRecordDtlDto.CreateTime = startTime;
  302. bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
  303. bizTestRecordDtlDto.UpdateTime = DateTime.Now;
  304. var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
  305. _iBizTestRecordDtlService.Add(testRecordDtl);
  306. //跟新测试记录的_iBizTestRecord的完成时间
  307. var findRecord = _iBizTestRecordService.Find((int)recordId);
  308. if (findRecord != null)
  309. {
  310. findRecord.finish_test_time = finishTime;
  311. _iBizTestRecordService.Edit(findRecord);
  312. }
  313. }
  314. /// <summary>
  315. /// 前置项结果判定
  316. /// </summary>
  317. /// <returns></returns>
  318. private int GetPrecedtionResult()
  319. {
  320. //前置项
  321. int beforeResult = 0;
  322. if (BeforeConList.Count == 0)
  323. {
  324. beforeResult = 1;
  325. }
  326. else
  327. {
  328. if (SelectLogic == "OR")
  329. {
  330. var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
  331. if (find != null)
  332. {
  333. beforeResult = 1;
  334. }
  335. else
  336. {
  337. beforeResult = 0;
  338. }
  339. }
  340. else
  341. {
  342. if (SelectLogic == "AND" || SelectLogic == "ONLY")
  343. {
  344. var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
  345. if (find != null)
  346. {
  347. beforeResult = 0;
  348. }
  349. else
  350. {
  351. beforeResult = 1;
  352. }
  353. }
  354. else
  355. {
  356. if (SelectLogic == "NULL")
  357. {
  358. beforeResult = 1;
  359. }
  360. }
  361. }
  362. }
  363. return beforeResult;
  364. }
  365. /// <summary>
  366. /// 判定结果
  367. /// </summary>
  368. /// <returns></returns>
  369. private int GetTestResult()
  370. {
  371. //前置项
  372. int beforeResult = 0;
  373. int inResult = 0;
  374. int outResult = 0;
  375. if (BeforeConList.Count == 0)
  376. {
  377. beforeResult = 1;
  378. }
  379. else
  380. {
  381. if (SelectLogic == "OR")
  382. {
  383. var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
  384. if (find != null)
  385. {
  386. beforeResult = 1;
  387. }
  388. else
  389. {
  390. beforeResult = 0;
  391. }
  392. }
  393. else
  394. {
  395. if (SelectLogic == "AND" || SelectLogic == "ONLY")
  396. {
  397. var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
  398. if (find != null)
  399. {
  400. beforeResult = 0;
  401. }
  402. else
  403. {
  404. beforeResult = 1;
  405. }
  406. }
  407. else
  408. {
  409. if (SelectLogic == "NULL")
  410. {
  411. beforeResult = 1;
  412. }
  413. }
  414. }
  415. }
  416. //输入项
  417. if (InConList.Count == 0)
  418. {
  419. inResult = 1;
  420. }
  421. else
  422. {
  423. if (InSelectLogic == "OR")
  424. {
  425. var find = InConList.FirstOrDefault(x => x.TestResult == "通过");
  426. if (find != null)
  427. {
  428. inResult = 1;
  429. }
  430. else
  431. {
  432. inResult = 0;
  433. }
  434. }
  435. else
  436. {
  437. if (InSelectLogic == "AND" || InSelectLogic == "ONLY")
  438. {
  439. var find = InConList.FirstOrDefault(x => x.TestResult == "不通过");
  440. if (find != null)
  441. {
  442. inResult = 0;
  443. }
  444. else
  445. {
  446. inResult = 1;
  447. }
  448. }
  449. else
  450. {
  451. if (InSelectLogic == "NULL")
  452. {
  453. inResult = 1;
  454. }
  455. }
  456. }
  457. }
  458. //输出项
  459. if (OutConList.Count == 0)
  460. {
  461. outResult = 1;
  462. }
  463. else
  464. {
  465. if (OutSelectLogic == "OR")
  466. {
  467. var find = OutConList.FirstOrDefault(x => x.TestResult == "通过");
  468. if (find != null)
  469. {
  470. outResult = 1;
  471. }
  472. else
  473. {
  474. outResult = 0;
  475. }
  476. }
  477. else
  478. {
  479. if (OutSelectLogic == "AND" || OutSelectLogic == "ONLY")
  480. {
  481. var find = OutConList.FirstOrDefault(x => x.TestResult == "不通过");
  482. if (find != null)
  483. {
  484. outResult = 0;
  485. }
  486. else
  487. {
  488. outResult = 1;
  489. }
  490. }
  491. else
  492. {
  493. if (OutSelectLogic == "NULL")
  494. {
  495. outResult = 1;
  496. }
  497. }
  498. }
  499. }
  500. if (beforeResult == 1 && inResult == 1 && outResult == 1)
  501. {
  502. return 1;
  503. }
  504. else
  505. {
  506. return 0;
  507. }
  508. }
  509. /// <summary>
  510. /// 更新测试记录
  511. /// </summary>
  512. private void UpdateTesDtltRecord()
  513. {
  514. var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
  515. _iBizTestRecordDtlService.Edit(testRecordDtl);
  516. }
  517. /// <summary>
  518. /// 完成时间
  519. /// </summary>
  520. /// <param name="obj"></param>
  521. private void Done(object obj)
  522. {
  523. endTime = DateTime.Now;
  524. RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
  525. }
  526. private void Next(object obj)
  527. {
  528. StepIndex = 0;
  529. ///查找方案下的所有方案明细,并排序,
  530. var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderBy(x => x.sort).ThenBy(x => x.scheme_dtl_id);
  531. foreach (var item in basicSchDtls)
  532. {
  533. //在测试结果明细中查看
  534. long schDetailId = item.scheme_dtl_id;
  535. if (schDetailId > globalSchDetailId)
  536. {
  537. globalSchDetailId = schDetailId;
  538. int id = Convert.ToInt32(schDetailId);
  539. SelectItemIndex++;
  540. //界面显示
  541. GetDetailInfo(id);
  542. //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
  543. break;
  544. }
  545. long maxDtlId = basicSchDtls.Select(x => x.scheme_dtl_id).Max();
  546. if (globalSchDetailId == maxDtlId)
  547. {
  548. MessageBox.Show("已是此测试方案最后一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
  549. break;
  550. }
  551. }
  552. }
  553. private void Previous(object obj)
  554. {
  555. StepIndex = 0;
  556. ///查找方案下的所有方案明细,并排序,
  557. var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderByDescending(x => x.sort).ThenByDescending(x=>x.scheme_dtl_id);
  558. foreach (var item in basicSchDtls)
  559. {
  560. //在测试结果明细中查看
  561. long schDetailId = item.scheme_dtl_id;
  562. if (schDetailId < globalSchDetailId)
  563. {
  564. globalSchDetailId = schDetailId;
  565. int id = Convert.ToInt32(schDetailId);
  566. SelectItemIndex--;
  567. //界面显示
  568. GetDetailInfo(id);
  569. //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
  570. break;
  571. }
  572. }
  573. long maxDtlId = basicSchDtls.Select(x => x.scheme_dtl_id).Min();
  574. if (globalSchDetailId == maxDtlId)
  575. {
  576. SelectItemIndex = 0;
  577. MessageBox.Show("已是此测试方案的第一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
  578. }
  579. }
  580. /// <summary>
  581. /// 开始检测
  582. /// </summary>
  583. /// <param name="obj"></param>
  584. private async void Start(object obj)
  585. {
  586. StartEnalbe = false;
  587. _logger.LogInformation($"开始手动测试。方案名{ScheduleName},测试项{TestName}");
  588. SendLogToDis($"开始手动测试。方案名{ScheduleName},测试项{TestName}");
  589. //开始时间
  590. startTime = DateTime.Now;
  591. //增加测试记录主表
  592. AddTestRecord();
  593. //前置项
  594. bool preBool = TestPreceditionMethod();
  595. if (!preBool)
  596. {
  597. StepIndex = 0;
  598. StartEnalbe = true;
  599. return;
  600. }
  601. //输入项
  602. bool isAction = TestActionMethod();
  603. if (!isAction)
  604. {
  605. StepIndex = 0;
  606. StartEnalbe = true;
  607. return;
  608. }
  609. //前置项结果判断
  610. int preceditionResult = GetPrecedtionResult();
  611. if (preceditionResult == 0)
  612. {
  613. MessageBoxResult boxResult = MessageBox.Show("前置项条件不满足,请确认前置条件!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
  614. StartEnalbe = true;
  615. return;
  616. }
  617. //输出项
  618. bool isJudgeResult = await TestJudgementMethod();
  619. if (!isJudgeResult)
  620. {
  621. StepIndex = 0;
  622. StartEnalbe = true;
  623. return;
  624. }
  625. //将测试结果添加到数据库
  626. AddDtltRecord(globalSchDetailId);
  627. SendLogToDis($"手动测试完成。方案名{ScheduleName},测试项{TestName}");
  628. _logger.LogInformation($"手动测试完成。方案名{ScheduleName},测试项{TestName}");
  629. StartEnalbe = true;
  630. }
  631. /// <summary>
  632. /// 更新测试结果
  633. /// </summary>
  634. private void UpdateTestRecord()
  635. {
  636. }
  637. /// <summary>
  638. /// 测试前置项目
  639. /// </summary>
  640. private bool TestPreceditionMethod()
  641. {
  642. switch (BeforeSelectJudge)
  643. {
  644. case "人工判定":
  645. //弹出确认的对话框
  646. if (string.IsNullOrEmpty(BeforeDetail))
  647. {
  648. return true;
  649. }
  650. MessageBoxResult boxResult = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  651. if (boxResult == MessageBoxResult.OK)
  652. {
  653. //前置项测试结果json转化
  654. string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
  655. //json字符串
  656. bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
  657. bizTestRecordDtlDto.PreconditionResult = "通过";
  658. StepIndex = 1;
  659. }
  660. else
  661. {
  662. return false;
  663. }
  664. break;
  665. case "自动判定":
  666. //读取plc的值
  667. switch (SelectLogic)
  668. {
  669. case "NULL":
  670. //弹出确认的对话框
  671. if (string.IsNullOrEmpty(BeforeDetail))
  672. {
  673. return true;
  674. }
  675. MessageBoxResult boxResultAuto = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  676. if (boxResultAuto == MessageBoxResult.OK)
  677. {
  678. //前置项测试结果json转化
  679. string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
  680. //json字符串
  681. bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
  682. bizTestRecordDtlDto.PreconditionResult = "通过";
  683. StepIndex = 1;
  684. }
  685. else
  686. {
  687. return false;
  688. }
  689. break;
  690. case "AND":
  691. case "ONLY":
  692. case "OR":
  693. ReadPredice(SelectLogic);
  694. break;
  695. case "ORDER":
  696. break;
  697. }
  698. break;
  699. }
  700. return true;
  701. }
  702. private void ReadPredice(string strLogic)
  703. {
  704. int countCond = 0;
  705. foreach (var item in BeforeConList.OrderBy(x => x.Id))
  706. {
  707. string plcAddress = item.PlcAddress;
  708. string plcAddType = item.PlcAddType;
  709. string plcValue = item.PlcValue;
  710. switch (plcAddType)
  711. {
  712. case "bool":
  713. string readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
  714. ///实时值记录
  715. item.RealValue = readResult;
  716. item.TestTime = DateTime.Now;
  717. if (readResult.Trim() == plcValue?.Trim())
  718. {
  719. item.TestResult = "通过";
  720. countCond++;
  721. }
  722. else
  723. {
  724. item.TestResult = "不通过";
  725. }
  726. break;
  727. case "word":
  728. break;
  729. }
  730. }
  731. //测试记录存入数据库
  732. //前置项测试结果json转化
  733. string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
  734. //json字符串
  735. bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
  736. //条件满足
  737. switch (strLogic)
  738. {
  739. case "AND":
  740. case "ONLY":
  741. if ((countCond == BeforeConList.Count) && (countCond != 0))
  742. {
  743. bizTestRecordDtlDto.PreconditionResult = "通过";
  744. }
  745. else
  746. {
  747. bizTestRecordDtlDto.PreconditionResult = "不通过";
  748. }
  749. break;
  750. case "OR":
  751. if ((countCond != 0))
  752. {
  753. bizTestRecordDtlDto.PreconditionResult = "通过";
  754. }
  755. else
  756. {
  757. bizTestRecordDtlDto.PreconditionResult = "不通过";
  758. }
  759. break;
  760. }
  761. StepIndex = 1;
  762. }
  763. /// <summary>
  764. /// 输入项写入
  765. /// </summary>
  766. private bool TestActionMethod()
  767. {
  768. bool isActionResult = true;
  769. switch (SelectInJudge)
  770. {
  771. case "人工判定":
  772. //弹出确认的对话框
  773. MessageBoxResult boxResult = MessageBox.Show(InDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  774. if (boxResult == MessageBoxResult.OK)
  775. {
  776. //前置项测试结果json转化
  777. string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
  778. //json字符串
  779. bizTestRecordDtlDto.ActionFinal = actionJsonStr;
  780. bizTestRecordDtlDto.ActionResult = "通过";
  781. StepIndex = 2;
  782. }
  783. else
  784. {
  785. isActionResult = false;
  786. }
  787. break;
  788. case "自动判定":
  789. //读取plc的值
  790. switch (InSelectLogic)
  791. {
  792. case "NULL":
  793. //弹出确认的对话框
  794. MessageBoxResult boxResultAction = MessageBox.Show(InDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  795. if (boxResultAction == MessageBoxResult.OK)
  796. {
  797. //前置项测试结果json转化
  798. string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
  799. //json字符串
  800. bizTestRecordDtlDto.ActionFinal = actionJsonStr;
  801. bizTestRecordDtlDto.ActionResult = "通过";
  802. StepIndex = 2;
  803. }
  804. else
  805. {
  806. isActionResult = false;
  807. }
  808. break;
  809. case "AND":
  810. case "ONLY":
  811. case "OR":
  812. isActionResult = SendActionToPLC(InSelectLogic);
  813. break;
  814. case "ORDER":
  815. break;
  816. }
  817. break;
  818. }
  819. return isActionResult;
  820. }
  821. /// <summary>
  822. /// 发送命令给PLC
  823. /// </summary>
  824. private bool SendActionToPLC(string strActionLogic)
  825. {
  826. bool isAction = true;
  827. int countCond = 0;
  828. foreach (var item in InConList.OrderBy(x => x.Id))
  829. {
  830. string plcAddress = item.PlcAddress;
  831. string plcAddType = item.PlcAddType;
  832. string plcValue = item.PlcValue;
  833. switch (plcAddType)
  834. {
  835. case "bool":
  836. DialogParameters parm = new DialogParameters();
  837. parm.Add("Key", plcAddress);
  838. parm.Add("Key2", plcValue);
  839. //弹出写入对话框
  840. _dialog.ShowDialog("WritePLCView", parm, async callback =>
  841. {
  842. if (callback.Result == ButtonResult.OK)
  843. {
  844. string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
  845. bool writeResult = PLCConnectionFactory.CreatePLCCont().WritePlcObject(plcAddress, VarType.Bit, plcRealValue);
  846. ///实时值记录
  847. item.RealValue = plcRealValue;
  848. item.TestTime = DateTime.Now;
  849. if (writeResult)
  850. {
  851. ///单个测试项通过
  852. item.TestResult = "通过";
  853. countCond++;
  854. }
  855. else
  856. {
  857. item.TestResult = "不通过";
  858. }
  859. }
  860. else
  861. {
  862. isAction = false;
  863. }
  864. });
  865. break;
  866. case "word":
  867. DialogParameters parm2 = new DialogParameters();
  868. parm2.Add("Key", plcAddress);
  869. parm2.Add("Key2", plcValue);
  870. //弹出写入对话框
  871. _dialog.ShowDialog("WritePLCView", parm2, async callback =>
  872. {
  873. if (callback.Result == ButtonResult.OK)
  874. {
  875. string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
  876. bool writeResult = PLCConnectionFactory.CreatePLCCont().WritePlcObject(plcAddress, VarType.Word, plcRealValue);
  877. ///实时值记录
  878. item.RealValue = plcRealValue;
  879. item.TestTime = DateTime.Now;
  880. if (writeResult)
  881. {
  882. ///单个测试项通过
  883. item.TestResult = "通过";
  884. countCond++;
  885. }
  886. else
  887. {
  888. item.TestResult = "不通过";
  889. }
  890. }
  891. else
  892. {
  893. isAction = false;
  894. }
  895. });
  896. break;
  897. }
  898. }
  899. if (!isAction)
  900. {
  901. return isAction;
  902. }
  903. //测试记录存入数据库
  904. //前置项测试结果json转化
  905. string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
  906. //json字符串
  907. bizTestRecordDtlDto.ActionFinal = actionJsonStr;
  908. //条件满足
  909. //条件满足
  910. switch (strActionLogic)
  911. {
  912. case "AND":
  913. case "ONLY":
  914. if ((countCond == BeforeConList.Count) && (countCond != 0))
  915. {
  916. bizTestRecordDtlDto.ActionResult = "通过";
  917. }
  918. else
  919. {
  920. bizTestRecordDtlDto.ActionResult = "不通过";
  921. }
  922. break;
  923. case "OR":
  924. if ((countCond != 0))
  925. {
  926. bizTestRecordDtlDto.ActionResult = "通过";
  927. }
  928. else
  929. {
  930. bizTestRecordDtlDto.ActionResult = "不通过";
  931. }
  932. break;
  933. }
  934. StepIndex = 2;
  935. return isAction;
  936. }
  937. /// <summary>
  938. /// 结果项判定
  939. /// </summary>
  940. private async Task<bool> TestJudgementMethod()
  941. {
  942. bool isJudge = true;
  943. switch (SelectOutJudge)
  944. {
  945. case "人工判定":
  946. //弹出确认的对话框
  947. MessageBoxResult boxResult = MessageBox.Show(OutDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  948. if (boxResult == MessageBoxResult.OK)
  949. {
  950. bizTestRecordDtlDto.JudgementResult = "通过";
  951. StepIndex = 3;
  952. }
  953. else
  954. {
  955. isJudge = false;
  956. }
  957. break;
  958. case "自动判定":
  959. //读取plc的值
  960. switch (OutSelectLogic)
  961. {
  962. case "NULL":
  963. bizTestRecordDtlDto.JudgementResult = "通过";
  964. StepIndex = 3;
  965. break;
  966. case "AND":
  967. case "ONLY":
  968. case "OR":
  969. await ReadJudge(OutSelectLogic);
  970. break;
  971. case "ORDER":
  972. break;
  973. }
  974. break;
  975. }
  976. //更新测试记录
  977. //更新测试记录
  978. endTime = DateTime.Now;
  979. return isJudge;
  980. }
  981. /// <summary>
  982. /// 读取结果
  983. /// </summary>
  984. private async Task ReadJudge(String strLogic)
  985. {
  986. int countCond = 0;
  987. DateTime entryTime = DateTime.Now;
  988. foreach (var item in OutConList.OrderBy(x => x.Id))
  989. {
  990. string plcAddress = item.PlcAddress;
  991. string plcAddType = item.PlcAddType;
  992. string plcValue = item.PlcValue;
  993. switch (plcAddType)
  994. {
  995. case "bool":
  996. string readResult = string.Empty;
  997. //一直读
  998. await Task.Run(async () =>
  999. {
  1000. while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
  1001. {
  1002. //显示进度条
  1003. System.Windows.Application.Current.Dispatcher.Invoke((delegate
  1004. {
  1005. ProVisibility = Visibility.Visible;
  1006. }));
  1007. //先延时,在读取,避免读取传感器刚开始的数据
  1008. await Task.Delay(1000);
  1009. readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
  1010. if (readResult == item.PlcValue)
  1011. {
  1012. break;
  1013. }
  1014. }
  1015. });
  1016. //可能有多个条件判定的,第二次时间到了直接跳出延时,直接读取,不用在延时20s
  1017. readResult = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Bit);
  1018. ProVisibility = Visibility.Hidden;
  1019. ///实时值记录
  1020. item.RealValue = readResult;
  1021. item.TestTime = DateTime.Now;
  1022. if (readResult.Trim() == plcValue?.Trim())
  1023. {
  1024. item.TestResult = "通过";
  1025. countCond++;
  1026. }
  1027. else
  1028. {
  1029. item.TestResult = "不通过";
  1030. }
  1031. break;
  1032. case "word":
  1033. // DateTime entryTime2 = DateTime.Now;
  1034. string readResult2 = string.Empty;
  1035. //一直读
  1036. await Task.Run(async () =>
  1037. {
  1038. while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
  1039. {
  1040. //显示进度条
  1041. System.Windows.Application.Current.Dispatcher.Invoke((delegate
  1042. {
  1043. ProVisibility = Visibility.Visible;
  1044. }));
  1045. readResult2 = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Word);
  1046. if (readResult2 == item.PlcValue)
  1047. {
  1048. break;
  1049. }
  1050. await Task.Delay(1000);
  1051. }
  1052. });
  1053. //可能有多个条件判定的,第二次直接跳出延时,直接读取
  1054. readResult2 = PLCConnectionFactory.CreatePLCCont().ReadPlcObject(plcAddress, VarType.Word);
  1055. ProVisibility = Visibility.Hidden;
  1056. ///实时值记录
  1057. item.RealValue = readResult2;
  1058. item.TestTime = DateTime.Now;
  1059. if (readResult2.Trim() == plcValue?.Trim())
  1060. {
  1061. item.TestResult = "通过";
  1062. countCond++;
  1063. }
  1064. else
  1065. {
  1066. item.TestResult = "不通过";
  1067. }
  1068. break;
  1069. }
  1070. }
  1071. //测试记录存入数据库
  1072. //输出项测试结果json转化
  1073. string prefixJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
  1074. //json字符串
  1075. bizTestRecordDtlDto.JudgementResultFinal = prefixJsonStr;
  1076. //条件满足
  1077. switch (strLogic)
  1078. {
  1079. case "AND":
  1080. case "ONLY":
  1081. if ((countCond == OutConList.Count) && (countCond != 0))
  1082. {
  1083. bizTestRecordDtlDto.JudgementResult = "通过";
  1084. }
  1085. else
  1086. {
  1087. bizTestRecordDtlDto.JudgementResult = "不通过";
  1088. }
  1089. break;
  1090. case "OR":
  1091. if (countCond != 0)
  1092. {
  1093. bizTestRecordDtlDto.JudgementResult = "通过";
  1094. }
  1095. else
  1096. {
  1097. bizTestRecordDtlDto.JudgementResult = "不通过";
  1098. }
  1099. break;
  1100. }
  1101. StepIndex = 3;
  1102. }
  1103. /// <summary>
  1104. /// 获取配置
  1105. /// </summary>
  1106. private void GetConfigOption()
  1107. {
  1108. var configList = _optionConfigService.QueryList();
  1109. _optionConfigs = _mapper.Map<List<OptionConfig>, List<OptionConfigDto>>(configList);
  1110. var tests = _optionConfigs.FindAll(x => x.TypeID == 1);
  1111. TestKinds = new List<string>();
  1112. foreach (var test in tests)
  1113. {
  1114. TestKinds.Add(test.ContentOption);
  1115. }
  1116. //测试项类型
  1117. var judges = _optionConfigs.FindAll(x => x.TypeID == 2);
  1118. foreach (var judge in judges)
  1119. {
  1120. BeforeJudgeKinds.Add(judge.ContentOption);
  1121. InJudgeKinds.Add(judge.ContentOption);
  1122. OutJudgeKinds.Add(judge.ContentOption);
  1123. }
  1124. //判定逻辑
  1125. var logics = _optionConfigs.FindAll(x => x.TypeID == 3);
  1126. foreach (var logic in logics)
  1127. {
  1128. JudgeLogicKinds.Add(logic.ContentOption);
  1129. InJudgeLogicKinds.Add(logic.ContentOption);
  1130. OutJudgeLogicKinds.Add(logic.ContentOption);
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 关闭按钮
  1135. /// </summary>
  1136. private void Close()
  1137. {
  1138. MessageBoxResult boxResult = MessageBox.Show("确认退出自动测试", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
  1139. if (boxResult == MessageBoxResult.OK)
  1140. {
  1141. RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
  1142. }
  1143. }
  1144. /// <summary>
  1145. /// mode转json
  1146. /// </summary>
  1147. /// <param name="itemType"></param>
  1148. /// <param name="itemLogical"></param>
  1149. /// <param name="description"></param>
  1150. /// <param name="conList"></param>
  1151. /// <returns></returns>
  1152. private string ModelToJsonToStr(string itemType, string itemLogical, string description, ObservableCollection<BasPlcItemConfigDto> conList)
  1153. {
  1154. JsonModel prefixJsonModel = new JsonModel();
  1155. prefixJsonModel.ItemType = itemType;
  1156. prefixJsonModel.ItemLogical = itemLogical;
  1157. prefixJsonModel.Description = description;
  1158. prefixJsonModel.DetailInfo = new List<DetailPLC>();
  1159. foreach (var item in conList)
  1160. {
  1161. DetailPLC plcItem = new DetailPLC();
  1162. plcItem.Id = item.Id;
  1163. plcItem.PlcItem = item.PlcItem;
  1164. plcItem.PlcAddress = item.PlcAddress;
  1165. plcItem.PlcAddType = item.PlcAddType;
  1166. plcItem.PlcValue = item.PlcValue;
  1167. plcItem.RealValue = item.RealValue;
  1168. plcItem.TestTime = item.TestTime;
  1169. plcItem.TestResult = item.TestResult;
  1170. plcItem.Remark = item.Remark;
  1171. prefixJsonModel.DetailInfo.Add(plcItem);
  1172. }
  1173. string prefixJsonStr = JsonConvert.SerializeObject(prefixJsonModel);
  1174. return prefixJsonStr;
  1175. }
  1176. #endregion
  1177. #region 命令绑定
  1178. public DelegateCommand CloseCommand { set; get; }
  1179. public DelegateCommand<object> StartCommand { set; get; }
  1180. public DelegateCommand<object> PreviousCommand { set; get; }
  1181. public DelegateCommand<object> NextCommand { set; get; }
  1182. public DelegateCommand<object> DoneCommand { set; get; }
  1183. public DelegateCommand ItemChangeCommand { set; get; }
  1184. #endregion
  1185. #region 变量绑定
  1186. /// <summary>
  1187. /// 测试方案编码
  1188. /// </summary>
  1189. private string scheduleName;
  1190. public string ScheduleName
  1191. {
  1192. get { return scheduleName; }
  1193. set { scheduleName = value; RaisePropertyChanged(); }
  1194. }
  1195. /// <summary>
  1196. /// 设备名称
  1197. /// </summary>
  1198. private string deviceKindName;
  1199. public string DeviceKindName
  1200. {
  1201. get { return deviceKindName; }
  1202. set { deviceKindName = value; RaisePropertyChanged(); }
  1203. }
  1204. /// <summary>
  1205. /// 测试项名称
  1206. /// </summary>
  1207. private string testName;
  1208. public string TestName
  1209. {
  1210. get { return testName; }
  1211. set { testName = value; RaisePropertyChanged(); }
  1212. }
  1213. /// <summary>
  1214. /// 测试项类型
  1215. /// </summary>
  1216. private List<string> testKinds = new List<string>();
  1217. public List<string> TestKinds
  1218. {
  1219. get { return testKinds; }
  1220. set { testKinds = value; RaisePropertyChanged(); }
  1221. }
  1222. /// <summary>
  1223. ///
  1224. /// </summary>
  1225. private string selectTest;
  1226. public string SelectTest
  1227. {
  1228. get { return selectTest; }
  1229. set { selectTest = value; RaisePropertyChanged(); }
  1230. }
  1231. /// <summary>
  1232. /// 判定类型(前置项)
  1233. /// </summary>
  1234. private List<string> beforeJudgeKinds = new List<string>();
  1235. public List<string> BeforeJudgeKinds
  1236. {
  1237. get { return beforeJudgeKinds; }
  1238. set { beforeJudgeKinds = value; RaisePropertyChanged(); }
  1239. }
  1240. private string beforeSelectJudge;
  1241. public string BeforeSelectJudge
  1242. {
  1243. get { return beforeSelectJudge; }
  1244. set { beforeSelectJudge = value; RaisePropertyChanged(); }
  1245. }
  1246. /// <summary>
  1247. /// 逻辑判断
  1248. /// </summary>
  1249. private List<string> judgeLogicKinds = new List<string>();
  1250. public List<string> JudgeLogicKinds
  1251. {
  1252. get { return judgeLogicKinds; }
  1253. set { judgeLogicKinds = value; RaisePropertyChanged(); }
  1254. }
  1255. private string selectLogic;
  1256. public string SelectLogic
  1257. {
  1258. get { return selectLogic; }
  1259. set { selectLogic = value; RaisePropertyChanged(); }
  1260. }
  1261. private string beforeDetail;
  1262. public string BeforeDetail
  1263. {
  1264. get { return beforeDetail; }
  1265. set { beforeDetail = value; RaisePropertyChanged(); }
  1266. }
  1267. private ObservableCollection<BasPlcItemConfigDto> beforeConList;
  1268. public ObservableCollection<BasPlcItemConfigDto> BeforeConList
  1269. {
  1270. get { return beforeConList; }
  1271. set { beforeConList = value; RaisePropertyChanged(); }
  1272. }
  1273. /// <summary>
  1274. /// 判定类型(输入项)
  1275. /// </summary>
  1276. private List<string> inJudgeKinds = new List<string>();
  1277. public List<string> InJudgeKinds
  1278. {
  1279. get { return inJudgeKinds; }
  1280. set { inJudgeKinds = value; RaisePropertyChanged(); }
  1281. }
  1282. private string selectInJudge;
  1283. public string SelectInJudge
  1284. {
  1285. get { return selectInJudge; }
  1286. set { selectInJudge = value; RaisePropertyChanged(); }
  1287. }
  1288. /// <summary>
  1289. /// 逻辑判断
  1290. /// </summary>
  1291. private List<string> inJudgeLogicKinds = new List<string>();
  1292. public List<string> InJudgeLogicKinds
  1293. {
  1294. get { return inJudgeLogicKinds; }
  1295. set { inJudgeLogicKinds = value; RaisePropertyChanged(); }
  1296. }
  1297. private string inSelectLogic;
  1298. public string InSelectLogic
  1299. {
  1300. get { return inSelectLogic; }
  1301. set { inSelectLogic = value; RaisePropertyChanged(); }
  1302. }
  1303. private string inDetail;
  1304. public string InDetail
  1305. {
  1306. get { return inDetail; }
  1307. set { inDetail = value; RaisePropertyChanged(); }
  1308. }
  1309. private ObservableCollection<BasPlcItemConfigDto> inConList;
  1310. public ObservableCollection<BasPlcItemConfigDto> InConList
  1311. {
  1312. get { return inConList; }
  1313. set { inConList = value; RaisePropertyChanged(); }
  1314. }
  1315. /// <summary>
  1316. /// 判定类型(结果项)
  1317. /// </summary>
  1318. private List<string> outJudgeKinds = new List<string>();
  1319. public List<string> OutJudgeKinds
  1320. {
  1321. get { return outJudgeKinds; }
  1322. set { outJudgeKinds = value; RaisePropertyChanged(); }
  1323. }
  1324. private string selectOutJudge;
  1325. public string SelectOutJudge
  1326. {
  1327. get { return selectOutJudge; }
  1328. set { selectOutJudge = value; RaisePropertyChanged(); }
  1329. }
  1330. /// <summary>
  1331. /// 逻辑判断
  1332. /// </summary>
  1333. private List<string> outJudgeLogicKinds = new List<string>();
  1334. public List<string> OutJudgeLogicKinds
  1335. {
  1336. get { return outJudgeLogicKinds; }
  1337. set { outJudgeLogicKinds = value; RaisePropertyChanged(); }
  1338. }
  1339. private string outSelectLogic;
  1340. public string OutSelectLogic
  1341. {
  1342. get { return outSelectLogic; }
  1343. set { outSelectLogic = value; RaisePropertyChanged(); }
  1344. }
  1345. private string outDetail;
  1346. public string OutDetail
  1347. {
  1348. get { return outDetail; }
  1349. set { outDetail = value; RaisePropertyChanged(); }
  1350. }
  1351. private ObservableCollection<BasPlcItemConfigDto> outConList;
  1352. public ObservableCollection<BasPlcItemConfigDto> OutConList
  1353. {
  1354. get { return outConList; }
  1355. set { outConList = value; RaisePropertyChanged(); }
  1356. }
  1357. private int stepIndex = 0;
  1358. public int StepIndex
  1359. {
  1360. get { return stepIndex; }
  1361. set { stepIndex = value; RaisePropertyChanged(); }
  1362. }
  1363. private Visibility proVisibility = Visibility.Hidden;
  1364. public Visibility ProVisibility
  1365. {
  1366. get { return proVisibility; }
  1367. set { proVisibility = value; RaisePropertyChanged(); }
  1368. }
  1369. private bool startEnalbe = true;
  1370. public bool StartEnalbe
  1371. {
  1372. get { return startEnalbe; }
  1373. set { startEnalbe = value; RaisePropertyChanged(); }
  1374. }
  1375. //所有测试项列表
  1376. private List<string> schItems = new List<string>();
  1377. public List<string> SchItems
  1378. {
  1379. get { return schItems; }
  1380. set { schItems = value; RaisePropertyChanged(); }
  1381. }
  1382. //所选测试方案
  1383. private string selectItem;
  1384. public string SelectItem
  1385. {
  1386. get { return selectItem; }
  1387. set { selectItem = value; RaisePropertyChanged(); }
  1388. }
  1389. private int selectItemIndex;
  1390. public int SelectItemIndex
  1391. {
  1392. get { return selectItemIndex; }
  1393. set { selectItemIndex = value; RaisePropertyChanged(); }
  1394. }
  1395. #endregion
  1396. }
  1397. }