TMViewModel.cs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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. #endregion
  727. #region 构造函数
  728. public TMViewModel()
  729. {
  730. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  731. PMAIsInstalled = allModules.Contains("PMA");
  732. PMBIsInstalled = allModules.Contains("PMB");
  733. PMCIsInstalled = allModules.Contains("PMC");
  734. PMDIsInstalled = allModules.Contains("PMD");
  735. LLAIsInstalled = allModules.Contains("LLA");
  736. LLBIsInstalled = allModules.Contains("LLB");
  737. TMIsInstalled= allModules.Contains("TM");
  738. if (PMAIsInstalled == true)
  739. {
  740. TMModules.Add(TMModule.PMA);
  741. }
  742. if (PMBIsInstalled == true)
  743. {
  744. TMModules.Add(TMModule.PMB);
  745. }
  746. if (PMCIsInstalled == true)
  747. {
  748. TMModules.Add(TMModule.PMC);
  749. }
  750. if (PMDIsInstalled == true)
  751. {
  752. TMModules.Add(TMModule.PMD);
  753. }
  754. if (LLAIsInstalled == true)
  755. {
  756. OriginalCycle.Add("LLA");
  757. ToCycle.Add("LLA");
  758. TMModules.Add(TMModule.LLA);
  759. }
  760. if (LLBIsInstalled == true)
  761. {
  762. OriginalCycle.Add("LLB");
  763. ToCycle.Add("LLB");
  764. TMModules.Add(TMModule.LLB);
  765. }
  766. addDataKeys();
  767. DispatcherTimer timer = new DispatcherTimer();
  768. timer.Interval = TimeSpan.FromSeconds(0.1);
  769. timer.Tick += Timer_Tick;
  770. timer.Start();
  771. PickSoltItemsSource.Add(1);
  772. PlaceSoltItemsSource.Add(1);
  773. ExtendSoltItemsSource.Add(1);
  774. RetractSoltItemsSource.Add(1);
  775. //Robot1TAction = WaferRobotTAction.PMA;
  776. //Robot2TAction = WaferRobotTAction.PMD;
  777. }
  778. private void Timer_Tick(object sender, EventArgs e)
  779. {
  780. if (LLAIsInstalled == true)
  781. {
  782. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x=>x.WaferStatus!=0);
  783. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  784. }
  785. if (LLBIsInstalled == true)
  786. {
  787. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  788. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  789. }
  790. if (PMAIsInstalled == true)
  791. {
  792. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  793. }
  794. if (PMBIsInstalled == true)
  795. {
  796. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  797. }
  798. if (PMCIsInstalled == true)
  799. {
  800. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  801. }
  802. if (PMDIsInstalled == true)
  803. {
  804. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  805. }
  806. if (TMIsInstalled == true)
  807. {
  808. BladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];
  809. BladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];
  810. }
  811. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  812. var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");
  813. if (TMRobotMoveActionArmTarget != null)
  814. {
  815. RobotArm = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus.ToString();
  816. }
  817. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  818. if (TMRobotMoveActionBladeTarget != null)
  819. {
  820. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  821. }
  822. var TMRobotMoveActionRobotAction = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.RobotAction");
  823. if (TMRobotMoveActionRobotAction != null)
  824. {
  825. RobotAction2 = TMRobotMoveActionRobotAction.ToString();
  826. }
  827. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  828. }
  829. #endregion
  830. #region 命令方法
  831. private void OnGoto()
  832. {
  833. if (GoToSelectedBlade == TMBlade.Blade1)
  834. {
  835. Robot1TAction = WaferRobotTAction;
  836. }
  837. else if (GoToSelectedBlade == TMBlade.Blade2)
  838. {
  839. Robot2TAction = WaferRobotTAction;
  840. }
  841. }
  842. private void OnExtend()
  843. {
  844. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  845. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  846. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Extend}", moduleName, 0, selectedHand);
  847. }
  848. private void OnRetract()
  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.Retract}", moduleName, 0, selectedHand);
  853. }
  854. private void OnModuleChange(object obj)
  855. {
  856. var value = obj.ToString();
  857. switch (value)
  858. {
  859. case "Pick":
  860. PickSoltItemsSource.Clear();
  861. if ((int)PickSelectedModule == 4)
  862. {
  863. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  864. {
  865. PickSoltItemsSource.Add(i);
  866. }
  867. }
  868. else if ((int)PickSelectedModule == 5)
  869. {
  870. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  871. {
  872. PickSoltItemsSource.Add(i);
  873. }
  874. }
  875. else
  876. {
  877. PickSoltItemsSource.Add(1);
  878. }
  879. PickSoltSelectedIndex = 0;
  880. break;
  881. case "Place":
  882. PlaceSoltItemsSource.Clear();
  883. if ((int)PlaceSelectedModule == 4)
  884. {
  885. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  886. {
  887. PlaceSoltItemsSource.Add(i);
  888. }
  889. }
  890. else if ((int)PlaceSelectedModule == 5)
  891. {
  892. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  893. {
  894. PlaceSoltItemsSource.Add(i);
  895. }
  896. }
  897. else
  898. {
  899. PlaceSoltItemsSource.Add(1);
  900. }
  901. PlaceSoltSelectedIndex = 0;
  902. break;
  903. case "Extend":
  904. ExtendSoltItemsSource.Clear();
  905. if ((int)ExtendSelectedModule == 4)
  906. {
  907. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  908. {
  909. ExtendSoltItemsSource.Add(i);
  910. }
  911. }
  912. else if ((int)ExtendSelectedModule == 5)
  913. {
  914. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  915. {
  916. ExtendSoltItemsSource.Add(i);
  917. }
  918. }
  919. else
  920. {
  921. ExtendSoltItemsSource.Add(1);
  922. }
  923. ExtendSoltSelectedIndex = 0;
  924. break;
  925. case "Retract":
  926. RetractSoltItemsSource.Clear();
  927. if ((int)RetractSelectedModule == 4)
  928. {
  929. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  930. {
  931. RetractSoltItemsSource.Add(i);
  932. }
  933. //RetractSoltItemsSource = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
  934. }
  935. else if ((int)RetractSelectedModule == 5)
  936. {
  937. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  938. {
  939. RetractSoltItemsSource.Add(i);
  940. }
  941. }
  942. else
  943. {
  944. RetractSoltItemsSource.Add(1);
  945. }
  946. RetractSoltSelectedIndex = 0;
  947. break;
  948. }
  949. }
  950. private void OnPick()
  951. {
  952. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  953. var moduleName= (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  954. var selectedHand= (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  955. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  956. moveItems.Enqueue(moveItem);
  957. if ((int)PickSelectedModule > 3)
  958. {
  959. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPick}", moveItems);
  960. }
  961. else
  962. {
  963. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPick}", moveItems);
  964. }
  965. }
  966. private void OnPlace()
  967. {
  968. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  969. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  970. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  971. MoveItem moveItem = new MoveItem(0,0,moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex]-1, selectedHand);
  972. moveItems.Enqueue(moveItem);
  973. if ((int)PlaceSelectedModule > 3)
  974. {
  975. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPlace}", moveItems);
  976. }
  977. else
  978. {
  979. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPlace}", moveItems);
  980. }
  981. }
  982. private void OnHome()
  983. {
  984. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");
  985. }
  986. private void OnVent()
  987. {
  988. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}");
  989. }
  990. private void OnPump()
  991. {
  992. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}");
  993. }
  994. private void OnPurge()
  995. {
  996. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}");
  997. }
  998. private void OnModuleChecked(object obj)
  999. {
  1000. m_ModuleCheckedName=obj.ToString();
  1001. }
  1002. private void OnAbort()
  1003. {
  1004. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}");
  1005. }
  1006. private void OnStartCycle()
  1007. {
  1008. if (CycleEnable == false)
  1009. {
  1010. return;
  1011. }
  1012. List<string> strings = new List<string>();
  1013. if (OriginalCycleSelectedItem != "")
  1014. {
  1015. strings.Add(OriginalCycleSelectedItem);
  1016. }
  1017. else
  1018. {
  1019. return;
  1020. }
  1021. if (PMAIsCycle==true)
  1022. {
  1023. strings.Add("PMA");
  1024. }
  1025. if (PMBIsCycle == true)
  1026. {
  1027. strings.Add("PMB");
  1028. }
  1029. if (PMCIsCycle == true)
  1030. {
  1031. strings.Add("PMC");
  1032. }
  1033. if (PMDIsCycle == true)
  1034. {
  1035. strings.Add("PMD");
  1036. }
  1037. if (ToCycleSelectedItem != "")
  1038. {
  1039. strings.Add(ToCycleSelectedItem);
  1040. }
  1041. else
  1042. {
  1043. return;
  1044. }
  1045. InvokeClient.Instance.Service.DoOperation("TMCycle.Start", strings.ToArray(),CycleCount);
  1046. }
  1047. private void OnStopCycle()
  1048. {
  1049. InvokeClient.Instance.Service.DoOperation("TMCycle.Abort");
  1050. }
  1051. private void OnSystemHome()
  1052. {
  1053. InvokeClient.Instance.Service.DoOperation("System.Home");
  1054. }
  1055. #endregion
  1056. #region 私有方法
  1057. private void addDataKeys()
  1058. {
  1059. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  1060. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  1061. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  1062. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  1063. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  1064. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  1065. m_RtDataKeys.Add("TMCycle.CycleIndex");
  1066. }
  1067. #endregion
  1068. }
  1069. }