VPWCellViewModel.cs 14 KB

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