OperationOverViewModel.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. using MECF.Framework.Common.CommonData;
  2. using MECF.Framework.Common.DataCenter;
  3. using OpenSEMI.ClientBase;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Threading;
  12. using Venus_MainPages.Unity;
  13. using Venus_Themes.CustomControls;
  14. namespace Venus_MainPages.ViewModels
  15. {
  16. public class OperationOverViewModel : BindableBase
  17. {
  18. #region 私有字段
  19. private bool m_TabIsChecked=true;
  20. private ModuleInfo m_LP1ModuleInfo;
  21. private ModuleInfo m_LP2ModuleInfo;
  22. private ModuleInfo m_LP3ModuleInfo;
  23. private WaferRobotTAction m_Robot1TAction;
  24. private WaferRobotXAction m_Robot1XAction;
  25. private WaferRobotTAction m_Robot2TAction;
  26. private WaferRobotXAction m_Robot2XAction;
  27. private RobotMoveInfo m_robotMoveInfo;
  28. int arm1oldWaferStatus = 100;
  29. int arm2oldWaferStatus = 100;
  30. private WaferInfo m_PMAWafer;
  31. private WaferInfo m_PMBWafer;
  32. private WaferInfo m_PMCWafer;
  33. private WaferInfo m_PMDWafer;
  34. private WaferInfo m_LLAWafer;
  35. private WaferInfo m_LLBWafer;
  36. private WaferInfo m_TMBladeAWafer;
  37. private WaferInfo m_TMBladeBWafer;
  38. private List<string> m_RtDataKeys = new List<string>();
  39. private Dictionary<string, object> m_RtDataValues;
  40. private bool m_PMAIsInstalled;
  41. private bool m_PMBIsInstalled;
  42. private bool m_PMCIsInstalled;
  43. private bool m_PMDIsInstalled;
  44. private bool m_LLAIsInstalled;
  45. private bool m_LLBIsInstalled;
  46. private bool m_TMIsInstalled;
  47. private bool m_EFEMIsInstalled;
  48. private WaferInfo m_EFEMBladeAWafer;
  49. private WaferInfo m_EFEMBladeBWafer;
  50. private WaferInfo m_Aligner1Wafer;
  51. private int m_LP1WaferCount;
  52. private int m_LP2WaferCount;
  53. private int m_LP3WaferCount;
  54. private WaferAssociationInfo _lp1WaferAssociation;
  55. private WaferAssociationInfo _lp2WaferAssociation;
  56. private WaferAssociationInfo _lp3WaferAssociation;
  57. #endregion
  58. #region 属性
  59. public bool TabIsChecked
  60. {
  61. get { return m_TabIsChecked; }
  62. set { SetProperty(ref m_TabIsChecked, value); }
  63. }
  64. public ModuleInfo LP1ModuleInfo
  65. {
  66. get { return m_LP1ModuleInfo; }
  67. set { SetProperty(ref m_LP1ModuleInfo, value); }
  68. }
  69. public ModuleInfo LP2ModuleInfo
  70. {
  71. get { return m_LP2ModuleInfo; }
  72. set { SetProperty(ref m_LP2ModuleInfo, value); }
  73. }
  74. public ModuleInfo LP3ModuleInfo
  75. {
  76. get { return m_LP3ModuleInfo; }
  77. set { SetProperty(ref m_LP3ModuleInfo, value); }
  78. }
  79. public WaferRobotTAction Robot1TAction
  80. {
  81. get { return m_Robot1TAction; }
  82. set { SetProperty(ref m_Robot1TAction, value); }
  83. }
  84. public WaferRobotXAction Robot1XAction
  85. {
  86. get { return m_Robot1XAction; }
  87. set { SetProperty(ref m_Robot1XAction, value); }
  88. }
  89. public WaferRobotTAction Robot2TAction
  90. {
  91. get { return m_Robot2TAction; }
  92. set { SetProperty(ref m_Robot2TAction, value); }
  93. }
  94. public WaferRobotXAction Robot2XAction
  95. {
  96. get { return m_Robot2XAction; }
  97. set { SetProperty(ref m_Robot2XAction, value); }
  98. }
  99. public RobotMoveInfo RobotMoveInfo
  100. {
  101. get { return m_robotMoveInfo; }
  102. set
  103. {
  104. RobotMoveInfoChanged(m_robotMoveInfo, value);
  105. m_robotMoveInfo = value;
  106. }
  107. }
  108. public WaferInfo LLAWafer
  109. {
  110. get { return m_LLAWafer; }
  111. set { SetProperty(ref m_LLAWafer, value); }
  112. }
  113. public WaferInfo LLBWafer
  114. {
  115. get { return m_LLBWafer; }
  116. set { SetProperty(ref m_LLBWafer, value); }
  117. }
  118. public WaferInfo PMAWafer
  119. {
  120. get { return m_PMAWafer; }
  121. set { SetProperty(ref m_PMAWafer, value); }
  122. }
  123. public WaferInfo PMBWafer
  124. {
  125. get { return m_PMBWafer; }
  126. set { SetProperty(ref m_PMBWafer, value); }
  127. }
  128. public WaferInfo PMCWafer
  129. {
  130. get { return m_PMCWafer; }
  131. set { SetProperty(ref m_PMCWafer, value); }
  132. }
  133. public WaferInfo PMDWafer
  134. {
  135. get { return m_PMDWafer; }
  136. set { SetProperty(ref m_PMDWafer, value); }
  137. }
  138. public WaferInfo TMBladeAWafer
  139. {
  140. get { return m_TMBladeAWafer; }
  141. set { SetProperty(ref m_TMBladeAWafer, value); }
  142. }
  143. public WaferInfo TMBladeBWafer
  144. {
  145. get { return m_TMBladeBWafer; }
  146. set { SetProperty(ref m_TMBladeBWafer, value); }
  147. }
  148. public Dictionary<string, object> RtDataValues
  149. {
  150. get { return m_RtDataValues; }
  151. set { SetProperty(ref m_RtDataValues, value); }
  152. }
  153. public bool PMAIsInstalled
  154. {
  155. get { return m_PMAIsInstalled; }
  156. set { SetProperty(ref m_PMAIsInstalled, value); }
  157. }
  158. public bool PMBIsInstalled
  159. {
  160. get { return m_PMBIsInstalled; }
  161. set { SetProperty(ref m_PMBIsInstalled, value); }
  162. }
  163. public bool PMCIsInstalled
  164. {
  165. get { return m_PMCIsInstalled; }
  166. set { SetProperty(ref m_PMCIsInstalled, value); }
  167. }
  168. public bool PMDIsInstalled
  169. {
  170. get { return m_PMDIsInstalled; }
  171. set { SetProperty(ref m_PMDIsInstalled, value); }
  172. }
  173. public bool LLAIsInstalled
  174. {
  175. get { return m_LLAIsInstalled; }
  176. set { SetProperty(ref m_LLAIsInstalled, value); }
  177. }
  178. public bool LLBIsInstalled
  179. {
  180. get { return m_LLBIsInstalled; }
  181. set { SetProperty(ref m_LLBIsInstalled, value); }
  182. }
  183. public bool TMIsInstalled
  184. {
  185. get { return m_TMIsInstalled; }
  186. set { SetProperty(ref m_TMIsInstalled, value); }
  187. }
  188. public bool EFEMIsInstalled
  189. {
  190. get { return m_EFEMIsInstalled; }
  191. set { SetProperty(ref m_EFEMIsInstalled, value); }
  192. }
  193. public WaferInfo EFEMBladeAWafer
  194. {
  195. get { return m_EFEMBladeAWafer; }
  196. set { SetProperty(ref m_EFEMBladeAWafer, value); }
  197. }
  198. public WaferInfo EFEMBladeBWafer
  199. {
  200. get { return m_EFEMBladeBWafer; }
  201. set { SetProperty(ref m_EFEMBladeBWafer, value); }
  202. }
  203. public WaferInfo Aligner1Wafer
  204. {
  205. get { return m_Aligner1Wafer; }
  206. set { SetProperty(ref m_Aligner1Wafer, value); }
  207. }
  208. public int LP1WaferCount
  209. {
  210. get { return m_LP1WaferCount; }
  211. set { SetProperty(ref m_LP1WaferCount, value); }
  212. }
  213. public int LP2WaferCount
  214. {
  215. get { return m_LP2WaferCount; }
  216. set { SetProperty(ref m_LP2WaferCount, value); }
  217. }
  218. public int LP3WaferCount
  219. {
  220. get { return m_LP3WaferCount; }
  221. set { SetProperty(ref m_LP3WaferCount, value); }
  222. }
  223. public WaferAssociationInfo LP1WaferAssociation
  224. {
  225. get { return _lp1WaferAssociation; }
  226. set { SetProperty(ref _lp1WaferAssociation, value); }
  227. }
  228. public WaferAssociationInfo LP2WaferAssociation
  229. {
  230. get { return _lp2WaferAssociation; }
  231. set { SetProperty(ref _lp2WaferAssociation, value); }
  232. }
  233. public WaferAssociationInfo LP3WaferAssociation
  234. {
  235. get { return _lp3WaferAssociation; }
  236. set { SetProperty(ref _lp3WaferAssociation, value); }
  237. }
  238. #endregion
  239. #region 命令
  240. private DelegateCommand _LoadCommand;
  241. public DelegateCommand LoadCommand =>
  242. _LoadCommand ?? (_LoadCommand = new DelegateCommand(OnLoad));
  243. #endregion
  244. #region 构造函数
  245. public OperationOverViewModel()
  246. {
  247. DispatcherTimer timer = new DispatcherTimer();
  248. timer.Interval = TimeSpan.FromSeconds(0.5);
  249. timer.Tick += Timer_Tick;
  250. timer.Start();
  251. addDataKeys();
  252. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  253. PMAIsInstalled = allModules.Contains("PMA");
  254. PMBIsInstalled = allModules.Contains("PMB");
  255. PMCIsInstalled = allModules.Contains("PMC");
  256. PMDIsInstalled = allModules.Contains("PMD");
  257. LLAIsInstalled = allModules.Contains("LLA");
  258. LLBIsInstalled = allModules.Contains("LLB");
  259. EFEMIsInstalled = allModules.Contains("EFEM");
  260. }
  261. #endregion
  262. #region 命令方法
  263. private void OnLoad()
  264. {
  265. LP1WaferAssociation = new WaferAssociationInfo();
  266. LP1WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP1"];
  267. LP2WaferAssociation = new WaferAssociationInfo();
  268. LP2WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP2"];
  269. LP3WaferAssociation = new WaferAssociationInfo();
  270. LP3WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP3"];
  271. }
  272. #endregion
  273. #region 私有方法
  274. private void Timer_Tick(object sender, EventArgs e)
  275. {
  276. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  277. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  278. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  279. if (LLAIsInstalled == true)
  280. {
  281. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  282. }
  283. if (LLBIsInstalled == true)
  284. {
  285. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  286. }
  287. if (PMAIsInstalled == true)
  288. {
  289. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  290. }
  291. if (PMBIsInstalled == true)
  292. {
  293. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  294. }
  295. if (PMCIsInstalled == true)
  296. {
  297. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  298. }
  299. if (PMDIsInstalled == true)
  300. {
  301. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  302. }
  303. if (TMIsInstalled == true)
  304. {
  305. TMBladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];
  306. TMBladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];
  307. }
  308. if (EFEMIsInstalled == true)
  309. {
  310. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  311. EFEMBladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
  312. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  313. }
  314. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  315. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  316. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x=>x.WaferStatus!=0).Count();
  317. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  318. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  319. }
  320. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  321. {
  322. string RobotTarget;
  323. if (oldValue == null || newValue == null)
  324. {
  325. return;
  326. }
  327. #region pick 和 place LL
  328. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  329. {
  330. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  331. if (TMRobotMoveActionBladeTarget != null)
  332. {
  333. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  334. }
  335. else
  336. {
  337. return;
  338. }
  339. var values = RobotTarget.Split('.');
  340. var arm = values[0];
  341. var module = values[1];
  342. if (arm == "ArmA")
  343. {
  344. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  345. await Task.Delay(1500);
  346. Robot1XAction = WaferRobotXAction.Extend;
  347. await Task.Delay(3000);
  348. Robot1XAction = WaferRobotXAction.Retract;
  349. }
  350. else if (arm == "ArmB")
  351. {
  352. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  353. await Task.Delay(1500);
  354. Robot2XAction = WaferRobotXAction.Extend;
  355. await Task.Delay(3000);
  356. Robot2XAction = WaferRobotXAction.Retract;
  357. }
  358. }
  359. #endregion
  360. #region pick 和 place pm
  361. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  362. {
  363. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  364. if (TMRobotMoveActionBladeTarget != null)
  365. {
  366. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  367. }
  368. else
  369. {
  370. return;
  371. }
  372. var values = RobotTarget.Split('.');
  373. var arm = values[0];
  374. var module = values[1];
  375. if (arm == "ArmA")
  376. {
  377. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  378. await Task.Delay(1500);
  379. Robot1XAction = WaferRobotXAction.Extend;
  380. }
  381. else if (arm == "ArmB")
  382. {
  383. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  384. await Task.Delay(1500);
  385. Robot2XAction = WaferRobotXAction.Extend;
  386. }
  387. }
  388. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  389. {
  390. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  391. if (TMRobotMoveActionBladeTarget != null)
  392. {
  393. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  394. }
  395. else
  396. {
  397. return;
  398. }
  399. var values = RobotTarget.Split('.');
  400. var arm = values[0];
  401. if (arm == "ArmA")
  402. {
  403. Robot1XAction = WaferRobotXAction.Retract;
  404. }
  405. else if (arm == "ArmB")
  406. {
  407. Robot2XAction = WaferRobotXAction.Retract;
  408. }
  409. }
  410. #endregion
  411. arm1oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus;
  412. arm2oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus;
  413. }
  414. private void addDataKeys()
  415. {
  416. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  417. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  418. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  419. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  420. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  421. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  422. }
  423. #endregion
  424. }
  425. }