MetalSHHomePageViewModel.cs 17 KB

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