PlatingCellHomePageViewModel.cs 16 KB

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