VPWCellViewModel.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. using Aitex.Core.Common;
  2. using Aitex.Core.UI.MVVM;
  3. using MECF.Framework.Common.CommonData.Vpw;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.OperationCenter;
  7. using MECF.Framework.Common.Persistent.VpwCell;
  8. using MECF.Framework.Common.Persistent.VpwMain;
  9. using MECF.Framework.Common.Utilities;
  10. using Prism.Mvvm;
  11. using PunkHPX8_MainPages.Unity;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using System.Windows.Input;
  18. using System.Windows.Threading;
  19. using WaferInfo = OpenSEMI.ClientBase.WaferInfo;
  20. namespace PunkHPX8_MainPages.ViewModels
  21. {
  22. public class VPWCellViewModel:BindableBase
  23. {
  24. #region 常量
  25. private const string COMMONDATA = "CommonData";
  26. private const string VPW = "vpw";
  27. private const string PERSISTENT_VALUE = "PersistentValue";
  28. #endregion
  29. #region 内部变量
  30. #region Common
  31. /// <summary>
  32. /// 模块名称
  33. /// </summary>
  34. private string _module;
  35. /// <summary>
  36. /// StateMachine
  37. /// </summary>
  38. private string _stateMachine;
  39. /// <summary>
  40. /// Status
  41. /// </summary>
  42. private string _status;
  43. /// <summary>
  44. /// 数据
  45. /// </summary>
  46. private VpwCellCommonData _vpwCellCommonData;
  47. /// <summary>
  48. /// VPW Main数据
  49. /// </summary>
  50. private VpwMainCommonData _vpwMainCommonData;
  51. /// <summary>
  52. /// Threshold
  53. /// </summary>
  54. private VpwCellPersistentValue _vpwCellPersistent;
  55. /// <summary>
  56. /// 是否是Manual模式
  57. /// </summary>
  58. private bool _isManualOperationMode;
  59. /// <summary>
  60. /// WaferSize
  61. /// </summary>
  62. private int _selectedWaferSize = 0;
  63. /// <summary>
  64. /// Wafer Size List
  65. /// </summary>
  66. private List<int> _waferSizeList = new List<int>();
  67. #endregion
  68. #region VPW recipe
  69. /// <summary>
  70. /// RecipeModuleName
  71. /// </summary>
  72. private string _recipeModuleName;
  73. /// <summary>
  74. /// RecipeType
  75. /// </summary>
  76. private string _recipeType;
  77. /// <summary>
  78. /// AchievedRunRecipeCycle
  79. /// </summary>
  80. private int _achievedRunRecipeCycle;
  81. /// <summary>
  82. /// 当前Recipe
  83. /// </summary>
  84. private string _currentRecipe;
  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 Machine
  103. /// </summary>
  104. private string _state;
  105. /// <summary>
  106. /// RecipeMode
  107. /// </summary>
  108. private string _recipeMode;
  109. #endregion
  110. #region UI
  111. /// <summary>
  112. /// IsErrorState 用于腔体变红
  113. /// </summary>
  114. private bool _isErrorState;
  115. /// <summary>
  116. /// 页面功能启用
  117. /// </summary>
  118. private bool _isEnabled;
  119. /// <summary>
  120. /// AutoMode页面功能启用
  121. /// </summary>
  122. private bool _isAutoEnabled;
  123. /// <summary>
  124. /// 水阻值
  125. /// </summary>
  126. private double _diwLoopDo;
  127. #endregion
  128. #endregion
  129. #region 系统数据
  130. /// <summary>
  131. /// 定时器
  132. /// </summary>
  133. DispatcherTimer _timer;
  134. /// <summary>
  135. /// 查询后台数据集合
  136. /// </summary>
  137. private List<string> _rtDataKeys = new List<string>();
  138. /// <summary>
  139. /// rt查询key数值字典
  140. /// </summary>
  141. private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
  142. #endregion
  143. #region 属性
  144. #region Common
  145. /// <summary>
  146. /// 模块名称
  147. /// </summary>
  148. public string Module { get { return _module; } set { SetProperty(ref _module, value); } }
  149. /// <summary>
  150. /// StateMachine
  151. /// </summary>
  152. public string StateMachine { get { return _stateMachine; } set { SetProperty(ref _stateMachine, value); } }
  153. /// <summary>
  154. /// Status
  155. /// </summary>
  156. public string Status { get { return _status; } set { SetProperty(ref _status, value); } }
  157. /// <summary>
  158. /// Commondata
  159. /// </summary>
  160. public VpwMainCommonData VpwMainCommonData
  161. {
  162. get { return _vpwMainCommonData; }
  163. set { SetProperty(ref _vpwMainCommonData, value); }
  164. }
  165. /// <summary>
  166. /// Commondata
  167. /// </summary>
  168. public VpwCellCommonData VpwCellCommonData
  169. {
  170. get { return _vpwCellCommonData; }
  171. set { SetProperty(ref _vpwCellCommonData, value); }
  172. }
  173. /// <summary>
  174. /// Persistent
  175. /// </summary>
  176. public VpwCellPersistentValue VpwCellPersistent
  177. {
  178. get { return _vpwCellPersistent; }
  179. set { SetProperty(ref _vpwCellPersistent, value); }
  180. }
  181. /// <summary>
  182. /// 是否是Manual模式
  183. /// </summary>
  184. public bool IsManualOperationMode { get { return _isManualOperationMode; } set { SetProperty(ref _isManualOperationMode, value); } }
  185. #endregion
  186. #region VPW recipe
  187. /// <summary>
  188. /// RecipeModuleName
  189. /// </summary>
  190. public string RecipeModuleName
  191. {
  192. get { return _recipeModuleName; }
  193. set { SetProperty(ref _recipeModuleName, value); }
  194. }
  195. /// <summary>
  196. /// RecipeType
  197. /// </summary>
  198. public string RecipeType
  199. {
  200. get { return _recipeType; }
  201. set { SetProperty(ref _recipeType, value); }
  202. }
  203. public int AchievedRunRecipeCycle
  204. {
  205. get { return _achievedRunRecipeCycle; }
  206. set { SetProperty(ref _achievedRunRecipeCycle, value); }
  207. }
  208. /// <summary>
  209. /// 当前运行的Recipe
  210. /// </summary>
  211. public string CurrentRecipe
  212. {
  213. get { return _currentRecipe; }
  214. set { SetProperty(ref _currentRecipe, value); }
  215. }
  216. /// <summary>
  217. /// RecipeContent
  218. /// </summary>
  219. public string RecipeContent
  220. {
  221. get { return _recipeContent; }
  222. set { SetProperty(ref _recipeContent, value); }
  223. }
  224. /// <summary>
  225. /// TimeRemaining
  226. /// </summary>
  227. public int TimeRemaining
  228. {
  229. get { return _timeRemaining; }
  230. set { SetProperty(ref _timeRemaining, value); }
  231. }
  232. /// <summary>
  233. /// TotalTime
  234. /// </summary>
  235. public int TotalTime
  236. {
  237. get { return _totalTime; }
  238. set { SetProperty(ref _totalTime, value); }
  239. }
  240. /// <summary>
  241. /// OperatingMode
  242. /// </summary>
  243. public string OperatingMode
  244. {
  245. get { return _operatingMode; }
  246. set { SetProperty(ref _operatingMode, value); }
  247. }
  248. /// <summary>
  249. /// State
  250. /// </summary>
  251. public string State
  252. {
  253. get { return _state; }
  254. set { SetProperty(ref _state, value); }
  255. }
  256. /// <summary>
  257. /// RecipeMode
  258. /// </summary>
  259. public string RecipeMode
  260. {
  261. get { return _recipeMode; }
  262. set { SetProperty(ref _recipeMode, value); }
  263. }
  264. /// <summary>
  265. /// WaferSize
  266. /// </summary>
  267. public int SelectedWaferSize
  268. {
  269. get { return _selectedWaferSize; }
  270. set { SetProperty(ref _selectedWaferSize, value); }
  271. }
  272. /// <summary>
  273. /// WaferSizeList
  274. /// </summary>
  275. public List<int> WaferSizeList
  276. {
  277. get { return _waferSizeList; }
  278. set { SetProperty(ref _waferSizeList, value); }
  279. }
  280. #endregion
  281. #region UI
  282. /// <summary>
  283. /// IsErrorState
  284. /// </summary>
  285. public bool IsErrorState { get { return _isErrorState; } set { SetProperty(ref _isErrorState, value); } }
  286. /// <summary>
  287. /// 页面功能启用
  288. /// </summary>
  289. public bool IsEnabled
  290. {
  291. get { return _isEnabled; }
  292. set { SetProperty(ref _isEnabled, value); }
  293. }
  294. /// <summary>
  295. /// AutoMode页面功能启用
  296. /// </summary>
  297. public bool IsAutoEnabled
  298. {
  299. get { return _isAutoEnabled; }
  300. set { SetProperty(ref _isAutoEnabled, value); }
  301. }
  302. /// <summary>
  303. /// 水阻值
  304. /// </summary>
  305. public double DiwLoopDo
  306. {
  307. get { return _diwLoopDo; }
  308. set { SetProperty(ref _diwLoopDo, value); }
  309. }
  310. #endregion
  311. #region wafer
  312. /// <summary>
  313. /// WaferID
  314. /// </summary>
  315. private string _waferID = "";
  316. /// <summary>
  317. /// SeqRecipe
  318. /// </summary>
  319. private string _seqRecipe;
  320. /// <summary>
  321. /// Wafer信息
  322. /// </summary>
  323. private WaferInfo _waferInfo;
  324. #endregion
  325. #region wafer
  326. /// <summary>
  327. /// WaferID
  328. /// </summary>
  329. public string WaferID
  330. {
  331. get { return _waferID; }
  332. set { SetProperty(ref _waferID, value); }
  333. }
  334. /// <summary>
  335. /// SeqRecipe
  336. /// </summary>
  337. public string SeqRecipe
  338. {
  339. get { return _seqRecipe; }
  340. set { SetProperty(ref _seqRecipe, value); }
  341. }
  342. /// <summary>
  343. /// Wafer信息
  344. /// </summary>
  345. public WaferInfo WaferInfo
  346. {
  347. get { return _waferInfo; }
  348. set { SetProperty(ref _waferInfo, value); }
  349. }
  350. #endregion
  351. #endregion
  352. #region Command指令
  353. public ICommand InitializeCommand { get; set; }
  354. public ICommand HomeCommand { get; set; }
  355. #endregion
  356. public VPWCellViewModel()
  357. {
  358. InitializeCommand = new DelegateCommand<object>(InitializeAction);
  359. HomeCommand = new DelegateCommand<object>(HomeAction);
  360. WaferSizeList.Add((int)WaferSize.WS6);
  361. WaferSizeList.Add((int)WaferSize.WS8);
  362. WaferSizeList.Add((int)WaferSize.WS12);
  363. }
  364. /// <summary>
  365. /// 加载数据
  366. /// </summary>
  367. public void LoadData(string systemName)
  368. {
  369. Module = systemName;
  370. RecipeModuleName = "VPW Recipe";
  371. RecipeType = "vpw";
  372. _rtDataKeys.Clear();
  373. List<string> lst = new List<string>();
  374. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(lst);
  375. _rtDataKeys.Add($"{Module}.{PERSISTENT_VALUE}");
  376. _rtDataKeys.Add($"{Module}.{COMMONDATA}");
  377. _rtDataKeys.Add($"{Module}.FsmState");
  378. _rtDataKeys.Add($"VPWMain1.{COMMONDATA}");
  379. _rtDataKeys.Add($"{Module}.AchievedCycle");
  380. _rtDataKeys.Add($"{Module}.LoopDoValue");
  381. _rtDataKeys.Add($"{Module}.VpwWaferSize");
  382. if (_timer == null)
  383. {
  384. _timer = new DispatcherTimer();
  385. _timer.Interval = TimeSpan.FromMilliseconds(200);
  386. _timer.Tick += Timer_Tick;
  387. }
  388. _timer.Start();
  389. }
  390. /// <summary>
  391. /// 定时器执行
  392. /// </summary>
  393. /// <param name="sender"></param>
  394. /// <param name="e"></param>
  395. private void Timer_Tick(object sender, EventArgs e)
  396. {
  397. if (_rtDataKeys.Count != 0)
  398. {
  399. _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
  400. if (_rtDataValueDic != null)
  401. {
  402. VpwCellCommonData = CommonFunction.GetValue<VpwCellCommonData>(_rtDataValueDic, $"{Module}.{COMMONDATA}");
  403. VpwMainCommonData = CommonFunction.GetValue<VpwMainCommonData>(_rtDataValueDic, $"VPWMain1.{COMMONDATA}");
  404. VpwCellPersistent = CommonFunction.GetValue<VpwCellPersistentValue>(_rtDataValueDic, $"{Module}.{PERSISTENT_VALUE}");
  405. StateMachine = CommonFunction.GetValue<string>(_rtDataValueDic, $"{Module}.FsmState");
  406. //VPW Wafer信息
  407. if (ModuleManager.ModuleInfos[Module].WaferManager.Wafers.Count != 0)
  408. {
  409. WaferInfo = ModuleManager.ModuleInfos[Module].WaferManager.Wafers[0];
  410. }
  411. if ("Manual".Equals(VpwCellPersistent.OperatingMode))
  412. {
  413. IsEnabled = true;
  414. IsAutoEnabled = true;
  415. }
  416. else if ("Auto".Equals(VpwCellPersistent.OperatingMode))
  417. {
  418. IsAutoEnabled = true;
  419. IsEnabled = false;
  420. }
  421. else
  422. {
  423. State = "Stopped";
  424. IsEnabled = false;
  425. IsAutoEnabled = false;
  426. }
  427. AchievedRunRecipeCycle = CommonFunction.GetValue<int>(_rtDataValueDic, $"{Module}.AchievedCycle");
  428. DiwLoopDo = CommonFunction.GetValue<double>(_rtDataValueDic, $"{Module}.LoopDoValue");
  429. }
  430. }
  431. }
  432. /// <summary>
  433. /// 隐藏
  434. /// </summary>
  435. public void Hide()
  436. {
  437. if (_timer != null)
  438. {
  439. _timer.Stop();
  440. }
  441. }
  442. #region 指令Action
  443. /// <summary>
  444. /// Initialize Action
  445. /// </summary>
  446. /// <param name="param"></param>
  447. private void InitializeAction(object param)
  448. {
  449. InvokeClient.Instance.Service.DoOperation($"{ModuleName.VPWMain1}.InitializeAll");
  450. }
  451. /// <summary>
  452. /// Home Action
  453. /// </summary>
  454. /// <param name="param"></param>
  455. private void HomeAction(object param)
  456. {
  457. InvokeClient.Instance.Service.DoOperation($"{Module}.Home");
  458. }
  459. #endregion
  460. }
  461. }