SeTMViewModel.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  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 OpenSEMI.Ctrlib.Controls;
  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.Text;
  16. using System.Threading.Tasks;
  17. using System.Windows.Threading;
  18. using Venus_Core;
  19. using Venus_MainPages.Unity;
  20. using Venus_Themes.CustomControls;
  21. using static Venus_Themes.CustomControls.DERobot;
  22. using static Venus_Themes.CustomControls.SERobot;
  23. namespace Venus_MainPages.ViewModels
  24. {
  25. public enum SeTMModule
  26. {
  27. PMA, PMB, PMC, LP1, Aligner1
  28. }
  29. public enum SeTMBlade
  30. {
  31. Blade1, Blade2
  32. }
  33. public class SeTMViewModel : BindableBase
  34. {
  35. #region 私有字段
  36. public double m_Alignerangle;
  37. private ModuleInfo m_VCEModuleInfo;
  38. private ModuleInfo m_AlignerModuleInfo;
  39. private ModuleInfo m_TMModuleInfo;
  40. //Wafer
  41. private WaferInfo m_PMAWafer;
  42. private WaferInfo m_PMBWafer;
  43. private WaferInfo m_PMCWafer;
  44. public WaferInfo m_RobotUpperWafer;
  45. public WaferInfo m_RobotLowerWafer;
  46. public WaferInfo m_PAWafer;
  47. //Door
  48. private bool m_PMADoorIsOpen;
  49. private bool m_PMBDoorIsOpen;
  50. private bool m_PMCDoorIsOpen;
  51. private bool m_VCEDoorIsOpen;
  52. private bool m_VCEOutDoorIsOpen;
  53. //Pick、Place、Extend、Retract行下拉框内容
  54. private SeTMModule m_PickSelectedModule;
  55. private SeTMModule m_PlaceSelectedModule;
  56. private SeTMModule m_ExtendSelectedModule;
  57. private SeTMModule m_RetractSelectedModule;
  58. private SeTMModule m_GotoSelectedModule;
  59. private SeTMBlade m_PickSelectedBlade;
  60. private SeTMBlade m_PlaceSelectedBlade;
  61. private SeTMBlade m_ExtendSelectedBlade;
  62. private SeTMBlade m_RetractSelectedBlade;
  63. private SeTMBlade m_GoToSelectedBlade;
  64. //Pick、Place、Extend、Retract行下拉框关联
  65. private ObservableCollection<int> m_PickSoltItemsSource = new ObservableCollection<int>();
  66. private ObservableCollection<int> m_PlaceSoltItemsSource = 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. //下拉框内容
  74. private List<SeTMModule> m_TMModules = new List<SeTMModule>();
  75. private bool m_PMAIsInstalled;
  76. private bool m_PMBIsInstalled;
  77. private bool m_PMCIsInstalled;
  78. private bool m_VCEIsInstalled;
  79. private bool m_AlignerIsInstalled;
  80. private Dictionary<string, object> m_RtDataValues = new Dictionary<string, object>();
  81. private List<string> m_RtDataKeys = new List<string>();
  82. //Robot动画
  83. private SERobotTAction m_SERobotTAction;
  84. private SERobotTAction m_Robot1TAction;
  85. private SERobotXAction m_Robot1XAction;
  86. private SERobotTAction m_Robot2TAction;
  87. private SERobotXAction m_Robot2XAction;
  88. public RobotMoveInfo m_robotMoveInfo;
  89. //Cycle
  90. private List<string> m_OriginalCycle = new List<string>();
  91. private List<string> m_ToCycle = new List<string>();
  92. private bool m_CycleEnable;
  93. private bool m_PMAIsCycle;
  94. private bool m_PMBIsCycle;
  95. private bool m_PMCIsCycle;
  96. private int m_CycleCount;
  97. #endregion
  98. #region 属性
  99. public double Alignerangle
  100. {
  101. get { return m_Alignerangle; }
  102. set { SetProperty(ref m_Alignerangle, value); }
  103. }
  104. public WaferInfo PMAWafer
  105. {
  106. get { return m_PMAWafer; }
  107. set { SetProperty(ref m_PMAWafer, value); }
  108. }
  109. public WaferInfo PMBWafer
  110. {
  111. get { return m_PMBWafer; }
  112. set { SetProperty(ref m_PMBWafer, value); }
  113. }
  114. public WaferInfo PMCWafer
  115. {
  116. get { return m_PMCWafer; }
  117. set { SetProperty(ref m_PMCWafer, value); }
  118. }
  119. public WaferInfo RobotUpperWafer
  120. {
  121. get { return m_RobotUpperWafer; }
  122. set { SetProperty(ref m_RobotUpperWafer, value); }
  123. }
  124. public WaferInfo RobotLowerWafer
  125. {
  126. get { return m_RobotLowerWafer; }
  127. set { SetProperty(ref m_RobotLowerWafer, value); }
  128. }
  129. public WaferInfo PAWafer
  130. {
  131. get { return m_PAWafer; }
  132. set { SetProperty(ref m_PAWafer, value); }
  133. }
  134. public bool VCEDoorIsOpen { get => m_VCEDoorIsOpen; set => SetProperty(ref m_VCEDoorIsOpen, value); }
  135. public bool VCEOutDoorIsOpen { get => m_VCEOutDoorIsOpen; set => SetProperty(ref m_VCEOutDoorIsOpen, value); }
  136. public bool PMCDoorIsOpen
  137. {
  138. get => m_PMCDoorIsOpen;
  139. set
  140. {
  141. SetProperty(ref m_PMCDoorIsOpen, value);
  142. }
  143. }
  144. public bool PMADoorIsOpen
  145. {
  146. get { return m_PMADoorIsOpen; }
  147. set { SetProperty(ref m_PMADoorIsOpen, value); }
  148. }
  149. public bool PMBDoorIsOpen
  150. {
  151. get { return m_PMBDoorIsOpen; }
  152. set { SetProperty(ref m_PMBDoorIsOpen, value); }
  153. }
  154. public ModuleInfo VCEModuleInfo
  155. {
  156. get { return m_VCEModuleInfo; }
  157. set
  158. {
  159. SetProperty(ref m_VCEModuleInfo, value);
  160. }
  161. }
  162. public ModuleInfo AlignerModuleInfo
  163. {
  164. get { return m_AlignerModuleInfo; }
  165. set
  166. {
  167. SetProperty(ref m_AlignerModuleInfo, value);
  168. }
  169. }
  170. public Dictionary<string, object> RtDataValues
  171. {
  172. get { return m_RtDataValues; }
  173. set { SetProperty(ref m_RtDataValues, value); }
  174. }
  175. public bool PMAIsInstalled
  176. {
  177. get { return m_PMAIsInstalled; }
  178. set { SetProperty(ref m_PMAIsInstalled, value); }
  179. }
  180. public bool PMBIsInstalled
  181. {
  182. get { return m_PMBIsInstalled; }
  183. set { SetProperty(ref m_PMBIsInstalled, value); }
  184. }
  185. public bool PMCIsInstalled
  186. {
  187. get { return m_PMCIsInstalled; }
  188. set { SetProperty(ref m_PMCIsInstalled, value); }
  189. }
  190. public bool VCEIsInstalled
  191. {
  192. get { return m_VCEIsInstalled; }
  193. set { SetProperty(ref m_VCEIsInstalled, value); }
  194. }
  195. public bool AlignerIsInstalled
  196. {
  197. get { return m_AlignerIsInstalled; }
  198. set { SetProperty(ref m_AlignerIsInstalled, value); }
  199. }
  200. public List<SeTMModule> TMModules
  201. {
  202. get { return m_TMModules; }
  203. set { SetProperty(ref m_TMModules, value); }
  204. }
  205. //Module属性
  206. public SeTMModule PickSelectedModule
  207. {
  208. get { return m_PickSelectedModule; }
  209. set { SetProperty(ref m_PickSelectedModule, value); }
  210. }
  211. public SeTMModule PlaceSelectedModule
  212. {
  213. get { return m_PlaceSelectedModule; }
  214. set { SetProperty(ref m_PlaceSelectedModule, value); }
  215. }
  216. public SeTMModule ExtendSelectedModule
  217. {
  218. get { return m_ExtendSelectedModule; }
  219. set { SetProperty(ref m_ExtendSelectedModule, value); }
  220. }
  221. public SeTMModule RetractSelectedModule
  222. {
  223. get { return m_RetractSelectedModule; }
  224. set { SetProperty(ref m_RetractSelectedModule, value); }
  225. }
  226. public SeTMModule GotoSelectedModule
  227. {
  228. get { return m_GotoSelectedModule; }
  229. set { SetProperty(ref m_GotoSelectedModule, value); }
  230. }
  231. public ModuleInfo TMModuleInfo
  232. {
  233. get { return m_TMModuleInfo; }
  234. set
  235. {
  236. SetProperty(ref m_TMModuleInfo, value);
  237. }
  238. }
  239. //Blade属性
  240. public SeTMBlade PickSelectedBlade
  241. {
  242. get { return m_PickSelectedBlade; }
  243. set { SetProperty(ref m_PickSelectedBlade, value); }
  244. }
  245. public SeTMBlade PlaceSelectedBlade
  246. {
  247. get { return m_PlaceSelectedBlade; }
  248. set { SetProperty(ref m_PlaceSelectedBlade, value); }
  249. }
  250. public SeTMBlade ExtendSelectedBlade
  251. {
  252. get { return m_ExtendSelectedBlade; }
  253. set { SetProperty(ref m_ExtendSelectedBlade, value); }
  254. }
  255. public SeTMBlade RetractSelectedBlade
  256. {
  257. get { return m_RetractSelectedBlade; }
  258. set { SetProperty(ref m_RetractSelectedBlade, value); }
  259. }
  260. public SeTMBlade GoToSelectedBlade
  261. {
  262. get { return m_GoToSelectedBlade; }
  263. set { SetProperty(ref m_GoToSelectedBlade, value); }
  264. }
  265. public ObservableCollection<int> PickSoltItemsSource
  266. {
  267. get { return m_PickSoltItemsSource; }
  268. set { SetProperty(ref m_PickSoltItemsSource, value); }
  269. }
  270. public ObservableCollection<int> PlaceSoltItemsSource
  271. {
  272. get { return m_PlaceSoltItemsSource; }
  273. set { SetProperty(ref m_PlaceSoltItemsSource, value); }
  274. }
  275. public ObservableCollection<int> ExtendSoltItemsSource
  276. {
  277. get { return m_ExtendSoltItemsSource; }
  278. set { SetProperty(ref m_ExtendSoltItemsSource, value); }
  279. }
  280. public ObservableCollection<int> RetractSoltItemsSource
  281. {
  282. get { return m_RetractSoltItemsSource; }
  283. set { SetProperty(ref m_RetractSoltItemsSource, value); }
  284. }
  285. public int PickSoltSelectedIndex
  286. {
  287. get { return m_PickSoltSelectedIndex; }
  288. set { SetProperty(ref m_PickSoltSelectedIndex, value); }
  289. }
  290. public int PlaceSoltSelectedIndex
  291. {
  292. get { return m_PlaceSoltSelectedIndex; }
  293. set { SetProperty(ref m_PlaceSoltSelectedIndex, value); }
  294. }
  295. public int ExtendSoltSelectedIndex
  296. {
  297. get { return m_ExtendSoltSelectedIndex; }
  298. set { SetProperty(ref m_ExtendSoltSelectedIndex, value); }
  299. }
  300. public int RetractSoltSelectedIndex
  301. {
  302. get { return m_RetractSoltSelectedIndex; }
  303. set { SetProperty(ref m_RetractSoltSelectedIndex, value); }
  304. }
  305. //Robot动作
  306. public SERobotTAction SERobotTAction
  307. {
  308. get { return m_SERobotTAction; }
  309. set { SetProperty(ref m_SERobotTAction, value); }
  310. }
  311. public SERobotTAction Robot1TAction
  312. {
  313. get { return m_Robot1TAction; }
  314. set { SetProperty(ref m_Robot1TAction, value); }
  315. }
  316. public SERobotXAction Robot1XAction
  317. {
  318. get { return m_Robot1XAction; }
  319. set { SetProperty(ref m_Robot1XAction, value); }
  320. }
  321. public SERobotTAction Robot2TAction
  322. {
  323. get { return m_Robot2TAction; }
  324. set { SetProperty(ref m_Robot2TAction, value); }
  325. }
  326. public SERobotXAction Robot2XAction
  327. {
  328. get { return m_Robot2XAction; }
  329. set { SetProperty(ref m_Robot2XAction, value); }
  330. }
  331. public RobotMoveInfo RobotMoveInfo
  332. {
  333. get { return m_robotMoveInfo; }
  334. set
  335. {
  336. RobotMoveInfoChanged(m_robotMoveInfo, value);
  337. m_robotMoveInfo = value;
  338. }
  339. }
  340. //Cycle
  341. public List<string> OriginalCycle
  342. {
  343. get { return m_OriginalCycle; }
  344. set { SetProperty(ref m_OriginalCycle, value); }
  345. }
  346. public List<string> ToCycle
  347. {
  348. get { return m_ToCycle; }
  349. set { SetProperty(ref m_ToCycle, value); }
  350. }
  351. public bool CycleEnable
  352. {
  353. get { return m_CycleEnable; }
  354. set { SetProperty(ref m_CycleEnable, value); }
  355. }
  356. public bool PMAIsCycle
  357. {
  358. get { return m_PMAIsCycle; }
  359. set { SetProperty(ref m_PMAIsCycle, value); }
  360. }
  361. public bool PMBIsCycle
  362. {
  363. get { return m_PMBIsCycle; }
  364. set { SetProperty(ref m_PMBIsCycle, value); }
  365. }
  366. public bool PMCIsCycle
  367. {
  368. get { return m_PMCIsCycle; }
  369. set { SetProperty(ref m_PMCIsCycle, value); }
  370. }
  371. public int CycleCount
  372. {
  373. get { return m_CycleCount; }
  374. set { SetProperty(ref m_CycleCount, value); }
  375. }
  376. #endregion
  377. #region 命令
  378. //模块下拉框选择命令
  379. private DelegateCommand<object> _ModuleChangeCommand;
  380. public DelegateCommand<object> ModuleChangeCommand =>
  381. _ModuleChangeCommand ?? (_ModuleChangeCommand = new DelegateCommand<object>(OnModuleChange));
  382. //Pick按钮命令
  383. private DelegateCommand _PickCommand;
  384. public DelegateCommand PickCommand =>
  385. _PickCommand ?? (_PickCommand = new DelegateCommand(OnPick));
  386. //Place按钮命令
  387. private DelegateCommand _PlaceCommand;
  388. public DelegateCommand PlaceCommand =>
  389. _PlaceCommand ?? (_PlaceCommand = new DelegateCommand(OnPlace));
  390. //Extend按钮命令
  391. private DelegateCommand _ExtendCommand;
  392. public DelegateCommand ExtendCommand =>
  393. _ExtendCommand ?? (_ExtendCommand = new DelegateCommand(OnExtend));
  394. //Retract按钮命令
  395. private DelegateCommand _RetractCommand;
  396. public DelegateCommand RetractCommand =>
  397. _RetractCommand ?? (_RetractCommand = new DelegateCommand(OnRetract));
  398. //RobotHome按钮命令
  399. public DelegateCommand _RobotHomeCommand;
  400. public DelegateCommand RobotHomeCommand =>
  401. _RobotHomeCommand ?? (_RobotHomeCommand = new DelegateCommand(OnRobotHome));
  402. private DelegateCommand _HomeCommand;
  403. public DelegateCommand HomeCommand =>
  404. _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome));
  405. private DelegateCommand _GotoCommand;
  406. public DelegateCommand GotoCommand =>
  407. _GotoCommand ?? (_GotoCommand = new DelegateCommand(OnGoto));
  408. #endregion
  409. //Cycle
  410. private DelegateCommand _StartCycleCommand;
  411. public DelegateCommand StartCycleCommand =>
  412. _StartCycleCommand ?? (_StartCycleCommand = new DelegateCommand(OnStartCycle));
  413. private DelegateCommand _StopCycleCommand;
  414. public DelegateCommand StopCycleCommand =>
  415. _StopCycleCommand ?? (_StopCycleCommand = new DelegateCommand(OnStopCycle));
  416. #region 构造函数
  417. public SeTMViewModel()
  418. {
  419. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  420. PMAIsInstalled = allModules.Contains("PMA");
  421. PMBIsInstalled = allModules.Contains("PMB");
  422. PMCIsInstalled = allModules.Contains("PMC");
  423. VCEIsInstalled = allModules.Contains("VCE1");
  424. AlignerIsInstalled = allModules.Contains("Aligner1");
  425. if (PMAIsInstalled == true)
  426. {
  427. TMModules.Add(SeTMModule.PMA);
  428. }
  429. if (PMBIsInstalled == true)
  430. {
  431. TMModules.Add(SeTMModule.PMB);
  432. }
  433. if (PMCIsInstalled == true)
  434. {
  435. TMModules.Add(SeTMModule.PMC);
  436. m_Alignerangle = 270;
  437. }
  438. else
  439. {
  440. m_Alignerangle = 180;
  441. }
  442. if (VCEIsInstalled == true)
  443. {
  444. TMModules.Add(SeTMModule.LP1);
  445. }
  446. if (AlignerIsInstalled == true)
  447. {
  448. TMModules.Add(SeTMModule.Aligner1);
  449. }
  450. PickSoltItemsSource.Add(1);
  451. PlaceSoltItemsSource.Add(1);
  452. ExtendSoltItemsSource.Add(1);
  453. RetractSoltItemsSource.Add(1);
  454. addDataKeys();
  455. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  456. VCEDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.VCESlitDoorClosed");
  457. PMADoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMASlitDoorClosed");
  458. PMBDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMBSlitDoorClosed");
  459. PMCDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMCSlitDoorClosed");
  460. VCEOutDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "VCE1.VCEOutDoorClosed");
  461. DispatcherTimer timer = new DispatcherTimer();
  462. timer.Interval = TimeSpan.FromSeconds(0.5);
  463. timer.Tick += Timer_Tick;
  464. timer.Start();
  465. }
  466. #endregion
  467. #region 命令方法
  468. private void addDataKeys()
  469. {
  470. m_RtDataKeys.Add($"TM.VCESlitDoorClosed");
  471. m_RtDataKeys.Add($"TM.PMASlitDoorClosed");
  472. m_RtDataKeys.Add($"TM.PMBSlitDoorClosed");
  473. m_RtDataKeys.Add($"TM.PMCSlitDoorClosed");
  474. m_RtDataKeys.Add($"VCE1.VCEOutDoorClosed");
  475. m_RtDataKeys.Add($"PMA.ChamberPressure");
  476. m_RtDataKeys.Add($"PMB.ChamberPressure");
  477. m_RtDataKeys.Add($"PMC.ChamberPressure");
  478. m_RtDataKeys.Add($"TM.VCEPressure.Value");
  479. m_RtDataKeys.Add($"VCE1.CassetteArrive");
  480. m_RtDataKeys.Add($"TMCycle.CycleIndex");
  481. }
  482. //模块选择根据obj选择下拉框内容
  483. private void OnModuleChange(object obj)
  484. {
  485. var value = obj.ToString();
  486. switch (value)
  487. {
  488. case "Pick":
  489. PickSoltItemsSource.Clear();
  490. if ((int)PickSelectedModule == 3)
  491. {
  492. for (int i = 1; i <= 25; i++)
  493. {
  494. PickSoltItemsSource.Add(i);
  495. }
  496. }
  497. else
  498. {
  499. PickSoltItemsSource.Add(1);
  500. }
  501. PickSoltSelectedIndex = 0;
  502. break;
  503. case "Place":
  504. PlaceSoltItemsSource.Clear();
  505. if ((int)PlaceSelectedModule == 3)
  506. {
  507. for (int i = 1; i <= 25; i++)
  508. {
  509. PlaceSoltItemsSource.Add(i);
  510. }
  511. }
  512. else
  513. {
  514. PlaceSoltItemsSource.Add(1);
  515. }
  516. PlaceSoltSelectedIndex = 0;
  517. break;
  518. case "Extend":
  519. ExtendSoltItemsSource.Clear();
  520. if ((int)ExtendSelectedModule == 3)
  521. {
  522. for (int i = 1; i <= 25; i++)
  523. {
  524. ExtendSoltItemsSource.Add(i);
  525. }
  526. }
  527. else
  528. {
  529. ExtendSoltItemsSource.Add(1);
  530. }
  531. ExtendSoltSelectedIndex = 0;
  532. break;
  533. case "Retract":
  534. RetractSoltItemsSource.Clear();
  535. if ((int)RetractSelectedModule == 3)
  536. {
  537. for (int i = 1; i <= 25; i++)
  538. {
  539. RetractSoltItemsSource.Add(i);
  540. }
  541. }
  542. else
  543. {
  544. RetractSoltItemsSource.Add(1);
  545. }
  546. RetractSoltSelectedIndex = 0;
  547. break;
  548. }
  549. }
  550. private void OnPick()
  551. {
  552. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  553. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  554. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  555. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, ModuleName.TMRobot, 0, selectedHand);
  556. moveItems.Enqueue(moveItem);
  557. if ((int)PickSelectedModule < TMModules.Count - 2)
  558. {
  559. InvokeClient.Instance.Service.DoOperation($"TM.PMPick", moveItems);
  560. }
  561. else
  562. {
  563. InvokeClient.Instance.Service.DoOperation($"TM.Pick", moveItems);
  564. }
  565. }
  566. private void OnPlace()
  567. {
  568. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  569. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  570. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  571. MoveItem moveItem = new MoveItem(ModuleName.TMRobot, 0, moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex] - 1, selectedHand);
  572. moveItems.Enqueue(moveItem);
  573. if ((int)PlaceSelectedModule < TMModules.Count - 2)
  574. {
  575. InvokeClient.Instance.Service.DoOperation($"TM.PMPlace", moveItems);
  576. }
  577. //VCE、Aligner1
  578. else
  579. {
  580. InvokeClient.Instance.Service.DoOperation($"TM.Place", moveItems);
  581. }
  582. }
  583. private void OnExtend()
  584. {
  585. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), ExtendSelectedModule.ToString(), true);
  586. var selectedHand = (Hand)Enum.Parse(typeof(Hand), ExtendSelectedBlade.ToString(), true);
  587. InvokeClient.Instance.Service.DoOperation($"TM.Extend", moduleName, ExtendSoltItemsSource[ExtendSoltSelectedIndex] - 1, selectedHand);
  588. }
  589. private void OnRetract()
  590. {
  591. //Queue<MoveItem> moveItems = new Queue<MoveItem>();
  592. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), RetractSelectedModule.ToString(), true);
  593. var selectedHand = (Hand)Enum.Parse(typeof(Hand), RetractSelectedBlade.ToString(), true);
  594. //MoveItem moveItem = new MoveItem(moduleName, RetractSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  595. //moveItems.Enqueue(moveItem);
  596. InvokeClient.Instance.Service.DoOperation($"TM.Retract", moduleName, RetractSoltItemsSource[PlaceSoltSelectedIndex] - 1, selectedHand);
  597. }
  598. //令选择的模块下发Home指令
  599. private void OnRobotHome()
  600. {
  601. InvokeClient.Instance.Service.DoOperation($"TM.Home", "TMRobot");
  602. }
  603. private void OnHome()
  604. {
  605. InvokeClient.Instance.Service.DoOperation($"TM.Home");
  606. }
  607. private void OnGoto()
  608. {
  609. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), GotoSelectedModule.ToString(), true);
  610. var selectedHand = (Hand)Enum.Parse(typeof(Hand), GoToSelectedBlade.ToString(), true);
  611. InvokeClient.Instance.Service.DoOperation($"TM.Goto", moduleName, 0, selectedHand);
  612. }
  613. //Cycle
  614. private void OnStartCycle()
  615. {
  616. if (CycleEnable == false)
  617. {
  618. return;
  619. }
  620. List<string> stations = new List<string>();
  621. stations.Add("VCE1");
  622. stations.Add("Aligner1");
  623. if (PMAIsCycle == true)
  624. {
  625. stations.Add("PMA");
  626. }
  627. if (PMBIsCycle == true)
  628. {
  629. stations.Add("PMB");
  630. }
  631. if (PMCIsCycle == true)
  632. {
  633. stations.Add("PMC");
  634. }
  635. stations.Add("VCE1");
  636. InvokeClient.Instance.Service.DoOperation("System.SETMCycle", stations.ToArray(), CycleCount);
  637. }
  638. private void OnStopCycle()
  639. {
  640. InvokeClient.Instance.Service.DoOperation("System.SEAbort");
  641. }
  642. #endregion
  643. #region 私有方法
  644. private void Timer_Tick(object sender, EventArgs e)
  645. {
  646. TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];
  647. if (VCEIsInstalled)
  648. {
  649. }
  650. if (PMAIsInstalled == true)
  651. {
  652. ModuleInfo PMAModuleInfo = ModuleManager.ModuleInfos["PMA"];
  653. PMAWafer = PMAModuleInfo.WaferManager.Wafers[0];
  654. }
  655. if (PMBIsInstalled == true)
  656. {
  657. ModuleInfo PMBModuleInfo = ModuleManager.ModuleInfos["PMB"];
  658. PMBWafer = PMBModuleInfo.WaferManager.Wafers[0];
  659. }
  660. if (PMCIsInstalled == true)
  661. {
  662. ModuleInfo PMCModuleInfo = ModuleManager.ModuleInfos["PMC"];
  663. PMCWafer = PMCModuleInfo.WaferManager.Wafers[0];
  664. }
  665. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  666. VCEDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.VCESlitDoorClosed");
  667. PMADoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMASlitDoorClosed");
  668. PMBDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMBSlitDoorClosed");
  669. PMCDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "TM.PMCSlitDoorClosed");
  670. VCEOutDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "VCE1.VCEOutDoorClosed");
  671. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  672. PAWafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  673. RobotUpperWafer = TMModuleInfo.WaferManager.Wafers[0];
  674. RobotLowerWafer = TMModuleInfo.WaferManager.Wafers[1];
  675. }
  676. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  677. {
  678. string RobotTarget;
  679. if (oldValue == null || newValue == null)
  680. {
  681. return;
  682. }
  683. #region Rotating
  684. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  685. {
  686. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  687. if (TMRobotMoveActionBladeTarget != null)
  688. {
  689. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  690. }
  691. else
  692. {
  693. return;
  694. }
  695. var values = RobotTarget.Split('.');
  696. var arm = values[0];
  697. var module = values[1];
  698. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  699. if (SERobotTAction != Robot1TAction || SERobotTAction != Robot2TAction)
  700. {
  701. Robot1TAction = SERobotTAction;
  702. Robot2TAction = SERobotTAction;
  703. }
  704. }
  705. #endregion
  706. #region Aligner1、VCE1 Pick、Place
  707. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  708. {
  709. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  710. if (TMRobotMoveActionBladeTarget != null)
  711. {
  712. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  713. }
  714. else
  715. {
  716. return;
  717. }
  718. var values = RobotTarget.Split('.');
  719. var arm = values[0];
  720. var module = values[1];
  721. if (module == "Aligner1")
  722. {
  723. module = PMCIsInstalled ? "Aligner1" : "VPARight";
  724. }
  725. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  726. if (SERobotTAction != Robot1TAction || SERobotTAction != Robot2TAction)
  727. {
  728. Robot1TAction = SERobotTAction;
  729. Robot2TAction = SERobotTAction;
  730. }
  731. if (arm == "ArmA")
  732. {
  733. await Task.Delay(600);
  734. if (module == "VCE1")
  735. {
  736. Robot1XAction = SERobotXAction.ToVCE;
  737. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  738. {
  739. await Task.Delay(100);
  740. }
  741. Robot1XAction = SERobotXAction.FromVCE;
  742. }
  743. else if (module == "Aligner1" || module == "VPARight")
  744. {
  745. Robot1XAction = SERobotXAction.ToAligner;
  746. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  747. {
  748. await Task.Delay(100);
  749. }
  750. Robot1XAction = SERobotXAction.FromAligner;
  751. }
  752. else
  753. {
  754. Robot1XAction = SERobotXAction.Extend;
  755. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  756. {
  757. await Task.Delay(100);
  758. }
  759. Robot1XAction = SERobotXAction.Retract;
  760. }
  761. }
  762. else if (arm == "ArmB")
  763. {
  764. await Task.Delay(600);
  765. if (module == "VCE1")
  766. {
  767. Robot2XAction = SERobotXAction.ToVCE2;
  768. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))
  769. {
  770. await Task.Delay(100);
  771. }
  772. Robot2XAction = SERobotXAction.FromVCE2;
  773. }
  774. else if (module == "Aligner1" || module == "VPARight")
  775. {
  776. Robot2XAction = SERobotXAction.ToAligner2;
  777. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))
  778. {
  779. await Task.Delay(100);
  780. }
  781. Robot2XAction = SERobotXAction.FromAligner2;
  782. }
  783. else
  784. {
  785. Robot2XAction = SERobotXAction.Extend2;
  786. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))
  787. {
  788. await Task.Delay(100);
  789. }
  790. Robot2XAction = SERobotXAction.Retract2;
  791. }
  792. }
  793. }
  794. #endregion
  795. #region PM pick、PM place
  796. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  797. {
  798. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  799. if (TMRobotMoveActionBladeTarget != null)
  800. {
  801. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  802. }
  803. else
  804. {
  805. return;
  806. }
  807. var values = RobotTarget.Split('.');
  808. var arm = values[0];
  809. var module = values[1];
  810. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  811. if (SERobotTAction != Robot1TAction || SERobotTAction != Robot2TAction)
  812. {
  813. Robot1TAction = SERobotTAction;
  814. Robot2TAction = SERobotTAction;
  815. }
  816. if (arm == "ArmA")
  817. {
  818. await Task.Delay(600);
  819. Robot1XAction = SERobotXAction.Extend;
  820. }
  821. else if (arm == "ArmB")
  822. {
  823. await Task.Delay(600);
  824. Robot2XAction = SERobotXAction.Extend2;
  825. }
  826. }
  827. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  828. {
  829. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  830. if (TMRobotMoveActionBladeTarget != null)
  831. {
  832. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  833. }
  834. else
  835. {
  836. return;
  837. }
  838. var values = RobotTarget.Split('.');
  839. var arm = values[0];
  840. if (arm == "ArmA")
  841. {
  842. await Task.Delay(100);
  843. Robot1XAction = SERobotXAction.Retract;
  844. }
  845. else if (arm == "ArmB")
  846. {
  847. await Task.Delay(100);
  848. Robot2XAction = SERobotXAction.Retract2;
  849. }
  850. }
  851. #endregion
  852. #region Home
  853. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  854. {
  855. if (Robot1XAction == SERobotXAction.Extend)
  856. {
  857. Robot1XAction = SERobotXAction.Retract;
  858. }
  859. if (Robot2XAction == SERobotXAction.Extend2)
  860. {
  861. Robot2XAction = SERobotXAction.Retract2;
  862. }
  863. await Task.Delay(2000);
  864. if (Robot1TAction != SERobotTAction.T_Origin)
  865. {
  866. Robot1TAction = SERobotTAction.T_Origin;
  867. }
  868. if (Robot2TAction != SERobotTAction.T_Origin)
  869. {
  870. Robot2TAction = SERobotTAction.T_Origin;
  871. }
  872. }
  873. #endregion
  874. }
  875. #endregion
  876. }
  877. }