TMViewModel.cs 41 KB

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