TMViewModel.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  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.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows;
  17. using System.Windows.Controls;
  18. using System.Windows.Threading;
  19. using Venus_Core;
  20. using Venus_MainPages.Unity;
  21. using Venus_Themes.CustomControls;
  22. namespace Venus_MainPages.ViewModels
  23. {
  24. public enum TMModule
  25. {
  26. PMA, PMB, PMC, PMD, LLA, LLB
  27. }
  28. public enum TMBlade
  29. {
  30. Blade1, Blade2
  31. }
  32. internal class TMViewModel : BindableBase
  33. {
  34. #region 私有字段
  35. //private ModuleInfo m_PMAWafer;
  36. private ModuleInfo m_LLAModuleInfo;
  37. private ModuleInfo m_LLBModuleInfo;
  38. private bool m_TMIsOFFline;
  39. private bool m_LLIsOFFline;
  40. private WaferInfo m_PMAWafer;
  41. private WaferInfo m_PMBWafer;
  42. private WaferInfo m_PMCWafer;
  43. private WaferInfo m_PMDWafer;
  44. private WaferInfo m_LLAWafer;
  45. private WaferInfo m_LLBWafer;
  46. private WaferInfo m_BladeAWafer;
  47. private WaferInfo m_BladeBWafer;
  48. private bool m_PMADoorIsOpen;
  49. //private bool m_PMBDoorIsOpen;
  50. //private bool m_PMCDoorIsOpen;
  51. //private bool m_PMDDoorIsOpen;
  52. private bool m_LLADoorIsOpen;
  53. private WaferRobotTAction m_WaferRobotTAction;
  54. private WaferRobotTAction m_Robot1TAction;
  55. private WaferRobotXAction m_Robot1XAction;
  56. private WaferRobotTAction m_Robot2TAction;
  57. private WaferRobotXAction m_Robot2XAction;
  58. private TMModule m_PickSelectedModule;
  59. private TMModule m_PlaceSelectedModule;
  60. private TMModule m_ExtendSelectedModule;
  61. private TMModule m_RetractSelectedModule;
  62. private TMBlade m_PickSelectedBlade;
  63. private TMBlade m_PlaceSelectedBlade;
  64. private TMBlade m_ExtendSelectedBlade;
  65. private TMBlade m_RetractSelectedBlade;
  66. private TMBlade m_GoToSelectedBlade;
  67. private ObservableCollection<int> m_PlaceSoltItemsSource = new ObservableCollection<int>();
  68. private ObservableCollection<int> m_PickSoltItemsSource = new ObservableCollection<int>();
  69. private ObservableCollection<int> m_ExtendSoltItemsSource = new ObservableCollection<int>();
  70. private ObservableCollection<int> m_RetractSoltItemsSource = new ObservableCollection<int>();
  71. private int m_PickSoltSelectedIndex;
  72. private int m_PlaceSoltSelectedIndex;
  73. private int m_ExtendSoltSelectedIndex;
  74. private int m_RetractSoltSelectedIndex;
  75. private List<string> m_RtDataKeys=new List<string> ();
  76. private Dictionary<string, object> m_RtDataValues;
  77. private string m_ModuleCheckedName="TM";
  78. private string m_RobotAction;
  79. private string m_RobotTarget;
  80. private string m_RobotArm;
  81. private bool m_PMAIsInstalled;
  82. private bool m_PMBIsInstalled;
  83. private bool m_PMCIsInstalled;
  84. private bool m_PMDIsInstalled;
  85. private bool m_LLAIsInstalled;
  86. private bool m_LLBIsInstalled;
  87. #endregion
  88. #region 属性
  89. public string RobotAction
  90. {
  91. get { return m_RobotAction; }
  92. set
  93. {
  94. RobotActiont(m_RobotAction, value);
  95. SetProperty(ref m_RobotAction, value);
  96. }
  97. }
  98. public string RobotTarget
  99. {
  100. get { return m_RobotTarget; }
  101. set
  102. {
  103. SetProperty(ref m_RobotTarget, value);
  104. }
  105. }
  106. public string RobotArm
  107. {
  108. get { return m_RobotArm; }
  109. set
  110. {
  111. SetProperty(ref m_RobotArm, value);
  112. }
  113. }
  114. int arm1oldWaferStatus = 100;
  115. int arm2oldWaferStatus = 100;
  116. private async void RobotActiont(string oldValue,string newValue)
  117. {
  118. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus==1)
  119. {
  120. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  121. if (TMRobotMoveActionBladeTarget != null)
  122. {
  123. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  124. }
  125. else
  126. {
  127. return;
  128. }
  129. var values = RobotTarget.Split('.');
  130. var arm = values[0];
  131. var module = values[1];
  132. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  133. await Task.Delay(1500);
  134. Robot1XAction = WaferRobotXAction.Extend;
  135. if (arm == "ArmA")
  136. {
  137. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  138. await Task.Delay(1500);
  139. Robot1XAction = WaferRobotXAction.Extend;
  140. }
  141. else if (arm == "ArmB")
  142. {
  143. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  144. await Task.Delay(1500);
  145. Robot2XAction = WaferRobotXAction.Extend;
  146. }
  147. }
  148. if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 1)
  149. {
  150. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  151. if (TMRobotMoveActionBladeTarget != null)
  152. {
  153. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  154. }
  155. else
  156. {
  157. return;
  158. }
  159. var values = RobotTarget.Split('.');
  160. var arm = values[0];
  161. var module = values[1];
  162. if (arm == "ArmA")
  163. {
  164. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  165. await Task.Delay(1500);
  166. Robot1XAction = WaferRobotXAction.Extend;
  167. }
  168. else if (arm == "ArmB")
  169. {
  170. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  171. await Task.Delay(1500);
  172. Robot2XAction = WaferRobotXAction.Extend;
  173. }
  174. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  175. //await Task.Delay(1500);
  176. //Robot2XAction = WaferRobotXAction.Extend;
  177. }
  178. if (arm1oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus)
  179. {
  180. Robot1XAction = WaferRobotXAction.Retract;
  181. }
  182. if (arm2oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus)
  183. {
  184. Robot2XAction = WaferRobotXAction.Retract;
  185. }
  186. if (oldValue == "None" && newValue == "Picking" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 0)
  187. {
  188. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  189. if (TMRobotMoveActionBladeTarget != null)
  190. {
  191. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  192. }
  193. else
  194. {
  195. return;
  196. }
  197. var values = RobotTarget.Split('.');
  198. var arm = values[0];
  199. var module = values[1];
  200. if (arm == "ArmA")
  201. {
  202. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  203. await Task.Delay(1500);
  204. Robot1XAction = WaferRobotXAction.Extend;
  205. }
  206. else if (arm == "ArmB")
  207. {
  208. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  209. await Task.Delay(1500);
  210. Robot2XAction = WaferRobotXAction.Extend;
  211. }
  212. }
  213. #region pick 和 place pm
  214. if (oldValue == "None" && newValue == "Extending")
  215. {
  216. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  217. if (TMRobotMoveActionBladeTarget != null)
  218. {
  219. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  220. }
  221. else
  222. {
  223. return;
  224. }
  225. var values = RobotTarget.Split('.');
  226. var arm = values[0];
  227. var module = values[1];
  228. if (arm == "ArmA")
  229. {
  230. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  231. await Task.Delay(1500);
  232. Robot1XAction = WaferRobotXAction.Extend;
  233. }
  234. else if (arm == "ArmB")
  235. {
  236. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  237. await Task.Delay(1500);
  238. Robot2XAction = WaferRobotXAction.Extend;
  239. }
  240. }
  241. if (oldValue == "None" && newValue == "Retracting")
  242. {
  243. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  244. if (TMRobotMoveActionBladeTarget != null)
  245. {
  246. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  247. }
  248. else
  249. {
  250. return;
  251. }
  252. var values = RobotTarget.Split('.');
  253. var arm = values[0];
  254. if (arm == "ArmA")
  255. {
  256. Robot1XAction = WaferRobotXAction.Retract;
  257. }
  258. else if (arm == "ArmB")
  259. {
  260. Robot2XAction = WaferRobotXAction.Retract;
  261. }
  262. }
  263. #endregion
  264. arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;
  265. arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;
  266. }
  267. public WaferInfo LLAWafer
  268. {
  269. get { return m_LLAWafer; }
  270. set { SetProperty(ref m_LLAWafer, value); }
  271. }
  272. public WaferInfo LLBWafer
  273. {
  274. get { return m_LLBWafer; }
  275. set { SetProperty(ref m_LLBWafer, value); }
  276. }
  277. public WaferInfo PMAWafer
  278. {
  279. get { return m_PMAWafer; }
  280. set { SetProperty(ref m_PMAWafer, value); }
  281. }
  282. public WaferInfo PMBWafer
  283. {
  284. get { return m_PMBWafer; }
  285. set { SetProperty(ref m_PMBWafer, value); }
  286. }
  287. public WaferInfo PMCWafer
  288. {
  289. get { return m_PMCWafer; }
  290. set { SetProperty(ref m_PMCWafer, value); }
  291. }
  292. public WaferInfo PMDWafer
  293. {
  294. get { return m_PMDWafer; }
  295. set { SetProperty(ref m_PMDWafer, value); }
  296. }
  297. public WaferInfo BladeAWafer
  298. {
  299. get { return m_BladeAWafer; }
  300. set { SetProperty(ref m_BladeAWafer, value); }
  301. }
  302. public WaferInfo BladeBWafer
  303. {
  304. get { return m_BladeBWafer; }
  305. set { SetProperty(ref m_BladeBWafer, value); }
  306. }
  307. public ModuleInfo LLAModuleInfo
  308. {
  309. get { return m_LLAModuleInfo; }
  310. set { SetProperty(ref m_LLAModuleInfo, value); }
  311. }
  312. public ModuleInfo LLBModuleInfo
  313. {
  314. get { return m_LLBModuleInfo; }
  315. set { SetProperty(ref m_LLBModuleInfo, value); }
  316. }
  317. public bool TMIsOFFline
  318. {
  319. get { return m_TMIsOFFline; }
  320. set { SetProperty(ref m_TMIsOFFline, value); }
  321. }
  322. public bool LLIsOFFline
  323. {
  324. get { return m_LLIsOFFline; }
  325. set { SetProperty(ref m_LLIsOFFline, value); }
  326. }
  327. public bool PMADoorIsOpen
  328. {
  329. get { return m_PMADoorIsOpen; }
  330. set { SetProperty(ref m_PMADoorIsOpen, value); }
  331. }
  332. public bool LLADoorIsOpen
  333. {
  334. get { return m_LLADoorIsOpen; }
  335. set { SetProperty(ref m_LLADoorIsOpen, value); }
  336. }
  337. public WaferRobotTAction WaferRobotTAction
  338. {
  339. get { return m_WaferRobotTAction; }
  340. set { SetProperty(ref m_WaferRobotTAction, value); }
  341. }
  342. public WaferRobotTAction Robot1TAction
  343. {
  344. get { return m_Robot1TAction; }
  345. set { SetProperty(ref m_Robot1TAction, value); }
  346. }
  347. public WaferRobotXAction Robot1XAction
  348. {
  349. get { return m_Robot1XAction; }
  350. set { SetProperty(ref m_Robot1XAction, value); }
  351. }
  352. public WaferRobotTAction Robot2TAction
  353. {
  354. get { return m_Robot2TAction; }
  355. set { SetProperty(ref m_Robot2TAction, value); }
  356. }
  357. public WaferRobotXAction Robot2XAction
  358. {
  359. get { return m_Robot2XAction; }
  360. set { SetProperty(ref m_Robot2XAction, value); }
  361. }
  362. public TMModule PickSelectedModule
  363. {
  364. get { return m_PickSelectedModule; }
  365. set { SetProperty(ref m_PickSelectedModule, value); }
  366. }
  367. public TMModule PlaceSelectedModule
  368. {
  369. get { return m_PlaceSelectedModule; }
  370. set { SetProperty(ref m_PlaceSelectedModule, value); }
  371. }
  372. public TMModule ExtendSelectedModule
  373. {
  374. get { return m_ExtendSelectedModule; }
  375. set { SetProperty(ref m_ExtendSelectedModule, value); }
  376. }
  377. public TMModule RetractSelectedModule
  378. {
  379. get { return m_RetractSelectedModule; }
  380. set { SetProperty(ref m_RetractSelectedModule, value); }
  381. }
  382. public TMBlade PickSelectedBlade
  383. {
  384. get { return m_PickSelectedBlade; }
  385. set { SetProperty(ref m_PickSelectedBlade, value); }
  386. }
  387. public TMBlade PlaceSelectedBlade
  388. {
  389. get { return m_PlaceSelectedBlade; }
  390. set { SetProperty(ref m_PlaceSelectedBlade, value); }
  391. }
  392. public TMBlade ExtendSelectedBlade
  393. {
  394. get { return m_ExtendSelectedBlade; }
  395. set { SetProperty(ref m_ExtendSelectedBlade, value); }
  396. }
  397. public TMBlade RetractSelectedBlade
  398. {
  399. get { return m_RetractSelectedBlade; }
  400. set { SetProperty(ref m_RetractSelectedBlade, value); }
  401. }
  402. public TMBlade GoToSelectedBlade
  403. {
  404. get { return m_GoToSelectedBlade; }
  405. set { SetProperty(ref m_GoToSelectedBlade, value); }
  406. }
  407. public ObservableCollection<int> PickSoltItemsSource
  408. {
  409. get { return m_PickSoltItemsSource; }
  410. set { SetProperty(ref m_PickSoltItemsSource, value); }
  411. }
  412. public ObservableCollection<int> PlaceSoltItemsSource
  413. {
  414. get { return m_PlaceSoltItemsSource; }
  415. set { SetProperty(ref m_PlaceSoltItemsSource, value); }
  416. }
  417. public ObservableCollection<int> ExtendSoltItemsSource
  418. {
  419. get { return m_ExtendSoltItemsSource; }
  420. set { SetProperty(ref m_ExtendSoltItemsSource, value); }
  421. }
  422. public ObservableCollection<int> RetractSoltItemsSource
  423. {
  424. get { return m_RetractSoltItemsSource; }
  425. set { SetProperty(ref m_RetractSoltItemsSource, value); }
  426. }
  427. public int PickSoltSelectedIndex
  428. {
  429. get { return m_PickSoltSelectedIndex; }
  430. set { SetProperty(ref m_PickSoltSelectedIndex, value); }
  431. }
  432. public int PlaceSoltSelectedIndex
  433. {
  434. get { return m_PlaceSoltSelectedIndex; }
  435. set { SetProperty(ref m_PlaceSoltSelectedIndex, value); }
  436. }
  437. public int ExtendSoltSelectedIndex
  438. {
  439. get { return m_ExtendSoltSelectedIndex; }
  440. set { SetProperty(ref m_ExtendSoltSelectedIndex, value); }
  441. }
  442. public int RetractSoltSelectedIndex
  443. {
  444. get { return m_RetractSoltSelectedIndex; }
  445. set { SetProperty(ref m_RetractSoltSelectedIndex, value); }
  446. }
  447. public Dictionary<string, object> RtDataValues
  448. {
  449. get { return m_RtDataValues; }
  450. set { SetProperty(ref m_RtDataValues, value); }
  451. }
  452. public bool PMAIsInstalled
  453. {
  454. get { return m_PMAIsInstalled; }
  455. set { SetProperty(ref m_PMAIsInstalled, value); }
  456. }
  457. public bool PMBIsInstalled
  458. {
  459. get { return m_PMBIsInstalled; }
  460. set { SetProperty(ref m_PMBIsInstalled, value); }
  461. }
  462. public bool PMCIsInstalled
  463. {
  464. get { return m_PMCIsInstalled; }
  465. set { SetProperty(ref m_PMCIsInstalled, value); }
  466. }
  467. public bool PMDIsInstalled
  468. {
  469. get { return m_PMDIsInstalled; }
  470. set { SetProperty(ref m_PMDIsInstalled, value); }
  471. }
  472. public bool LLAIsInstalled
  473. {
  474. get { return m_LLAIsInstalled; }
  475. set { SetProperty(ref m_LLAIsInstalled, value); }
  476. }
  477. public bool LLBIsInstalled
  478. {
  479. get { return m_LLBIsInstalled; }
  480. set { SetProperty(ref m_LLBIsInstalled, value); }
  481. }
  482. #endregion
  483. #region 命令
  484. private DelegateCommand _GotoCommand;
  485. public DelegateCommand GotoCommand =>
  486. _GotoCommand ?? (_GotoCommand = new DelegateCommand(OnGoto));
  487. private DelegateCommand _ExtendCommand;
  488. public DelegateCommand ExtendCommand =>
  489. _ExtendCommand ?? (_ExtendCommand = new DelegateCommand(OnExtend));
  490. private DelegateCommand _RetractCommand;
  491. public DelegateCommand RetractCommand =>
  492. _RetractCommand ?? (_RetractCommand = new DelegateCommand(OnRetract));
  493. private DelegateCommand<object> _ModuleChangeCommand;
  494. public DelegateCommand<object> ModuleChangeCommand =>
  495. _ModuleChangeCommand ?? (_ModuleChangeCommand = new DelegateCommand<object>(OnModuleChange));
  496. private DelegateCommand _PickCommand;
  497. public DelegateCommand PickCommand =>
  498. _PickCommand ?? (_PickCommand = new DelegateCommand(OnPick));
  499. private DelegateCommand _PlaceCommand;
  500. public DelegateCommand PlaceCommand =>
  501. _PlaceCommand ?? (_PlaceCommand = new DelegateCommand(OnPlace));
  502. private DelegateCommand _HomeCommand;
  503. public DelegateCommand HomeCommand =>
  504. _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome));
  505. private DelegateCommand _VentCommand;
  506. public DelegateCommand VentCommand =>
  507. _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent));
  508. private DelegateCommand _PumpCommand;
  509. public DelegateCommand PumpCommand =>
  510. _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump));
  511. private DelegateCommand _PurgeCommand;
  512. public DelegateCommand PurgeCommand =>
  513. _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge));
  514. private DelegateCommand<object> _ModuleCheckedCommand;
  515. public DelegateCommand<object> ModuleCheckedCommand =>
  516. _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand<object>(OnModuleChecked));
  517. private DelegateCommand _AbortCommand;
  518. public DelegateCommand AbortCommand =>
  519. _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));
  520. #endregion
  521. #region 构造函数
  522. public TMViewModel()
  523. {
  524. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  525. PMAIsInstalled = allModules.Contains("PMA");
  526. PMBIsInstalled = allModules.Contains("PMB");
  527. PMCIsInstalled = allModules.Contains("PMC");
  528. PMDIsInstalled = allModules.Contains("PMD");
  529. LLAIsInstalled = allModules.Contains("LLA");
  530. LLBIsInstalled = allModules.Contains("LLB");
  531. addDataKeys();
  532. DispatcherTimer timer = new DispatcherTimer();
  533. timer.Interval = TimeSpan.FromSeconds(0.5);
  534. timer.Tick += Timer_Tick;
  535. timer.Start();
  536. PickSoltItemsSource.Add(1);
  537. PlaceSoltItemsSource.Add(1);
  538. ExtendSoltItemsSource.Add(1);
  539. RetractSoltItemsSource.Add(1);
  540. //Robot1TAction = WaferRobotTAction.PMA;
  541. //Robot2TAction = WaferRobotTAction.PMD;
  542. VenusGlobalEvents.SlotRightClickChangedEvent += Instance_SlotRightClickChangedEvent;
  543. }
  544. private void Instance_SlotRightClickChangedEvent(OpenSEMI.Ctrlib.Controls.Slot slot)
  545. {
  546. if (slot!=null)
  547. {
  548. ContextMenu cm = ContextMenuManager.Instance.GetSlotMenus(slot);
  549. if (cm != null)
  550. {
  551. slot.ContextMenu = cm;
  552. }
  553. return;
  554. }
  555. }
  556. private void Timer_Tick(object sender, EventArgs e)
  557. {
  558. if (LLAIsInstalled == true)
  559. {
  560. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  561. }
  562. if (LLBIsInstalled == true)
  563. {
  564. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  565. }
  566. //LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers[0];
  567. //LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers[3];
  568. if (PMAIsInstalled == true)
  569. {
  570. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  571. }
  572. if (PMBIsInstalled == true)
  573. {
  574. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  575. }
  576. if (PMCIsInstalled == true)
  577. {
  578. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  579. }
  580. if (PMDIsInstalled == true)
  581. {
  582. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  583. }
  584. BladeAWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0];
  585. BladeBWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1];
  586. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  587. var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");
  588. if (TMRobotMoveActionArmTarget != null)
  589. {
  590. RobotArm = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus.ToString();
  591. }
  592. var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");
  593. if (TMRobotMoveActionBladeTarget != null)
  594. {
  595. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  596. }
  597. var TMRobotMoveActionRobotAction = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.RobotAction");
  598. if (TMRobotMoveActionRobotAction != null)
  599. {
  600. RobotAction = TMRobotMoveActionRobotAction.ToString();
  601. }
  602. }
  603. #endregion
  604. #region 命令方法
  605. private void OnGoto()
  606. {
  607. if (GoToSelectedBlade == TMBlade.Blade1)
  608. {
  609. Robot1TAction = WaferRobotTAction;
  610. }
  611. else if (GoToSelectedBlade == TMBlade.Blade2)
  612. {
  613. Robot2TAction = WaferRobotTAction;
  614. }
  615. }
  616. private void OnExtend()
  617. {
  618. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  619. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  620. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Extend}", moduleName, 0, selectedHand);
  621. }
  622. private void OnRetract()
  623. {
  624. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  625. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  626. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Retract}", moduleName, 0, selectedHand);
  627. }
  628. private void OnModuleChange(object obj)
  629. {
  630. var value = obj.ToString();
  631. switch (value)
  632. {
  633. case "Pick":
  634. PickSoltItemsSource.Clear();
  635. if ((int)PickSelectedModule == 4)
  636. {
  637. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  638. {
  639. PickSoltItemsSource.Add(i);
  640. }
  641. }
  642. else if ((int)PickSelectedModule == 5)
  643. {
  644. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  645. {
  646. PickSoltItemsSource.Add(i);
  647. }
  648. }
  649. else
  650. {
  651. PickSoltItemsSource.Add(1);
  652. }
  653. PickSoltSelectedIndex = 0;
  654. break;
  655. case "Place":
  656. PlaceSoltItemsSource.Clear();
  657. if ((int)PlaceSelectedModule == 4)
  658. {
  659. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  660. {
  661. PlaceSoltItemsSource.Add(i);
  662. }
  663. }
  664. else if ((int)PlaceSelectedModule == 5)
  665. {
  666. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  667. {
  668. PlaceSoltItemsSource.Add(i);
  669. }
  670. }
  671. else
  672. {
  673. PlaceSoltItemsSource.Add(1);
  674. }
  675. PlaceSoltSelectedIndex = 0;
  676. break;
  677. case "Extend":
  678. ExtendSoltItemsSource.Clear();
  679. if ((int)ExtendSelectedModule == 4)
  680. {
  681. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  682. {
  683. ExtendSoltItemsSource.Add(i);
  684. }
  685. }
  686. else if ((int)ExtendSelectedModule == 5)
  687. {
  688. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  689. {
  690. ExtendSoltItemsSource.Add(i);
  691. }
  692. }
  693. else
  694. {
  695. ExtendSoltItemsSource.Add(1);
  696. }
  697. ExtendSoltSelectedIndex = 0;
  698. break;
  699. case "Retract":
  700. RetractSoltItemsSource.Clear();
  701. if ((int)RetractSelectedModule == 4)
  702. {
  703. for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)
  704. {
  705. RetractSoltItemsSource.Add(i);
  706. }
  707. //RetractSoltItemsSource = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
  708. }
  709. else if ((int)RetractSelectedModule == 5)
  710. {
  711. for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)
  712. {
  713. RetractSoltItemsSource.Add(i);
  714. }
  715. }
  716. else
  717. {
  718. RetractSoltItemsSource.Add(1);
  719. }
  720. RetractSoltSelectedIndex = 0;
  721. break;
  722. }
  723. }
  724. private void OnPick()
  725. {
  726. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  727. var moduleName= (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  728. var selectedHand= (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  729. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  730. moveItems.Enqueue(moveItem);
  731. if ((int)PickSelectedModule > 3)
  732. {
  733. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPick}", moveItems);
  734. }
  735. else
  736. {
  737. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPick}", moveItems);
  738. }
  739. }
  740. private void OnPlace()
  741. {
  742. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  743. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  744. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  745. MoveItem moveItem = new MoveItem(0,0,moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, selectedHand);
  746. moveItems.Enqueue(moveItem);
  747. if ((int)PlaceSelectedModule > 3)
  748. {
  749. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPlace}", moveItems);
  750. }
  751. else
  752. {
  753. InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPlace}", moveItems);
  754. }
  755. }
  756. private void OnHome()
  757. {
  758. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");
  759. }
  760. private void OnVent()
  761. {
  762. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}");
  763. }
  764. private void OnPump()
  765. {
  766. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}");
  767. }
  768. private void OnPurge()
  769. {
  770. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}");
  771. }
  772. private void OnModuleChecked(object obj)
  773. {
  774. m_ModuleCheckedName=obj.ToString();
  775. }
  776. private void OnAbort()
  777. {
  778. InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}");
  779. }
  780. #endregion
  781. #region 私有方法
  782. private void addDataKeys()
  783. {
  784. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  785. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  786. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  787. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  788. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  789. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  790. //m_RtDataKeys.Add("TM.RobotMoveAction");
  791. }
  792. #endregion
  793. }
  794. }