DryerHomePageViewModel.cs 16 KB

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