RecipeAlarmActionSubViewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. using MECF.Framework.Common.DataCenter;
  2. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  3. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  4. using OpenSEMI.ClientBase;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using FurnaceUI.Models;
  13. using FurnaceUI.Views.Recipes;
  14. using ProcessTypeFileItem = MECF.Framework.UI.Client.CenterViews.Editors.Recipe.ProcessTypeFileItem;
  15. namespace FurnaceUI.Views.Editors
  16. {
  17. public class RecipeAlarmActionSubViewModel : FurnaceUIViewModelBase
  18. {
  19. public ObservableCollection<FileNode> FileListByProcessType { get; set; }
  20. public ObservableCollection<string> ChamberType { get; set; }
  21. public int ChamberTypeIndexSelection { get; set; }
  22. private RecipeProvider _recipeProvider = new RecipeProvider();
  23. private ObservableCollection<Step> _stepList = new ObservableCollection<Step>();
  24. public ObservableCollection<Step> StepList
  25. {
  26. get => _stepList;
  27. set
  28. {
  29. _stepList = value;
  30. NotifyOfPropertyChange("StepList");
  31. }
  32. }
  33. private int _alarmTableNo;
  34. public int AlarmTableNo
  35. {
  36. get => _alarmTableNo;
  37. set
  38. {
  39. _alarmTableNo = value;
  40. NotifyOfPropertyChange("AlarmTableNo");
  41. }
  42. }
  43. private int _alarmGroupNo;
  44. public int AlarmGroupNo
  45. {
  46. get => _alarmGroupNo;
  47. set
  48. {
  49. _alarmGroupNo = value;
  50. NotifyOfPropertyChange("AlarmGroupNo");
  51. }
  52. }
  53. private string _alarmType;
  54. public string AlarmType
  55. {
  56. get => _alarmType;
  57. set
  58. {
  59. _alarmType = value;
  60. NotifyOfPropertyChange("AlarmType");
  61. }
  62. }
  63. private string _alarmDetails;
  64. public string AlarmDetails
  65. {
  66. get => _alarmDetails;
  67. set
  68. {
  69. _alarmDetails = value;
  70. NotifyOfPropertyChange("AlarmDetails");
  71. }
  72. }
  73. private Visibility _abortRecipeVisibility;
  74. public Visibility AbortRecipeVisibility
  75. {
  76. get => _abortRecipeVisibility;
  77. set
  78. {
  79. _abortRecipeVisibility = value;
  80. NotifyOfPropertyChange("AbortRecipeVisibility");
  81. }
  82. }
  83. private Visibility _jumpStepVisibility;
  84. public Visibility JumpStepVisibility
  85. {
  86. get => _jumpStepVisibility;
  87. set
  88. {
  89. _jumpStepVisibility = value;
  90. NotifyOfPropertyChange("JumpStepVisibility");
  91. }
  92. }
  93. public string CurrentStepName { get; set; }
  94. public string SelectedStepName { get; set; }
  95. public string AbortRecipeName { get; set; }
  96. private bool _isCheckJumpAbortRecipe;
  97. public bool IsCheckJumpAbortRecipe
  98. {
  99. get => _isCheckJumpAbortRecipe;
  100. set
  101. {
  102. _isCheckJumpAbortRecipe = value;
  103. NotifyOfPropertyChange(nameof(IsCheckJumpAbortRecipe));
  104. }
  105. }
  106. private bool _isCheckJumpStep;
  107. public bool IsCheckJumpStep
  108. {
  109. get => _isCheckJumpStep;
  110. set
  111. {
  112. _isCheckJumpStep = value;
  113. NotifyOfPropertyChange(nameof(IsCheckJumpStep));
  114. }
  115. }
  116. private bool _isCheckJumpStepCancelLoop;
  117. public bool IsCheckJumpStepCancelLoop
  118. {
  119. get => _isCheckJumpStepCancelLoop;
  120. set
  121. {
  122. _isCheckJumpStepCancelLoop = value;
  123. NotifyOfPropertyChange(nameof(IsCheckJumpStepCancelLoop));
  124. }
  125. }
  126. private bool _isCheckAbort;
  127. public bool IsCheckAbort
  128. {
  129. get => _isCheckAbort;
  130. set
  131. {
  132. _isCheckAbort = value;
  133. NotifyOfPropertyChange(nameof(IsCheckAbort));
  134. }
  135. }
  136. private bool _isCheckHold;
  137. public bool IsCheckHold
  138. {
  139. get => _isCheckHold;
  140. set
  141. {
  142. _isCheckHold = value;
  143. NotifyOfPropertyChange(nameof(IsCheckHold));
  144. }
  145. }
  146. private bool _isCheckIgnoreAlarm;
  147. public bool IsCheckIgnoreAlarm
  148. {
  149. get => _isCheckIgnoreAlarm;
  150. set
  151. {
  152. _isCheckIgnoreAlarm = value;
  153. NotifyOfPropertyChange(nameof(IsCheckIgnoreAlarm));
  154. }
  155. }
  156. protected override void OnInitialize()
  157. {
  158. base.OnInitialize();
  159. }
  160. private void ShowControl(string alarmType)
  161. {
  162. AbortRecipeVisibility = Visibility.Hidden;
  163. JumpStepVisibility = Visibility.Hidden;
  164. switch (alarmType)
  165. {
  166. case "Jump Abort Recipe":
  167. AbortRecipeVisibility = Visibility.Visible;
  168. break;
  169. case "Jump Step":
  170. JumpStepVisibility = Visibility.Visible;
  171. break;
  172. case "Jump Step(Cancel Call Loop)":
  173. JumpStepVisibility = Visibility.Visible;
  174. break;
  175. case "Abort":
  176. break;
  177. case "Hold":
  178. break;
  179. case "Ignore Alarm":
  180. break;
  181. default:
  182. break;
  183. }
  184. }
  185. public void SelectStep(object step)
  186. {
  187. if (step is Step)
  188. {
  189. if (AlarmType == "Jump Step")
  190. {
  191. AlarmDetails = $"Jump Step/{((Step)step).Name}";
  192. SelectedStepName = ((Step)step).Name;
  193. }
  194. else if (AlarmType == "Jump Step(Cancel Call Loop)")
  195. {
  196. AlarmDetails = $"Jump Step(Cancel Call Loop)/{((Step)step).Name}";
  197. SelectedStepName = ((Step)step).Name;
  198. }
  199. }
  200. }
  201. public void TreeSelectChanged(object abortRecipeName)
  202. {
  203. if (abortRecipeName is FileNode)
  204. {
  205. AlarmDetails = $"Abort Recipe/{((FileNode)abortRecipeName).Name}";
  206. AbortRecipeName = ((FileNode)abortRecipeName).Name;
  207. }
  208. }
  209. public void SelectAlarmGroupCommand(string alarmType)
  210. {
  211. AlarmType = alarmType;
  212. switch (alarmType)
  213. {
  214. case "Jump Abort Recipe":
  215. AlarmDetails = @"Abort Recipe/";
  216. break;
  217. case "Jump Step":
  218. AlarmDetails = @"Jump Step/";
  219. break;
  220. case "Jump Step(Cancel Call Loop)":
  221. AlarmDetails = @"Jump Step(Cancel Call Loop)/";
  222. break;
  223. case "Abort":
  224. AlarmDetails = "";
  225. break;
  226. case "Hold":
  227. AlarmDetails = "";
  228. break;
  229. case "Ignore Alarm":
  230. AlarmDetails = "";
  231. break;
  232. default:
  233. break;
  234. }
  235. SelectedStepName = "";
  236. AbortRecipeName = "";
  237. ShowControl(alarmType);
  238. }
  239. protected override void OnViewLoaded(object view)
  240. {
  241. base.OnViewLoaded(view);
  242. GetAbortRecipeFileList();
  243. switch (AlarmType)
  244. {
  245. case "Jump Abort Recipe":
  246. IsCheckJumpAbortRecipe = true;
  247. break;
  248. case "Jump Step":
  249. IsCheckJumpStep = true;
  250. break;
  251. case "Jump Step(Cancel Call Loop)":
  252. IsCheckJumpStepCancelLoop = true;
  253. break;
  254. case "Abort":
  255. IsCheckAbort = true;
  256. break;
  257. case "Hold":
  258. IsCheckHold = true;
  259. break;
  260. case "Ignore Alarm":
  261. IsCheckIgnoreAlarm = true;
  262. break;
  263. default:
  264. IsCheckIgnoreAlarm = true;
  265. break;
  266. }
  267. ShowControl(AlarmType);
  268. }
  269. private void GetAbortRecipeFileList()
  270. {
  271. var processType = "Abort";
  272. var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
  273. if (chamberType == null)
  274. {
  275. ChamberType = new ObservableCollection<string>() { "Default" };
  276. }
  277. else
  278. {
  279. ChamberType = new ObservableCollection<string>(((string)(chamberType)).Split(','));
  280. }
  281. ChamberTypeIndexSelection = 0;
  282. ObservableCollection<ProcessTypeFileItem> typeFileList = new ObservableCollection<ProcessTypeFileItem>();
  283. string[] recipeProcessType = ((string)processType).Split(',');
  284. for (int i = 0; i < recipeProcessType.Length; i++)
  285. {
  286. var prefix = $"{ChamberType[ChamberTypeIndexSelection]}\\{recipeProcessType[i]}";
  287. var recipes = _recipeProvider.GetXmlRecipeList(prefix);
  288. FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files;
  289. }
  290. }
  291. public void SaveCmd()
  292. {
  293. if (AlarmType == "Jump Step" || AlarmType == "Jump Step(Cancel Call Loop)")
  294. {
  295. if (string.IsNullOrEmpty(SelectedStepName))
  296. {
  297. DialogBox.ShowWarning("Jump Step is empty!");
  298. return;
  299. }
  300. if (SelectedStepName == CurrentStepName)
  301. {
  302. DialogBox.ShowWarning($"Jump Step cannot be the same as {CurrentStepName}!");
  303. return;
  304. }
  305. }
  306. if (AlarmType == "Jump Abort Recipe")
  307. {
  308. if (string.IsNullOrEmpty(AbortRecipeName))
  309. {
  310. DialogBox.ShowWarning("Abort Recipe Name is empty!");
  311. return;
  312. }
  313. }
  314. ((Window)GetView()).DialogResult = true;
  315. }
  316. public void CloseCmd()
  317. {
  318. ((Window)GetView()).DialogResult = false;
  319. }
  320. }
  321. }