RecipeTempModeViewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. using Aitex.Core.RT.SCCore;
  2. using Caliburn.Micro;
  3. using Caliburn.Micro.Core;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.RecipeCenter;
  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.Parameter;
  16. using FurnaceUI.Views.Recipes;
  17. using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
  18. using SciChart.Charting2D.Interop;
  19. using RecipeEditorLib.RecipeModel.Params;
  20. using OpenSEMI.ClientBase;
  21. using MECF.Framework.UI.Client.ClientBase;
  22. namespace FurnaceUI.Views.Editors
  23. {
  24. public class RecipeTempModeViewModel : FurnaceUIViewModelBase
  25. {
  26. private bool _isProfileSelected = false;
  27. public bool IsProfileSelected
  28. {
  29. get => _isProfileSelected;
  30. set
  31. {
  32. _isProfileSelected = value;
  33. NotifyOfPropertyChange(nameof(IsProfileSelected));
  34. }
  35. }
  36. private string _selectProfileTable = "";
  37. public string SelectProfileTable
  38. {
  39. get => _selectProfileTable;
  40. set
  41. {
  42. _selectProfileTable = value;
  43. NotifyOfPropertyChange(nameof(SelectProfileTable));
  44. }
  45. }
  46. private bool _modelLeftVisibility;
  47. public bool ModelLeftVisibility
  48. {
  49. get => _modelLeftVisibility;
  50. set
  51. {
  52. _modelLeftVisibility = value;
  53. NotifyOfPropertyChange(nameof(ModelLeftVisibility));
  54. }
  55. }
  56. private RecipeDataBase _CurrentRecipe;
  57. public RecipeDataBase CurrentRecipe
  58. {
  59. get { return _CurrentRecipe; }
  60. set { _CurrentRecipe = value; this.NotifyOfPropertyChange(nameof(CurrentRecipe)); }
  61. }
  62. private bool _heaterControlIsChecked;
  63. public bool HeaterControlIsChecked
  64. {
  65. get { return _heaterControlIsChecked; }
  66. set { _heaterControlIsChecked = value; this.NotifyOfPropertyChange(nameof(HeaterControlIsChecked)); }
  67. }
  68. private bool _furnaceControlIsChecked;
  69. public bool FurnaceControlIsChecked
  70. {
  71. get { return _furnaceControlIsChecked; }
  72. set { _furnaceControlIsChecked = value; this.NotifyOfPropertyChange(nameof(FurnaceControlIsChecked)); }
  73. }
  74. private bool _furnaceDirectControlIsChecked;
  75. public bool FurnaceDirectControlIsChecked
  76. {
  77. get { return _furnaceDirectControlIsChecked; }
  78. set { _furnaceDirectControlIsChecked = value; this.NotifyOfPropertyChange(nameof(FurnaceDirectControlIsChecked)); }
  79. }
  80. private bool _profileControlIsChecked;
  81. public bool ProfileControlIsChecked
  82. {
  83. get { return _profileControlIsChecked; }
  84. set { _profileControlIsChecked = value; this.NotifyOfPropertyChange(nameof(ProfileControlIsChecked)); }
  85. }
  86. public bool IsSave { get; set; }
  87. public bool IsManualSet { get; set; }
  88. private string _selectBtnName;
  89. public string SelectBtnName
  90. {
  91. get { return _selectBtnName; }
  92. set { _selectBtnName = value; this.NotifyOfPropertyChange(nameof(SelectBtnName)); }
  93. }
  94. public RecipeTempModeViewModel()
  95. {
  96. }
  97. private bool _isEnable;
  98. public bool IsEnable
  99. {
  100. get { return _isEnable; }
  101. set { _isEnable = value; this.NotifyOfPropertyChange(nameof(IsEnable)); }
  102. }
  103. public string ResultString { get; set; }
  104. public string RecipeType { get; set; }
  105. protected override void OnViewLoaded(object view)
  106. {
  107. base.OnViewLoaded(view);
  108. LoadData();
  109. InitModelLeftVisibility();
  110. IsEnable = IsManualSet == true ? IsManualSet : CGlobal.RecipeProcessEditViewEnable;
  111. }
  112. private void LoadData()
  113. {
  114. if (!string.IsNullOrEmpty(SelectProfileTable))
  115. {
  116. SelectProfileTable = SelectProfileTable.TrimEnd(')');
  117. }
  118. else
  119. {
  120. SelectProfileTable = "Heater";
  121. }
  122. InitControlBtn();
  123. }
  124. private const string FURNACE = "Furnace";
  125. private const string DIRECT = "Furnace Direct";
  126. private const string HEATER = "Heater";
  127. private const string PROFILE = "Profile";
  128. private void InitControlBtn()
  129. {
  130. if (string.IsNullOrEmpty(SelectBtnName))
  131. {
  132. if (!string.IsNullOrEmpty(SelectProfileTable))
  133. {
  134. if (SelectProfileTable.StartsWith(PROFILE))
  135. SelectBtnName = PROFILE;
  136. else if (SelectProfileTable.StartsWith(HEATER))
  137. SelectBtnName = HEATER;
  138. else if (SelectProfileTable.StartsWith(DIRECT))
  139. SelectBtnName = DIRECT;
  140. else
  141. SelectBtnName = FURNACE;
  142. }
  143. else
  144. SelectBtnName = HEATER;
  145. }
  146. if (PROFILE.Equals(SelectBtnName))
  147. {
  148. FurnaceDirectControlIsChecked = false;
  149. FurnaceControlIsChecked = false;
  150. HeaterControlIsChecked = false;
  151. ProfileControlIsChecked = true;
  152. IsProfileSelected = true;
  153. }
  154. if (FURNACE.Equals(SelectBtnName))
  155. {
  156. FurnaceDirectControlIsChecked = false;
  157. FurnaceControlIsChecked = true;
  158. HeaterControlIsChecked = false;
  159. ProfileControlIsChecked = false;
  160. }
  161. if (HEATER.Equals(SelectBtnName))
  162. {
  163. FurnaceDirectControlIsChecked = false;
  164. FurnaceControlIsChecked = false;
  165. HeaterControlIsChecked = true;
  166. ProfileControlIsChecked = false;
  167. }
  168. if (DIRECT.Equals(SelectBtnName))
  169. {
  170. FurnaceDirectControlIsChecked = true;
  171. FurnaceControlIsChecked = false;
  172. HeaterControlIsChecked = false;
  173. ProfileControlIsChecked = false;
  174. }
  175. }
  176. /// <summary>
  177. /// Profile Control按钮 手动且Heater不展示 Recipe展示
  178. /// </summary>
  179. private void InitModelLeftVisibility()
  180. {
  181. ModelLeftVisibility = true;
  182. //if (null == CurrentRecipe)
  183. //{
  184. if (!string.IsNullOrEmpty(SelectBtnName) && SelectBtnName.ToUpper().Equals(HEATER))
  185. {
  186. ModelLeftVisibility = false;
  187. }
  188. //}
  189. }
  190. public void ProfileClick()
  191. {
  192. ShowProfileTable();
  193. }
  194. public void RdoChecked(string cmd)
  195. {
  196. SelectBtnName = cmd;
  197. switch (cmd)
  198. {
  199. case "Heater":
  200. ResultString = "Heater";
  201. IsProfileSelected = false;
  202. ProfileControlIsChecked = false;
  203. InitModelLeftVisibility();
  204. break;
  205. case "Furnace":
  206. ResultString = "Furnace";
  207. IsProfileSelected = false;
  208. ProfileControlIsChecked = false;
  209. ModelLeftVisibility = true;
  210. break;
  211. case "Direct":
  212. SelectBtnName = "Furnace Direct";
  213. ResultString = "Furnace Direct";
  214. ProfileControlIsChecked = false;
  215. IsProfileSelected = false;
  216. ModelLeftVisibility = true;
  217. break;
  218. case "Profile":
  219. ResultString = "Profile";
  220. IsProfileSelected = true;
  221. ShowProfileTable();
  222. break;
  223. default:
  224. break;
  225. }
  226. }
  227. public void ShowProfileTable()
  228. {
  229. var windowManager = IoC.Get<IWindowManager>();//"Combination.ProfileCondition"
  230. StringParam profile = CurrentRecipe.ConfigItems.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;
  231. if (profile == null)
  232. {
  233. DialogBox.ShowDialog(DialogButton.Cancel, DialogType.INFO, "Please set the combinatin file first");
  234. return;
  235. }
  236. TempProfileEditViewModel tempProfileEditViewModel;
  237. tempProfileEditViewModel = new TempProfileEditViewModel();
  238. tempProfileEditViewModel.CurrentRecipe = CurrentRecipe;
  239. tempProfileEditViewModel.IsEditEnabled = false;
  240. tempProfileEditViewModel.ProfileTable1.IsChecked = false;
  241. tempProfileEditViewModel.ProfileTable2.IsChecked = false;
  242. tempProfileEditViewModel.ProfileTable3.IsChecked = false;
  243. string test = SelectProfileTable;
  244. if (SelectProfileTable != null && SelectProfileTable != "Heater" && SelectProfileTable != "Furnace Direct" && SelectProfileTable != "Furnace" && SelectProfileTable != "")
  245. {
  246. if (CurrentRecipe == null && SelectProfileTable.Contains(":"))
  247. {
  248. if (SelectProfileTable.Split(':')[0] == "1")
  249. {
  250. tempProfileEditViewModel.Table1CheckinRecipe = true;
  251. }
  252. if (SelectProfileTable.Split(':')[0] == "2")
  253. {
  254. tempProfileEditViewModel.Table2CheckinRecipe = true;
  255. }
  256. if (SelectProfileTable.Split(':')[0] == "3")
  257. {
  258. tempProfileEditViewModel.Table3CheckinRecipe = true;
  259. }
  260. }
  261. else
  262. {
  263. if (SelectProfileTable.Split(',')[1] == "1")
  264. {
  265. tempProfileEditViewModel.Table1CheckinRecipe = true;
  266. }
  267. if (SelectProfileTable.Split(',')[1] == "2")
  268. {
  269. tempProfileEditViewModel.Table2CheckinRecipe = true;
  270. }
  271. if (SelectProfileTable.Split(',')[1] == "3")
  272. {
  273. tempProfileEditViewModel.Table3CheckinRecipe = true;
  274. }
  275. }
  276. }
  277. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(tempProfileEditViewModel, null, "TempProfileEdit"))
  278. {
  279. SelectProfileTable = tempProfileEditViewModel.ResultString;
  280. ResultString = $"Profile({tempProfileEditViewModel.ResultString})";
  281. }
  282. else
  283. {
  284. if (string.IsNullOrEmpty(tempProfileEditViewModel.ResultString))
  285. {
  286. if (!string.IsNullOrEmpty(ResultString) && !ResultString.Contains(","))
  287. {
  288. ResultString = "";
  289. SelectProfileTable = "";
  290. }
  291. }
  292. }
  293. }
  294. public void TempSetSave()
  295. {
  296. if (string.IsNullOrEmpty(ResultString) && !string.IsNullOrEmpty(SelectProfileTable))
  297. {
  298. ResultString = SelectProfileTable.Contains("Profile") ? $"{SelectProfileTable})" : SelectProfileTable;
  299. }
  300. IsSave = true;
  301. ((Window)GetView()).DialogResult = true;
  302. }
  303. public void TempSetCancel()
  304. {
  305. IsSave = false;
  306. ((Window)GetView()).DialogResult = false;
  307. }
  308. }
  309. }