OperationOverViewModel.cs 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. using MECF.Framework.Common.CommonData;
  2. using MECF.Framework.Common.DataCenter;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.OperationCenter;
  5. using OpenSEMI.ClientBase;
  6. using Prism.Commands;
  7. using Prism.Mvvm;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Threading;
  15. using Venus_Core;
  16. using Venus_MainPages.Unity;
  17. using Venus_MainPages.Views;
  18. using Venus_Themes.CustomControls;
  19. using Venus_Themes.Unity;
  20. using static Venus_Themes.UserControls.EFEM;
  21. namespace Venus_MainPages.ViewModels
  22. {
  23. public class OperationOverViewModel : BindableBase
  24. {
  25. #region 私有字段
  26. private bool m_TabIsChecked=true;
  27. private ModuleInfo m_LP1ModuleInfo;
  28. private ModuleInfo m_LP2ModuleInfo;
  29. private ModuleInfo m_LLAModuleInfo;
  30. private ModuleInfo m_LLBModuleInfo;
  31. private ModuleInfo m_LP3ModuleInfo;
  32. private ModuleInfo m_EFEMModuleInfo;
  33. private ModuleInfo m_TMModuleInfo;
  34. private WaferRobotTAction m_Robot1TAction;
  35. private WaferRobotXAction m_Robot1XAction;
  36. private WaferRobotTAction m_Robot2TAction;
  37. private WaferRobotXAction m_Robot2XAction;
  38. private WaferRobotTAction m_Robot3TAction;
  39. private WaferRobotXAction m_Robot3XAction;
  40. private WaferRobotTAction m_Robot4TAction;
  41. private WaferRobotXAction m_Robot4XAction;
  42. private RobotMoveInfo m_robotMoveInfo;
  43. int arm1oldWaferStatus = 100;
  44. int arm2oldWaferStatus = 100;
  45. private WaferInfo m_PMAWafer;
  46. private WaferInfo m_PMBWafer;
  47. private WaferInfo m_PMCWafer;
  48. private WaferInfo m_PMDWafer;
  49. private WaferInfo m_LLAWafer;
  50. private WaferInfo m_LLBWafer;
  51. private WaferInfo m_TMBladeAWafer;
  52. private WaferInfo m_TMBladeBWafer;
  53. private List<string> m_RtDataKeys = new List<string>();
  54. private Dictionary<string, object> m_RtDataValues;
  55. private bool m_PMAIsInstalled;
  56. private bool m_PMBIsInstalled;
  57. private bool m_PMCIsInstalled;
  58. private bool m_PMDIsInstalled;
  59. private bool m_LLAIsInstalled;
  60. private bool m_LLBIsInstalled;
  61. private bool m_TMIsInstalled;
  62. private bool m_EFEMIsInstalled;
  63. private WaferInfo m_EFEMBladeAWafer;
  64. private WaferInfo m_EFEMBladeBWafer;
  65. private WaferInfo m_Aligner1Wafer;
  66. private int m_LP1WaferCount;
  67. private int m_LP2WaferCount;
  68. private int m_LP3WaferCount;
  69. private WaferAssociationInfo _lp1WaferAssociation;
  70. private WaferAssociationInfo _lp2WaferAssociation;
  71. private WaferAssociationInfo _lp3WaferAssociation;
  72. private int m_CycledWafer;
  73. private int m_CycleCountDisplay;
  74. private RobotPosition m_CurrentRobotPosition;
  75. private WaferInfo m_BladeAWafer;
  76. private WaferInfo m_BladeBWafer;
  77. private RecipeResult m_PMARecipeResult;
  78. private RecipeResult m_PMBRecipeResult;
  79. private RecipeResult m_PMCRecipeResult;
  80. private RecipeResult m_PMDRecipeResult;
  81. private string m_ATMModeIsOn;
  82. #endregion
  83. #region 属性
  84. public bool TabIsChecked
  85. {
  86. get { return m_TabIsChecked; }
  87. set { SetProperty(ref m_TabIsChecked, value); }
  88. }
  89. public ModuleInfo LP1ModuleInfo
  90. {
  91. get { return m_LP1ModuleInfo; }
  92. set { SetProperty(ref m_LP1ModuleInfo, value); }
  93. }
  94. public ModuleInfo LLAModuleInfo
  95. {
  96. get { return m_LLAModuleInfo; }
  97. set { SetProperty(ref m_LLAModuleInfo, value); }
  98. }
  99. public ModuleInfo LLBModuleInfo
  100. {
  101. get { return m_LLBModuleInfo; }
  102. set { SetProperty(ref m_LLBModuleInfo, value); }
  103. }
  104. public ModuleInfo EFEMModuleInfo
  105. {
  106. get { return m_EFEMModuleInfo; }
  107. set { SetProperty(ref m_EFEMModuleInfo, value); }
  108. }
  109. public ModuleInfo TMModuleInfo
  110. {
  111. get { return m_TMModuleInfo; }
  112. set { SetProperty(ref m_TMModuleInfo, value); }
  113. }
  114. public ModuleInfo LP2ModuleInfo
  115. {
  116. get { return m_LP2ModuleInfo; }
  117. set { SetProperty(ref m_LP2ModuleInfo, value); }
  118. }
  119. public ModuleInfo LP3ModuleInfo
  120. {
  121. get { return m_LP3ModuleInfo; }
  122. set { SetProperty(ref m_LP3ModuleInfo, value); }
  123. }
  124. public WaferRobotTAction Robot1TAction
  125. {
  126. get { return m_Robot1TAction; }
  127. set { SetProperty(ref m_Robot1TAction, value); }
  128. }
  129. public WaferRobotXAction Robot1XAction
  130. {
  131. get { return m_Robot1XAction; }
  132. set { SetProperty(ref m_Robot1XAction, value); }
  133. }
  134. public WaferRobotTAction Robot2TAction
  135. {
  136. get { return m_Robot2TAction; }
  137. set { SetProperty(ref m_Robot2TAction, value); }
  138. }
  139. public WaferRobotXAction Robot2XAction
  140. {
  141. get { return m_Robot2XAction; }
  142. set { SetProperty(ref m_Robot2XAction, value); }
  143. }
  144. public WaferRobotTAction Robot3TAction
  145. {
  146. get{ return m_Robot3TAction;}
  147. set{SetProperty(ref m_Robot3TAction ,value);}
  148. }
  149. public WaferRobotXAction Robot3XAction
  150. {
  151. get{ return m_Robot3XAction;}
  152. set{SetProperty(ref m_Robot3XAction ,value);}
  153. }
  154. public WaferRobotTAction Robot4TAction
  155. {
  156. get{ return m_Robot4TAction;}
  157. set{SetProperty(ref m_Robot4TAction ,value);}
  158. }
  159. public WaferRobotXAction Robot4XAction
  160. {
  161. get{ return m_Robot4XAction;}
  162. set{SetProperty(ref m_Robot4XAction, value);}
  163. }
  164. public RobotMoveInfo RobotMoveInfo
  165. {
  166. get { return m_robotMoveInfo; }
  167. set
  168. {
  169. RobotMoveInfoChanged(m_robotMoveInfo, value);
  170. m_robotMoveInfo = value;
  171. }
  172. }
  173. public WaferInfo LLAWafer
  174. {
  175. get { return m_LLAWafer; }
  176. set { SetProperty(ref m_LLAWafer, value); }
  177. }
  178. public WaferInfo LLBWafer
  179. {
  180. get { return m_LLBWafer; }
  181. set { SetProperty(ref m_LLBWafer, value); }
  182. }
  183. public WaferInfo PMAWafer
  184. {
  185. get { return m_PMAWafer; }
  186. set { SetProperty(ref m_PMAWafer, value); }
  187. }
  188. public WaferInfo PMBWafer
  189. {
  190. get { return m_PMBWafer; }
  191. set { SetProperty(ref m_PMBWafer, value); }
  192. }
  193. public WaferInfo PMCWafer
  194. {
  195. get { return m_PMCWafer; }
  196. set { SetProperty(ref m_PMCWafer, value); }
  197. }
  198. public WaferInfo PMDWafer
  199. {
  200. get { return m_PMDWafer; }
  201. set { SetProperty(ref m_PMDWafer, value); }
  202. }
  203. public WaferInfo TMBladeAWafer
  204. {
  205. get { return m_TMBladeAWafer; }
  206. set { SetProperty(ref m_TMBladeAWafer, value); }
  207. }
  208. public WaferInfo TMBladeBWafer
  209. {
  210. get { return m_TMBladeBWafer; }
  211. set { SetProperty(ref m_TMBladeBWafer, value); }
  212. }
  213. public Dictionary<string, object> RtDataValues
  214. {
  215. get { return m_RtDataValues; }
  216. set { SetProperty(ref m_RtDataValues, value); }
  217. }
  218. public bool PMAIsInstalled
  219. {
  220. get { return m_PMAIsInstalled; }
  221. set { SetProperty(ref m_PMAIsInstalled, value); }
  222. }
  223. public bool PMBIsInstalled
  224. {
  225. get { return m_PMBIsInstalled; }
  226. set { SetProperty(ref m_PMBIsInstalled, value); }
  227. }
  228. public bool PMCIsInstalled
  229. {
  230. get { return m_PMCIsInstalled; }
  231. set { SetProperty(ref m_PMCIsInstalled, value); }
  232. }
  233. public bool PMDIsInstalled
  234. {
  235. get { return m_PMDIsInstalled; }
  236. set { SetProperty(ref m_PMDIsInstalled, value); }
  237. }
  238. public bool LLAIsInstalled
  239. {
  240. get { return m_LLAIsInstalled; }
  241. set { SetProperty(ref m_LLAIsInstalled, value); }
  242. }
  243. public bool LLBIsInstalled
  244. {
  245. get { return m_LLBIsInstalled; }
  246. set { SetProperty(ref m_LLBIsInstalled, value); }
  247. }
  248. public bool TMIsInstalled
  249. {
  250. get { return m_TMIsInstalled; }
  251. set { SetProperty(ref m_TMIsInstalled, value); }
  252. }
  253. public bool EFEMIsInstalled
  254. {
  255. get { return m_EFEMIsInstalled; }
  256. set { SetProperty(ref m_EFEMIsInstalled, value); }
  257. }
  258. public WaferInfo EFEMBladeAWafer
  259. {
  260. get { return m_EFEMBladeAWafer; }
  261. set { SetProperty(ref m_EFEMBladeAWafer, value); }
  262. }
  263. public WaferInfo EFEMBladeBWafer
  264. {
  265. get { return m_EFEMBladeBWafer; }
  266. set { SetProperty(ref m_EFEMBladeBWafer, value); }
  267. }
  268. public WaferInfo Aligner1Wafer
  269. {
  270. get { return m_Aligner1Wafer; }
  271. set { SetProperty(ref m_Aligner1Wafer, value); }
  272. }
  273. public int LP1WaferCount
  274. {
  275. get { return m_LP1WaferCount; }
  276. set { SetProperty(ref m_LP1WaferCount, value); }
  277. }
  278. public int LP2WaferCount
  279. {
  280. get { return m_LP2WaferCount; }
  281. set { SetProperty(ref m_LP2WaferCount, value); }
  282. }
  283. public int LP3WaferCount
  284. {
  285. get { return m_LP3WaferCount; }
  286. set { SetProperty(ref m_LP3WaferCount, value); }
  287. }
  288. public WaferAssociationInfo LP1WaferAssociation
  289. {
  290. get { return _lp1WaferAssociation; }
  291. set { SetProperty(ref _lp1WaferAssociation, value); }
  292. }
  293. public WaferAssociationInfo LP2WaferAssociation
  294. {
  295. get { return _lp2WaferAssociation; }
  296. set { SetProperty(ref _lp2WaferAssociation, value); }
  297. }
  298. public WaferAssociationInfo LP3WaferAssociation
  299. {
  300. get { return _lp3WaferAssociation; }
  301. set { SetProperty(ref _lp3WaferAssociation, value); }
  302. }
  303. public int CycledWafer
  304. {
  305. get { return m_CycledWafer; }
  306. set { SetProperty(ref m_CycledWafer, value); }
  307. }
  308. public int CycleCountDisplay
  309. {
  310. get { return m_CycleCountDisplay; }
  311. set { SetProperty(ref m_CycleCountDisplay, value); }
  312. }
  313. public RobotMoveInfo m_EfemRobotMoveInfo;
  314. public RobotMoveInfo EfemRobotMoveInfo
  315. {
  316. get { return m_EfemRobotMoveInfo; }
  317. set
  318. {
  319. EFEMRobotMoveInfoChanged(m_EfemRobotMoveInfo, value);
  320. m_EfemRobotMoveInfo = value;
  321. }
  322. }
  323. public RobotPosition CurrentRobotPosition
  324. {
  325. get { return m_CurrentRobotPosition; }
  326. set { SetProperty(ref m_CurrentRobotPosition, value); }
  327. }
  328. public WaferInfo BladeAWafer
  329. {
  330. get { return m_BladeAWafer; }
  331. set { SetProperty(ref m_BladeAWafer, value); }
  332. }
  333. public WaferInfo BladeBWafer
  334. {
  335. get { return m_BladeBWafer; }
  336. set { SetProperty(ref m_BladeBWafer, value); }
  337. }
  338. public RecipeResult PMARecipeResult
  339. {
  340. get { return m_PMARecipeResult; }
  341. set { SetProperty(ref m_PMARecipeResult, value); }
  342. }
  343. public RecipeResult PMBRecipeResult
  344. {
  345. get { return m_PMBRecipeResult; }
  346. set { SetProperty(ref m_PMBRecipeResult, value); }
  347. }
  348. public RecipeResult PMCRecipeResult
  349. {
  350. get { return m_PMCRecipeResult; }
  351. set { SetProperty(ref m_PMCRecipeResult, value); }
  352. }
  353. public RecipeResult PMDRecipeResult
  354. {
  355. get { return m_PMDRecipeResult; }
  356. set { SetProperty(ref m_PMDRecipeResult, value); }
  357. }
  358. public string ATMModeIsOn
  359. {
  360. get { return m_ATMModeIsOn; }
  361. set { SetProperty(ref m_ATMModeIsOn, value); }
  362. }
  363. #endregion
  364. #region 命令
  365. private DelegateCommand _LoadCommand;
  366. public DelegateCommand LoadCommand =>
  367. _LoadCommand ?? (_LoadCommand = new DelegateCommand(OnLoad));
  368. private DelegateCommand<object> _LoadWaferCommand;
  369. public DelegateCommand<object> LoadWaferCommand =>
  370. _LoadWaferCommand ?? (_LoadWaferCommand = new DelegateCommand<object>(OnLoadWafer));
  371. private DelegateCommand<object> _UnLoadWaferCommand;
  372. public DelegateCommand<object> UnLoadWaferCommand =>
  373. _UnLoadWaferCommand ?? (_UnLoadWaferCommand = new DelegateCommand<object>(OnUnLoadWafer));
  374. private DelegateCommand<object> _SelectAllCommand;
  375. public DelegateCommand<object> SelectAllCommand =>
  376. _SelectAllCommand ?? (_SelectAllCommand = new DelegateCommand<object>(OnSelectAll));
  377. private DelegateCommand<object> _UnSelectAllCommand;
  378. public DelegateCommand<object> UnSelectAllCommand =>
  379. _UnSelectAllCommand ?? (_UnSelectAllCommand = new DelegateCommand<object>(OnUnSelectAll));
  380. private DelegateCommand<object> _StartCommand;
  381. public DelegateCommand<object> StartCommand =>
  382. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  383. private DelegateCommand<object> _StopCommand;
  384. public DelegateCommand<object> StopCommand =>
  385. _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
  386. private DelegateCommand<object> _AbortCommand;
  387. public DelegateCommand<object> AbortCommand =>
  388. _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(OnAbort));
  389. private DelegateCommand _HomeAllCommand;
  390. public DelegateCommand HomeAllCommand =>
  391. _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll));
  392. private DelegateCommand _PauseAllJobCommand;
  393. public DelegateCommand PauseAllJobCommand =>
  394. _PauseAllJobCommand ?? (_PauseAllJobCommand = new DelegateCommand(OnPauseAllJob));
  395. private DelegateCommand _AbortAllCommand;
  396. public DelegateCommand AbortAllCommand =>
  397. _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll));
  398. private DelegateCommand _ReturnAllWaferCommand;
  399. public DelegateCommand ReturnAllWaferCommand =>
  400. _ReturnAllWaferCommand ?? (_ReturnAllWaferCommand = new DelegateCommand(OnReturnAllWafer));
  401. private DelegateCommand<object> _SetSequenceCommand;
  402. public DelegateCommand<object> SetSequenceCommand =>
  403. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  404. private DelegateCommand<object> _CreateJobCommand;
  405. public DelegateCommand<object> CreateJobCommand =>
  406. _CreateJobCommand ?? (_CreateJobCommand = new DelegateCommand<object>(OnCreateJob));
  407. private DelegateCommand _EnableAutoCommand;
  408. public DelegateCommand EnableAutoCommand =>
  409. _EnableAutoCommand ?? (_EnableAutoCommand = new DelegateCommand(OnEnableAuto));
  410. private DelegateCommand _EnableManualCommand;
  411. public DelegateCommand EnableManualCommand =>
  412. _EnableManualCommand ?? (_EnableManualCommand = new DelegateCommand(OnEnableManual));
  413. public bool SwitchFlag;
  414. #endregion
  415. #region 构造函数
  416. public OperationOverViewModel()
  417. {
  418. DispatcherTimer timer = new DispatcherTimer();
  419. timer.Interval = TimeSpan.FromSeconds(0.5);
  420. timer.Tick += Timer_Tick;
  421. timer.Start();
  422. addDataKeys();
  423. string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();
  424. PMAIsInstalled = allModules.Contains("PMA");
  425. PMBIsInstalled = allModules.Contains("PMB");
  426. PMCIsInstalled = allModules.Contains("PMC");
  427. PMDIsInstalled = allModules.Contains("PMD");
  428. LLAIsInstalled = allModules.Contains("LLA");
  429. LLBIsInstalled = allModules.Contains("LLB");
  430. EFEMIsInstalled = allModules.Contains("EFEM");
  431. TMIsInstalled = allModules.Contains("TM");
  432. SwitchFlag = false;
  433. ATMModeIsOn = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig("System.IsATMMode")) == true ? "ATM Mode On" : "ATM Mode Off";
  434. }
  435. #endregion
  436. #region 命令方法
  437. private void OnLoad()
  438. {
  439. if (!SwitchFlag)
  440. {
  441. LP1WaferAssociation = new WaferAssociationInfo();
  442. LP3WaferAssociation = new WaferAssociationInfo();
  443. LP2WaferAssociation = new WaferAssociationInfo();
  444. LP1WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP1"];
  445. LP2WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP2"];
  446. LP3WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP3"];
  447. SwitchFlag = true;
  448. }
  449. }
  450. private void OnLoadWafer(object obj)
  451. {
  452. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Load", ModuleManager.ModuleInfos[obj.ToString()].ModuleID);
  453. }
  454. private void OnUnLoadWafer(object obj)
  455. {
  456. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Unload", ModuleManager.ModuleInfos[obj.ToString()].ModuleID);
  457. }
  458. private void OnSelectAll(object obj)
  459. {
  460. var info=obj as WaferAssociationInfo;
  461. info.SlotFrom = 1;
  462. info.SlotTo = 25;
  463. AssociateSequence(info, true);
  464. }
  465. private void OnUnSelectAll(object obj)
  466. {
  467. var info = obj as WaferAssociationInfo;
  468. info.SlotFrom = 1;
  469. info.SlotTo = 25;
  470. AssociateSequence(info, false);
  471. }
  472. private void OnStart(object obj)
  473. {
  474. var info = obj as WaferAssociationInfo;
  475. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId);
  476. }
  477. private void OnStop(object obj)
  478. {
  479. var info = obj as WaferAssociationInfo;
  480. InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID);
  481. }
  482. private void OnAbort(object obj)
  483. {
  484. var info = obj as WaferAssociationInfo;
  485. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID);
  486. }
  487. private void OnHomeAll()
  488. {
  489. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  490. }
  491. private void OnPauseAllJob()
  492. {
  493. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP1WaferAssociation.JobID);
  494. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP2WaferAssociation.JobID);
  495. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP3WaferAssociation.JobID);
  496. }
  497. private void OnAbortAll()
  498. {
  499. InvokeClient.Instance.Service.DoOperation("System.Abort");
  500. }
  501. private void OnReturnAllWafer()
  502. {
  503. //Dialog
  504. WaferDialogView dialog = new WaferDialogView()
  505. {
  506. Owner = Application.Current.MainWindow,
  507. };
  508. dialog.Left = Application.Current.MainWindow.Width / 2 - 150;
  509. dialog.Top = Application.Current.MainWindow.Height / 2 - 200;
  510. dialog.Height = 300;
  511. dialog.Width = 400;
  512. double angel = 0;
  513. double coolingtime = 0;
  514. if (dialog.ShowDialog() == true)
  515. {
  516. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  517. {
  518. angel = Convert.ToDouble(dialog.Angle);
  519. }
  520. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  521. {
  522. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  523. }
  524. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag,coolingtime, dialog.AlignFlag, angel);
  525. }
  526. }
  527. private void OnSetSequence(object obj)
  528. {
  529. var info = obj as WaferInfo;
  530. bool flag = info.SequenceName != "" ? false : true;
  531. if (info.ModuleID == "LP1")
  532. {
  533. AssociateSequence(LP1WaferAssociation, flag, info.SlotID);
  534. }
  535. else if (info.ModuleID == "LP2")
  536. {
  537. AssociateSequence(LP2WaferAssociation, flag, info.SlotID);
  538. }
  539. else if (info.ModuleID == "LP3")
  540. {
  541. AssociateSequence(LP3WaferAssociation, flag, info.SlotID);
  542. }
  543. }
  544. private void OnCreateJob(object obj)
  545. {
  546. var info = obj as WaferAssociationInfo;
  547. List<string> slotSequence = new List<string>();
  548. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  549. string jobId = info.LotId.Trim();
  550. if (string.IsNullOrEmpty(jobId))
  551. jobId = "CJ_Local_" + info.ModuleData.ModuleID;
  552. info.LotId = jobId;
  553. info.JobID = jobId;
  554. info.JobStatus = "WaitingForStart";
  555. info.LotIdSaved = true;
  556. Dictionary<string, object> param = new Dictionary<string, object>()
  557. {
  558. {"JobId", jobId},
  559. {"Module", info.ModuleData.ModuleID},
  560. {"SlotSequence", slotSequence.ToArray()},
  561. {"AutoStart", true},
  562. };
  563. InvokeClient.Instance.Service.DoOperation("System.CreateJob", param);
  564. }
  565. private void OnEnableAuto()
  566. {
  567. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  568. }
  569. private void OnEnableManual()
  570. {
  571. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  572. }
  573. #endregion
  574. #region 私有方法
  575. private void Timer_Tick(object sender, EventArgs e)
  576. {
  577. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  578. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  579. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  580. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  581. TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];
  582. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  583. BladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
  584. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  585. if (LLAIsInstalled == true)
  586. {
  587. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  588. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  589. }
  590. if (LLBIsInstalled == true)
  591. {
  592. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  593. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  594. }
  595. if (PMAIsInstalled == true)
  596. {
  597. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  598. PMARecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMA.CurrentRecipeResult");
  599. }
  600. if (PMBIsInstalled == true)
  601. {
  602. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  603. PMBRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMB.CurrentRecipeResult");
  604. }
  605. if (PMCIsInstalled == true)
  606. {
  607. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  608. PMCRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMC.CurrentRecipeResult");
  609. }
  610. if (PMDIsInstalled == true)
  611. {
  612. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  613. PMDRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMD.CurrentRecipeResult");
  614. }
  615. if (TMIsInstalled == true)
  616. {
  617. TMBladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];
  618. TMBladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];
  619. }
  620. if (EFEMIsInstalled == true)
  621. {
  622. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  623. EFEMBladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
  624. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  625. }
  626. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  627. EfemRobotMoveInfo=(RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  628. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x=>x.WaferStatus!=0).Count();
  629. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  630. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  631. }
  632. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  633. {
  634. string RobotTarget;
  635. if (oldValue == null || newValue == null)
  636. {
  637. return;
  638. }
  639. #region pick 和 place LL
  640. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  641. {
  642. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  643. if (TMRobotMoveActionBladeTarget != null)
  644. {
  645. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  646. }
  647. else
  648. {
  649. return;
  650. }
  651. var values = RobotTarget.Split('.');
  652. var arm = values[0];
  653. var module = values[1];
  654. if (arm == "ArmA")
  655. {
  656. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  657. await Task.Delay(1500);
  658. Robot1XAction = WaferRobotXAction.Extend;
  659. await Task.Delay(3000);
  660. Robot1XAction = WaferRobotXAction.Retract;
  661. }
  662. else if (arm == "ArmB")
  663. {
  664. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  665. await Task.Delay(1500);
  666. Robot2XAction = WaferRobotXAction.Extend;
  667. await Task.Delay(3000);
  668. Robot2XAction = WaferRobotXAction.Retract;
  669. }
  670. }
  671. #endregion
  672. #region pick 和 place pm
  673. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  674. {
  675. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  676. if (TMRobotMoveActionBladeTarget != null)
  677. {
  678. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  679. }
  680. else
  681. {
  682. return;
  683. }
  684. var values = RobotTarget.Split('.');
  685. var arm = values[0];
  686. var module = values[1];
  687. if (arm == "ArmA")
  688. {
  689. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  690. await Task.Delay(1500);
  691. Robot1XAction = WaferRobotXAction.Extend;
  692. }
  693. else if (arm == "ArmB")
  694. {
  695. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  696. await Task.Delay(1500);
  697. Robot2XAction = WaferRobotXAction.Extend;
  698. }
  699. }
  700. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  701. {
  702. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  703. if (TMRobotMoveActionBladeTarget != null)
  704. {
  705. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  706. }
  707. else
  708. {
  709. return;
  710. }
  711. var values = RobotTarget.Split('.');
  712. var arm = values[0];
  713. if (arm == "ArmA")
  714. {
  715. Robot1XAction = WaferRobotXAction.Retract;
  716. }
  717. else if (arm == "ArmB")
  718. {
  719. Robot2XAction = WaferRobotXAction.Retract;
  720. }
  721. }
  722. #endregion
  723. arm1oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus;
  724. arm2oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus;
  725. }
  726. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  727. {
  728. string RobotTarget;
  729. if (oldValue == null || newValue == null)
  730. {
  731. return;
  732. }
  733. #region pick 和 place LL
  734. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  735. {
  736. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  737. if (TMRobotMoveActionBladeTarget != null)
  738. {
  739. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  740. }
  741. else
  742. {
  743. return;
  744. }
  745. var values = RobotTarget.Split('.');
  746. var arm = values[0];
  747. var module = values[1];
  748. if (arm == "ArmA")
  749. {
  750. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  751. await Task.Delay(2000);
  752. await ChangePosition(robot3Robot3TAction);
  753. Robot3TAction = robot3Robot3TAction;
  754. await Task.Delay(1500);
  755. //ChangePosition(Robot3TAction);
  756. // await Task.Delay(2000);
  757. Robot3XAction = WaferRobotXAction.Extend;
  758. await Task.Delay(3000);
  759. Robot3XAction = WaferRobotXAction.Retract;
  760. }
  761. else if (arm == "ArmB")
  762. {
  763. var robot4Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  764. await Task.Delay(2000);
  765. await ChangePosition(robot4Robot4TAction);
  766. Robot4TAction = robot4Robot4TAction;
  767. await Task.Delay(1500);
  768. //ChangePosition(Robot4TAction);
  769. //await Task.Delay(2000);
  770. Robot4XAction = WaferRobotXAction.Extend;
  771. await Task.Delay(3000);
  772. Robot4XAction = WaferRobotXAction.Retract;
  773. }
  774. }
  775. #endregion
  776. #region pick 和 place pm
  777. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  778. {
  779. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  780. if (TMRobotMoveActionBladeTarget != null)
  781. {
  782. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  783. }
  784. else
  785. {
  786. return;
  787. }
  788. var values = RobotTarget.Split('.');
  789. var arm = values[0];
  790. var module = values[1];
  791. if (arm == "ArmA")
  792. {
  793. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  794. await Task.Delay(1500);
  795. //ChangePosition(Robot3TAction);
  796. //await Task.Delay(2000);
  797. Robot3XAction = WaferRobotXAction.Extend;
  798. }
  799. else if (arm == "ArmB")
  800. {
  801. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  802. await Task.Delay(1500);
  803. //ChangePosition(Robot4TAction);
  804. //await Task.Delay(2000);
  805. Robot4XAction = WaferRobotXAction.Extend;
  806. }
  807. }
  808. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  809. {
  810. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  811. if (TMRobotMoveActionBladeTarget != null)
  812. {
  813. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  814. }
  815. else
  816. {
  817. return;
  818. }
  819. var values = RobotTarget.Split('.');
  820. var arm = values[0];
  821. if (arm == "ArmA")
  822. {
  823. Robot3XAction = WaferRobotXAction.Retract;
  824. await Task.Delay(3000);
  825. //ChangePosition(Robot3TAction);
  826. //await Task.Delay(2000);
  827. }
  828. else if (arm == "ArmB")
  829. {
  830. Robot4XAction = WaferRobotXAction.Retract;
  831. await Task.Delay(3000);
  832. //ChangePosition(Robot3TAction);
  833. //await Task.Delay(2000);
  834. }
  835. }
  836. #endregion
  837. }
  838. private void addDataKeys()
  839. {
  840. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  841. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  842. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  843. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  844. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  845. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  846. m_RtDataKeys.Add("TM.LLAESlitDoor.IsClosed");
  847. m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed");
  848. m_RtDataKeys.Add("System.IsAutoMode");
  849. m_RtDataKeys.Add("Scheduler.CycledCount");
  850. m_RtDataKeys.Add("Scheduler.CycledWafer");
  851. m_RtDataKeys.Add("Scheduler.CycleSetPoint");
  852. m_RtDataKeys.Add("LP1.IsLoaded");
  853. m_RtDataKeys.Add("LP2.IsLoaded");
  854. m_RtDataKeys.Add("LP3.IsLoaded");
  855. m_RtDataKeys.Add("LP1.CassettePlaced");
  856. m_RtDataKeys.Add("LP2.CassettePlaced");
  857. m_RtDataKeys.Add("LP3.CassettePlaced");
  858. m_RtDataKeys.Add("PMA.CurrentRecipeResult");
  859. m_RtDataKeys.Add("PMB.CurrentRecipeResult");
  860. m_RtDataKeys.Add("PMC.CurrentRecipeResult");
  861. m_RtDataKeys.Add("PMD.CurrentRecipeResult");
  862. }
  863. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  864. {
  865. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  866. if (slot >= 0) //by wafer
  867. {
  868. int index = wafers.Count - slot - 1;
  869. if (index < wafers.Count)
  870. {
  871. if (flag && HasWaferOnSlot(wafers, index))
  872. wafers[index].SequenceName = info.SequenceName;
  873. else
  874. wafers[index].SequenceName = string.Empty;
  875. }
  876. }
  877. else //by from-to
  878. {
  879. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  880. {
  881. int index = wafers.Count - i - 1;
  882. if (index < wafers.Count)
  883. {
  884. if (flag && HasWaferOnSlot(wafers, index))
  885. wafers[index].SequenceName = info.SequenceName;
  886. else
  887. wafers[index].SequenceName = string.Empty;
  888. }
  889. }
  890. }
  891. switch (info.ModuleData.ModuleID)
  892. {
  893. case "LP1":
  894. LP1WaferAssociation = info;
  895. break;
  896. case "LP2":
  897. LP2WaferAssociation = info;
  898. break;
  899. case "LP3":
  900. LP3WaferAssociation = info;
  901. break;
  902. }
  903. }
  904. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  905. {
  906. if (wafers[index].WaferStatus == 0)
  907. return false;
  908. return true;
  909. }
  910. private async Task ChangePosition(WaferRobotTAction waferRobotTAction)
  911. {
  912. if (waferRobotTAction == WaferRobotTAction.LP1)
  913. {
  914. CurrentRobotPosition = RobotPosition.Left;
  915. }
  916. else if (waferRobotTAction == WaferRobotTAction.LP3)
  917. {
  918. CurrentRobotPosition = RobotPosition.Right;
  919. }
  920. else if (waferRobotTAction == WaferRobotTAction.LP2)
  921. {
  922. CurrentRobotPosition = RobotPosition.Middle;
  923. }
  924. else
  925. {
  926. CurrentRobotPosition = RobotPosition.Origin;
  927. }
  928. await Task.Delay(1500);
  929. }
  930. #endregion
  931. }
  932. }