TMViewModel.cs 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. using Aitex.Sorter.Common;
  2. using MECF.Framework.Common.CommonData;
  3. using MECF.Framework.Common.DataCenter;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.OperationCenter;
  6. using MECF.Framework.Common.Schedulers;
  7. using OpenSEMI.ClientBase;
  8. using Prism.Commands;
  9. using Prism.Mvvm;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.Linq;
  14. using System.Threading.Tasks;
  15. using System.Windows.Threading;
  16. using Venus_Core;
  17. using Venus_MainPages.Unity;
  18. using Venus_Themes.CustomControls;
  19. namespace Venus_MainPages.ViewModels
  20. {
  21. public enum TMModule
  22. {
  23. PMA, PMB, PMC, PMD, LLA, LLB
  24. }
  25. public enum TMBlade
  26. {
  27. Blade1, Blade2
  28. }
  29. internal class TMViewModel : BindableBase
  30. {
  31. #region 私有字段
  32. //private ModuleInfo m_PMAWafer;
  33. private ModuleInfo m_LLAModuleInfo;
  34. private ModuleInfo m_LLBModuleInfo;
  35. private bool m_TMIsOFFline;
  36. private bool m_LLIsOFFline;
  37. private WaferInfo m_PMAWafer;
  38. private WaferInfo m_PMBWafer;
  39. private WaferInfo m_PMCWafer;
  40. private WaferInfo m_PMDWafer;
  41. private WaferInfo m_LLAWafer;
  42. private WaferInfo m_LLBWafer;
  43. private WaferInfo m_BladeAWafer;
  44. private WaferInfo m_BladeBWafer;
  45. private bool m_PMADoorIsOpen;
  46. //private bool m_PMBDoorIsOpen;
  47. //private bool m_PMCDoorIsOpen;
  48. //private bool m_PMDDoorIsOpen;
  49. private bool m_LLADoorIsOpen;
  50. private WaferRobotTAction m_WaferRobotTAction;
  51. private WaferRobotTAction m_Robot1TAction;
  52. private WaferRobotXAction m_Robot1XAction;
  53. private WaferRobotTAction m_Robot2TAction;
  54. private WaferRobotXAction m_Robot2XAction;
  55. private TMModule m_PickSelectedModule;
  56. private TMModule m_PlaceSelectedModule;
  57. private TMModule m_ExtendSelectedModule;
  58. private TMModule m_RetractSelectedModule;
  59. private TMBlade m_PickSelectedBlade;
  60. private TMBlade m_PlaceSelectedBlade;
  61. private TMBlade m_ExtendSelectedBlade;
  62. private TMBlade m_RetractSelectedBlade;
  63. private TMBlade m_GoToSelectedBlade;
  64. private ObservableCollection<int> m_PlaceSoltItemsSource = new ObservableCollection<int>();
  65. private ObservableCollection<int> m_PickSoltItemsSource = new ObservableCollection<int>();
  66. private ObservableCollection<int> m_ExtendSoltItemsSource = new ObservableCollection<int>();
  67. private ObservableCollection<int> m_RetractSoltItemsSource = new ObservableCollection<int>();
  68. private int m_PickSoltSelectedIndex;
  69. private int m_PlaceSoltSelectedIndex;
  70. private int m_ExtendSoltSelectedIndex;
  71. private int m_RetractSoltSelectedIndex;
  72. private List<string> m_RtDataKeys=new List<string> ();
  73. private Dictionary<string, object> m_RtDataValues;
  74. private string m_ModuleCheckedName="TM";
  75. private string m_RobotAction;
  76. private string m_RobotTarget;
  77. private string m_RobotArm;
  78. private bool m_PMAIsInstalled;
  79. private bool m_PMBIsInstalled;
  80. private bool m_PMCIsInstalled;
  81. private bool m_PMDIsInstalled;
  82. private bool m_LLAIsInstalled;
  83. private bool m_LLBIsInstalled;
  84. private bool m_TMIsInstalled;
  85. private List<string> m_OriginalCycle=new List<string> ();
  86. private List<string> m_ToCycle = new List<string>();
  87. private List<TMModule> m_TMModules= new List<TMModule>();
  88. private bool m_CycleEnable;
  89. private string m_OriginalCycleSelectedItem;
  90. private string m_ToCycleSelectedItem;
  91. private bool m_PMAIsCycle;
  92. private bool m_PMBIsCycle;
  93. private bool m_PMCIsCycle;
  94. private bool m_PMDIsCycle;
  95. private int m_CycleCount;
  96. #endregion
  97. #region 属性
  98. public List<string> OriginalCycle
  99. {
  100. get { return m_OriginalCycle; }
  101. set { SetProperty(ref m_OriginalCycle, value); }
  102. }
  103. public List<string> ToCycle
  104. {
  105. get { return m_ToCycle; }
  106. set { SetProperty(ref m_ToCycle, value); }
  107. }
  108. public string RobotAction2
  109. {
  110. get { return m_RobotAction; }
  111. set
  112. {
  113. //RobotActiont(m_RobotAction, value);
  114. SetProperty(ref m_RobotAction, value);
  115. }
  116. }
  117. public RobotMoveInfo m_robotMoveInfo;
  118. public RobotMoveInfo RobotMoveInfo
  119. {
  120. get { return m_robotMoveInfo; }
  121. set
  122. {
  123. RobotMoveInfoChanged(m_robotMoveInfo, value);
  124. m_robotMoveInfo = value;
  125. }
  126. }
  127. public string RobotTarget
  128. {
  129. get { return m_RobotTarget; }
  130. set
  131. {
  132. SetProperty(ref m_RobotTarget, value);
  133. }
  134. }
  135. public string RobotArm
  136. {
  137. get { return m_RobotArm; }
  138. set
  139. {
  140. SetProperty(ref m_RobotArm, value);
  141. }
  142. }
  143. int arm1oldWaferStatus = 100;
  144. int arm2oldWaferStatus = 100;
  145. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue,RobotMoveInfo newValue)
  146. {
  147. if (oldValue == null ||newValue==null)
  148. {
  149. return;
  150. }
  151. #region pick 和 place LL
  152. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  153. {
  154. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  155. if (TMRobotMoveActionBladeTarget != null)
  156. {
  157. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  158. }
  159. else
  160. {
  161. return;
  162. }
  163. var values = RobotTarget.Split('.');
  164. var arm = values[0];
  165. var module = values[1];
  166. if (arm == "ArmA")
  167. {
  168. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  169. await Task.Delay(1500);
  170. Robot1XAction = WaferRobotXAction.Extend;
  171. await Task.Delay(3000);
  172. Robot1XAction = WaferRobotXAction.Retract;
  173. }
  174. else if (arm == "ArmB")
  175. {
  176. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  177. await Task.Delay(1500);
  178. Robot2XAction = WaferRobotXAction.Extend;
  179. await Task.Delay(3000);
  180. Robot2XAction = WaferRobotXAction.Retract;
  181. }
  182. }
  183. //if ((oldValue.Action==RobotAction.Placing||oldValue.Action==RobotAction.Picking) && newValue.Action==RobotAction.None)
  184. //{
  185. // var TMRobotMoveActionBladeTarget = oldValue.BladeTarget;
  186. // if (TMRobotMoveActionBladeTarget != null)
  187. // {
  188. // RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  189. // }
  190. // else
  191. // {
  192. // return;
  193. // }
  194. // var values = RobotTarget.Split('.');
  195. // var arm = values[0];
  196. // var module = values[1];
  197. // if (arm == "ArmA")
  198. // {
  199. // Robot1XAction = WaferRobotXAction.Retract;
  200. // }
  201. // else if (arm == "ArmB")
  202. // {
  203. // Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  204. // await Task.Delay(1500);
  205. // Robot2XAction = WaferRobotXAction.Retract;
  206. // }
  207. //}
  208. #endregion
  209. #region pick 和 place pm
  210. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  211. {
  212. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  213. if (TMRobotMoveActionBladeTarget != null)
  214. {
  215. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  216. }
  217. else
  218. {
  219. return;
  220. }
  221. var values = RobotTarget.Split('.');
  222. var arm = values[0];
  223. var module = values[1];
  224. if (arm == "ArmA")
  225. {
  226. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  227. await Task.Delay(1500);
  228. Robot1XAction = WaferRobotXAction.Extend;
  229. }
  230. else if (arm == "ArmB")
  231. {
  232. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  233. await Task.Delay(1500);
  234. Robot2XAction = WaferRobotXAction.Extend;
  235. }
  236. }
  237. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  238. {
  239. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  240. if (TMRobotMoveActionBladeTarget != null)
  241. {
  242. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  243. }
  244. else
  245. {
  246. return;
  247. }
  248. var values = RobotTarget.Split('.');
  249. var arm = values[0];
  250. if (arm == "ArmA")
  251. {
  252. Robot1XAction = WaferRobotXAction.Retract;
  253. }
  254. else if (arm == "ArmB")
  255. {
  256. Robot2XAction = WaferRobotXAction.Retract;
  257. }
  258. }
  259. #endregion
  260. arm1oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus;
  261. arm2oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus;
  262. }
  263. private async void RobotActiont(string oldValue,string newValue)
  264. {
  265. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus==1)
  266. {
  267. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  268. if (TMRobotMoveActionBladeTarget != null)
  269. {
  270. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  271. }
  272. else
  273. {
  274. return;
  275. }
  276. var values = RobotTarget.Split('.');
  277. var arm = values[0];
  278. var module = values[1];
  279. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  280. await Task.Delay(1500);
  281. Robot1XAction = WaferRobotXAction.Extend;
  282. if (arm == "ArmA")
  283. {
  284. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  285. await Task.Delay(1500);
  286. Robot1XAction = WaferRobotXAction.Extend;
  287. }
  288. else if (arm == "ArmB")
  289. {
  290. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  291. await Task.Delay(1500);
  292. Robot2XAction = WaferRobotXAction.Extend;
  293. }
  294. }
  295. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 1)
  296. {
  297. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  298. if (TMRobotMoveActionBladeTarget != null)
  299. {
  300. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  301. }
  302. else
  303. {
  304. return;
  305. }
  306. var values = RobotTarget.Split('.');
  307. var arm = values[0];
  308. var module = values[1];
  309. if (arm == "ArmA")
  310. {
  311. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  312. await Task.Delay(1500);
  313. Robot1XAction = WaferRobotXAction.Extend;
  314. }
  315. else if (arm == "ArmB")
  316. {
  317. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  318. await Task.Delay(1500);
  319. Robot2XAction = WaferRobotXAction.Extend;
  320. }
  321. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  322. //await Task.Delay(1500);
  323. //Robot2XAction = WaferRobotXAction.Extend;
  324. }
  325. if (arm1oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus)
  326. {
  327. Robot1XAction = WaferRobotXAction.Retract;
  328. }
  329. if (arm2oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus)
  330. {
  331. Robot2XAction = WaferRobotXAction.Retract;
  332. }
  333. if (oldValue == "None" && newValue == "Picking" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 0)
  334. {
  335. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  336. if (TMRobotMoveActionBladeTarget != null)
  337. {
  338. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  339. }
  340. else
  341. {
  342. return;
  343. }
  344. var values = RobotTarget.Split('.');
  345. var arm = values[0];
  346. var module = values[1];
  347. if (arm == "ArmA")
  348. {
  349. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  350. await Task.Delay(1500);
  351. Robot1XAction = WaferRobotXAction.Extend;
  352. }
  353. else if (arm == "ArmB")
  354. {
  355. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  356. await Task.Delay(1500);
  357. Robot2XAction = WaferRobotXAction.Extend;
  358. }
  359. }
  360. #region pick 和 place pm
  361. if (oldValue == "None" && newValue == "Extending")
  362. {
  363. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.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 == "None" && newValue == "Retracting")
  389. {
  390. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.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["TM"].WaferManager.Wafers[0].WaferStatus;
  412. arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;
  413. }
  414. public WaferInfo LLAWafer
  415. {
  416. get { return m_LLAWafer; }
  417. set { SetProperty(ref m_LLAWafer, value); }
  418. }
  419. public WaferInfo LLBWafer
  420. {
  421. get { return m_LLBWafer; }
  422. set { SetProperty(ref m_LLBWafer, value); }
  423. }
  424. public WaferInfo PMAWafer
  425. {
  426. get { return m_PMAWafer; }
  427. set { SetProperty(ref m_PMAWafer, value); }
  428. }
  429. public WaferInfo PMBWafer
  430. {
  431. get { return m_PMBWafer; }
  432. set { SetProperty(ref m_PMBWafer, value); }
  433. }
  434. public WaferInfo PMCWafer
  435. {
  436. get { return m_PMCWafer; }
  437. set { SetProperty(ref m_PMCWafer, value); }
  438. }
  439. public WaferInfo PMDWafer
  440. {
  441. get { return m_PMDWafer; }
  442. set { SetProperty(ref m_PMDWafer, value); }
  443. }
  444. public WaferInfo BladeAWafer
  445. {
  446. get { return m_BladeAWafer; }
  447. set { SetProperty(ref m_BladeAWafer, value); }
  448. }
  449. public WaferInfo BladeBWafer
  450. {
  451. get { return m_BladeBWafer; }
  452. set { SetProperty(ref m_BladeBWafer, value); }
  453. }
  454. public ModuleInfo LLAModuleInfo
  455. {
  456. get { return m_LLAModuleInfo; }
  457. set { SetProperty(ref m_LLAModuleInfo, value); }
  458. }
  459. public ModuleInfo LLBModuleInfo
  460. {
  461. get { return m_LLBModuleInfo; }
  462. set { SetProperty(ref m_LLBModuleInfo, value); }
  463. }
  464. public bool TMIsOFFline
  465. {
  466. get { return m_TMIsOFFline; }
  467. set { SetProperty(ref m_TMIsOFFline, value); }
  468. }
  469. public bool LLIsOFFline
  470. {
  471. get { return m_LLIsOFFline; }
  472. set { SetProperty(ref m_LLIsOFFline, value); }
  473. }
  474. public bool PMADoorIsOpen
  475. {
  476. get { return m_PMADoorIsOpen; }
  477. set { SetProperty(ref m_PMADoorIsOpen, value); }
  478. }
  479. public bool LLADoorIsOpen
  480. {
  481. get { return m_LLADoorIsOpen; }
  482. set { SetProperty(ref m_LLADoorIsOpen, value); }
  483. }
  484. public WaferRobotTAction WaferRobotTAction
  485. {
  486. get { return m_WaferRobotTAction; }
  487. set { SetProperty(ref m_WaferRobotTAction, value); }
  488. }
  489. public WaferRobotTAction Robot1TAction
  490. {
  491. get { return m_Robot1TAction; }
  492. set { SetProperty(ref m_Robot1TAction, value); }
  493. }
  494. public WaferRobotXAction Robot1XAction
  495. {
  496. get { return m_Robot1XAction; }
  497. set { SetProperty(ref m_Robot1XAction, value); }
  498. }
  499. public WaferRobotTAction Robot2TAction
  500. {
  501. get { return m_Robot2TAction; }
  502. set { SetProperty(ref m_Robot2TAction, value); }
  503. }
  504. public WaferRobotXAction Robot2XAction
  505. {
  506. get { return m_Robot2XAction; }
  507. set { SetProperty(ref m_Robot2XAction, value); }
  508. }
  509. public TMModule PickSelectedModule
  510. {
  511. get { return m_PickSelectedModule; }
  512. set { SetProperty(ref m_PickSelectedModule, value); }
  513. }
  514. public TMModule PlaceSelectedModule
  515. {
  516. get { return m_PlaceSelectedModule; }
  517. set { SetProperty(ref m_PlaceSelectedModule, value); }
  518. }
  519. public TMModule ExtendSelectedModule
  520. {
  521. get { return m_ExtendSelectedModule; }
  522. set { SetProperty(ref m_ExtendSelectedModule, value); }
  523. }
  524. public TMModule RetractSelectedModule
  525. {
  526. get { return m_RetractSelectedModule; }
  527. set { SetProperty(ref m_RetractSelectedModule, value); }
  528. }
  529. public TMBlade PickSelectedBlade
  530. {
  531. get { return m_PickSelectedBlade; }
  532. set { SetProperty(ref m_PickSelectedBlade, value); }
  533. }
  534. public TMBlade PlaceSelectedBlade
  535. {
  536. get { return m_PlaceSelectedBlade; }
  537. set { SetProperty(ref m_PlaceSelectedBlade, value); }
  538. }
  539. public TMBlade ExtendSelectedBlade
  540. {
  541. get { return m_ExtendSelectedBlade; }
  542. set { SetProperty(ref m_ExtendSelectedBlade, value); }
  543. }
  544. public TMBlade RetractSelectedBlade
  545. {
  546. get { return m_RetractSelectedBlade; }
  547. set { SetProperty(ref m_RetractSelectedBlade, value); }
  548. }
  549. public TMBlade GoToSelectedBlade
  550. {
  551. get { return m_GoToSelectedBlade; }
  552. set { SetProperty(ref m_GoToSelectedBlade, value); }
  553. }
  554. public ObservableCollection<int> PickSoltItemsSource
  555. {
  556. get { return m_PickSoltItemsSource; }
  557. set { SetProperty(ref m_PickSoltItemsSource, value); }
  558. }
  559. public ObservableCollection<int> PlaceSoltItemsSource
  560. {
  561. get { return m_PlaceSoltItemsSource; }
  562. set { SetProperty(ref m_PlaceSoltItemsSource, value); }
  563. }
  564. public ObservableCollection<int> ExtendSoltItemsSource
  565. {
  566. get { return m_ExtendSoltItemsSource; }
  567. set { SetProperty(ref m_ExtendSoltItemsSource, value); }
  568. }
  569. public ObservableCollection<int> RetractSoltItemsSource
  570. {
  571. get { return m_RetractSoltItemsSource; }
  572. set { SetProperty(ref m_RetractSoltItemsSource, value); }
  573. }
  574. public int PickSoltSelectedIndex
  575. {
  576. get { return m_PickSoltSelectedIndex; }
  577. set { SetProperty(ref m_PickSoltSelectedIndex, value); }
  578. }
  579. public int PlaceSoltSelectedIndex
  580. {
  581. get { return m_PlaceSoltSelectedIndex; }
  582. set { SetProperty(ref m_PlaceSoltSelectedIndex, value); }
  583. }
  584. public int ExtendSoltSelectedIndex
  585. {
  586. get { return m_ExtendSoltSelectedIndex; }
  587. set { SetProperty(ref m_ExtendSoltSelectedIndex, value); }
  588. }
  589. public int RetractSoltSelectedIndex
  590. {
  591. get { return m_RetractSoltSelectedIndex; }
  592. set { SetProperty(ref m_RetractSoltSelectedIndex, value); }
  593. }
  594. public Dictionary<string, object> RtDataValues
  595. {
  596. get { return m_RtDataValues; }
  597. set { SetProperty(ref m_RtDataValues, value); }
  598. }
  599. public bool PMAIsInstalled
  600. {
  601. get { return m_PMAIsInstalled; }
  602. set { SetProperty(ref m_PMAIsInstalled, value); }
  603. }
  604. public bool PMBIsInstalled
  605. {
  606. get { return m_PMBIsInstalled; }
  607. set { SetProperty(ref m_PMBIsInstalled, value); }
  608. }
  609. public bool PMCIsInstalled
  610. {
  611. get { return m_PMCIsInstalled; }
  612. set { SetProperty(ref m_PMCIsInstalled, value); }
  613. }
  614. public bool PMDIsInstalled
  615. {
  616. get { return m_PMDIsInstalled; }
  617. set { SetProperty(ref m_PMDIsInstalled, value); }
  618. }
  619. public bool LLAIsInstalled
  620. {
  621. get { return m_LLAIsInstalled; }
  622. set { SetProperty(ref m_LLAIsInstalled, value); }
  623. }
  624. public bool LLBIsInstalled
  625. {
  626. get { return m_LLBIsInstalled; }
  627. set { SetProperty(ref m_LLBIsInstalled, value); }
  628. }
  629. public bool TMIsInstalled
  630. {
  631. get { return m_TMIsInstalled; }
  632. set { SetProperty(ref m_TMIsInstalled, value); }
  633. }
  634. public List<TMModule> TMModules
  635. {
  636. get { return m_TMModules; }
  637. set { SetProperty(ref m_TMModules, value); }
  638. }
  639. public bool CycleEnable
  640. {
  641. get { return m_CycleEnable; }
  642. set { SetProperty(ref m_CycleEnable, value); }
  643. }
  644. public string OriginalCycleSelectedItem
  645. {
  646. get { return m_OriginalCycleSelectedItem; }
  647. set { SetProperty(ref m_OriginalCycleSelectedItem, value); }
  648. }
  649. public string ToCycleSelectedItem
  650. {
  651. get { return m_ToCycleSelectedItem; }
  652. set { SetProperty(ref m_ToCycleSelectedItem, value); }
  653. }
  654. public bool PMAIsCycle
  655. {
  656. get { return m_PMAIsCycle; }
  657. set { SetProperty(ref m_PMAIsCycle, value); }
  658. }
  659. public bool PMBIsCycle
  660. {
  661. get { return m_PMBIsCycle; }
  662. set { SetProperty(ref m_PMBIsCycle, value); }
  663. }
  664. public bool PMCIsCycle
  665. {
  666. get { return m_PMCIsCycle; }
  667. set { SetProperty(ref m_PMCIsCycle, value); }
  668. }
  669. public bool PMDIsCycle
  670. {
  671. get { return m_PMDIsCycle; }
  672. set { SetProperty(ref m_PMDIsCycle, value); }
  673. }
  674. public int CycleCount
  675. {
  676. get { return m_CycleCount; }
  677. set { SetProperty(ref m_CycleCount, value); }
  678. }
  679. #endregion
  680. #region 命令
  681. private DelegateCommand _GotoCommand;
  682. public DelegateCommand GotoCommand =>
  683. _GotoCommand ?? (_GotoCommand = new DelegateCommand(OnGoto));
  684. private DelegateCommand _ExtendCommand;
  685. public DelegateCommand ExtendCommand =>
  686. _ExtendCommand ?? (_ExtendCommand = new DelegateCommand(OnExtend));
  687. private DelegateCommand _RetractCommand;
  688. public DelegateCommand RetractCommand =>
  689. _RetractCommand ?? (_RetractCommand = new DelegateCommand(OnRetract));
  690. private DelegateCommand<object> _ModuleChangeCommand;
  691. public DelegateCommand<object> ModuleChangeCommand =>
  692. _ModuleChangeCommand ?? (_ModuleChangeCommand = new DelegateCommand<object>(OnModuleChange));
  693. private DelegateCommand _PickCommand;
  694. public DelegateCommand PickCommand =>
  695. _PickCommand ?? (_PickCommand = new DelegateCommand(OnPick));
  696. private DelegateCommand _PlaceCommand;
  697. public DelegateCommand PlaceCommand =>
  698. _PlaceCommand ?? (_PlaceCommand = new DelegateCommand(OnPlace));
  699. private DelegateCommand _HomeCommand;
  700. public DelegateCommand HomeCommand =>
  701. _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome));
  702. private DelegateCommand _VentCommand;
  703. public DelegateCommand VentCommand =>
  704. _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent));
  705. private DelegateCommand _PumpCommand;
  706. public DelegateCommand PumpCommand =>
  707. _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump));
  708. private DelegateCommand _PurgeCommand;
  709. public DelegateCommand PurgeCommand =>
  710. _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge));
  711. private DelegateCommand<object> _ModuleCheckedCommand;
  712. public DelegateCommand<object> ModuleCheckedCommand =>
  713. _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand<object>(OnModuleChecked));
  714. private DelegateCommand _AbortCommand;
  715. public DelegateCommand AbortCommand =>
  716. _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));
  717. private DelegateCommand _StartCycleCommand;
  718. public DelegateCommand StartCycleCommand =>
  719. _StartCycleCommand ?? (_StartCycleCommand = new DelegateCommand(OnStartCycle));
  720. private DelegateCommand _StopCycleCommand;
  721. public DelegateCommand StopCycleCommand =>
  722. _StopCycleCommand ?? (_StopCycleCommand = new DelegateCommand(OnStopCycle));
  723. private DelegateCommand _SystemHomeCommand;
  724. public DelegateCommand SystemHomeCommand =>
  725. _SystemHomeCommand ?? (_SystemHomeCommand = new DelegateCommand(OnSystemHome));
  726. private DelegateCommand<object> _ChamberDoorOpenCommand;
  727. public DelegateCommand<object> ChamberDoorOpenCommand =>
  728. _ChamberDoorOpenCommand ?? (_ChamberDoorOpenCommand = new DelegateCommand<object>(OnChamberDoorOpen));
  729. private DelegateCommand<object> _ChamberDoorCloseCommand;
  730. public DelegateCommand<object> ChamberDoorCloseCommand =>
  731. _ChamberDoorCloseCommand ?? (_ChamberDoorCloseCommand = new DelegateCommand<object>(OnChamberDoorClose));
  732. #endregion
  733. #region 构造函数
  734. public TMViewModel()
  735. {
  736. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  737. PMAIsInstalled = allModules.Contains("PMA");
  738. PMBIsInstalled = allModules.Contains("PMB");
  739. PMCIsInstalled = allModules.Contains("PMC");
  740. PMDIsInstalled = allModules.Contains("PMD");
  741. LLAIsInstalled = allModules.Contains("LLA");
  742. LLBIsInstalled = allModules.Contains("LLB");
  743. TMIsInstalled= allModules.Contains("TM");
  744. if (PMAIsInstalled == true)
  745. {
  746. TMModules.Add(TMModule.PMA);
  747. }
  748. if (PMBIsInstalled == true)
  749. {
  750. TMModules.Add(TMModule.PMB);
  751. }
  752. if (PMCIsInstalled == true)
  753. {
  754. TMModules.Add(TMModule.PMC);
  755. }
  756. if (PMDIsInstalled == true)
  757. {
  758. TMModules.Add(TMModule.PMD);
  759. }
  760. if (LLAIsInstalled == true)
  761. {
  762. OriginalCycle.Add("LLA");
  763. ToCycle.Add("LLA");
  764. TMModules.Add(TMModule.LLA);
  765. }
  766. if (LLBIsInstalled == true)
  767. {
  768. OriginalCycle.Add("LLB");
  769. ToCycle.Add("LLB");
  770. TMModules.Add(TMModule.LLB);
  771. }
  772. addDataKeys();
  773. DispatcherTimer timer = new DispatcherTimer();
  774. timer.Interval = TimeSpan.FromSeconds(0.1);
  775. timer.Tick += Timer_Tick;
  776. timer.Start();
  777. PickSoltItemsSource.Add(1);
  778. PlaceSoltItemsSource.Add(1);
  779. ExtendSoltItemsSource.Add(1);
  780. RetractSoltItemsSource.Add(1);
  781. //Robot1TAction = WaferRobotTAction.PMA;
  782. //Robot2TAction = WaferRobotTAction.PMD;
  783. }
  784. private void Timer_Tick(object sender, EventArgs e)
  785. {
  786. if (LLAIsInstalled == true)
  787. {
  788. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x=>x.WaferStatus!=0);
  789. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  790. }
  791. if (LLBIsInstalled == true)
  792. {
  793. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  794. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  795. }
  796. if (PMAIsInstalled == true)
  797. {
  798. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  799. }
  800. if (PMBIsInstalled == true)
  801. {
  802. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  803. }
  804. if (PMCIsInstalled == true)
  805. {
  806. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  807. }
  808. if (PMDIsInstalled == true)
  809. {
  810. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  811. }
  812. if (TMIsInstalled == true)
  813. {
  814. BladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];
  815. BladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];
  816. }
  817. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  818. var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");
  819. if (TMRobotMoveActionArmTarget != null)
  820. {
  821. RobotArm = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus.ToString();
  822. }
  823. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  824. if (TMRobotMoveActionBladeTarget != null)
  825. {
  826. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  827. }
  828. var TMRobotMoveActionRobotAction = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.RobotAction");
  829. if (TMRobotMoveActionRobotAction != null)
  830. {
  831. RobotAction2 = TMRobotMoveActionRobotAction.ToString();
  832. }
  833. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  834. }
  835. #endregion
  836. #region 命令方法
  837. private void OnGoto()
  838. {
  839. if (GoToSelectedBlade == TMBlade.Blade1)
  840. {
  841. Robot1TAction = WaferRobotTAction;
  842. }
  843. else if (GoToSelectedBlade == TMBlade.Blade2)
  844. {
  845. Robot2TAction = WaferRobotTAction;
  846. }
  847. }
  848. private void OnExtend()
  849. {
  850. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  851. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  852. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Extend}", moduleName, 0, selectedHand);
  853. }
  854. private void OnRetract()
  855. {
  856. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  857. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  858. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Retract}", moduleName, 0, selectedHand);
  859. }
  860. private void OnModuleChange(object obj)
  861. {
  862. var value = obj.ToString();
  863. switch (value)
  864. {
  865. case "Pick":
  866. PickSoltItemsSource.Clear();
  867. if ((int)PickSelectedModule == 4)
  868. {
  869. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  870. {
  871. PickSoltItemsSource.Add(i);
  872. }
  873. }
  874. else if ((int)PickSelectedModule == 5)
  875. {
  876. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  877. {
  878. PickSoltItemsSource.Add(i);
  879. }
  880. }
  881. else
  882. {
  883. PickSoltItemsSource.Add(1);
  884. }
  885. PickSoltSelectedIndex = 0;
  886. break;
  887. case "Place":
  888. PlaceSoltItemsSource.Clear();
  889. if ((int)PlaceSelectedModule == 4)
  890. {
  891. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  892. {
  893. PlaceSoltItemsSource.Add(i);
  894. }
  895. }
  896. else if ((int)PlaceSelectedModule == 5)
  897. {
  898. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  899. {
  900. PlaceSoltItemsSource.Add(i);
  901. }
  902. }
  903. else
  904. {
  905. PlaceSoltItemsSource.Add(1);
  906. }
  907. PlaceSoltSelectedIndex = 0;
  908. break;
  909. case "Extend":
  910. ExtendSoltItemsSource.Clear();
  911. if ((int)ExtendSelectedModule == 4)
  912. {
  913. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  914. {
  915. ExtendSoltItemsSource.Add(i);
  916. }
  917. }
  918. else if ((int)ExtendSelectedModule == 5)
  919. {
  920. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  921. {
  922. ExtendSoltItemsSource.Add(i);
  923. }
  924. }
  925. else
  926. {
  927. ExtendSoltItemsSource.Add(1);
  928. }
  929. ExtendSoltSelectedIndex = 0;
  930. break;
  931. case "Retract":
  932. RetractSoltItemsSource.Clear();
  933. if ((int)RetractSelectedModule == 4)
  934. {
  935. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  936. {
  937. RetractSoltItemsSource.Add(i);
  938. }
  939. //RetractSoltItemsSource = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
  940. }
  941. else if ((int)RetractSelectedModule == 5)
  942. {
  943. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  944. {
  945. RetractSoltItemsSource.Add(i);
  946. }
  947. }
  948. else
  949. {
  950. RetractSoltItemsSource.Add(1);
  951. }
  952. RetractSoltSelectedIndex = 0;
  953. break;
  954. }
  955. }
  956. private void OnPick()
  957. {
  958. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  959. var moduleName= (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  960. var selectedHand= (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  961. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  962. moveItems.Enqueue(moveItem);
  963. if ((int)PickSelectedModule > 3)
  964. {
  965. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPick}", moveItems);
  966. }
  967. else
  968. {
  969. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPick}", moveItems);
  970. }
  971. }
  972. private void OnPlace()
  973. {
  974. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  975. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  976. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  977. MoveItem moveItem = new MoveItem(0,0,moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex]-1, selectedHand);
  978. moveItems.Enqueue(moveItem);
  979. if ((int)PlaceSelectedModule > 3)
  980. {
  981. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPlace}", moveItems);
  982. }
  983. else
  984. {
  985. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPlace}", moveItems);
  986. }
  987. }
  988. private void OnHome()
  989. {
  990. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");
  991. }
  992. private void OnVent()
  993. {
  994. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}");
  995. }
  996. private void OnPump()
  997. {
  998. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}");
  999. }
  1000. private void OnPurge()
  1001. {
  1002. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}");
  1003. }
  1004. private void OnModuleChecked(object obj)
  1005. {
  1006. m_ModuleCheckedName=obj.ToString();
  1007. }
  1008. private void OnAbort()
  1009. {
  1010. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}");
  1011. }
  1012. private void OnStartCycle()
  1013. {
  1014. if (CycleEnable == false)
  1015. {
  1016. return;
  1017. }
  1018. List<string> strings = new List<string>();
  1019. if (OriginalCycleSelectedItem != "")
  1020. {
  1021. strings.Add(OriginalCycleSelectedItem);
  1022. }
  1023. else
  1024. {
  1025. return;
  1026. }
  1027. if (PMAIsCycle==true)
  1028. {
  1029. strings.Add("PMA");
  1030. }
  1031. if (PMBIsCycle == true)
  1032. {
  1033. strings.Add("PMB");
  1034. }
  1035. if (PMCIsCycle == true)
  1036. {
  1037. strings.Add("PMC");
  1038. }
  1039. if (PMDIsCycle == true)
  1040. {
  1041. strings.Add("PMD");
  1042. }
  1043. if (ToCycleSelectedItem != "")
  1044. {
  1045. strings.Add(ToCycleSelectedItem);
  1046. }
  1047. else
  1048. {
  1049. return;
  1050. }
  1051. InvokeClient.Instance.Service.DoOperation("TMCycle.Start", strings.ToArray(),CycleCount);
  1052. }
  1053. private void OnStopCycle()
  1054. {
  1055. InvokeClient.Instance.Service.DoOperation("TMCycle.Abort");
  1056. }
  1057. private void OnSystemHome()
  1058. {
  1059. InvokeClient.Instance.Service.DoOperation("System.Home");
  1060. }
  1061. private void OnChamberDoorOpen(object obj)
  1062. {
  1063. InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Open");
  1064. }
  1065. private void OnChamberDoorClose(object obj)
  1066. {
  1067. InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Close");
  1068. }
  1069. #endregion
  1070. #region 私有方法
  1071. private void addDataKeys()
  1072. {
  1073. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  1074. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  1075. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  1076. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  1077. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  1078. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  1079. m_RtDataKeys.Add("TM.LLAESlitDoor.IsClosed");
  1080. m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed");
  1081. m_RtDataKeys.Add("TMCycle.CycleIndex");
  1082. }
  1083. #endregion
  1084. }
  1085. }