RecipeStandbySettingViewModel.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using MECF.Framework.Common.DataCenter;
  4. using MECF.Framework.Common.RecipeCenter;
  5. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  6. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using FurnaceUI.Models;
  15. using FurnaceUI.Views.Recipes;
  16. using RecipeEditorLib.RecipeModel.Params;
  17. namespace FurnaceUI.Views.Editors
  18. {
  19. public class RecipeStandbySettingViewModel : FurnaceUIViewModelBase
  20. {
  21. private Step _standbyStep = new Step();
  22. public Step StandbyStep
  23. {
  24. get => _standbyStep;
  25. set
  26. {
  27. _standbyStep = value;
  28. NotifyOfPropertyChange(nameof(StandbyStep));
  29. }
  30. }
  31. private string _selectedStepName = "Standby";
  32. public string SelectedStepName
  33. {
  34. get
  35. {
  36. return _selectedStepName;
  37. }
  38. set
  39. {
  40. _selectedStepName = value;
  41. NotifyOfPropertyChange("SelectedStepName");
  42. }
  43. }
  44. private string _selectedTempSetting1;
  45. public string SelectedTempSetting1
  46. {
  47. get
  48. {
  49. return _selectedTempSetting1;
  50. }
  51. set
  52. {
  53. _selectedTempSetting1 = value;
  54. NotifyOfPropertyChange("SelectedTempSetting1");
  55. }
  56. }
  57. private string _selectedTempSetting2;
  58. public string SelectedTempSetting2
  59. {
  60. get
  61. {
  62. return _selectedTempSetting2;
  63. }
  64. set
  65. {
  66. _selectedTempSetting2 = value;
  67. NotifyOfPropertyChange("SelectedTempSetting2");
  68. }
  69. }
  70. private string _selectedTempSetting3;
  71. public string SelectedTempSetting3
  72. {
  73. get
  74. {
  75. return _selectedTempSetting3;
  76. }
  77. set
  78. {
  79. _selectedTempSetting3 = value;
  80. NotifyOfPropertyChange("SelectedTempSetting3");
  81. }
  82. }
  83. private string _selectedTempSetting4;
  84. public string SelectedTempSetting4
  85. {
  86. get
  87. {
  88. return _selectedTempSetting4;
  89. }
  90. set
  91. {
  92. _selectedTempSetting4 = value;
  93. NotifyOfPropertyChange("SelectedTempSetting4");
  94. }
  95. }
  96. private string _selectedTempSetting5;
  97. public string SelectedTempSetting5
  98. {
  99. get
  100. {
  101. return _selectedTempSetting5;
  102. }
  103. set
  104. {
  105. _selectedTempSetting5 = value;
  106. NotifyOfPropertyChange("SelectedTempSetting5");
  107. }
  108. }
  109. private string _selectedTempSettingValue1;
  110. public string SelectedTempSettingValue1
  111. {
  112. get
  113. {
  114. return _selectedTempSettingValue1;
  115. }
  116. set
  117. {
  118. _selectedTempSettingValue1 = value;
  119. NotifyOfPropertyChange("SelectedTempSettingValue1");
  120. }
  121. }
  122. private string _selectedTempSettingValue2;
  123. public string SelectedTempSettingValue2
  124. {
  125. get
  126. {
  127. return _selectedTempSettingValue2;
  128. }
  129. set
  130. {
  131. _selectedTempSettingValue2 = value;
  132. NotifyOfPropertyChange("SelectedTempSettingValue2");
  133. }
  134. }
  135. private string _selectedTempSettingValue3;
  136. public string SelectedTempSettingValue3
  137. {
  138. get
  139. {
  140. return _selectedTempSettingValue3;
  141. }
  142. set
  143. {
  144. _selectedTempSettingValue3 = value;
  145. NotifyOfPropertyChange("SelectedTempSettingValue3");
  146. }
  147. }
  148. private string _selectedTempSettingValue4;
  149. public string SelectedTempSettingValue4
  150. {
  151. get
  152. {
  153. return _selectedTempSettingValue4;
  154. }
  155. set
  156. {
  157. _selectedTempSettingValue4 = value;
  158. NotifyOfPropertyChange("SelectedTempSettingValue4");
  159. }
  160. }
  161. private string _selectedTempSettingValue5;
  162. public string SelectedTempSettingValue5
  163. {
  164. get
  165. {
  166. return _selectedTempSettingValue5;
  167. }
  168. set
  169. {
  170. _selectedTempSettingValue5 = value;
  171. NotifyOfPropertyChange("SelectedTempSettingValue5");
  172. }
  173. }
  174. private string _selectedGasSetting1;
  175. public string SelectedGasSetting1
  176. {
  177. get
  178. {
  179. return _selectedGasSetting1;
  180. }
  181. set
  182. {
  183. _selectedGasSetting1 = value;
  184. NotifyOfPropertyChange("SelectedGasSetting1");
  185. }
  186. }
  187. private string _selectedGasSetting2;
  188. public string SelectedGasSetting2
  189. {
  190. get
  191. {
  192. return _selectedGasSetting2;
  193. }
  194. set
  195. {
  196. _selectedGasSetting2 = value;
  197. NotifyOfPropertyChange("SelectedGasSetting2");
  198. }
  199. }
  200. private string _selectedGasSetting3;
  201. public string SelectedGasSetting3
  202. {
  203. get
  204. {
  205. return _selectedGasSetting3;
  206. }
  207. set
  208. {
  209. _selectedGasSetting3 = value;
  210. NotifyOfPropertyChange("SelectedGasSetting3");
  211. }
  212. }
  213. private string _selectedGasSetting4;
  214. public string SelectedGasSetting4
  215. {
  216. get
  217. {
  218. return _selectedGasSetting4;
  219. }
  220. set
  221. {
  222. _selectedGasSetting4 = value;
  223. NotifyOfPropertyChange("SelectedGasSetting4");
  224. }
  225. }
  226. private string _selectedGasSetting5;
  227. public string SelectedGasSetting5
  228. {
  229. get
  230. {
  231. return _selectedGasSetting5;
  232. }
  233. set
  234. {
  235. _selectedGasSetting5 = value;
  236. NotifyOfPropertyChange("SelectedGasSetting5");
  237. }
  238. }
  239. private string _selectedGasSetting6;
  240. public string SelectedGasSetting6
  241. {
  242. get
  243. {
  244. return _selectedGasSetting6;
  245. }
  246. set
  247. {
  248. _selectedGasSetting6 = value;
  249. NotifyOfPropertyChange("SelectedGasSetting6");
  250. }
  251. }
  252. public Dictionary<string, string> TemperatureValues { get; set; }
  253. public ObservableCollection<TempSetData> HeadLst { get; set; }
  254. public Dictionary<string, ObservableCollection<RecipeTemplateColumnBase>> RecipeTemplate { get; set; }
  255. public RecipeDataBase CurrentRecipe { get; set; }
  256. private Step _selectedRecipeStep;
  257. public Step SelectedRecipeStep
  258. {
  259. get => _selectedRecipeStep;
  260. set
  261. {
  262. if (value != null)
  263. {
  264. _selectedRecipeStep = value;
  265. NotifyOfPropertyChange("SelectedRecipeStep");
  266. }
  267. else
  268. {
  269. _selectedRecipeStep = null;
  270. NotifyOfPropertyChange("SelectedRecipeStep");
  271. }
  272. }
  273. }
  274. //private ObservableCollection<MFCData> _mFCDatas = new ObservableCollection<MFCData>();
  275. //public ObservableCollection<MFCData> MFCDataList
  276. //{
  277. // get => _mFCDatas;
  278. // set
  279. // {
  280. // _mFCDatas = value;
  281. // NotifyOfPropertyChange("MFCDataList");
  282. // }
  283. //}
  284. public List<ConfigNode> ConfigNodes { get; private set; }
  285. RecipeTempSetViewModel recipeTempSetViewModel = null;
  286. public string RecipeType { get; set; }
  287. public RecipeStandbySettingViewModel()
  288. {
  289. }
  290. protected override void OnInitialize()
  291. {
  292. base.OnInitialize();
  293. LoadData();
  294. }
  295. private void LoadData()
  296. {
  297. Step step = StandbyStep;
  298. if (step.MFCSets != null && step.MFCSets.Count > 0)
  299. {
  300. //int index2 = 0;
  301. StringBuilder stringBuilder = new StringBuilder();
  302. var MfcItems = this.GetMfcItem();
  303. int mfcIndex = 0;
  304. foreach (var item in MfcItems)
  305. {
  306. var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{item.Name}.IsMFCInstalled");
  307. //var key = step.MFCSets.Keys.ToList()[mfcIndex];
  308. mfcIndex++;
  309. if (!(bool)isInstalled) continue;
  310. //MFCDataList.Add(new MFCData()
  311. //{
  312. // SetValueParam = step.MFCSets[key.ToString()].SetValueParam,
  313. // Name = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.GasName"),
  314. // // Unit = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.FlowUnit"),
  315. //});
  316. }
  317. }
  318. }
  319. public void RecipeEdit(object cmdName, object value)
  320. {
  321. var windowManager = IoC.Get<IWindowManager>();
  322. switch ((string)cmdName)
  323. {
  324. case "StepTime":
  325. RecipeStepTimeViewModel recipeStepTimeViewModel = new RecipeStepTimeViewModel("StepTime");
  326. recipeStepTimeViewModel.SelectTime = StandbyStep.Time;
  327. (windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepTimeViewModel, null, "Standby Time Setting");
  328. if (recipeStepTimeViewModel.IsSave)
  329. {
  330. StandbyStep.Time = recipeStepTimeViewModel.SelectTime;
  331. if (recipeStepTimeViewModel.SelectTime == "Value")
  332. {
  333. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.SelectValueTime;
  334. StandbyStep.Time = recipeStepTimeViewModel.SelectValueTime;
  335. }
  336. else
  337. {
  338. SelectedRecipeStep.Time = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.RecipeStepTime[recipeStepTimeViewModel.SelectTime];
  339. }
  340. }
  341. break;
  342. case "AlarmAction":
  343. RecipeAlarmActionViewModel recipeAlarmActionViewModel = new RecipeAlarmActionViewModel
  344. {
  345. CurrentRecipe = CurrentRecipe,
  346. CurrentStepName = SelectedRecipeStep.Name,
  347. TableIndex = StandbyStep.AlarmConditionTable.Value,
  348. AlarmActions = StandbyStep.AlarmActionSets
  349. };
  350. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAlarmActionViewModel, null, "Standby Alarm Action"))
  351. {
  352. StandbyStep.AlarmConditionTable.Value = recipeAlarmActionViewModel.TableIndex;
  353. StandbyStep.AlarmActionSets = recipeAlarmActionViewModel.AlarmActions;
  354. }
  355. break;
  356. case "TempSetting":
  357. if (recipeTempSetViewModel is null)
  358. {
  359. recipeTempSetViewModel = new RecipeTempSetViewModel
  360. {
  361. RecipeTemplate = RecipeTemplate
  362. };
  363. }
  364. var tempSets = StandbyStep;
  365. recipeTempSetViewModel.TemperatureValues = tempSets.TemperatureSets;
  366. recipeTempSetViewModel.StepType = SelectedStepName;
  367. recipeTempSetViewModel.RecipeType = RecipeType;
  368. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTempSetViewModel, null, "Standby Temperature Setting"))
  369. {
  370. if (recipeTempSetViewModel.TemperatureValues != null && recipeTempSetViewModel.TemperatureValues.Count > 0 && recipeTempSetViewModel.IsSave)
  371. {
  372. StringBuilder tempStr = new StringBuilder();
  373. List<string> temperatureValue = new List<string>();
  374. List<string> tempLis = new List<string>();
  375. string strTemperatureValue = "", strTemperatureName = "";
  376. int index = 0;
  377. }
  378. }
  379. break;
  380. case "GASSetting":
  381. RecipeGASSettingViewModel recipeGASSettingViewModel = new RecipeGASSettingViewModel();
  382. var tempValveSets = StandbyStep.ValveSets;
  383. if (tempValveSets != null && tempValveSets.Count > 0)
  384. {
  385. recipeGASSettingViewModel.ValveSets= StandbyStep.ValveSets;
  386. }
  387. recipeGASSettingViewModel.MFCSets = StandbyStep.MFCSets;
  388. var tempMFMSets = StandbyStep.MFMSets;
  389. if (tempMFMSets != null && tempMFMSets.Count > 0)
  390. {
  391. foreach (var item in tempMFMSets.Keys)
  392. {
  393. if (recipeGASSettingViewModel.MFMSets.ContainsKey(item))
  394. {
  395. recipeGASSettingViewModel.MFMSets[item] = tempMFMSets[item];
  396. }
  397. else
  398. {
  399. recipeGASSettingViewModel.MFMSets.Add(item, tempMFMSets[item]);
  400. }
  401. }
  402. }
  403. var tempEXOU = StandbyStep.EXOUSets;
  404. if (tempEXOU != null && tempEXOU.Count > 0)
  405. {
  406. foreach (var item in tempEXOU.Keys)
  407. {
  408. var keyName = $"EXOU{item.Substring(12)}";
  409. if (recipeGASSettingViewModel.ExternalOutSets.ContainsKey(keyName))
  410. {
  411. recipeGASSettingViewModel.ExternalOutSets[keyName] = tempEXOU[item];
  412. }
  413. else
  414. {
  415. recipeGASSettingViewModel.ExternalOutSets.Add(keyName, tempEXOU[item]);
  416. }
  417. }
  418. }
  419. recipeGASSettingViewModel.RecipeTemplate = RecipeTemplate;
  420. recipeGASSettingViewModel.RecipeType = RecipeType;
  421. if (!(bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeGASSettingViewModel, null, "Standby Gas Setting")) return;
  422. if (StandbyStep.MFMSets != null)
  423. {
  424. if (recipeGASSettingViewModel.MFMSets != null)
  425. {
  426. StandbyStep.MFMSets = recipeGASSettingViewModel.MFMSets;
  427. }
  428. }
  429. if (StandbyStep.ValveSets != null)
  430. {
  431. if (recipeGASSettingViewModel.ValveSets != null && recipeGASSettingViewModel.ValveSets.Count > 0)
  432. {
  433. var step = StandbyStep;
  434. step.ValveSets = recipeGASSettingViewModel.ValveSets;
  435. }
  436. }
  437. if (StandbyStep.MFCSets != null)
  438. {
  439. if (recipeGASSettingViewModel.MFCSets != null && recipeGASSettingViewModel.MFCSets.Count > 0)
  440. {
  441. var step = StandbyStep;
  442. var MfcItems = this.GetMfcItem();
  443. int mfcIndex = 0;
  444. foreach (var item in MfcItems)
  445. {
  446. var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{item.Name}.IsMFCInstalled");
  447. //var key = StandbyStep.MFCSets.Keys.ToList()[mfcIndex];
  448. mfcIndex++;
  449. if (!(bool)isInstalled) continue;
  450. //MFCDataList.Add(new MFCData()
  451. //{
  452. // SetValueParam =StandbyStep.MFCSets[key.ToString()].SetValueParam,
  453. // Name = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.GasName"),
  454. // Unit = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.FlowUnit"),
  455. //});
  456. }
  457. }
  458. }
  459. if (StandbyStep.EXOUSets != null)
  460. {
  461. if (recipeGASSettingViewModel.ExternalOutSets != null && recipeGASSettingViewModel.ExternalOutSets.Count > 0)
  462. {
  463. var step = StandbyStep;
  464. foreach (var item in recipeGASSettingViewModel.ExternalOutSets.Keys)
  465. {
  466. var key = $"External.Out{ item.Substring(4)}";
  467. if (step.EXOUSets.ContainsKey(key))
  468. {
  469. step.EXOUSets[key] = recipeGASSettingViewModel.ExternalOutSets[item];
  470. }
  471. else
  472. {
  473. step.EXOUSets.Add(key, recipeGASSettingViewModel.ExternalOutSets[item]);
  474. }
  475. }
  476. }
  477. }
  478. break;
  479. case "PressureSetting":
  480. RecipePressureSettingViewModel recipePressureSettingViewModel = new RecipePressureSettingViewModel();
  481. var tempStep = StandbyStep;
  482. //recipePressureSettingViewModel.PressureSonsorValue = tempStep.PressureSonserValue;
  483. //recipePressureSettingViewModel.PressureValveAngleValue = tempStep.PressureValveAngle;
  484. //if (!string.IsNullOrEmpty(tempStep.PressureAlarmTableNo))
  485. //{
  486. // if (tempStep.PressureAlarmTableNo.ToLower() == "none")
  487. // recipePressureSettingViewModel.PressureAlarmWatchTable = "None";
  488. // else
  489. // recipePressureSettingViewModel.PressureAlarmWatchTable = tempStep.PressureAlarmTableNo;
  490. //}
  491. //if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipePressureSettingViewModel, null, "Standby Pressure Setting"))
  492. //{
  493. // if (StandbyStep != null)
  494. // {
  495. // StandbyStep.PressureSonserValue = recipePressureSettingViewModel.PressureSonsorValue;
  496. // StandbyStep.PressureValveAngle = recipePressureSettingViewModel.PressureValveAngleValue;
  497. // StandbyStep.PressureAlarmTableNo = recipePressureSettingViewModel.PressureAlarmWatchTable;
  498. // SelectedRecipeStep.PressureSonserValue = $"{recipePressureSettingViewModel.PressureSonsorValue}";
  499. // }
  500. //}
  501. break;
  502. }
  503. }
  504. public List<ConfigNode> GetMfcItem()
  505. {
  506. this.SystemName = "System";
  507. ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;
  508. var MfcItems = ConfigNodes.Where(x => x.Display == "Parameter").FirstOrDefault().SubNodes.Where(y => y.Name == "MFC").FirstOrDefault().SubNodes;
  509. return MfcItems;
  510. }
  511. public void RecipeSave()
  512. {
  513. ((Window)GetView()).DialogResult = true;
  514. }
  515. public void RecipeCancel()
  516. {
  517. ((Window)GetView()).DialogResult = false;
  518. }
  519. }
  520. }