TMViewModel.cs 38 KB

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