TMViewModel.cs 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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 List<string> m_OriginalCycle=new List<string> ();
  85. private List<string> m_ToCycle = new List<string>();
  86. private List<TMModule> m_TMModules= new List<TMModule>();
  87. #endregion
  88. #region 属性
  89. public List<string> OriginalCycle
  90. {
  91. get { return m_OriginalCycle; }
  92. set { SetProperty(ref m_OriginalCycle, value); }
  93. }
  94. public List<string> ToCycle
  95. {
  96. get { return m_ToCycle; }
  97. set { SetProperty(ref m_ToCycle, value); }
  98. }
  99. public string RobotAction2
  100. {
  101. get { return m_RobotAction; }
  102. set
  103. {
  104. //RobotActiont(m_RobotAction, value);
  105. SetProperty(ref m_RobotAction, value);
  106. }
  107. }
  108. public RobotMoveInfo m_robotMoveInfo;
  109. public RobotMoveInfo RobotMoveInfo
  110. {
  111. get { return m_robotMoveInfo; }
  112. set
  113. {
  114. RobotMoveInfoChanged(m_robotMoveInfo, value);
  115. m_robotMoveInfo = value;
  116. }
  117. }
  118. public string RobotTarget
  119. {
  120. get { return m_RobotTarget; }
  121. set
  122. {
  123. SetProperty(ref m_RobotTarget, value);
  124. }
  125. }
  126. public string RobotArm
  127. {
  128. get { return m_RobotArm; }
  129. set
  130. {
  131. SetProperty(ref m_RobotArm, value);
  132. }
  133. }
  134. int arm1oldWaferStatus = 100;
  135. int arm2oldWaferStatus = 100;
  136. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue,RobotMoveInfo newValue)
  137. {
  138. if (oldValue == null ||newValue==null)
  139. {
  140. return;
  141. }
  142. #region pick 和 place LL
  143. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  144. {
  145. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  146. if (TMRobotMoveActionBladeTarget != null)
  147. {
  148. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  149. }
  150. else
  151. {
  152. return;
  153. }
  154. var values = RobotTarget.Split('.');
  155. var arm = values[0];
  156. var module = values[1];
  157. if (arm == "ArmA")
  158. {
  159. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  160. await Task.Delay(1500);
  161. Robot1XAction = WaferRobotXAction.Extend;
  162. }
  163. else if (arm == "ArmB")
  164. {
  165. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  166. await Task.Delay(1500);
  167. Robot2XAction = WaferRobotXAction.Extend;
  168. }
  169. }
  170. if ((oldValue.Action==RobotAction.Placing||oldValue.Action==RobotAction.Picking) && newValue.Action==RobotAction.None)
  171. {
  172. var TMRobotMoveActionBladeTarget = oldValue.BladeTarget;
  173. if (TMRobotMoveActionBladeTarget != null)
  174. {
  175. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  176. }
  177. else
  178. {
  179. return;
  180. }
  181. var values = RobotTarget.Split('.');
  182. var arm = values[0];
  183. var module = values[1];
  184. if (arm == "ArmA")
  185. {
  186. Robot1XAction = WaferRobotXAction.Retract;
  187. }
  188. else if (arm == "ArmB")
  189. {
  190. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  191. await Task.Delay(1500);
  192. Robot2XAction = WaferRobotXAction.Retract;
  193. }
  194. }
  195. #endregion
  196. #region pick 和 place pm
  197. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  198. {
  199. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  200. if (TMRobotMoveActionBladeTarget != null)
  201. {
  202. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  203. }
  204. else
  205. {
  206. return;
  207. }
  208. var values = RobotTarget.Split('.');
  209. var arm = values[0];
  210. var module = values[1];
  211. if (arm == "ArmA")
  212. {
  213. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  214. await Task.Delay(1500);
  215. Robot1XAction = WaferRobotXAction.Extend;
  216. }
  217. else if (arm == "ArmB")
  218. {
  219. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  220. await Task.Delay(1500);
  221. Robot2XAction = WaferRobotXAction.Extend;
  222. }
  223. }
  224. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  225. {
  226. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  227. if (TMRobotMoveActionBladeTarget != null)
  228. {
  229. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  230. }
  231. else
  232. {
  233. return;
  234. }
  235. var values = RobotTarget.Split('.');
  236. var arm = values[0];
  237. if (arm == "ArmA")
  238. {
  239. Robot1XAction = WaferRobotXAction.Retract;
  240. }
  241. else if (arm == "ArmB")
  242. {
  243. Robot2XAction = WaferRobotXAction.Retract;
  244. }
  245. }
  246. #endregion
  247. arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;
  248. arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;
  249. }
  250. private async void RobotActiont(string oldValue,string newValue)
  251. {
  252. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus==1)
  253. {
  254. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  255. if (TMRobotMoveActionBladeTarget != null)
  256. {
  257. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  258. }
  259. else
  260. {
  261. return;
  262. }
  263. var values = RobotTarget.Split('.');
  264. var arm = values[0];
  265. var module = values[1];
  266. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  267. await Task.Delay(1500);
  268. Robot1XAction = WaferRobotXAction.Extend;
  269. if (arm == "ArmA")
  270. {
  271. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  272. await Task.Delay(1500);
  273. Robot1XAction = WaferRobotXAction.Extend;
  274. }
  275. else if (arm == "ArmB")
  276. {
  277. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  278. await Task.Delay(1500);
  279. Robot2XAction = WaferRobotXAction.Extend;
  280. }
  281. }
  282. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 1)
  283. {
  284. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  285. if (TMRobotMoveActionBladeTarget != null)
  286. {
  287. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  288. }
  289. else
  290. {
  291. return;
  292. }
  293. var values = RobotTarget.Split('.');
  294. var arm = values[0];
  295. var module = values[1];
  296. if (arm == "ArmA")
  297. {
  298. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  299. await Task.Delay(1500);
  300. Robot1XAction = WaferRobotXAction.Extend;
  301. }
  302. else if (arm == "ArmB")
  303. {
  304. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  305. await Task.Delay(1500);
  306. Robot2XAction = WaferRobotXAction.Extend;
  307. }
  308. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  309. //await Task.Delay(1500);
  310. //Robot2XAction = WaferRobotXAction.Extend;
  311. }
  312. if (arm1oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus)
  313. {
  314. Robot1XAction = WaferRobotXAction.Retract;
  315. }
  316. if (arm2oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus)
  317. {
  318. Robot2XAction = WaferRobotXAction.Retract;
  319. }
  320. if (oldValue == "None" && newValue == "Picking" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 0)
  321. {
  322. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  323. if (TMRobotMoveActionBladeTarget != null)
  324. {
  325. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  326. }
  327. else
  328. {
  329. return;
  330. }
  331. var values = RobotTarget.Split('.');
  332. var arm = values[0];
  333. var module = values[1];
  334. if (arm == "ArmA")
  335. {
  336. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  337. await Task.Delay(1500);
  338. Robot1XAction = WaferRobotXAction.Extend;
  339. }
  340. else if (arm == "ArmB")
  341. {
  342. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  343. await Task.Delay(1500);
  344. Robot2XAction = WaferRobotXAction.Extend;
  345. }
  346. }
  347. #region pick 和 place pm
  348. if (oldValue == "None" && newValue == "Extending")
  349. {
  350. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  351. if (TMRobotMoveActionBladeTarget != null)
  352. {
  353. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  354. }
  355. else
  356. {
  357. return;
  358. }
  359. var values = RobotTarget.Split('.');
  360. var arm = values[0];
  361. var module = values[1];
  362. if (arm == "ArmA")
  363. {
  364. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  365. await Task.Delay(1500);
  366. Robot1XAction = WaferRobotXAction.Extend;
  367. }
  368. else if (arm == "ArmB")
  369. {
  370. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  371. await Task.Delay(1500);
  372. Robot2XAction = WaferRobotXAction.Extend;
  373. }
  374. }
  375. if (oldValue == "None" && newValue == "Retracting")
  376. {
  377. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  378. if (TMRobotMoveActionBladeTarget != null)
  379. {
  380. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  381. }
  382. else
  383. {
  384. return;
  385. }
  386. var values = RobotTarget.Split('.');
  387. var arm = values[0];
  388. if (arm == "ArmA")
  389. {
  390. Robot1XAction = WaferRobotXAction.Retract;
  391. }
  392. else if (arm == "ArmB")
  393. {
  394. Robot2XAction = WaferRobotXAction.Retract;
  395. }
  396. }
  397. #endregion
  398. arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;
  399. arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;
  400. }
  401. public WaferInfo LLAWafer
  402. {
  403. get { return m_LLAWafer; }
  404. set { SetProperty(ref m_LLAWafer, value); }
  405. }
  406. public WaferInfo LLBWafer
  407. {
  408. get { return m_LLBWafer; }
  409. set { SetProperty(ref m_LLBWafer, value); }
  410. }
  411. public WaferInfo PMAWafer
  412. {
  413. get { return m_PMAWafer; }
  414. set { SetProperty(ref m_PMAWafer, value); }
  415. }
  416. public WaferInfo PMBWafer
  417. {
  418. get { return m_PMBWafer; }
  419. set { SetProperty(ref m_PMBWafer, value); }
  420. }
  421. public WaferInfo PMCWafer
  422. {
  423. get { return m_PMCWafer; }
  424. set { SetProperty(ref m_PMCWafer, value); }
  425. }
  426. public WaferInfo PMDWafer
  427. {
  428. get { return m_PMDWafer; }
  429. set { SetProperty(ref m_PMDWafer, value); }
  430. }
  431. public WaferInfo BladeAWafer
  432. {
  433. get { return m_BladeAWafer; }
  434. set { SetProperty(ref m_BladeAWafer, value); }
  435. }
  436. public WaferInfo BladeBWafer
  437. {
  438. get { return m_BladeBWafer; }
  439. set { SetProperty(ref m_BladeBWafer, value); }
  440. }
  441. public ModuleInfo LLAModuleInfo
  442. {
  443. get { return m_LLAModuleInfo; }
  444. set { SetProperty(ref m_LLAModuleInfo, value); }
  445. }
  446. public ModuleInfo LLBModuleInfo
  447. {
  448. get { return m_LLBModuleInfo; }
  449. set { SetProperty(ref m_LLBModuleInfo, value); }
  450. }
  451. public bool TMIsOFFline
  452. {
  453. get { return m_TMIsOFFline; }
  454. set { SetProperty(ref m_TMIsOFFline, value); }
  455. }
  456. public bool LLIsOFFline
  457. {
  458. get { return m_LLIsOFFline; }
  459. set { SetProperty(ref m_LLIsOFFline, value); }
  460. }
  461. public bool PMADoorIsOpen
  462. {
  463. get { return m_PMADoorIsOpen; }
  464. set { SetProperty(ref m_PMADoorIsOpen, value); }
  465. }
  466. public bool LLADoorIsOpen
  467. {
  468. get { return m_LLADoorIsOpen; }
  469. set { SetProperty(ref m_LLADoorIsOpen, value); }
  470. }
  471. public WaferRobotTAction WaferRobotTAction
  472. {
  473. get { return m_WaferRobotTAction; }
  474. set { SetProperty(ref m_WaferRobotTAction, value); }
  475. }
  476. public WaferRobotTAction Robot1TAction
  477. {
  478. get { return m_Robot1TAction; }
  479. set { SetProperty(ref m_Robot1TAction, value); }
  480. }
  481. public WaferRobotXAction Robot1XAction
  482. {
  483. get { return m_Robot1XAction; }
  484. set { SetProperty(ref m_Robot1XAction, value); }
  485. }
  486. public WaferRobotTAction Robot2TAction
  487. {
  488. get { return m_Robot2TAction; }
  489. set { SetProperty(ref m_Robot2TAction, value); }
  490. }
  491. public WaferRobotXAction Robot2XAction
  492. {
  493. get { return m_Robot2XAction; }
  494. set { SetProperty(ref m_Robot2XAction, value); }
  495. }
  496. public TMModule PickSelectedModule
  497. {
  498. get { return m_PickSelectedModule; }
  499. set { SetProperty(ref m_PickSelectedModule, value); }
  500. }
  501. public TMModule PlaceSelectedModule
  502. {
  503. get { return m_PlaceSelectedModule; }
  504. set { SetProperty(ref m_PlaceSelectedModule, value); }
  505. }
  506. public TMModule ExtendSelectedModule
  507. {
  508. get { return m_ExtendSelectedModule; }
  509. set { SetProperty(ref m_ExtendSelectedModule, value); }
  510. }
  511. public TMModule RetractSelectedModule
  512. {
  513. get { return m_RetractSelectedModule; }
  514. set { SetProperty(ref m_RetractSelectedModule, value); }
  515. }
  516. public TMBlade PickSelectedBlade
  517. {
  518. get { return m_PickSelectedBlade; }
  519. set { SetProperty(ref m_PickSelectedBlade, value); }
  520. }
  521. public TMBlade PlaceSelectedBlade
  522. {
  523. get { return m_PlaceSelectedBlade; }
  524. set { SetProperty(ref m_PlaceSelectedBlade, value); }
  525. }
  526. public TMBlade ExtendSelectedBlade
  527. {
  528. get { return m_ExtendSelectedBlade; }
  529. set { SetProperty(ref m_ExtendSelectedBlade, value); }
  530. }
  531. public TMBlade RetractSelectedBlade
  532. {
  533. get { return m_RetractSelectedBlade; }
  534. set { SetProperty(ref m_RetractSelectedBlade, value); }
  535. }
  536. public TMBlade GoToSelectedBlade
  537. {
  538. get { return m_GoToSelectedBlade; }
  539. set { SetProperty(ref m_GoToSelectedBlade, value); }
  540. }
  541. public ObservableCollection<int> PickSoltItemsSource
  542. {
  543. get { return m_PickSoltItemsSource; }
  544. set { SetProperty(ref m_PickSoltItemsSource, value); }
  545. }
  546. public ObservableCollection<int> PlaceSoltItemsSource
  547. {
  548. get { return m_PlaceSoltItemsSource; }
  549. set { SetProperty(ref m_PlaceSoltItemsSource, value); }
  550. }
  551. public ObservableCollection<int> ExtendSoltItemsSource
  552. {
  553. get { return m_ExtendSoltItemsSource; }
  554. set { SetProperty(ref m_ExtendSoltItemsSource, value); }
  555. }
  556. public ObservableCollection<int> RetractSoltItemsSource
  557. {
  558. get { return m_RetractSoltItemsSource; }
  559. set { SetProperty(ref m_RetractSoltItemsSource, value); }
  560. }
  561. public int PickSoltSelectedIndex
  562. {
  563. get { return m_PickSoltSelectedIndex; }
  564. set { SetProperty(ref m_PickSoltSelectedIndex, value); }
  565. }
  566. public int PlaceSoltSelectedIndex
  567. {
  568. get { return m_PlaceSoltSelectedIndex; }
  569. set { SetProperty(ref m_PlaceSoltSelectedIndex, value); }
  570. }
  571. public int ExtendSoltSelectedIndex
  572. {
  573. get { return m_ExtendSoltSelectedIndex; }
  574. set { SetProperty(ref m_ExtendSoltSelectedIndex, value); }
  575. }
  576. public int RetractSoltSelectedIndex
  577. {
  578. get { return m_RetractSoltSelectedIndex; }
  579. set { SetProperty(ref m_RetractSoltSelectedIndex, value); }
  580. }
  581. public Dictionary<string, object> RtDataValues
  582. {
  583. get { return m_RtDataValues; }
  584. set { SetProperty(ref m_RtDataValues, value); }
  585. }
  586. public bool PMAIsInstalled
  587. {
  588. get { return m_PMAIsInstalled; }
  589. set { SetProperty(ref m_PMAIsInstalled, value); }
  590. }
  591. public bool PMBIsInstalled
  592. {
  593. get { return m_PMBIsInstalled; }
  594. set { SetProperty(ref m_PMBIsInstalled, value); }
  595. }
  596. public bool PMCIsInstalled
  597. {
  598. get { return m_PMCIsInstalled; }
  599. set { SetProperty(ref m_PMCIsInstalled, value); }
  600. }
  601. public bool PMDIsInstalled
  602. {
  603. get { return m_PMDIsInstalled; }
  604. set { SetProperty(ref m_PMDIsInstalled, value); }
  605. }
  606. public bool LLAIsInstalled
  607. {
  608. get { return m_LLAIsInstalled; }
  609. set { SetProperty(ref m_LLAIsInstalled, value); }
  610. }
  611. public bool LLBIsInstalled
  612. {
  613. get { return m_LLBIsInstalled; }
  614. set { SetProperty(ref m_LLBIsInstalled, value); }
  615. }
  616. public List<TMModule> TMModules
  617. {
  618. get { return m_TMModules; }
  619. set { SetProperty(ref m_TMModules, value); }
  620. }
  621. #endregion
  622. #region 命令
  623. private DelegateCommand _GotoCommand;
  624. public DelegateCommand GotoCommand =>
  625. _GotoCommand ?? (_GotoCommand = new DelegateCommand(OnGoto));
  626. private DelegateCommand _ExtendCommand;
  627. public DelegateCommand ExtendCommand =>
  628. _ExtendCommand ?? (_ExtendCommand = new DelegateCommand(OnExtend));
  629. private DelegateCommand _RetractCommand;
  630. public DelegateCommand RetractCommand =>
  631. _RetractCommand ?? (_RetractCommand = new DelegateCommand(OnRetract));
  632. private DelegateCommand<object> _ModuleChangeCommand;
  633. public DelegateCommand<object> ModuleChangeCommand =>
  634. _ModuleChangeCommand ?? (_ModuleChangeCommand = new DelegateCommand<object>(OnModuleChange));
  635. private DelegateCommand _PickCommand;
  636. public DelegateCommand PickCommand =>
  637. _PickCommand ?? (_PickCommand = new DelegateCommand(OnPick));
  638. private DelegateCommand _PlaceCommand;
  639. public DelegateCommand PlaceCommand =>
  640. _PlaceCommand ?? (_PlaceCommand = new DelegateCommand(OnPlace));
  641. private DelegateCommand _HomeCommand;
  642. public DelegateCommand HomeCommand =>
  643. _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome));
  644. private DelegateCommand _VentCommand;
  645. public DelegateCommand VentCommand =>
  646. _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent));
  647. private DelegateCommand _PumpCommand;
  648. public DelegateCommand PumpCommand =>
  649. _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump));
  650. private DelegateCommand _PurgeCommand;
  651. public DelegateCommand PurgeCommand =>
  652. _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge));
  653. private DelegateCommand<object> _ModuleCheckedCommand;
  654. public DelegateCommand<object> ModuleCheckedCommand =>
  655. _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand<object>(OnModuleChecked));
  656. private DelegateCommand _AbortCommand;
  657. public DelegateCommand AbortCommand =>
  658. _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));
  659. #endregion
  660. #region 构造函数
  661. public TMViewModel()
  662. {
  663. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  664. PMAIsInstalled = allModules.Contains("PMA");
  665. PMBIsInstalled = allModules.Contains("PMB");
  666. PMCIsInstalled = allModules.Contains("PMC");
  667. PMDIsInstalled = allModules.Contains("PMD");
  668. LLAIsInstalled = allModules.Contains("LLA");
  669. LLBIsInstalled = allModules.Contains("LLB");
  670. if (PMAIsInstalled == true)
  671. {
  672. TMModules.Add(TMModule.PMA);
  673. }
  674. if (PMBIsInstalled == true)
  675. {
  676. TMModules.Add(TMModule.PMB);
  677. }
  678. if (PMCIsInstalled == true)
  679. {
  680. TMModules.Add(TMModule.PMC);
  681. }
  682. if (PMDIsInstalled == true)
  683. {
  684. TMModules.Add(TMModule.PMD);
  685. }
  686. if (LLAIsInstalled == true)
  687. {
  688. OriginalCycle.Add("LLA");
  689. ToCycle.Add("LLA");
  690. TMModules.Add(TMModule.LLA);
  691. }
  692. if (LLBIsInstalled == true)
  693. {
  694. OriginalCycle.Add("LLB");
  695. ToCycle.Add("LLB");
  696. TMModules.Add(TMModule.LLB);
  697. }
  698. addDataKeys();
  699. DispatcherTimer timer = new DispatcherTimer();
  700. timer.Interval = TimeSpan.FromSeconds(0.5);
  701. timer.Tick += Timer_Tick;
  702. timer.Start();
  703. PickSoltItemsSource.Add(1);
  704. PlaceSoltItemsSource.Add(1);
  705. ExtendSoltItemsSource.Add(1);
  706. RetractSoltItemsSource.Add(1);
  707. //Robot1TAction = WaferRobotTAction.PMA;
  708. //Robot2TAction = WaferRobotTAction.PMD;
  709. }
  710. private void Timer_Tick(object sender, EventArgs e)
  711. {
  712. if (LLAIsInstalled == true)
  713. {
  714. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x=>x.WaferStatus!=0);
  715. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  716. }
  717. if (LLBIsInstalled == true)
  718. {
  719. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  720. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  721. }
  722. if (PMAIsInstalled == true)
  723. {
  724. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  725. }
  726. if (PMBIsInstalled == true)
  727. {
  728. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  729. }
  730. if (PMCIsInstalled == true)
  731. {
  732. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  733. }
  734. if (PMDIsInstalled == true)
  735. {
  736. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  737. }
  738. BladeAWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0];
  739. BladeBWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1];
  740. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  741. var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");
  742. if (TMRobotMoveActionArmTarget != null)
  743. {
  744. RobotArm = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus.ToString();
  745. }
  746. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  747. if (TMRobotMoveActionBladeTarget != null)
  748. {
  749. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  750. }
  751. var TMRobotMoveActionRobotAction = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.RobotAction");
  752. if (TMRobotMoveActionRobotAction != null)
  753. {
  754. RobotAction2 = TMRobotMoveActionRobotAction.ToString();
  755. }
  756. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  757. }
  758. #endregion
  759. #region 命令方法
  760. private void OnGoto()
  761. {
  762. if (GoToSelectedBlade == TMBlade.Blade1)
  763. {
  764. Robot1TAction = WaferRobotTAction;
  765. }
  766. else if (GoToSelectedBlade == TMBlade.Blade2)
  767. {
  768. Robot2TAction = WaferRobotTAction;
  769. }
  770. }
  771. private void OnExtend()
  772. {
  773. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  774. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  775. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Extend}", moduleName, 0, selectedHand);
  776. }
  777. private void OnRetract()
  778. {
  779. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  780. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  781. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Retract}", moduleName, 0, selectedHand);
  782. }
  783. private void OnModuleChange(object obj)
  784. {
  785. var value = obj.ToString();
  786. switch (value)
  787. {
  788. case "Pick":
  789. PickSoltItemsSource.Clear();
  790. if ((int)PickSelectedModule == 4)
  791. {
  792. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  793. {
  794. PickSoltItemsSource.Add(i);
  795. }
  796. }
  797. else if ((int)PickSelectedModule == 5)
  798. {
  799. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  800. {
  801. PickSoltItemsSource.Add(i);
  802. }
  803. }
  804. else
  805. {
  806. PickSoltItemsSource.Add(1);
  807. }
  808. PickSoltSelectedIndex = 0;
  809. break;
  810. case "Place":
  811. PlaceSoltItemsSource.Clear();
  812. if ((int)PlaceSelectedModule == 4)
  813. {
  814. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  815. {
  816. PlaceSoltItemsSource.Add(i);
  817. }
  818. }
  819. else if ((int)PlaceSelectedModule == 5)
  820. {
  821. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  822. {
  823. PlaceSoltItemsSource.Add(i);
  824. }
  825. }
  826. else
  827. {
  828. PlaceSoltItemsSource.Add(1);
  829. }
  830. PlaceSoltSelectedIndex = 0;
  831. break;
  832. case "Extend":
  833. ExtendSoltItemsSource.Clear();
  834. if ((int)ExtendSelectedModule == 4)
  835. {
  836. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  837. {
  838. ExtendSoltItemsSource.Add(i);
  839. }
  840. }
  841. else if ((int)ExtendSelectedModule == 5)
  842. {
  843. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  844. {
  845. ExtendSoltItemsSource.Add(i);
  846. }
  847. }
  848. else
  849. {
  850. ExtendSoltItemsSource.Add(1);
  851. }
  852. ExtendSoltSelectedIndex = 0;
  853. break;
  854. case "Retract":
  855. RetractSoltItemsSource.Clear();
  856. if ((int)RetractSelectedModule == 4)
  857. {
  858. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  859. {
  860. RetractSoltItemsSource.Add(i);
  861. }
  862. //RetractSoltItemsSource = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
  863. }
  864. else if ((int)RetractSelectedModule == 5)
  865. {
  866. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  867. {
  868. RetractSoltItemsSource.Add(i);
  869. }
  870. }
  871. else
  872. {
  873. RetractSoltItemsSource.Add(1);
  874. }
  875. RetractSoltSelectedIndex = 0;
  876. break;
  877. }
  878. }
  879. private void OnPick()
  880. {
  881. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  882. var moduleName= (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  883. var selectedHand= (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  884. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  885. moveItems.Enqueue(moveItem);
  886. if ((int)PickSelectedModule > 3)
  887. {
  888. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPick}", moveItems);
  889. }
  890. else
  891. {
  892. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPick}", moveItems);
  893. }
  894. }
  895. private void OnPlace()
  896. {
  897. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  898. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  899. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  900. MoveItem moveItem = new MoveItem(0,0,moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex]-1, selectedHand);
  901. moveItems.Enqueue(moveItem);
  902. if ((int)PlaceSelectedModule > 3)
  903. {
  904. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPlace}", moveItems);
  905. }
  906. else
  907. {
  908. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPlace}", moveItems);
  909. }
  910. }
  911. private void OnHome()
  912. {
  913. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");
  914. }
  915. private void OnVent()
  916. {
  917. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}");
  918. }
  919. private void OnPump()
  920. {
  921. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}");
  922. }
  923. private void OnPurge()
  924. {
  925. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}");
  926. }
  927. private void OnModuleChecked(object obj)
  928. {
  929. m_ModuleCheckedName=obj.ToString();
  930. }
  931. private void OnAbort()
  932. {
  933. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}");
  934. }
  935. #endregion
  936. #region 私有方法
  937. private void addDataKeys()
  938. {
  939. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  940. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  941. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  942. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  943. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  944. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  945. }
  946. #endregion
  947. }
  948. }