OperationOverViewModel.cs 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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. InvokeClient.Instance.Service.DoOperation("System.PauseJob", obj.ToString());
  480. }
  481. private void OnAbort(object obj)
  482. {
  483. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", obj.ToString());
  484. }
  485. private void OnHomeAll()
  486. {
  487. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  488. }
  489. private void OnPauseAllJob()
  490. {
  491. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP1WaferAssociation.JobID);
  492. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP2WaferAssociation.JobID);
  493. InvokeClient.Instance.Service.DoOperation("System.PauseJob", LP3WaferAssociation.JobID);
  494. }
  495. private void OnAbortAll()
  496. {
  497. InvokeClient.Instance.Service.DoOperation("System.Abort");
  498. }
  499. private void OnReturnAllWafer()
  500. {
  501. //Dialog
  502. WaferDialogView dialog = new WaferDialogView()
  503. {
  504. Owner = Application.Current.MainWindow,
  505. };
  506. dialog.Left = Application.Current.MainWindow.Width / 2 - 150;
  507. dialog.Top = Application.Current.MainWindow.Height / 2 - 200;
  508. dialog.Height = 300;
  509. dialog.Width = 400;
  510. double angel = 0;
  511. double coolingtime = 0;
  512. if (dialog.ShowDialog() == true)
  513. {
  514. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  515. {
  516. angel = Convert.ToDouble(dialog.Angle);
  517. }
  518. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  519. {
  520. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  521. }
  522. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag,coolingtime, dialog.AlignFlag, angel);
  523. }
  524. }
  525. private void OnSetSequence(object obj)
  526. {
  527. var info = obj as WaferInfo;
  528. bool flag = info.SequenceName != "" ? false : true;
  529. if (info.ModuleID == "LP1")
  530. {
  531. AssociateSequence(LP1WaferAssociation, flag, info.SlotID);
  532. }
  533. else if (info.ModuleID == "LP2")
  534. {
  535. AssociateSequence(LP2WaferAssociation, flag, info.SlotID);
  536. }
  537. else if (info.ModuleID == "LP3")
  538. {
  539. AssociateSequence(LP3WaferAssociation, flag, info.SlotID);
  540. }
  541. }
  542. private void OnCreateJob(object obj)
  543. {
  544. var info = obj as WaferAssociationInfo;
  545. List<string> slotSequence = new List<string>();
  546. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  547. string jobId = info.LotId.Trim();
  548. if (string.IsNullOrEmpty(jobId))
  549. jobId = "CJ_Local_" + info.ModuleData.ModuleID;
  550. info.LotId = jobId;
  551. info.JobID = jobId;
  552. info.JobStatus = "WaitingForStart";
  553. info.LotIdSaved = true;
  554. Dictionary<string, object> param = new Dictionary<string, object>()
  555. {
  556. {"JobId", jobId},
  557. {"Module", info.ModuleData.ModuleID},
  558. {"SlotSequence", slotSequence.ToArray()},
  559. {"AutoStart", true},
  560. };
  561. InvokeClient.Instance.Service.DoOperation("System.CreateJob", param);
  562. }
  563. private void OnEnableAuto()
  564. {
  565. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  566. }
  567. private void OnEnableManual()
  568. {
  569. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  570. }
  571. #endregion
  572. #region 私有方法
  573. private void Timer_Tick(object sender, EventArgs e)
  574. {
  575. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  576. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  577. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  578. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  579. TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];
  580. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  581. BladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
  582. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  583. if (LLAIsInstalled == true)
  584. {
  585. LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];
  586. LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  587. }
  588. if (LLBIsInstalled == true)
  589. {
  590. LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];
  591. LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);
  592. }
  593. if (PMAIsInstalled == true)
  594. {
  595. PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];
  596. PMARecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMA.CurrentRecipeResult");
  597. }
  598. if (PMBIsInstalled == true)
  599. {
  600. PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];
  601. PMBRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMB.CurrentRecipeResult");
  602. }
  603. if (PMCIsInstalled == true)
  604. {
  605. PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];
  606. PMCRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMC.CurrentRecipeResult");
  607. }
  608. if (PMDIsInstalled == true)
  609. {
  610. PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];
  611. PMDRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, $"PMD.CurrentRecipeResult");
  612. }
  613. if (TMIsInstalled == true)
  614. {
  615. TMBladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];
  616. TMBladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];
  617. }
  618. if (EFEMIsInstalled == true)
  619. {
  620. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  621. EFEMBladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];
  622. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  623. }
  624. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  625. EfemRobotMoveInfo=(RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  626. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x=>x.WaferStatus!=0).Count();
  627. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  628. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  629. }
  630. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  631. {
  632. string RobotTarget;
  633. if (oldValue == null || newValue == null)
  634. {
  635. return;
  636. }
  637. #region pick 和 place LL
  638. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  639. {
  640. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  641. if (TMRobotMoveActionBladeTarget != null)
  642. {
  643. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  644. }
  645. else
  646. {
  647. return;
  648. }
  649. var values = RobotTarget.Split('.');
  650. var arm = values[0];
  651. var module = values[1];
  652. if (arm == "ArmA")
  653. {
  654. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  655. await Task.Delay(1500);
  656. Robot1XAction = WaferRobotXAction.Extend;
  657. await Task.Delay(3000);
  658. Robot1XAction = WaferRobotXAction.Retract;
  659. }
  660. else if (arm == "ArmB")
  661. {
  662. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  663. await Task.Delay(1500);
  664. Robot2XAction = WaferRobotXAction.Extend;
  665. await Task.Delay(3000);
  666. Robot2XAction = WaferRobotXAction.Retract;
  667. }
  668. }
  669. #endregion
  670. #region pick 和 place pm
  671. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  672. {
  673. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  674. if (TMRobotMoveActionBladeTarget != null)
  675. {
  676. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  677. }
  678. else
  679. {
  680. return;
  681. }
  682. var values = RobotTarget.Split('.');
  683. var arm = values[0];
  684. var module = values[1];
  685. if (arm == "ArmA")
  686. {
  687. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  688. await Task.Delay(1500);
  689. Robot1XAction = WaferRobotXAction.Extend;
  690. }
  691. else if (arm == "ArmB")
  692. {
  693. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  694. await Task.Delay(1500);
  695. Robot2XAction = WaferRobotXAction.Extend;
  696. }
  697. }
  698. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  699. {
  700. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  701. if (TMRobotMoveActionBladeTarget != null)
  702. {
  703. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  704. }
  705. else
  706. {
  707. return;
  708. }
  709. var values = RobotTarget.Split('.');
  710. var arm = values[0];
  711. if (arm == "ArmA")
  712. {
  713. Robot1XAction = WaferRobotXAction.Retract;
  714. }
  715. else if (arm == "ArmB")
  716. {
  717. Robot2XAction = WaferRobotXAction.Retract;
  718. }
  719. }
  720. #endregion
  721. arm1oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus;
  722. arm2oldWaferStatus = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus;
  723. }
  724. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  725. {
  726. string RobotTarget;
  727. if (oldValue == null || newValue == null)
  728. {
  729. return;
  730. }
  731. #region pick 和 place LL
  732. if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  733. {
  734. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  735. if (TMRobotMoveActionBladeTarget != null)
  736. {
  737. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  738. }
  739. else
  740. {
  741. return;
  742. }
  743. var values = RobotTarget.Split('.');
  744. var arm = values[0];
  745. var module = values[1];
  746. if (arm == "ArmA")
  747. {
  748. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  749. await ChangePosition(robot3Robot3TAction);
  750. Robot3TAction = robot3Robot3TAction;
  751. await Task.Delay(1500);
  752. //ChangePosition(Robot3TAction);
  753. // await Task.Delay(2000);
  754. Robot3XAction = WaferRobotXAction.Extend;
  755. await Task.Delay(3000);
  756. Robot3XAction = WaferRobotXAction.Retract;
  757. }
  758. else if (arm == "ArmB")
  759. {
  760. var robot4Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  761. await ChangePosition(robot4Robot4TAction);
  762. Robot4TAction = robot4Robot4TAction;
  763. await Task.Delay(1500);
  764. //ChangePosition(Robot4TAction);
  765. //await Task.Delay(2000);
  766. Robot4XAction = WaferRobotXAction.Extend;
  767. await Task.Delay(3000);
  768. Robot4XAction = WaferRobotXAction.Retract;
  769. }
  770. }
  771. #endregion
  772. #region pick 和 place pm
  773. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  774. {
  775. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  776. if (TMRobotMoveActionBladeTarget != null)
  777. {
  778. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  779. }
  780. else
  781. {
  782. return;
  783. }
  784. var values = RobotTarget.Split('.');
  785. var arm = values[0];
  786. var module = values[1];
  787. if (arm == "ArmA")
  788. {
  789. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  790. await Task.Delay(1500);
  791. //ChangePosition(Robot3TAction);
  792. //await Task.Delay(2000);
  793. Robot3XAction = WaferRobotXAction.Extend;
  794. }
  795. else if (arm == "ArmB")
  796. {
  797. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  798. await Task.Delay(1500);
  799. //ChangePosition(Robot4TAction);
  800. //await Task.Delay(2000);
  801. Robot4XAction = WaferRobotXAction.Extend;
  802. }
  803. }
  804. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  805. {
  806. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  807. if (TMRobotMoveActionBladeTarget != null)
  808. {
  809. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  810. }
  811. else
  812. {
  813. return;
  814. }
  815. var values = RobotTarget.Split('.');
  816. var arm = values[0];
  817. if (arm == "ArmA")
  818. {
  819. Robot3XAction = WaferRobotXAction.Retract;
  820. await Task.Delay(3000);
  821. //ChangePosition(Robot3TAction);
  822. //await Task.Delay(2000);
  823. }
  824. else if (arm == "ArmB")
  825. {
  826. Robot4XAction = WaferRobotXAction.Retract;
  827. await Task.Delay(3000);
  828. //ChangePosition(Robot3TAction);
  829. //await Task.Delay(2000);
  830. }
  831. }
  832. #endregion
  833. }
  834. private void addDataKeys()
  835. {
  836. m_RtDataKeys.Add("PMA.IsSlitDoorClosed");
  837. m_RtDataKeys.Add("PMB.IsSlitDoorClosed");
  838. m_RtDataKeys.Add("PMC.IsSlitDoorClosed");
  839. m_RtDataKeys.Add("PMD.IsSlitDoorClosed");
  840. m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");
  841. m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");
  842. m_RtDataKeys.Add("TM.LLAESlitDoor.IsClosed");
  843. m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed");
  844. m_RtDataKeys.Add("System.IsAutoMode");
  845. m_RtDataKeys.Add("Scheduler.CycledCount");
  846. m_RtDataKeys.Add("Scheduler.CycledWafer");
  847. m_RtDataKeys.Add("Scheduler.CycleSetPoint");
  848. m_RtDataKeys.Add("LP1.IsLoaded");
  849. m_RtDataKeys.Add("LP2.IsLoaded");
  850. m_RtDataKeys.Add("LP3.IsLoaded");
  851. m_RtDataKeys.Add("LP1.CassettePlaced");
  852. m_RtDataKeys.Add("LP2.CassettePlaced");
  853. m_RtDataKeys.Add("LP3.CassettePlaced");
  854. m_RtDataKeys.Add("PMA.CurrentRecipeResult");
  855. m_RtDataKeys.Add("PMB.CurrentRecipeResult");
  856. m_RtDataKeys.Add("PMC.CurrentRecipeResult");
  857. m_RtDataKeys.Add("PMD.CurrentRecipeResult");
  858. }
  859. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  860. {
  861. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  862. if (slot >= 0) //by wafer
  863. {
  864. int index = wafers.Count - slot - 1;
  865. if (index < wafers.Count)
  866. {
  867. if (flag && HasWaferOnSlot(wafers, index))
  868. wafers[index].SequenceName = info.SequenceName;
  869. else
  870. wafers[index].SequenceName = string.Empty;
  871. }
  872. }
  873. else //by from-to
  874. {
  875. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  876. {
  877. int index = wafers.Count - i - 1;
  878. if (index < wafers.Count)
  879. {
  880. if (flag && HasWaferOnSlot(wafers, index))
  881. wafers[index].SequenceName = info.SequenceName;
  882. else
  883. wafers[index].SequenceName = string.Empty;
  884. }
  885. }
  886. }
  887. switch (info.ModuleData.ModuleID)
  888. {
  889. case "LP1":
  890. LP1WaferAssociation = info;
  891. break;
  892. case "LP2":
  893. LP2WaferAssociation = info;
  894. break;
  895. case "LP3":
  896. LP3WaferAssociation = info;
  897. break;
  898. }
  899. }
  900. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  901. {
  902. if (wafers[index].WaferStatus == 0)
  903. return false;
  904. return true;
  905. }
  906. private async Task ChangePosition(WaferRobotTAction waferRobotTAction)
  907. {
  908. //CurrentRobotPosition = RobotPosition.Origin;
  909. //await Task.Delay(1000);
  910. if (waferRobotTAction == WaferRobotTAction.LP1)
  911. {
  912. CurrentRobotPosition = RobotPosition.Left;
  913. }
  914. else if (waferRobotTAction == WaferRobotTAction.LP3)
  915. {
  916. CurrentRobotPosition = RobotPosition.Right;
  917. }
  918. else if (waferRobotTAction == WaferRobotTAction.LP2)
  919. {
  920. CurrentRobotPosition = RobotPosition.Middle;
  921. }
  922. else
  923. {
  924. CurrentRobotPosition = RobotPosition.Origin;
  925. }
  926. await Task.Delay(1500);
  927. }
  928. #endregion
  929. }
  930. }