PlatingCellHomePageViewModel.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.UI.MVVM;
  4. using Caliburn.Micro;
  5. using MECF.Framework.Common.CommonData.Metal;
  6. using MECF.Framework.Common.CommonData.PlatingCell;
  7. using MECF.Framework.Common.CommonData.PowerSupplier;
  8. using MECF.Framework.Common.CommonData.Reservoir;
  9. using MECF.Framework.Common.CommonData.SRD;
  10. using MECF.Framework.Common.DataCenter;
  11. using MECF.Framework.Common.OperationCenter;
  12. using MECF.Framework.Common.Persistent.Reservoirs;
  13. using MECF.Framework.Common.Persistent.SRD;
  14. using MECF.Framework.Common.RecipeCenter;
  15. using MECF.Framework.Common.ToolLayout;
  16. using MECF.Framework.Common.Utilities;
  17. using Prism.Mvvm;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. using System.Windows.Forms.VisualStyles;
  24. using System.Windows.Input;
  25. using System.Windows.Threading;
  26. namespace PunkHPX8_MainPages.ViewModels
  27. {
  28. public class PlatingCellHomePageViewModel : BindableBase
  29. {
  30. #region 常量
  31. private const string PERSISTENT_VALUE = "PersistentValue";
  32. private const string PLATINGCELLDATA = "PlatingCellData";
  33. #endregion
  34. #region 内部变量
  35. #region Common
  36. /// <summary>
  37. /// 模块名称
  38. /// </summary>
  39. private string _module;
  40. /// <summary>
  41. /// 当前选择Recipe节点
  42. /// </summary>
  43. private RecipeNode _selectedRecipeNode;
  44. /// <summary>
  45. /// PlatingCellData
  46. /// </summary>
  47. private PlatingCellData _platingCellCommonData;
  48. /// <summary>
  49. /// ReservoirData
  50. /// </summary>
  51. private ReservoirData _reservoirCommonData;
  52. /// <summary>
  53. /// Persistent
  54. /// </summary>
  55. private PlatingCellPersistentValue _platingCellPersistent;
  56. /// <summary>
  57. /// platingCellItem
  58. /// </summary>
  59. private PlatingCellItem _metalItem;
  60. /// <summary>
  61. /// WaferSize
  62. /// </summary>
  63. private int _selectedWaferSize = 0;
  64. /// <summary>
  65. /// Wafer Size List
  66. /// </summary>
  67. private List<int> _waferSizeList = new List<int>();
  68. /// <summary>
  69. /// 页面功能启用
  70. /// </summary>
  71. private bool _isEnabled;
  72. /// <summary>
  73. /// UI左边部分启用
  74. /// </summary>
  75. private bool _isLeftEnabled;
  76. /// <summary>
  77. /// AutoMode页面功能启用
  78. /// </summary>
  79. private bool _isAutoEnabled;
  80. /// <summary>
  81. /// 对应reservoir的name
  82. /// </summary>
  83. private string _reservoirName;
  84. #endregion
  85. /// <summary>
  86. /// SeqRecipe
  87. /// </summary>
  88. private string _seqRecipe;
  89. #region 系统数据
  90. /// <summary>
  91. /// 定时器
  92. /// </summary>
  93. DispatcherTimer _timer;
  94. /// <summary>
  95. /// 查询后台数据集合
  96. /// </summary>
  97. private List<string> _rtDataKeys = new List<string>();
  98. /// <summary>
  99. /// rt查询key数值字典
  100. /// </summary>
  101. private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
  102. #endregion
  103. #region platingCell
  104. /// <summary>
  105. /// RecipeContent
  106. /// </summary>
  107. private string _recipeContent;
  108. /// <summary>
  109. /// TimeRemaining
  110. /// </summary>
  111. private double _timeRemaining;
  112. /// <summary>
  113. /// OfTotalTime
  114. /// </summary>
  115. private double _totalTime;
  116. /// <summary>
  117. /// OperatingMode
  118. /// </summary>
  119. private string _operatingMode;
  120. /// <summary>
  121. /// State
  122. /// </summary>
  123. private string _state;
  124. /// <summary>
  125. /// RecipeMode
  126. /// </summary>
  127. private string _recipeMode;
  128. #endregion
  129. #region dep recipe
  130. /// <summary>
  131. /// RecipeModuleName
  132. /// </summary>
  133. private string _recipeModuleName;
  134. /// <summary>
  135. /// RecipeType
  136. /// </summary>
  137. private string _recipeType;
  138. /// <summary>
  139. /// AchievedRunRecipeCycle
  140. /// </summary>
  141. private int _achievedRunRecipeCycle;
  142. /// <summary>
  143. /// 当前Recipe
  144. /// </summary>
  145. private string _currentRecipe;
  146. /// <summary>
  147. /// 当前Recipe的化学液
  148. /// </summary>
  149. private string _chemistry;
  150. #endregion
  151. #region UI Related
  152. /// <summary>
  153. /// IsErrorState
  154. /// </summary>
  155. private bool _isErrorState;
  156. #endregion
  157. #region PowerSupplier
  158. /// <summary>
  159. /// PowerSuplier数据
  160. /// </summary>
  161. private PowerSupplierData _powerSupplierData;
  162. #endregion
  163. #region 属性
  164. #region Common
  165. /// <summary>
  166. /// PlatingCellData
  167. /// </summary>
  168. public PlatingCellData PlatingCellCommonData
  169. {
  170. get { return _platingCellCommonData; }
  171. set { SetProperty(ref _platingCellCommonData, value); }
  172. }
  173. /// <summary>
  174. /// PlatingCellData
  175. /// </summary>
  176. public ReservoirData ReservoirCommonData
  177. {
  178. get { return _reservoirCommonData; }
  179. set { SetProperty(ref _reservoirCommonData, value); }
  180. }
  181. /// <summary>
  182. /// Persistent
  183. /// </summary>
  184. public PlatingCellPersistentValue PlatingCellPersistent
  185. {
  186. get { return _platingCellPersistent; }
  187. set { SetProperty(ref _platingCellPersistent, value); }
  188. }
  189. /// <summary>
  190. /// 模块名称
  191. /// </summary>
  192. public string Module
  193. {
  194. get { return _module; }
  195. set { SetProperty(ref _module, value); }
  196. }
  197. /// <summary>
  198. /// 当前选择Recipe节点
  199. /// </summary>
  200. public RecipeNode SelectedRecipeNode
  201. {
  202. get { return _selectedRecipeNode; }
  203. set { SetProperty(ref _selectedRecipeNode, value); }
  204. }
  205. /// <summary>
  206. /// WaferSize
  207. /// </summary>
  208. public int SelectedWaferSize
  209. {
  210. get { return _selectedWaferSize; }
  211. set { SetProperty(ref _selectedWaferSize, value); }
  212. }
  213. /// <summary>
  214. /// WaferSizeList
  215. /// </summary>
  216. public List<int> WaferSizeList
  217. {
  218. get { return _waferSizeList; }
  219. set { SetProperty(ref _waferSizeList, value); }
  220. }
  221. /// <summary>
  222. /// 页面功能启用
  223. /// </summary>
  224. public bool IsEnabled
  225. {
  226. get { return _isEnabled; }
  227. set { SetProperty(ref _isEnabled, value); }
  228. }
  229. /// <summary>
  230. /// 页面ui左边功能启用
  231. /// </summary>
  232. public bool IsLeftEnabled
  233. {
  234. get { return _isLeftEnabled; }
  235. set { SetProperty(ref _isLeftEnabled, value); }
  236. }
  237. /// <summary>
  238. /// AutoMode页面功能启用
  239. /// </summary>
  240. public bool IsAutoEnabled
  241. {
  242. get { return _isAutoEnabled; }
  243. set { SetProperty(ref _isAutoEnabled, value); }
  244. }
  245. /// <summary>
  246. /// Reservoir Name
  247. /// </summary>
  248. public string ReservoirName
  249. {
  250. get { return _reservoirName; }
  251. set { SetProperty(ref _reservoirName, value); }
  252. }
  253. #endregion
  254. /// SeqRecipe
  255. /// </summary>
  256. public string SeqRecipe
  257. {
  258. get { return _seqRecipe; }
  259. set { SetProperty(ref _seqRecipe, value); }
  260. }
  261. #region PlatingCell
  262. /// <summary>
  263. /// RecipeContent
  264. /// </summary>
  265. public string RecipeContent
  266. {
  267. get { return _recipeContent; }
  268. set { SetProperty(ref _recipeContent, value); }
  269. }
  270. /// <summary>
  271. /// TimeRemaining
  272. /// </summary>
  273. public double TimeRemaining
  274. {
  275. get { return _timeRemaining; }
  276. set { SetProperty(ref _timeRemaining, value); }
  277. }
  278. /// <summary>
  279. /// TotalTime
  280. /// </summary>
  281. public double TotalTime
  282. {
  283. get { return _totalTime; }
  284. set { SetProperty(ref _totalTime, value); }
  285. }
  286. /// <summary>
  287. /// OperatingMode
  288. /// </summary>
  289. public string OperatingMode
  290. {
  291. get { return _operatingMode; }
  292. set { SetProperty(ref _operatingMode, value); }
  293. }
  294. /// <summary>
  295. /// State
  296. /// </summary>
  297. public string State
  298. {
  299. get { return _state; }
  300. set { SetProperty(ref _state, value); }
  301. }
  302. /// <summary>
  303. /// RecipeMode
  304. /// </summary>
  305. public string RecipeMode
  306. {
  307. get { return _recipeMode; }
  308. set { SetProperty(ref _recipeMode, value); }
  309. }
  310. #endregion
  311. #region Metal recipe
  312. /// <summary>
  313. /// RecipeModuleName
  314. /// </summary>
  315. public string RecipeModuleName
  316. {
  317. get { return _recipeModuleName; }
  318. set { SetProperty(ref _recipeModuleName, value); }
  319. }
  320. /// <summary>
  321. /// RecipeType
  322. /// </summary>
  323. public string RecipeType
  324. {
  325. get { return _recipeType; }
  326. set { SetProperty(ref _recipeType, value); }
  327. }
  328. /// <summary>
  329. /// Run Recipe已经完成的次数
  330. /// </summary>
  331. public int AchievedRunRecipeCycle
  332. {
  333. get { return _achievedRunRecipeCycle; }
  334. set { SetProperty(ref _achievedRunRecipeCycle, value); }
  335. }
  336. /// <summary>
  337. /// 当前Recipe
  338. /// </summary>
  339. public string CurrentRecipe
  340. {
  341. get { return _currentRecipe; }
  342. set { SetProperty(ref _currentRecipe, value); }
  343. }
  344. /// <summary>
  345. /// 当前Recipe
  346. /// </summary>
  347. public string Chemistry
  348. {
  349. get { return _chemistry; }
  350. set { SetProperty(ref _chemistry, value); }
  351. }
  352. #endregion
  353. #region UI Related
  354. /// <summary>
  355. /// IsErrorState
  356. /// </summary>
  357. public bool IsErrorState
  358. {
  359. get { return _isErrorState; }
  360. set { SetProperty(ref _isErrorState, value); }
  361. }
  362. #endregion
  363. /// <summary>
  364. /// SidA PowerSuplier数据
  365. /// </summary>
  366. public PowerSupplierData PowerSupplierData
  367. {
  368. get { return _powerSupplierData; }
  369. set { SetProperty(ref _powerSupplierData, value); }
  370. }
  371. #endregion
  372. #endregion
  373. #region Command指令
  374. public ICommand InitializeCommand { get; set; }
  375. #endregion
  376. /// <summary>
  377. /// 构造函数
  378. /// </summary>
  379. public PlatingCellHomePageViewModel()
  380. {
  381. InitializeCommand = new DelegateCommand<object>(InitializeAction);
  382. WaferSizeList.Add((int)WaferSize.WS6);
  383. WaferSizeList.Add((int)WaferSize.WS8);
  384. WaferSizeList.Add((int)WaferSize.WS12);
  385. }
  386. /// <summary>
  387. /// 加载数据
  388. /// </summary>
  389. public void LoadData(string systemName)
  390. {
  391. Module = systemName;
  392. if (!String.IsNullOrEmpty(Module) && ("PlatingCell1".Equals(Module) || "PlatingCell3".Equals(Module)))
  393. {
  394. IsLeftEnabled = true;
  395. }
  396. else
  397. {
  398. IsLeftEnabled= false;
  399. }
  400. RecipeModuleName = "DEP Recipe";
  401. RecipeType = "dep";
  402. _rtDataKeys.Clear();
  403. _rtDataKeys.Add($"{Module}.FsmState");
  404. _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
  405. _rtDataKeys.Add($"{Module}.CurrentRecipe");
  406. _rtDataKeys.Add($"{Module}.TotalTime");
  407. _rtDataKeys.Add($"{Module}.TimeRemain");
  408. _rtDataKeys.Add($"{Module}.{PLATINGCELLDATA}");
  409. _rtDataKeys.Add($"{Module}.ReservoirCommonData");
  410. _rtDataKeys.Add($"{Module}.ReservoirName");
  411. _rtDataKeys.Add($"{Module}.Chemistry");
  412. if (_timer == null)
  413. {
  414. _timer = new DispatcherTimer();
  415. _timer.Interval = TimeSpan.FromMilliseconds(200);
  416. _timer.Tick += Timer_Tick;
  417. }
  418. _timer.Start();
  419. }
  420. /// <summary>
  421. /// 定时器执行
  422. /// </summary>
  423. /// <param name="sender"></param>
  424. /// <param name="e"></param>
  425. private void Timer_Tick(object sender, EventArgs e)
  426. {
  427. if (_rtDataKeys.Count != 0)
  428. {
  429. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  430. if (_rtDataValueDic != null)
  431. {
  432. PlatingCellPersistent = CommonFunction.GetValue<PlatingCellPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
  433. State = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
  434. CurrentRecipe = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.CurrentRecipe");
  435. TotalTime = CommonFunction.GetValue<int>(_rtDataValueDic, $"{Module}.TotalTime");
  436. TimeRemaining = CommonFunction.GetValue<int>(_rtDataValueDic, $"{Module}.TimeRemain");
  437. PlatingCellCommonData = CommonFunction.GetValue<PlatingCellData>(_rtDataValueDic, $"{Module}.{PLATINGCELLDATA}");
  438. ReservoirCommonData = CommonFunction.GetValue<ReservoirData>(_rtDataValueDic, $"{Module}.ReservoirCommonData");
  439. Chemistry = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.Chemistry");
  440. ReservoirName = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.ReservoirName");
  441. }
  442. }
  443. }
  444. /// <summary>
  445. /// 隐藏
  446. /// </summary>
  447. public void Hide()
  448. {
  449. if (_timer != null)
  450. {
  451. _timer.Stop();
  452. }
  453. }
  454. /// <summary>
  455. /// Initialize Action
  456. /// </summary>
  457. /// <param name="param"></param>
  458. private void InitializeAction(object param)
  459. {
  460. InvokeClient.Instance.Service.DoOperation($"{Module}.InitializeAll");
  461. }
  462. }
  463. }