RecipeAlarmActionViewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using MECF.Framework.Common.OperationCenter;
  4. using MECF.Framework.UI.Client.CenterViews.Alarms;
  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 System.Windows.Controls;
  15. using FurnaceUI.Models;
  16. using FurnaceUI.Views.Recipes;
  17. namespace FurnaceUI.Views.Editors
  18. {
  19. public class RecipeAlarmActionViewModel : FurnaceUIViewModelBase
  20. {
  21. public Dictionary<int, AlarmAction> AlarmActions { get; set; } = new Dictionary<int, AlarmAction>();
  22. public bool IsEnabled { get; set; } = true;
  23. public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式
  24. private void CreateTestAlarmActions()
  25. {
  26. for (int j = 1; j < 11; j++)
  27. {
  28. AlarmAction alarmAction = new AlarmAction() { PtocessingType = "Ignore Alarm", PtocessingDetails = "" };
  29. if (!AlarmActions.ContainsKey(j))
  30. AlarmActions.Add(j, alarmAction);
  31. }
  32. }
  33. private string _tableIndex;
  34. public string TableIndex
  35. {
  36. get => _tableIndex;
  37. set
  38. {
  39. _tableIndex = value;
  40. }
  41. }
  42. public void AlarmStabilizeSelected(object obj)
  43. {
  44. if (obj is RadioButton)
  45. {
  46. // TableIndex = int.Parse((string)((RadioButton)obj).Content);
  47. }
  48. }
  49. private void SelectedTableShowValues()
  50. {
  51. Dictionary<int, AlarmAction> tempAlarm = AlarmActions;
  52. Alarm01Action = tempAlarm[1].PtocessingType;
  53. Alarm01Details = tempAlarm[1].PtocessingDetails;
  54. Alarm02Action = tempAlarm[2].PtocessingType;
  55. Alarm02Details = tempAlarm[2].PtocessingDetails;
  56. Alarm03Action = tempAlarm[3].PtocessingType;
  57. Alarm03Details = tempAlarm[3].PtocessingDetails;
  58. Alarm04Action = tempAlarm[4].PtocessingType;
  59. Alarm04Details = tempAlarm[4].PtocessingDetails;
  60. Alarm05Action = tempAlarm[5].PtocessingType;
  61. Alarm05Details = tempAlarm[5].PtocessingDetails;
  62. Alarm06Action = tempAlarm[6].PtocessingType;
  63. Alarm06Details = tempAlarm[6].PtocessingDetails;
  64. Alarm07Action = tempAlarm[7].PtocessingType;
  65. Alarm07Details = tempAlarm[7].PtocessingDetails;
  66. Alarm08Action = tempAlarm[8].PtocessingType;
  67. Alarm08Details = tempAlarm[8].PtocessingDetails;
  68. Alarm09Action = tempAlarm[9].PtocessingType;
  69. Alarm09Details = tempAlarm[9].PtocessingDetails;
  70. Alarm10Action = tempAlarm[10].PtocessingType;
  71. Alarm10Details = tempAlarm[10].PtocessingDetails;
  72. }
  73. private string _alarm01Action;
  74. public string Alarm01Action
  75. {
  76. get => _alarm01Action;
  77. set
  78. {
  79. _alarm01Action = value;
  80. NotifyOfPropertyChange("Alarm01Action");
  81. }
  82. }
  83. private string _alarm02Action;
  84. public string Alarm02Action
  85. {
  86. get => _alarm02Action;
  87. set
  88. {
  89. _alarm02Action = value;
  90. NotifyOfPropertyChange("Alarm02Action");
  91. }
  92. }
  93. private string _alarm03Action;
  94. public string Alarm03Action
  95. {
  96. get => _alarm03Action;
  97. set
  98. {
  99. _alarm03Action = value;
  100. NotifyOfPropertyChange("Alarm03Action");
  101. }
  102. }
  103. private string _alarm04Action;
  104. public string Alarm04Action
  105. {
  106. get => _alarm04Action;
  107. set
  108. {
  109. _alarm04Action = value;
  110. NotifyOfPropertyChange("Alarm04Action");
  111. }
  112. }
  113. private string _alarm05Action;
  114. public string Alarm05Action
  115. {
  116. get => _alarm05Action;
  117. set
  118. {
  119. _alarm05Action = value;
  120. NotifyOfPropertyChange("Alarm05Action");
  121. }
  122. }
  123. private string _alarm06Action;
  124. public string Alarm06Action
  125. {
  126. get => _alarm06Action;
  127. set
  128. {
  129. _alarm06Action = value;
  130. NotifyOfPropertyChange("Alarm06Action");
  131. }
  132. }
  133. private string _alarm07Action;
  134. public string Alarm07Action
  135. {
  136. get => _alarm07Action;
  137. set
  138. {
  139. _alarm07Action = value;
  140. NotifyOfPropertyChange("Alarm07Action");
  141. }
  142. }
  143. private string _alarm08Action;
  144. public string Alarm08Action
  145. {
  146. get => _alarm08Action;
  147. set
  148. {
  149. _alarm08Action = value;
  150. NotifyOfPropertyChange("Alarm08Action");
  151. }
  152. }
  153. private string _alarm09Action;
  154. public string Alarm09Action
  155. {
  156. get => _alarm09Action;
  157. set
  158. {
  159. _alarm09Action = value;
  160. NotifyOfPropertyChange("Alarm09Action");
  161. }
  162. }
  163. private string _alarm10Action;
  164. public string Alarm10Action
  165. {
  166. get => _alarm10Action;
  167. set
  168. {
  169. _alarm10Action = value;
  170. NotifyOfPropertyChange("Alarm10Action");
  171. }
  172. }
  173. private string _alarm01Details;
  174. public string Alarm01Details
  175. {
  176. get => _alarm01Details;
  177. set
  178. {
  179. _alarm01Details = value;
  180. NotifyOfPropertyChange("Alarm01Details");
  181. }
  182. }
  183. private string _alarm02Details;
  184. public string Alarm02Details
  185. {
  186. get => _alarm02Details;
  187. set
  188. {
  189. _alarm02Details = value;
  190. NotifyOfPropertyChange("Alarm02Details");
  191. }
  192. }
  193. private string _alarm03Details;
  194. public string Alarm03Details
  195. {
  196. get => _alarm03Details;
  197. set
  198. {
  199. _alarm03Details = value;
  200. NotifyOfPropertyChange("Alarm03Details");
  201. }
  202. }
  203. private string _alarm04Details;
  204. public string Alarm04Details
  205. {
  206. get => _alarm04Details;
  207. set
  208. {
  209. _alarm04Details = value;
  210. NotifyOfPropertyChange("Alarm04Details");
  211. }
  212. }
  213. private string _alarm05Details;
  214. public string Alarm05Details
  215. {
  216. get => _alarm05Details;
  217. set
  218. {
  219. _alarm05Details = value;
  220. NotifyOfPropertyChange("Alarm05Details");
  221. }
  222. }
  223. private string _alarm06Details;
  224. public string Alarm06Details
  225. {
  226. get => _alarm06Details;
  227. set
  228. {
  229. _alarm06Details = value;
  230. NotifyOfPropertyChange("Alarm06Details");
  231. }
  232. }
  233. private string _alarm07Details;
  234. public string Alarm07Details
  235. {
  236. get => _alarm07Details;
  237. set
  238. {
  239. _alarm07Details = value;
  240. NotifyOfPropertyChange("Alarm07Details");
  241. }
  242. }
  243. private string _alarm08Details;
  244. public string Alarm08Details
  245. {
  246. get => _alarm08Details;
  247. set
  248. {
  249. _alarm08Details = value;
  250. NotifyOfPropertyChange("Alarm08Details");
  251. }
  252. }
  253. private string _alarm09Details;
  254. public string Alarm09Details
  255. {
  256. get => _alarm09Details;
  257. set
  258. {
  259. _alarm09Details = value;
  260. NotifyOfPropertyChange("Alarm09Details");
  261. }
  262. }
  263. private string _alarm10Details;
  264. public string Alarm10Details
  265. {
  266. get => _alarm10Details;
  267. set
  268. {
  269. _alarm10Details = value;
  270. NotifyOfPropertyChange("Alarm10Details");
  271. }
  272. }
  273. public RecipeDataBase CurrentRecipe { get; set; }
  274. public string CurrentStepName { get; set; }
  275. protected override void OnViewLoaded(object view)
  276. {
  277. base.OnViewLoaded(view);
  278. CreateTestAlarmActions();
  279. SelectedTableShowValues();
  280. var winview = (RecipeAlarmActionView)(GetView() as Window).Content;
  281. var controls = winview.WPlTempStabilize.Children;
  282. foreach (var item in controls)
  283. {
  284. if ((item is RadioButton) && ((RadioButton)item).GroupName == "TempStabilize" && (string)((RadioButton)item).Content == TableIndex.ToString())
  285. {
  286. ((RadioButton)item).IsChecked = true;
  287. }
  288. }
  289. }
  290. public void AlarmActionSelected(string selectIndex)
  291. {
  292. if (!IsEnabled) return;
  293. var windowManager = IoC.Get<IWindowManager>();
  294. RecipeAlarmActionSubViewModel recipeAlarmActionSubViewModel = new RecipeAlarmActionSubViewModel();
  295. recipeAlarmActionSubViewModel.StepList = new ObservableCollection<Step>(CurrentRecipe.Steps.OrderBy(x => x.StepNo));
  296. recipeAlarmActionSubViewModel.CurrentStepName = CurrentStepName;
  297. recipeAlarmActionSubViewModel.AlarmType = AlarmActions[int.Parse(selectIndex)].PtocessingType;
  298. // recipeAlarmActionSubViewModel.AlarmTableNo = TableIndex;
  299. recipeAlarmActionSubViewModel.AlarmGroupNo = int.Parse(selectIndex);
  300. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAlarmActionSubViewModel, null, "Alarm Action Sub"))
  301. {
  302. var alarmTableNo = recipeAlarmActionSubViewModel.AlarmTableNo;
  303. var alarmGroupNo = recipeAlarmActionSubViewModel.AlarmGroupNo;
  304. var alarmType = recipeAlarmActionSubViewModel.AlarmType;
  305. var alarmDetails = recipeAlarmActionSubViewModel.AlarmDetails;
  306. AlarmActions[alarmGroupNo].PtocessingType = alarmType;
  307. AlarmActions[alarmGroupNo].PtocessingDetails = alarmDetails;
  308. SelectedTableShowValues();
  309. }
  310. }
  311. public void RecipeAlarmSave()
  312. {
  313. ((Window)GetView()).DialogResult = true;
  314. }
  315. public void RecipeAlarmCancel()
  316. {
  317. ((Window)GetView()).DialogResult = false;
  318. }
  319. }
  320. }