TMViewModel.cs 42 KB

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