OverViewModel.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Windows;
  5. using Aitex.Core.Common.DeviceData;
  6. using Aitex.Core.Util;
  7. using Aitex.Sorter.Common;
  8. using Bolt.Toolkit.Wpf.Data;
  9. using Bolt.Toolkit.Wpf.Data.Enum;
  10. using Caliburn.Micro;
  11. using MECF.Framework.Common.DataCenter;
  12. using MECF.Framework.Common.OperationCenter;
  13. using MECF.Framework.Common.RecipeCenter;
  14. using OpenSEMI.ClientBase;
  15. using VirgoCommon;
  16. using VirgoUI.Client.Dialog;
  17. using VirgoUI.Client.Models.Operate.WaferAssociation;
  18. using VirgoUI.Client.Models.Platform.LoadPort;
  19. using VirgoUI.Client.Models.Recipe;
  20. using VirgoUI.Client.Models.Sys;
  21. namespace VirgoUI.Client.Models.Operate
  22. {
  23. public class OverViewModel : UiViewModelBase
  24. {
  25. #region Property
  26. private int MenuPermission;
  27. #region PM
  28. public string PMABackground
  29. {
  30. get
  31. {
  32. if (!PMAIsOnline)
  33. return "Red";
  34. if (PMAServiceStatus == PMState.Error.ToString())
  35. return "Red";
  36. if (PMAServiceStatus == PMState.Idle.ToString()
  37. || PMAServiceStatus == PMState.Init.ToString())
  38. {
  39. return "Transparent";
  40. }
  41. return "Green";
  42. }
  43. }
  44. public string PMBBackground
  45. {
  46. get
  47. {
  48. if (!PMBIsOnline)
  49. return "Red";
  50. if (PMBServiceStatus == PMState.Error.ToString())
  51. return "Red";
  52. if (PMBServiceStatus == PMState.Idle.ToString()
  53. || PMBServiceStatus == PMState.Init.ToString())
  54. {
  55. return "Transparent";
  56. }
  57. return "Green";
  58. }
  59. }
  60. #endregion
  61. #region EFEM
  62. private WaferAssociationInfo _lp1WaferAssociation;
  63. public WaferAssociationInfo LP1WaferAssociation
  64. {
  65. get { return _lp1WaferAssociation; }
  66. set { _lp1WaferAssociation = value; }
  67. }
  68. private WaferAssociationInfo _lp2WaferAssociation;
  69. public WaferAssociationInfo LP2WaferAssociation
  70. {
  71. get { return _lp2WaferAssociation; }
  72. set { _lp2WaferAssociation = value; }
  73. }
  74. public string LP1ProcStatus
  75. {
  76. get
  77. {
  78. if (LP1WaferAssociation.JobStatus == "")
  79. {
  80. return "Idle";
  81. }
  82. return LP1WaferAssociation.JobStatus;
  83. }
  84. }
  85. public string LP2ProcStatus
  86. {
  87. get
  88. {
  89. if (LP2WaferAssociation.JobStatus == "")
  90. {
  91. return "Idle";
  92. }
  93. return LP2WaferAssociation.JobStatus;
  94. }
  95. }
  96. private string[] _LP1StatusColor = new string[2];
  97. public string[] LP1StatusColor
  98. {
  99. get
  100. {
  101. switch (LP1ProcStatus)
  102. {
  103. case "Idle":
  104. _LP1StatusColor[0] = "Gold";
  105. _LP1StatusColor[1] = "Black";
  106. break;
  107. case "WaitingForStart":
  108. _LP1StatusColor[0] = "Blue";
  109. _LP1StatusColor[1] = "White";
  110. break;
  111. case "Executing":
  112. _LP1StatusColor[0] = "Cyan";
  113. _LP1StatusColor[1] = "Black";
  114. break;
  115. case "Paused":
  116. _LP1StatusColor[0] = "Blue";
  117. _LP1StatusColor[1] = "White";
  118. break;
  119. default:
  120. _LP1StatusColor[0] = "Gold";
  121. _LP1StatusColor[1] = "Black";
  122. break;
  123. }
  124. return _LP1StatusColor;
  125. }
  126. }
  127. private string[] _LP2StatusColor = new string[2];
  128. public string[] LP2StatusColor
  129. {
  130. get
  131. {
  132. switch (LP2ProcStatus)
  133. {
  134. case "Idle":
  135. _LP2StatusColor[0] = "Gold";
  136. _LP2StatusColor[1] = "Black";
  137. break;
  138. case "WaitingForStart":
  139. _LP2StatusColor[0] = "Blue";
  140. _LP2StatusColor[1] = "White";
  141. break;
  142. case "Executing":
  143. _LP2StatusColor[0] = "Cyan";
  144. _LP2StatusColor[1] = "Black";
  145. break;
  146. case "Paused":
  147. _LP2StatusColor[0] = "Blue";
  148. _LP2StatusColor[1] = "White";
  149. break;
  150. default:
  151. _LP2StatusColor[0] = "Gold";
  152. _LP2StatusColor[1] = "Black";
  153. break;
  154. }
  155. return _LP2StatusColor;
  156. }
  157. }
  158. [Subscription("LP1.CassetteState")]
  159. public LoadportCassetteState LP1CassetteState { get; set; }
  160. [Subscription("LP1.FoupDoorState")]
  161. public FoupDoorState LP1DoorState { get; set; }
  162. [Subscription("LP2.CassetteState")]
  163. public LoadportCassetteState LP2CassetteState { get; set; }
  164. [Subscription("LP2.FoupDoorState")]
  165. public FoupDoorState LP2DoorState { get; set; }
  166. [Subscription("EfemRobot.RobotMoveAction")]
  167. public string EfemRobotMoveAction
  168. {
  169. get;
  170. set;
  171. }
  172. public bool Foup1Present
  173. {
  174. get { return LP1CassetteState == LoadportCassetteState.Normal; }
  175. }
  176. public bool Foup2Present
  177. {
  178. get { return LP2CassetteState == LoadportCassetteState.Normal; }
  179. }
  180. public RobotMoveInfo EfemRobotMoveInfo
  181. {
  182. get
  183. {
  184. RobotMoveInfo _moveInfo = new RobotMoveInfo() { BladeTarget = "System" };
  185. if (!string.IsNullOrEmpty(EfemRobotMoveAction))
  186. {
  187. var action = EfemRobotMoveAction.Split('.');
  188. _moveInfo.BladeTarget = action[0];
  189. _moveInfo.Action = (RobotAction)Enum.Parse(typeof(RobotAction), action[1]);
  190. }
  191. return _moveInfo;
  192. }
  193. }
  194. [Subscription("LP1.JobDone")]
  195. public bool LP1JobDone { get; set; }
  196. [Subscription("LP2.JobDone")]
  197. public bool LP2JobDone { get; set; }
  198. [Subscription("LP1.WaferSize")]
  199. public string LP1WaferSize { get; set; }
  200. public string WaferSizeLP1
  201. {
  202. get { return LP1CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP1WaferSize) : "--"; }
  203. }
  204. [Subscription("LP2.WaferSize")]
  205. public string LP2WaferSize { get; set; }
  206. public string WaferSizeLP2
  207. {
  208. get { return LP2CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP2WaferSize) : "--"; }
  209. }
  210. [Subscription("Aligner1.WaferSize")]
  211. public string Aligner1WaferSize { get; set; }
  212. public string WaferSizeAligner1
  213. {
  214. get { return GetWaferSize(Aligner1WaferSize); }
  215. }
  216. [Subscription("Aligner2.WaferSize")]
  217. public string Aligner2WaferSize { get; set; }
  218. public string WaferSizeAligner2
  219. {
  220. get { return GetWaferSize(Aligner2WaferSize); }
  221. }
  222. [Subscription("Cooling1.WaferSize")]
  223. public string Cooling1WaferSize { get; set; }
  224. public string WaferSizeCooling1
  225. {
  226. get { return GetWaferSize(Cooling1WaferSize); }
  227. }
  228. [Subscription("Cooling2.WaferSize")]
  229. public string Cooling2WaferSize { get; set; }
  230. public string WaferSizeCooling2
  231. {
  232. get { return GetWaferSize(Cooling2WaferSize); }
  233. }
  234. [Subscription("EfemRobot.WaferSize")]
  235. public string EfemRobotWaferSize { get; set; }
  236. public string WaferSizeEfemRobot
  237. {
  238. get { return GetWaferSize(EfemRobotWaferSize); }
  239. }
  240. [Subscription("PMA.WaferSize")]
  241. public string PMAWaferSize { get; set; }
  242. public string WaferSizePMA
  243. {
  244. get { return GetWaferSize(PMAWaferSize); }
  245. }
  246. [Subscription("PMB.WaferSize")]
  247. public string PMBWaferSize { get; set; }
  248. public string WaferSizePMB
  249. {
  250. get { return GetWaferSize(PMBWaferSize); }
  251. }
  252. [Subscription("PMA.IsAutoMode")]
  253. public bool PMAIsAutoMode { get; set; }
  254. [Subscription("PMB.IsAutoMode")]
  255. public bool PMBIsAutoMode { get; set; }
  256. [Subscription("PMA.IsOnline")]
  257. public bool PMAIsOnline { get; set; }
  258. [Subscription("PMB.IsOnline")]
  259. public bool PMBIsOnline { get; set; }
  260. public string PMAState
  261. {
  262. get
  263. {
  264. return "PMA/" + (PMAIsAutoMode ? "Auto/" : "Manual/") + (PMAIsOnline ? "Online" : "Offline");
  265. }
  266. }
  267. public string PMBState
  268. {
  269. get
  270. {
  271. return "PMB/" + (PMBIsAutoMode ? "Auto/" : "Manual/") + (PMBIsOnline ? "Online" : "Offline");
  272. }
  273. }
  274. [Subscription("EFEM.SmallWafer")]
  275. public int SmallWafer { get; set; }
  276. [Subscription("EFEM.MidWafer")]
  277. public int MidWafer { get; set; }
  278. [Subscription("EFEM.BigWafer")]
  279. public int BigWafer { get; set; }
  280. //[Subscription("EFEM.CassetteDoor")]
  281. //public AITSensorData CassetteDoorStatus
  282. //{
  283. // get;
  284. // set;
  285. //}
  286. [Subscription("EFEM.CassetteDoor")]
  287. public LidState CassetteDoorStatus
  288. {
  289. get;
  290. set;
  291. }
  292. public Visibility CassetteDoorIsOpened
  293. {
  294. get
  295. {
  296. return CassetteDoorStatus == LidState.Open ? Visibility.Visible : Visibility.Hidden;
  297. }
  298. }
  299. public Dictionary<string, string> _waferSizeMap = new Dictionary<string, string>()
  300. {
  301. {"WS3", "3'"},{"WS4", "4'"},{"WS6", "6'"}
  302. };
  303. private string GetWaferSize(string size)
  304. {
  305. if (size != null && _waferSizeMap.ContainsKey(size))
  306. switch (size)
  307. {
  308. case "WS3": return SmallWafer.ToString();
  309. case "WS4": return MidWafer.ToString();
  310. case "WS6": return BigWafer.ToString();
  311. default: return "";
  312. }
  313. //return _waferSizeMap[size];
  314. return "";
  315. }
  316. public DoorState Chamber1DoorState
  317. {
  318. get { return DoorState.Unknown; }
  319. }
  320. public DoorState Chamber2DoorState
  321. {
  322. get { return DoorState.Unknown; }
  323. }
  324. public bool EnableAuto
  325. {
  326. get { return !IsAutoMode; }
  327. }
  328. public bool EnableManual
  329. {
  330. get { return IsAutoMode; }
  331. }
  332. public bool IsRtInitialized
  333. {
  334. get { return false; }
  335. }
  336. public bool EnableMapLP1
  337. {
  338. get
  339. {
  340. return Foup1Present && CassetteDoorStatus == LidState.Close;
  341. }
  342. }
  343. public bool EnableMapLP2
  344. {
  345. get
  346. {
  347. return Foup2Present && CassetteDoorStatus == LidState.Close;
  348. }
  349. }
  350. public bool EnableJobLP1
  351. {
  352. get { return IsAutoMode; }
  353. }
  354. public bool EnableJobLP2
  355. {
  356. get { return IsAutoMode; }
  357. }
  358. #region Mainframe
  359. public bool ButtonControl { get; set; }
  360. [Subscription("Aligner.Status")]
  361. public string AlignerStatus { get; set; }
  362. [Subscription("EFEM.Status")]
  363. public string EFEMStatus { get; set; }
  364. [Subscription("LP1.Status")]
  365. public string LP1Status { get; set; }
  366. [Subscription("LP2.Status")]
  367. public string LP2Status { get; set; }
  368. #endregion Mainframe
  369. #region PM
  370. public string PMALabel
  371. {
  372. get;
  373. set;
  374. }
  375. public string PMBLabel
  376. {
  377. get;
  378. set;
  379. }
  380. [Subscription("PMA.FsmState")]
  381. public string PMAServiceStatus { get; set; }
  382. [Subscription("PMA.RecipeName")]
  383. public string PMARecipeName { get; set; }
  384. [Subscription("PMA.RecipeProcessTime")]
  385. public string PMARemainTime { get; set; }
  386. [Subscription("PMA.StepNo")]
  387. public int PMAStepNo { get; set; }
  388. [Subscription("PMA.RecipeStepName")]
  389. public string PMAStepName { get; set; }
  390. [Subscription("PMA.ChamberPressure")]
  391. public double PMAChamberPressure { get; set; }
  392. [Subscription("PMA.HeaterChamber.Temperature")]
  393. public double PMATemperature { get; set; }
  394. [Subscription("PMA.Chiller.CoolantOutletTempFeedback")]
  395. public double PMAChillerTemperature { get; set; }
  396. public bool PMASlitValveIsOpen
  397. {
  398. get { return SlitDoorDataA != null && SlitDoorDataA.OpenFeedback && !SlitDoorDataA.CloseFeedback; }
  399. }
  400. [Subscription("PMA.SlitDoor.DeviceData")]
  401. public AITCylinderData SlitDoorDataA
  402. {
  403. get;
  404. set;
  405. }
  406. [Subscription("PMB.FsmState")]
  407. public string PMBServiceStatus { get; set; }
  408. [Subscription("PMB.RecipeName")]
  409. public string PMBRecipeName { get; set; }
  410. [Subscription("PMB.RecipeProcessTime")]
  411. public string PMBRemainTime { get; set; }
  412. [Subscription("PMB.StepNo")]
  413. public string PMBStepNo { get; set; }
  414. [Subscription("PMB.RecipeStepName")]
  415. public string PMBStepName { get; set; }
  416. [Subscription("PMB.ChamberPressure")]
  417. public double PMBChamberPressure { get; set; }
  418. [Subscription("PMB.HeaterChamber.Temperature")]
  419. public double PMBTemperature { get; set; }
  420. [Subscription("PMB.Chiller.CoolantOutletTempFeedback")]
  421. public double PMBChillerTemperature { get; set; }
  422. public bool PMBSlitValveIsOpen
  423. {
  424. get { return SlitDoorDataB != null && SlitDoorDataB.OpenFeedback && !SlitDoorDataB.CloseFeedback; }
  425. }
  426. [Subscription("PMB.SlitDoor.DeviceData")]
  427. public AITCylinderData SlitDoorDataB
  428. {
  429. get;
  430. set;
  431. }
  432. public bool IsPMAChillerVisibility
  433. {
  434. get
  435. {
  436. return (bool)QueryDataClient.Instance.Service.GetConfig($"PMA.Chiller.EnableChiller");
  437. }
  438. }
  439. public bool IsPMBChillerVisibility
  440. {
  441. get
  442. {
  443. return (bool)QueryDataClient.Instance.Service.GetConfig($"PMB.Chiller.EnableChiller");
  444. }
  445. }
  446. public bool IsPMAHeaterVisibility
  447. {
  448. get
  449. {
  450. return !IsPMAChillerVisibility;
  451. }
  452. }
  453. public bool IsPMBHeaterVisibility
  454. {
  455. get
  456. {
  457. return !IsPMBChillerVisibility;
  458. }
  459. }
  460. #endregion PM
  461. #region Scheduler
  462. [Subscription("System.IsAutoMode")]
  463. public bool IsAutoMode { get; set; }
  464. public bool _isCycleMode;
  465. public bool _isATMMode;
  466. public Visibility IsCycleInfoVisibility
  467. {
  468. get { return _isCycleMode ? Visibility.Visible : Visibility.Hidden; }
  469. }
  470. public Visibility IsATMInfoVisibility
  471. {
  472. get { return _isATMMode ? Visibility.Visible : Visibility.Hidden; }
  473. }
  474. //[Subscription("Scheduler.CycledCount")]
  475. //public int CycledCount { get; set; }
  476. //[Subscription("Scheduler.CycledWafer")]
  477. //public int CycledWafer { get; set; }
  478. [Subscription("Scheduler.LP1CycledWafer")]
  479. public int LP1CycledWafer { get; set; }
  480. [Subscription("Scheduler.LP2CycledWafer")]
  481. public int LP2CycledWafer { get; set; }
  482. [Subscription("Scheduler.LP1CycledCount")]
  483. public int LP1CycledCount { get; set; }
  484. [Subscription("Scheduler.LP2CycledCount")]
  485. public int LP2CycledCount { get; set; }
  486. [Subscription("Scheduler.LP1CycleSetPoint")]
  487. public int LP1CycleSetPoint { get; set; }
  488. [Subscription("Scheduler.LP2CycleSetPoint")]
  489. public int LP2CycleSetPoint { get; set; }
  490. public string LP1CycleCountDisplay
  491. {
  492. get { return (LP1CycleSetPoint > 0 && (LP1CycledCount > LP1CycleSetPoint)) ? $"{LP1CycledCount + 1}/{LP1CycleSetPoint}" : $"{LP1CycledCount}/{LP1CycleSetPoint}"; }
  493. }
  494. public string LP2CycleCountDisplay
  495. {
  496. get { return (LP2CycleSetPoint > 0 && (LP2CycledCount > LP2CycleSetPoint)) ? $"{LP2CycledCount + 1}/{LP2CycleSetPoint}" : $"{LP2CycledCount}/{LP2CycleSetPoint}"; }
  497. }
  498. [Subscription("LP1.CurrentRecipeList")]
  499. public List<string> LP1CurrentRecipeList { get; set; }
  500. [Subscription("LP1.LocalJobName")]
  501. public string LP1JobName { get; set; }
  502. [Subscription("LP1.LocalJobStatus")]
  503. public string LP1JobStatus { get; set; }
  504. [Subscription("LP1.JobLotName")]
  505. public string LP1JobLotName { get; set; }
  506. [Subscription("LP2.CurrentRecipeList")]
  507. public List<string> LP2CurrentRecipeList { get; set; }
  508. [Subscription("LP2.LocalJobName")]
  509. public string LP2JobName { get; set; }
  510. [Subscription("LP2.LocalJobStatus")]
  511. public string LP2JobStatus { get; set; }
  512. [Subscription("LP2.JobLotName")]
  513. public string LP2JobLotName { get; set; }
  514. public bool IsPauseAllEnable => LP1JobStatus == "Executing" || LP2JobStatus == "Executing";
  515. #endregion Scheduler
  516. #endregion EFEM
  517. #endregion Property
  518. public OverViewModel()
  519. {
  520. this.DisplayName = "OverView";
  521. }
  522. protected override void OnInitialize()
  523. {
  524. base.OnInitialize();
  525. base.InitModules();
  526. LP1WaferAssociation = new WaferAssociationInfo();
  527. LP1WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP1"];
  528. LP2WaferAssociation = new WaferAssociationInfo();
  529. LP2WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP2"];
  530. }
  531. protected override void OnActivate()
  532. {
  533. base.OnActivate();
  534. _isCycleMode = (bool)QueryDataClient.Instance.Service.GetConfig("System.IsCycleMode");
  535. _isATMMode = (bool)QueryDataClient.Instance.Service.GetConfig("System.IsATMMode");
  536. PMALabel = (string)QueryDataClient.Instance.Service.GetConfig("PMA.ChamberLabel");
  537. PMBLabel = (string)QueryDataClient.Instance.Service.GetConfig("PMB.ChamberLabel");
  538. }
  539. public void Start()
  540. {
  541. if (MenuPermission != 3) return;
  542. InvokeClient.Instance.Service.DoOperation("System.StartAutoRun");
  543. }
  544. public void Stop()
  545. {
  546. //InvokeClient.Instance.Service.DoOperation("System.StartAutoRun");
  547. }
  548. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  549. {
  550. MenuPermission = ClientApp.Instance.GetPermission("Overview");
  551. ModuleTemperature["PMA"] = (float)PMATemperature;
  552. ModuleTemperature["PMB"] = (float)PMBTemperature;
  553. LP1WaferAssociation.JobID = LP1JobName;
  554. LP1WaferAssociation.JobStatus = LP1JobStatus;
  555. LP2WaferAssociation.JobID = LP2JobName;
  556. LP2WaferAssociation.JobStatus = LP2JobStatus;
  557. LP1WaferAssociation.JobID = LP1JobName;
  558. LP1WaferAssociation.JobStatus = LP1JobStatus;
  559. if (!string.IsNullOrEmpty(LP1JobName))
  560. LP1WaferAssociation.LotId = LP1JobLotName;
  561. LP2WaferAssociation.JobID = LP2JobName;
  562. LP2WaferAssociation.JobStatus = LP2JobStatus;
  563. if (!string.IsNullOrEmpty(LP2JobName))
  564. LP2WaferAssociation.LotId = LP2JobLotName;
  565. if (!string.IsNullOrEmpty(LP1JobStatus) && LP1JobStatus == "Executing")
  566. {
  567. var wafers = LP1WaferAssociation.ModuleData.WaferManager.Wafers;
  568. for (int i = 0; i < wafers.Count; i++)
  569. {
  570. wafers[i].SequenceName = LP1CurrentRecipeList[wafers[i].SlotID];
  571. }
  572. }
  573. if (!string.IsNullOrEmpty(LP2JobStatus) && LP2JobStatus == "Executing")
  574. {
  575. var wafers = LP2WaferAssociation.ModuleData.WaferManager.Wafers;
  576. for (int i = 0; i < wafers.Count; i++)
  577. {
  578. wafers[i].SequenceName = LP2CurrentRecipeList[wafers[i].SlotID];
  579. }
  580. }
  581. if (LP1CassetteState != LoadportCassetteState.Normal)
  582. {
  583. foreach (var wafer in LP1WaferAssociation.ModuleData.WaferManager.Wafers)
  584. {
  585. wafer.SequenceName = "";
  586. }
  587. }
  588. if (LP2CassetteState != LoadportCassetteState.Normal)
  589. {
  590. foreach (var wafer in LP2WaferAssociation.ModuleData.WaferManager.Wafers)
  591. {
  592. wafer.SequenceName = "";
  593. }
  594. }
  595. FOUPA.IsJobDone = LP1JobDone;
  596. FOUPB.IsJobDone = LP2JobDone;
  597. }
  598. #region LP Operation
  599. public void MapLP(string moduleID)
  600. {
  601. if (MenuPermission != 3) return;
  602. LoadPortProvider.Instance.MapLP(moduleID);
  603. }
  604. public void HomeAll()
  605. {
  606. if (MenuPermission != 3) return;
  607. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  608. }
  609. public void ReturnAllWafer()
  610. {
  611. if (MenuPermission != 3) return;
  612. WindowManager wm = new WindowManager();
  613. bool needCooling = false;
  614. int coolingTime = 0;
  615. WaferTransferDialogViewModel _transferVM = new WaferTransferDialogViewModel("Would the wafer need cooling?", false, true, "");
  616. bool? bret = wm.ShowDialogWithNoStyle(_transferVM);
  617. if ((bool)bret)
  618. {
  619. //get and use transfer conditions
  620. WaferTransferCondition conditions = _transferVM.DialogResult;
  621. needCooling = conditions.IsPassCooling;
  622. coolingTime = conditions.CoolingTime;
  623. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", needCooling, coolingTime);
  624. }
  625. //InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", needCooling, coolingTime);
  626. }
  627. public void PauseAllJob()
  628. {
  629. if (!string.IsNullOrEmpty(LP1WaferAssociation.JobID))
  630. WaferAssociationProvider.Instance.Pause(LP1WaferAssociation.JobID);
  631. if (!string.IsNullOrEmpty(LP2WaferAssociation.JobID))
  632. WaferAssociationProvider.Instance.Pause(LP2WaferAssociation.JobID);
  633. }
  634. public void Abort()
  635. {
  636. if (MenuPermission != 3) return;
  637. InvokeClient.Instance.Service.DoOperation("System.Abort");
  638. }
  639. public void Auto()
  640. {
  641. if (MenuPermission != 3) return;
  642. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  643. }
  644. public void Manual()
  645. {
  646. if (MenuPermission != 3) return;
  647. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  648. }
  649. #endregion LP Operation
  650. #region Sequence operation
  651. public void SelectSequence(WaferAssociationInfo info)
  652. {
  653. if (MenuPermission != 3) return;
  654. SequenceDialogViewModel dialog = new SequenceDialogViewModel();
  655. dialog.DisplayName = "Select Sequence";
  656. dialog.Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles(
  657. RecipeClient.Instance.Service.GetSequenceNameList()
  658. ));
  659. WindowManager wm = new WindowManager();
  660. bool? bret = wm.ShowDialog(dialog);
  661. if ((bool)bret)
  662. {
  663. info.SequenceName = dialog.DialogResult;
  664. }
  665. }
  666. public void SetSlot(WaferAssociationInfo info)
  667. {
  668. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  669. AssociateSequence(info, true);
  670. }
  671. public void SkipSlot(WaferAssociationInfo info)
  672. {
  673. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  674. AssociateSequence(info, false);
  675. }
  676. public void SetAll(WaferAssociationInfo info)
  677. {
  678. if (MenuPermission != 3) return;
  679. info.SlotFrom = 1;
  680. info.SlotTo = 25;
  681. AssociateSequence(info, true);
  682. }
  683. public void DeselectAll(WaferAssociationInfo info)
  684. {
  685. if (MenuPermission != 3) return;
  686. info.SlotFrom = 1;
  687. info.SlotTo = 25;
  688. AssociateSequence(info, false);
  689. }
  690. public void SetSequence(WaferAssociationInfo info, int slotIndex, string seqName)
  691. {
  692. bool flag = string.IsNullOrEmpty(seqName);
  693. AssociateSequence(info, flag, slotIndex - 1);
  694. }
  695. private bool InputSlotCheck(int from, int to)
  696. {
  697. if (from > to)
  698. {
  699. DialogBox.ShowInfo("This index of from slot should be large than the index of to slot.");
  700. return false;
  701. }
  702. if (from < 1 || to > 25)
  703. {
  704. DialogBox.ShowInfo("This input value for from should be between 1 and 25.");
  705. return false;
  706. }
  707. return true;
  708. }
  709. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  710. {
  711. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  712. if (slot >= 0) //by wafer
  713. {
  714. int index = wafers.Count - slot - 1;
  715. if (index < wafers.Count)
  716. {
  717. if (flag && HasWaferOnSlot(wafers, index))
  718. wafers[index].SequenceName = info.SequenceName;
  719. else
  720. wafers[index].SequenceName = string.Empty;
  721. }
  722. }
  723. else //by from-to
  724. {
  725. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  726. {
  727. int index = wafers.Count - i - 1;
  728. if (index < wafers.Count)
  729. {
  730. if (flag && HasWaferOnSlot(wafers, index))
  731. wafers[index].SequenceName = info.SequenceName;
  732. else
  733. wafers[index].SequenceName = string.Empty;
  734. }
  735. }
  736. }
  737. }
  738. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  739. {
  740. if (wafers[index].WaferStatus == 0)
  741. return false;
  742. return true;
  743. }
  744. public int LP1WaferCount
  745. {
  746. get
  747. {
  748. int iWaferCount = 0;
  749. foreach (var Wafers in ModuleManager.ModuleInfos["LP1"].WaferManager.Wafers)
  750. {
  751. if (Wafers.WaferStatus != 0)
  752. {
  753. iWaferCount++;
  754. }
  755. }
  756. return iWaferCount;
  757. }
  758. }
  759. public string LP1WaferCountInfo
  760. {
  761. get
  762. {
  763. return $"Wafer数量:{LP1WaferCount}";
  764. }
  765. }
  766. public int LP2WaferCount
  767. {
  768. get
  769. {
  770. int iWaferCount = 0;
  771. foreach (var Wafers in ModuleManager.ModuleInfos["LP2"].WaferManager.Wafers)
  772. {
  773. if (Wafers.WaferStatus != 0)
  774. {
  775. iWaferCount++;
  776. }
  777. }
  778. return iWaferCount;
  779. }
  780. }
  781. public string LP2WaferCountInfo
  782. {
  783. get
  784. {
  785. return $"Wafer数量:{LP2WaferCount}";
  786. }
  787. }
  788. #endregion Sequence operation
  789. #region Job operation
  790. private bool JobCheck(string jobID)
  791. {
  792. if (jobID.Length == 0)
  793. {
  794. DialogBox.ShowWarning("Please create job first.");
  795. return false;
  796. }
  797. else
  798. return true;
  799. }
  800. public void CreateJob(WaferAssociationInfo info)
  801. {
  802. if (MenuPermission != 3) return;
  803. List<string> slotSequence = new List<string>();
  804. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  805. string jobId = info.LotId.Trim();
  806. if (string.IsNullOrEmpty(jobId))
  807. jobId = "CJ_Local_" + info.ModuleData.ModuleID;
  808. info.LotId = jobId;
  809. info.LotIdSaved = true;
  810. WaferAssociationProvider.Instance.CreateJob(jobId, info.ModuleData.ModuleID, slotSequence, true);
  811. }
  812. public void AbortJob(string jobID)
  813. {
  814. if (MenuPermission != 3) return;
  815. if (JobCheck(jobID))
  816. WaferAssociationProvider.Instance.AbortJob(jobID);
  817. }
  818. public void Start(string jobID)
  819. {
  820. if (MenuPermission != 3) return;
  821. if (JobCheck(jobID))
  822. WaferAssociationProvider.Instance.Start(jobID);
  823. }
  824. public void Pause(string jobID)
  825. {
  826. if (MenuPermission != 3) return;
  827. if (JobCheck(jobID))
  828. WaferAssociationProvider.Instance.Pause(jobID);
  829. }
  830. public void Resume(string jobID)
  831. {
  832. if (MenuPermission != 3) return;
  833. if (JobCheck(jobID))
  834. WaferAssociationProvider.Instance.Resume(jobID);
  835. }
  836. public void Stop(string jobID)
  837. {
  838. if (MenuPermission != 3) return;
  839. if (JobCheck(jobID))
  840. WaferAssociationProvider.Instance.Stop(jobID);
  841. }
  842. #endregion Job operation
  843. }
  844. }