SeTMViewModel.cs 34 KB

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