VenusSeOperationOverViewModel.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  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 Venus_Core;
  14. using Venus_Themes.CustomControls;
  15. using System.Windows.Threading;
  16. using Venus_MainPages.Unity;
  17. using Microsoft.VisualBasic;
  18. using ExcelLibrary.BinaryFileFormat;
  19. using MECF.Framework.Common.Schedulers;
  20. using Venus_MainPages.Views;
  21. using System.Windows;
  22. using static Venus_Themes.CustomControls.SERobot;
  23. namespace Venus_MainPages.ViewModels
  24. {
  25. public class VenusSeOperationOverViewModel : BindableBase
  26. {
  27. #region 私有字段
  28. private ModuleInfo m_VCE1ModuleInfo;
  29. private ModuleInfo m_PMAModuleInfo;
  30. private ModuleInfo m_PMBModuleInfo;
  31. private ModuleInfo m_PMCModuleInfo;
  32. private ModuleInfo m_VPAModuleInfo;
  33. private ModuleInfo m_TMModuleInfo;
  34. public WaferInfo m_PMAWafer;
  35. public WaferInfo m_PMBWafer;
  36. public WaferInfo m_PMCWafer;
  37. public WaferInfo m_RobotUpperWafer;
  38. public WaferInfo m_RobotLowerWafer;
  39. public WaferInfo m_PAWafer;
  40. private SERobotTAction m_Robot1TAction;
  41. private SERobotXAction m_Robot1XAction;
  42. private SERobotTAction m_Robot2TAction;
  43. private SERobotXAction m_Robot2XAction;
  44. public RobotMoveInfo m_robotMoveInfo;
  45. private int m_VCE1WaferCount;
  46. private bool m_PMAIsInstalled;
  47. private bool m_PMBIsInstalled;
  48. private bool m_PMCIsInstalled;
  49. private bool m_VCEIsInstalled;
  50. private bool m_VCEDoorIsOpen;
  51. private bool m_PMADoorIsOpen;
  52. private bool m_PMBDoorIsOpen;
  53. private bool m_PMCDoorIsOpen;
  54. private bool m_VCEOutDoorIsOpen;
  55. private Dictionary<string, object> m_RtDataValues = new Dictionary<string, object>();
  56. private List<string> m_RtDataKeys = new List<string>();
  57. private double m_PMAPercent;
  58. private double m_PMBPercent;
  59. private double m_PMCPercent;
  60. private double m_VCEPercent;
  61. private int m_PickNum;
  62. private RecipeResult m_PMARecipeResult;
  63. private RecipeResult m_PMBRecipeResult;
  64. private RecipeResult m_PMCRecipeResult;
  65. private WaferAssociationInfo m_VCEwaferAssociation;
  66. private bool loadflag;
  67. #endregion
  68. #region 属性
  69. public SERobotTAction Robot1TAction
  70. {
  71. get { return m_Robot1TAction; }
  72. set { SetProperty(ref m_Robot1TAction, value); }
  73. }
  74. public SERobotXAction Robot1XAction
  75. {
  76. get { return m_Robot1XAction; }
  77. set { SetProperty(ref m_Robot1XAction, value); }
  78. }
  79. public SERobotTAction Robot2TAction
  80. {
  81. get { return m_Robot2TAction; }
  82. set { SetProperty(ref m_Robot2TAction, value); }
  83. }
  84. public SERobotXAction Robot2XAction
  85. {
  86. get { return m_Robot2XAction; }
  87. set { SetProperty(ref m_Robot2XAction, value); }
  88. }
  89. public RobotMoveInfo RobotMoveInfo
  90. {
  91. get { return m_robotMoveInfo; }
  92. set
  93. {
  94. RobotMoveInfoChanged(m_robotMoveInfo, value);
  95. m_robotMoveInfo = value;
  96. }
  97. }
  98. public RecipeResult PMARecipeResult
  99. {
  100. get { return m_PMARecipeResult; }
  101. set { SetProperty(ref m_PMARecipeResult, value); }
  102. }
  103. public RecipeResult PMBRecipeResult
  104. {
  105. get { return m_PMBRecipeResult; }
  106. set { SetProperty(ref m_PMBRecipeResult, value); }
  107. }
  108. public RecipeResult PMCRecipeResult
  109. {
  110. get { return m_PMCRecipeResult; }
  111. set { SetProperty(ref m_PMCRecipeResult, value); }
  112. }
  113. public double PMAPercent
  114. {
  115. get { return m_PMAPercent; }
  116. set { SetProperty(ref m_PMAPercent, value); }
  117. }
  118. public double PMBPercent
  119. {
  120. get { return m_PMBPercent; }
  121. set { SetProperty(ref m_PMBPercent, value); }
  122. }
  123. public double PMCPercent
  124. {
  125. get { return m_PMCPercent; }
  126. set { SetProperty(ref m_PMCPercent, value); }
  127. }
  128. public double VCEPercent
  129. {
  130. get { return m_VCEPercent; }
  131. set { SetProperty(ref m_VCEPercent, value); }
  132. }
  133. public int PickNum
  134. {
  135. get { return m_PickNum; }
  136. set { SetProperty(ref m_PickNum, value); }
  137. }
  138. public WaferInfo PMAWafer
  139. {
  140. get { return m_PMAWafer; }
  141. set { SetProperty(ref m_PMAWafer, value); }
  142. }
  143. public WaferInfo PMBWafer
  144. {
  145. get { return m_PMBWafer; }
  146. set { SetProperty(ref m_PMBWafer, value); }
  147. }
  148. public WaferInfo PMCWafer
  149. {
  150. get { return m_PMCWafer; }
  151. set { SetProperty(ref m_PMCWafer, value); }
  152. }
  153. public WaferInfo RobotUpperWafer
  154. {
  155. get { return m_RobotUpperWafer; }
  156. set { SetProperty(ref m_RobotUpperWafer, value); }
  157. }
  158. public WaferInfo RobotLowerWafer
  159. {
  160. get { return m_RobotLowerWafer; }
  161. set { SetProperty(ref m_RobotLowerWafer, value); }
  162. }
  163. public WaferInfo PAWafer
  164. {
  165. get { return m_PAWafer; }
  166. set { SetProperty(ref m_PAWafer, value); }
  167. }
  168. public ModuleInfo VCE1ModuleInfo
  169. {
  170. get { return m_VCE1ModuleInfo; }
  171. set
  172. {
  173. SetProperty(ref m_VCE1ModuleInfo, value);
  174. }
  175. }
  176. public ModuleInfo PMAModuleInfo
  177. {
  178. get { return m_PMAModuleInfo; }
  179. set
  180. {
  181. SetProperty(ref m_PMAModuleInfo, value);
  182. }
  183. }
  184. public ModuleInfo PMBModuleInfo
  185. {
  186. get { return m_PMBModuleInfo; }
  187. set
  188. {
  189. SetProperty(ref m_PMBModuleInfo, value);
  190. }
  191. }
  192. public ModuleInfo PMCModuleInfo
  193. {
  194. get { return m_PMCModuleInfo; }
  195. set
  196. {
  197. SetProperty(ref m_PMCModuleInfo, value);
  198. }
  199. }
  200. public ModuleInfo VPAModuleInfo
  201. {
  202. get { return m_VPAModuleInfo; }
  203. set
  204. {
  205. SetProperty(ref m_VPAModuleInfo, value);
  206. }
  207. }
  208. public ModuleInfo TMModuleInfo
  209. {
  210. get { return m_TMModuleInfo; }
  211. set
  212. {
  213. SetProperty(ref m_TMModuleInfo, value);
  214. }
  215. }
  216. public bool PMAIsInstalled
  217. {
  218. get { return m_PMAIsInstalled; }
  219. set
  220. {
  221. SetProperty(ref m_PMAIsInstalled, value);
  222. }
  223. }
  224. public bool PMBIsInstalled
  225. {
  226. get { return m_PMBIsInstalled; }
  227. set
  228. {
  229. SetProperty(ref m_PMBIsInstalled, value);
  230. }
  231. }
  232. public bool PMCIsInstalled
  233. {
  234. get { return m_PMCIsInstalled; }
  235. set
  236. {
  237. SetProperty(ref m_PMCIsInstalled, value);
  238. }
  239. }
  240. public bool VCEIsInstalled
  241. {
  242. get { return m_VCEIsInstalled; }
  243. set
  244. {
  245. SetProperty(ref m_VCEIsInstalled, value);
  246. }
  247. }
  248. public bool VCEDoorIsOpen { get => m_VCEDoorIsOpen; set => SetProperty(ref m_VCEDoorIsOpen, value); }
  249. public bool PMADoorIsOpen { get => m_PMADoorIsOpen; set => SetProperty(ref m_PMADoorIsOpen, value); }
  250. public bool PMBDoorIsOpen { get => m_PMBDoorIsOpen; set => SetProperty(ref m_PMBDoorIsOpen, value); }
  251. public bool PMCDoorIsOpen { get => m_PMCDoorIsOpen; set => SetProperty(ref m_PMCDoorIsOpen, value); }
  252. public bool VCEOutDoorIsOpen { get => m_VCEOutDoorIsOpen; set => SetProperty(ref m_VCEOutDoorIsOpen, value); }
  253. public int VCE1WaferCount
  254. {
  255. get { return m_VCE1WaferCount; }
  256. set
  257. {
  258. SetProperty(ref m_VCE1WaferCount, value);
  259. }
  260. }
  261. public Dictionary<string, object> RtDataValues
  262. {
  263. get { return m_RtDataValues; }
  264. set { SetProperty(ref m_RtDataValues, value); }
  265. }
  266. public WaferAssociationInfo VCEwaferAssociation
  267. {
  268. get { return m_VCEwaferAssociation; }
  269. set { SetProperty(ref m_VCEwaferAssociation, value); }
  270. }
  271. #endregion
  272. #region 命令
  273. private DelegateCommand _HomeAll;
  274. public DelegateCommand HomeAll => _HomeAll ?? (_HomeAll = new DelegateCommand(onHomeAll));
  275. private DelegateCommand _SetAutoMode;
  276. public DelegateCommand SetAutoMode => _SetAutoMode ?? (_SetAutoMode = new DelegateCommand(onSetAutoMode));
  277. private DelegateCommand _SetManualMode;
  278. public DelegateCommand SetManualMode => _SetManualMode ?? (_SetManualMode = new DelegateCommand(onSetManualMode));
  279. private DelegateCommand _StartSETMCycle;
  280. public DelegateCommand StartSETMCycle => _StartSETMCycle ?? (_StartSETMCycle = new DelegateCommand(onStartSETMCycle));
  281. private DelegateCommand<object> _StartCommand;
  282. public DelegateCommand<object> StartCommand =>
  283. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  284. private DelegateCommand _StopCycle;
  285. public DelegateCommand StopCycle => _StopCycle ?? (_StopCycle = new DelegateCommand(onStopCycle));
  286. private DelegateCommand _VCEHome;
  287. public DelegateCommand VCEHome => _VCEHome ?? (_VCEHome = new DelegateCommand(vceHome));
  288. private DelegateCommand _VCEReadMap;
  289. public DelegateCommand VCEReadMap => _VCEReadMap ?? (_VCEReadMap = new DelegateCommand(vceReadMap));
  290. private DelegateCommand _VCELoadPrepare;
  291. public DelegateCommand VCELoadPrepare =>
  292. _VCELoadPrepare ?? (_VCELoadPrepare = new DelegateCommand(vceLoadPrepare));
  293. private DelegateCommand __VCELoad;
  294. public DelegateCommand VCELoad =>
  295. __VCELoad ?? (__VCELoad = new DelegateCommand(vceLoad));
  296. private DelegateCommand __VCELoadWithSMIF;
  297. public DelegateCommand VCELoadWithSMIF =>
  298. __VCELoadWithSMIF ?? (__VCELoadWithSMIF = new DelegateCommand(vceLoadWithSMIF));
  299. private DelegateCommand __VCEUnLoadWithSMIF;
  300. public DelegateCommand VCEUnLoadWithSMIF =>
  301. __VCEUnLoadWithSMIF ?? (__VCEUnLoadWithSMIF = new DelegateCommand(vceUnLoadWithSMIF));
  302. private DelegateCommand _VCEUnLoad;
  303. public DelegateCommand VCEUnLoad =>
  304. _VCEUnLoad ?? (_VCEUnLoad = new DelegateCommand(vceUnLoad));
  305. private DelegateCommand _SMIFLoad;
  306. public DelegateCommand SMIFLoad =>
  307. _SMIFLoad ?? (_SMIFLoad = new DelegateCommand(smifLoad));
  308. private DelegateCommand _SMIFULoad;
  309. public DelegateCommand SMIFULoad =>
  310. _SMIFULoad ?? (_SMIFULoad = new DelegateCommand(smifUnLoad));
  311. private DelegateCommand _tmhome;
  312. public DelegateCommand TmHome =>
  313. _tmhome ?? (_tmhome = new DelegateCommand(tmhome));
  314. private DelegateCommand _tmPick;
  315. public DelegateCommand TmPick =>
  316. _tmPick ?? (_tmPick = new DelegateCommand(tmpick));
  317. private DelegateCommand _tmPlace;
  318. public DelegateCommand TMPlace =>
  319. _tmPlace ?? (_tmPlace = new DelegateCommand(tmplace));
  320. private DelegateCommand _tmSave;
  321. private DelegateCommand _LoadCommand;
  322. public DelegateCommand LoadCommand =>
  323. _LoadCommand ?? (_LoadCommand = new DelegateCommand(OnLoad));
  324. private DelegateCommand _PauseAllJobCommand;
  325. public DelegateCommand PauseAllJobCommand =>
  326. _PauseAllJobCommand ?? (_PauseAllJobCommand = new DelegateCommand(OnPauseAllJob));
  327. private DelegateCommand _AbortAllCommand;
  328. public DelegateCommand AbortAllCommand =>
  329. _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll));
  330. private DelegateCommand<object> _SetSequenceCommand;
  331. public DelegateCommand<object> SetSequenceCommand =>
  332. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  333. private DelegateCommand<object> _CreateJobCommand;
  334. public DelegateCommand<object> CreateJobCommand =>
  335. _CreateJobCommand ?? (_CreateJobCommand = new DelegateCommand<object>(OnCreateJob));
  336. private DelegateCommand<object> _SelectAllCommand;
  337. public DelegateCommand<object> SelectAllCommand =>
  338. _SelectAllCommand ?? (_SelectAllCommand = new DelegateCommand<object>(OnSelectAll));
  339. private DelegateCommand<object> _ReturnAllWafer;
  340. public DelegateCommand<object> ReturnAllWafer =>
  341. _ReturnAllWafer ?? (_ReturnAllWafer = new DelegateCommand<object>(OnReturnAllWafer));
  342. #endregion
  343. #region 构造函数
  344. public VenusSeOperationOverViewModel()
  345. {
  346. //页面不刷错的方法 页面中的PM做成List的形式 通过itemsource显示 同时提供各个位置的pm点位 旋转角度
  347. VCE1WaferCount = 25;
  348. string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');
  349. PMAIsInstalled = allModules.Contains("PMA");
  350. PMBIsInstalled = allModules.Contains("PMB");
  351. PMCIsInstalled = allModules.Contains("PMC");
  352. VCEIsInstalled = allModules.Contains("VCE1");
  353. addDataKeys();
  354. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  355. VCEDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESlitDoorClosed");
  356. PMADoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMASlitDoorClosed");
  357. PMBDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMBSlitDoorClosed");
  358. PMCDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMCSlitDoorClosed");
  359. VCEOutDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "VCE1.VCEOutDoorClosed");
  360. loadflag = false;
  361. DispatcherTimer timer = new DispatcherTimer();
  362. timer.Interval = TimeSpan.FromSeconds(0.1);
  363. timer.Tick += Timer_Tick;
  364. timer.Start();
  365. }
  366. #endregion
  367. #region 命令实现
  368. private void OnLoad()
  369. {
  370. if (VCEIsInstalled && !loadflag)
  371. {
  372. VCEwaferAssociation = new WaferAssociationInfo
  373. {
  374. ModuleData = ModuleManager.ModuleInfos["VCE1"]
  375. };
  376. loadflag = true;
  377. }
  378. }
  379. private void OnSelectAll(object obj)
  380. {
  381. var info = obj as WaferAssociationInfo;
  382. info.SlotFrom = 1;
  383. info.SlotTo = 25;
  384. AssociateSequence(info, true);
  385. }
  386. private void OnReturnAllWafer(object obj)
  387. {
  388. WaferDialogView dialog = new WaferDialogView()
  389. {
  390. Owner = Application.Current.MainWindow,
  391. };
  392. dialog.Height = 300;
  393. dialog.Width = 400;
  394. double angel = 0;
  395. double coolingtime = 0;
  396. string message = "Please Confirm Return Wafer";
  397. WaferDialogViewModel vm = new WaferDialogViewModel();
  398. vm.ConfirmText = message;
  399. dialog.DataContext = vm;
  400. if (dialog.ShowDialog() == true)
  401. {
  402. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  403. {
  404. angel = Convert.ToDouble(dialog.Angle);
  405. }
  406. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  407. {
  408. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  409. }
  410. InvokeClient.Instance.Service.DoOperation("System.ReturnAllSEWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel);
  411. }
  412. }
  413. private void OnCreateJob(object obj)
  414. {
  415. var info = obj as WaferAssociationInfo;
  416. List<string> slotSequence = new List<string>();
  417. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  418. string jobId = info.LotId.Trim();
  419. if (string.IsNullOrEmpty(jobId))
  420. jobId = "CJ_Local_" + info.ModuleData.ModuleID;
  421. info.LotId = jobId;
  422. info.JobID = jobId;
  423. info.JobStatus = "WaitingForStart";
  424. info.LotIdSaved = true;
  425. Dictionary<string, object> param = new Dictionary<string, object>()
  426. {
  427. {"JobId", jobId},
  428. {"Module", info.ModuleData.ModuleID},
  429. {"SlotSequence", slotSequence.ToArray()},
  430. {"AutoStart", true},
  431. };
  432. InvokeClient.Instance.Service.DoOperation("System.CreateSEJob", param);
  433. }
  434. private void OnSetSequence(object obj)
  435. {
  436. var info = obj as WaferInfo;
  437. bool flag = info.SequenceName != "" ? false : true;
  438. if (info.ModuleID == "VCE1")
  439. {
  440. AssociateSequence(VCEwaferAssociation, flag, info.SlotID);
  441. }
  442. }
  443. private void OnPauseAllJob()
  444. {
  445. InvokeClient.Instance.Service.DoOperation("System.PauseJob", VCEwaferAssociation.JobID);
  446. }
  447. private void OnAbortAll()
  448. {
  449. InvokeClient.Instance.Service.DoOperation("System.SEAbort");
  450. }
  451. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  452. {
  453. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  454. if (slot >= 0) //by wafer
  455. {
  456. int index = wafers.Count - slot - 1;
  457. if (index < wafers.Count)
  458. {
  459. //has wafer
  460. if (flag && !(wafers[index].WaferStatus == 0))
  461. wafers[index].SequenceName = info.SequenceName;
  462. else
  463. wafers[index].SequenceName = string.Empty;
  464. }
  465. }
  466. else //by from-to
  467. {
  468. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  469. {
  470. int index = wafers.Count - i - 1;
  471. if (index < wafers.Count)
  472. {
  473. if (flag && !(wafers[index].WaferStatus == 0))
  474. wafers[index].SequenceName = info.SequenceName;
  475. else
  476. wafers[index].SequenceName = string.Empty;
  477. }
  478. }
  479. }
  480. if (VCEIsInstalled)
  481. {
  482. VCEwaferAssociation = info;
  483. }
  484. }
  485. private void addDataKeys()
  486. {
  487. m_RtDataKeys.Add($"SETM.VCESlitDoorClosed");
  488. m_RtDataKeys.Add($"SETM.PMASlitDoorClosed");
  489. m_RtDataKeys.Add($"SETM.PMBSlitDoorClosed");
  490. m_RtDataKeys.Add($"SETM.PMCSlitDoorClosed");
  491. m_RtDataKeys.Add($"SETM.VCEPressure.Value");
  492. m_RtDataKeys.Add($"VCE1.VCEOutDoorClosed");
  493. m_RtDataKeys.Add($"VCE1.CassetteArrive");
  494. m_RtDataKeys.Add($"SEScheduler.CycledWafer");
  495. m_RtDataKeys.Add($"SEScheduler.CycleSetPoint");
  496. m_RtDataKeys.Add($"SEScheduler.CycleCount");
  497. m_RtDataKeys.Add($"SEScheduler.ThroughPut");
  498. if (PMAIsInstalled)
  499. {
  500. m_RtDataKeys.Add($"PMA.ProcessHighPressure");
  501. m_RtDataKeys.Add($"PMA.VentingFlag");
  502. m_RtDataKeys.Add($"PMA.CurrentRecipeResult");
  503. }
  504. if (PMBIsInstalled)
  505. {
  506. m_RtDataKeys.Add($"PMB.ProcessHighPressure");
  507. m_RtDataKeys.Add($"PMB.VentingFlag");
  508. m_RtDataKeys.Add($"PMB.CurrentRecipeResult");
  509. }
  510. if (PMCIsInstalled)
  511. {
  512. m_RtDataKeys.Add($"PMC.ProcessHighPressure");
  513. m_RtDataKeys.Add($"PMC.VentingFlag");
  514. m_RtDataKeys.Add($"PMC.CurrentRecipeResult");
  515. }
  516. }
  517. private void onHomeAll()
  518. {
  519. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  520. }
  521. private void onSetAutoMode()
  522. {
  523. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  524. }
  525. private void onSetManualMode()
  526. {
  527. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  528. }
  529. private void onStopCycle()
  530. {
  531. InvokeClient.Instance.Service.DoOperation("System.StopSECycle");
  532. }
  533. private void onStartSETMCycle()
  534. {
  535. List<string> stations = new List<string>();
  536. stations.Add("VCE1");
  537. stations.Add("VPA");
  538. if (PMAIsInstalled)
  539. {
  540. stations.Add("PMA");
  541. }
  542. if (PMBIsInstalled)
  543. {
  544. stations.Add("PMB");
  545. }
  546. if (PMCIsInstalled)
  547. {
  548. stations.Add("PMC");
  549. }
  550. stations.Add("VCE1");
  551. InvokeClient.Instance.Service.DoOperation("System.SETMCycle", stations.ToArray(), 1);
  552. }
  553. private void OnStart(object obj)
  554. {
  555. var info = obj as WaferAssociationInfo;
  556. InvokeClient.Instance.Service.DoOperation("System.StartSEJob", info.LotId);
  557. }
  558. private void vceHome()
  559. {
  560. InvokeClient.Instance.Service.DoOperation("VCE1.HOME");
  561. }
  562. private void vceReadMap()
  563. {
  564. InvokeClient.Instance.Service.DoOperation("VCE1.ReadMap");
  565. }
  566. private void vceLoadPrepare()
  567. {
  568. InvokeClient.Instance.Service.DoOperation("VCE1.LoadPrepare");
  569. }
  570. private void vceLoad()
  571. {
  572. InvokeClient.Instance.Service.DoOperation("VCE1.SafeLoad");
  573. }
  574. private void vceLoadWithSMIF()
  575. {
  576. InvokeClient.Instance.Service.DoOperation("VCE1.LoadWithSMIF");
  577. }
  578. private void vceUnLoadWithSMIF()
  579. {
  580. InvokeClient.Instance.Service.DoOperation("VCE1.UnLoadWithSMIF");
  581. }
  582. private void vceUnLoad()
  583. {
  584. InvokeClient.Instance.Service.DoOperation("VCE1.SafeUnload");
  585. }
  586. private void smifLoad() { }
  587. private void smifUnLoad() { }
  588. private void tmhome()
  589. {
  590. InvokeClient.Instance.Service.DoOperation("SETM.Home");
  591. }
  592. private void tmpick()
  593. {
  594. ModuleName target = ModuleName.VCE1;
  595. int slot = PickNum;
  596. MoveItem moveItem = new MoveItem(target, slot - 1, ModuleName.TMRobot, 0, 0);
  597. Queue<MoveItem> que = new Queue<MoveItem>();
  598. que.Enqueue(moveItem);
  599. InvokeClient.Instance.Service.DoOperation("SETM.Pick", que);
  600. }
  601. private void tmplace()
  602. {
  603. ModuleName target = ModuleName.VCE1;
  604. int slot = PickNum;
  605. MoveItem moveItem = new MoveItem( ModuleName.TMRobot, 0, target, slot - 1, 0);
  606. Queue<MoveItem> que = new Queue<MoveItem>();
  607. que.Enqueue(moveItem);
  608. InvokeClient.Instance.Service.DoOperation("SETM.Place", que);
  609. }
  610. #endregion
  611. #region 私有方法
  612. private void Timer_Tick(object sender, EventArgs e)
  613. {
  614. try
  615. {
  616. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  617. VCEDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.VCESlitDoorClosed");
  618. PMADoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMASlitDoorClosed");
  619. PMBDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMBSlitDoorClosed");
  620. PMCDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "SETM.PMCSlitDoorClosed");
  621. VCEOutDoorIsOpen = !CommonFunction.GetValue<bool>(RtDataValues, "VCE1.VCEOutDoorClosed");
  622. VCEPercent = CommonFunction.GetValue<double>(RtDataValues, "SETM.VCEPressure.Value") * 260 / 750000;
  623. if (PMAIsInstalled == true)
  624. {
  625. PMAModuleInfo = ModuleManager.ModuleInfos["PMA"];
  626. PMAWafer = PMAModuleInfo.WaferManager.Wafers[0];
  627. PMAPercent = CommonFunction.GetValue<double>(RtDataValues, "PMA.ProcessHighPressure") * 260 / 750000;
  628. PMARecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, "PMA.CurrentRecipeResult");
  629. }
  630. if (PMBIsInstalled == true)
  631. {
  632. PMBModuleInfo = ModuleManager.ModuleInfos["PMB"];
  633. PMBWafer = PMBModuleInfo.WaferManager.Wafers[0];
  634. PMBPercent = CommonFunction.GetValue<double>(RtDataValues, "PMB.ProcessHighPressure") * 260 / 750000;
  635. PMBRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, "PMB.CurrentRecipeResult");
  636. }
  637. if (PMCIsInstalled == true)
  638. {
  639. PMCModuleInfo = ModuleManager.ModuleInfos["PMC"];
  640. PMCWafer = PMCModuleInfo.WaferManager.Wafers[0];
  641. PMCPercent = CommonFunction.GetValue<double>(RtDataValues, "PMC.ProcessHighPressure") * 260 / 750000;
  642. PMCRecipeResult = CommonFunction.GetValue<RecipeResult>(RtDataValues, "PMC.CurrentRecipeResult");
  643. }
  644. if (VCEIsInstalled == true)
  645. {
  646. VCE1ModuleInfo = ModuleManager.ModuleInfos["VCE1"];
  647. }
  648. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("SETM.RobotMoveAction");
  649. TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];
  650. RobotUpperWafer = TMModuleInfo.WaferManager.Wafers[0];
  651. RobotLowerWafer = TMModuleInfo.WaferManager.Wafers[1];
  652. PAWafer = ModuleManager.ModuleInfos["VPA"].WaferManager.Wafers[0];
  653. }
  654. catch (Exception ex)
  655. {
  656. }
  657. }
  658. #endregion
  659. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  660. {
  661. string RobotTarget;
  662. if (oldValue == null || newValue == null)
  663. {
  664. return;
  665. }
  666. #region Rotating
  667. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  668. {
  669. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  670. if (TMRobotMoveActionBladeTarget != null)
  671. {
  672. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  673. }
  674. else
  675. {
  676. return;
  677. }
  678. var values = RobotTarget.Split('.');
  679. var arm = values[0];
  680. var module = values[1];
  681. if (arm == "ArmA")
  682. {
  683. Robot1TAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  684. }
  685. else if (arm == "ArmB")
  686. {
  687. Robot2TAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  688. }
  689. }
  690. #endregion
  691. #region VPA、VCE1 Pick、Place
  692. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  693. {
  694. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  695. var TMRobotMoveActionBladeCurrent = oldValue.BladeTarget;
  696. if (TMRobotMoveActionBladeTarget != null)
  697. {
  698. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  699. }
  700. else
  701. {
  702. return;
  703. }
  704. var values = RobotTarget.Split('.');
  705. var arm = values[0];
  706. var module = values[1];
  707. if (arm == "ArmA")
  708. {
  709. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  710. if (SERobotTAction != Robot1TAction)
  711. {
  712. Robot1TAction = SERobotTAction;
  713. }
  714. else
  715. {
  716. //await Task.Delay(100);
  717. }
  718. await Task.Delay(600);
  719. if (module == "VCE1")
  720. {
  721. Robot1XAction = SERobotXAction.ToVCE;
  722. }
  723. else
  724. {
  725. Robot1XAction = SERobotXAction.Extend;
  726. }
  727. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  728. {
  729. await Task.Delay(100);
  730. }
  731. Robot1XAction = SERobotXAction.Retract;
  732. }
  733. else if (arm == "ArmB")
  734. {
  735. var waferRobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  736. if (waferRobotTAction != Robot2TAction)
  737. {
  738. Robot2TAction = waferRobotTAction;
  739. }
  740. else
  741. {
  742. //await Task.Delay(100);
  743. }
  744. await Task.Delay(600);
  745. if (module == "VCE1")
  746. {
  747. Robot2XAction = SERobotXAction.ToVCE;
  748. }
  749. else
  750. {
  751. Robot2XAction = SERobotXAction.Extend;
  752. }
  753. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))
  754. {
  755. await Task.Delay(100);
  756. }
  757. Robot2XAction = SERobotXAction.Retract;
  758. }
  759. }
  760. #endregion
  761. #region PM pick、PM place
  762. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  763. {
  764. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  765. if (TMRobotMoveActionBladeTarget != null)
  766. {
  767. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  768. }
  769. else
  770. {
  771. return;
  772. }
  773. var values = RobotTarget.Split('.');
  774. var arm = values[0];
  775. var module = values[1];
  776. if (arm == "ArmA")
  777. {
  778. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  779. if (SERobotTAction != Robot1TAction)
  780. {
  781. Robot1TAction = SERobotTAction;
  782. }
  783. else
  784. {
  785. // await Task.Delay(100);
  786. }
  787. await Task.Delay(600);
  788. Robot1XAction = SERobotXAction.Extend;
  789. }
  790. else if (arm == "ArmB")
  791. {
  792. var SERobotTAction = (SERobotTAction)Enum.Parse(typeof(SERobotTAction), module, true);
  793. if (SERobotTAction != Robot2TAction)
  794. {
  795. Robot2TAction = SERobotTAction;
  796. }
  797. else
  798. {
  799. // await Task.Delay(100);
  800. }
  801. await Task.Delay(600);
  802. Robot2XAction = SERobotXAction.Extend;
  803. }
  804. }
  805. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  806. {
  807. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  808. if (TMRobotMoveActionBladeTarget != null)
  809. {
  810. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  811. }
  812. else
  813. {
  814. return;
  815. }
  816. var values = RobotTarget.Split('.');
  817. var arm = values[0];
  818. if (arm == "ArmA")
  819. {
  820. Robot1XAction = SERobotXAction.Retract;
  821. }
  822. else if (arm == "ArmB")
  823. {
  824. Robot2XAction = SERobotXAction.Retract;
  825. }
  826. }
  827. #endregion
  828. #region Home
  829. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  830. {
  831. if (Robot1XAction == SERobotXAction.Extend)
  832. {
  833. Robot1XAction = SERobotXAction.Retract;
  834. }
  835. if (Robot2XAction == SERobotXAction.Extend)
  836. {
  837. Robot2XAction = SERobotXAction.Retract;
  838. }
  839. await Task.Delay(2000);
  840. if (Robot1TAction != SERobotTAction.T_Origin)
  841. {
  842. Robot1TAction = SERobotTAction.T_Origin;
  843. }
  844. if (Robot2TAction != SERobotTAction.T_Origin)
  845. {
  846. Robot2TAction = SERobotTAction.T_Origin;
  847. }
  848. }
  849. #endregion
  850. }
  851. }
  852. }