SeTMViewModel.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  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. m_RtDataKeys.Add($"SETM.VCEPressure.Value");
  478. m_RtDataKeys.Add($"VCE1.CassetteArrive");
  479. m_RtDataKeys.Add($"TMCycle.CycleIndex");
  480. }
  481. //模块选择根据obj选择下拉框内容
  482. private void OnModuleChange(object obj)
  483. {
  484. var value = obj.ToString();
  485. switch (value)
  486. {
  487. case "Pick":
  488. PickSoltItemsSource.Clear();
  489. if ((int)PickSelectedModule == 3)
  490. {
  491. for (int i = 1; i <= 25; i++)
  492. {
  493. PickSoltItemsSource.Add(i);
  494. }
  495. }
  496. else
  497. {
  498. PickSoltItemsSource.Add(1);
  499. }
  500. PickSoltSelectedIndex = 0;
  501. break;
  502. case "Place":
  503. PlaceSoltItemsSource.Clear();
  504. if ((int)PlaceSelectedModule == 3)
  505. {
  506. for (int i = 1; i <= 25; i++)
  507. {
  508. PlaceSoltItemsSource.Add(i);
  509. }
  510. }
  511. else
  512. {
  513. PlaceSoltItemsSource.Add(1);
  514. }
  515. PlaceSoltSelectedIndex = 0;
  516. break;
  517. case "Extend":
  518. ExtendSoltItemsSource.Clear();
  519. if ((int)ExtendSelectedModule == 3)
  520. {
  521. for (int i = 1; i <= 25; i++)
  522. {
  523. ExtendSoltItemsSource.Add(i);
  524. }
  525. }
  526. else
  527. {
  528. ExtendSoltItemsSource.Add(1);
  529. }
  530. ExtendSoltSelectedIndex = 0;
  531. break;
  532. case "Retract":
  533. RetractSoltItemsSource.Clear();
  534. if ((int)RetractSelectedModule == 3)
  535. {
  536. for (int i = 1; i <= 25; i++)
  537. {
  538. RetractSoltItemsSource.Add(i);
  539. }
  540. }
  541. else
  542. {
  543. RetractSoltItemsSource.Add(1);
  544. }
  545. RetractSoltSelectedIndex = 0;
  546. break;
  547. }
  548. }
  549. private void OnPick()
  550. {
  551. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  552. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);
  553. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);
  554. MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex] - 1, ModuleName.TMRobot, 0, selectedHand);
  555. moveItems.Enqueue(moveItem);
  556. if ((int)PickSelectedModule < TMModules.Count - 2)
  557. {
  558. InvokeClient.Instance.Service.DoOperation($"SETM.PMPick", moveItems);
  559. }
  560. else
  561. {
  562. InvokeClient.Instance.Service.DoOperation($"SETM.Pick", moveItems);
  563. }
  564. }
  565. private void OnPlace()
  566. {
  567. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  568. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);
  569. var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);
  570. MoveItem moveItem = new MoveItem(ModuleName.TMRobot, 0, moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex] - 1, selectedHand);
  571. moveItems.Enqueue(moveItem);
  572. if ((int)PlaceSelectedModule < TMModules.Count - 2)
  573. {
  574. InvokeClient.Instance.Service.DoOperation($"SETM.PMPlace", moveItems);
  575. }
  576. //VCE、VPA
  577. else
  578. {
  579. InvokeClient.Instance.Service.DoOperation($"SETM.Place", moveItems);
  580. }
  581. }
  582. private void OnExtend()
  583. {
  584. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), ExtendSelectedModule.ToString(), true);
  585. var selectedHand = (Hand)Enum.Parse(typeof(Hand), ExtendSelectedBlade.ToString(), true);
  586. InvokeClient.Instance.Service.DoOperation($"SETM.Extend", moduleName, ExtendSoltItemsSource[ExtendSoltSelectedIndex] - 1, selectedHand);
  587. }
  588. private void OnRetract()
  589. {
  590. //Queue<MoveItem> moveItems = new Queue<MoveItem>();
  591. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), RetractSelectedModule.ToString(), true);
  592. var selectedHand = (Hand)Enum.Parse(typeof(Hand), RetractSelectedBlade.ToString(), true);
  593. //MoveItem moveItem = new MoveItem(moduleName, RetractSoltItemsSource[PickSoltSelectedIndex] - 1, 0, 0, selectedHand);
  594. //moveItems.Enqueue(moveItem);
  595. InvokeClient.Instance.Service.DoOperation($"SETM.Retract", moduleName, RetractSoltItemsSource[PlaceSoltSelectedIndex] - 1, selectedHand);
  596. }
  597. //令选择的模块下发Home指令
  598. private void OnRobotHome()
  599. {
  600. InvokeClient.Instance.Service.DoOperation($"SETM.Home", "TMRobot");
  601. }
  602. private void OnHome()
  603. {
  604. InvokeClient.Instance.Service.DoOperation($"SETM.Home");
  605. }
  606. private void OnGoto()
  607. {
  608. var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), GotoSelectedModule.ToString(), true);
  609. var selectedHand = (Hand)Enum.Parse(typeof(Hand), GoToSelectedBlade.ToString(), true);
  610. InvokeClient.Instance.Service.DoOperation($"SETM.Goto", moduleName, 0, selectedHand);
  611. }
  612. //Cycle
  613. private void OnStartCycle()
  614. {
  615. if (CycleEnable == false)
  616. {
  617. return;
  618. }
  619. List<string> stations = new List<string>();
  620. stations.Add("VCE1");
  621. stations.Add("VPA");
  622. if (PMAIsCycle == true)
  623. {
  624. stations.Add("PMA");
  625. }
  626. if (PMBIsCycle == true)
  627. {
  628. stations.Add("PMB");
  629. }
  630. if (PMCIsCycle == true)
  631. {
  632. stations.Add("PMC");
  633. }
  634. stations.Add("VCE1");
  635. InvokeClient.Instance.Service.DoOperation("System.SETMCycle", stations.ToArray(), CycleCount);
  636. }
  637. private void OnStopCycle()
  638. {
  639. InvokeClient.Instance.Service.DoOperation("System.SEAbort");
  640. }
  641. #endregion
  642. #region 私有方法
  643. private void Timer_Tick(object sender, EventArgs e)
  644. {
  645. TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];
  646. if (VCEIsInstalled)
  647. {
  648. }
  649. if (PMAIsInstalled == true)
  650. {
  651. ModuleInfo PMAModuleInfo = ModuleManager.ModuleInfos["PMA"];
  652. PMAWafer = PMAModuleInfo.WaferManager.Wafers[0];
  653. }
  654. if (PMBIsInstalled == true)
  655. {
  656. ModuleInfo PMBModuleInfo = ModuleManager.ModuleInfos["PMB"];
  657. PMBWafer = PMBModuleInfo.WaferManager.Wafers[0];
  658. }
  659. if (PMCIsInstalled == true)
  660. {
  661. ModuleInfo PMCModuleInfo = ModuleManager.ModuleInfos["PMC"];
  662. PMCWafer = PMCModuleInfo.WaferManager.Wafers[0];
  663. }
  664. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  665. VCEDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESlitDoorClosed");
  666. PMADoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMASlitDoorClosed");
  667. PMBDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMBSlitDoorClosed");
  668. PMCDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMCSlitDoorClosed");
  669. VCEOutDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "VCE1.VCEOutDoorClosed");
  670. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("SETM.RobotMoveAction");
  671. RobotUpperWafer = TMModuleInfo.WaferManager.Wafers[0];
  672. RobotLowerWafer = TMModuleInfo.WaferManager.Wafers[1];
  673. PAWafer = ModuleManager.ModuleInfos["VPA"].WaferManager.Wafers[0];
  674. }
  675. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  676. {
  677. string RobotTarget;
  678. if (oldValue == null || newValue == null)
  679. {
  680. return;
  681. }
  682. #region Rotating
  683. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  684. {
  685. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  686. if (TMRobotMoveActionBladeTarget != null)
  687. {
  688. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  689. }
  690. else
  691. {
  692. return;
  693. }
  694. var values = RobotTarget.Split('.');
  695. var arm = values[0];
  696. var module = values[1];
  697. if (arm == "ArmA")
  698. {
  699. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  700. if (SERobotTAction != Robot1TAction)
  701. {
  702. Robot1TAction = SERobotTAction;
  703. }
  704. }
  705. else if (arm == "ArmB")
  706. {
  707. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  708. if (SERobotTAction != Robot2TAction)
  709. {
  710. Robot2TAction = SERobotTAction;
  711. }
  712. }
  713. }
  714. #endregion
  715. #region VPA、VCE1 Pick、Place
  716. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  717. {
  718. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  719. if (TMRobotMoveActionBladeTarget != null)
  720. {
  721. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  722. }
  723. else
  724. {
  725. return;
  726. }
  727. var values = RobotTarget.Split('.');
  728. var arm = values[0];
  729. var module = values[1];
  730. //if (module == "VPA")
  731. //{
  732. // module = PMCIsInstalled ? "VPA" : "VPARight";
  733. //}
  734. if (arm == "ArmA")
  735. {
  736. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  737. if (SERobotTAction != Robot1TAction)
  738. {
  739. Robot1TAction = SERobotTAction;
  740. }
  741. await Task.Delay(600);
  742. if (module == "VCE1")
  743. {
  744. Robot1XAction = SERobotXAction.ToVCE;
  745. }
  746. else
  747. {
  748. Robot1XAction = SERobotXAction.Extend;
  749. }
  750. 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))
  751. {
  752. await Task.Delay(100);
  753. }
  754. Robot1XAction = SERobotXAction.Retract;
  755. }
  756. else if (arm == "ArmB")
  757. {
  758. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  759. if (SERobotTAction != Robot2TAction)
  760. {
  761. Robot2TAction = SERobotTAction;
  762. }
  763. else
  764. {
  765. //await Task.Delay(100);
  766. }
  767. await Task.Delay(600);
  768. if (module == "VCE1")
  769. {
  770. Robot2XAction = SERobotXAction.ToVCE2;
  771. }
  772. else
  773. {
  774. Robot2XAction = SERobotXAction.Extend2;
  775. }
  776. 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))
  777. {
  778. await Task.Delay(100);
  779. }
  780. Robot2XAction = SERobotXAction.Retract2;
  781. }
  782. }
  783. #endregion
  784. #region PM pick、PM place
  785. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  786. {
  787. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  788. if (TMRobotMoveActionBladeTarget != null)
  789. {
  790. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  791. }
  792. else
  793. {
  794. return;
  795. }
  796. var values = RobotTarget.Split('.');
  797. var arm = values[0];
  798. var module = values[1];
  799. if (arm == "ArmA")
  800. {
  801. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  802. if (SERobotTAction != Robot1TAction)
  803. {
  804. Robot1TAction = SERobotTAction;
  805. }
  806. else
  807. {
  808. // await Task.Delay(100);
  809. }
  810. await Task.Delay(600);
  811. Robot1XAction = SERobotXAction.Extend;
  812. }
  813. else if (arm == "ArmB")
  814. {
  815. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  816. if (SERobotTAction != Robot2TAction)
  817. {
  818. Robot2TAction = SERobotTAction;
  819. }
  820. else
  821. {
  822. // await Task.Delay(100);
  823. }
  824. await Task.Delay(600);
  825. Robot2XAction = SERobotXAction.Extend2;
  826. }
  827. }
  828. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  829. {
  830. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  831. if (TMRobotMoveActionBladeTarget != null)
  832. {
  833. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  834. }
  835. else
  836. {
  837. return;
  838. }
  839. var values = RobotTarget.Split('.');
  840. var arm = values[0];
  841. if (arm == "ArmA")
  842. {
  843. Robot1XAction = SERobotXAction.Retract;
  844. }
  845. else if (arm == "ArmB")
  846. {
  847. Robot2XAction = SERobotXAction.Retract2;
  848. }
  849. }
  850. #endregion
  851. #region Home
  852. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  853. {
  854. if (Robot1XAction == SERobotXAction.Extend)
  855. {
  856. Robot1XAction = SERobotXAction.Retract;
  857. }
  858. if (Robot2XAction == SERobotXAction.Extend2)
  859. {
  860. Robot2XAction = SERobotXAction.Retract2;
  861. }
  862. await Task.Delay(2000);
  863. if (Robot1TAction != SERobotTAction.T_Origin)
  864. {
  865. Robot1TAction = SERobotTAction.T_Origin;
  866. }
  867. if (Robot2TAction != SERobotTAction.T_Origin)
  868. {
  869. Robot2TAction = SERobotTAction.T_Origin;
  870. }
  871. }
  872. #endregion
  873. }
  874. #endregion
  875. }
  876. }