VenusDETMViewModel.cs 34 KB

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