OverViewModel.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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 Virgo_DUI.Client.Models.Operate.WaferAssociation;
  16. using Virgo_DUI.Client.Models.Platform.LoadPort;
  17. using Virgo_DUI.Client.Models.Recipe;
  18. using Virgo_DUI.Client.Models.Sys;
  19. namespace Virgo_DUI.Client.Models.Operate
  20. {
  21. public class OverViewModel : UiViewModelBase
  22. {
  23. #region Property
  24. #region EFEM
  25. private WaferAssociationInfo _lp1WaferAssociation;
  26. public WaferAssociationInfo LP1WaferAssociation
  27. {
  28. get { return _lp1WaferAssociation; }
  29. set { _lp1WaferAssociation = value; }
  30. }
  31. private WaferAssociationInfo _lp2WaferAssociation;
  32. public WaferAssociationInfo LP2WaferAssociation
  33. {
  34. get { return _lp2WaferAssociation; }
  35. set { _lp2WaferAssociation = value; }
  36. }
  37. [Subscription("LP1.CassetteState")]
  38. public LoadportCassetteState LP1CassetteState { get; set; }
  39. [Subscription("LP1.FoupDoorState")]
  40. public FoupDoorState LP1DoorState { get; set; }
  41. [Subscription("LP2.CassetteState")]
  42. public LoadportCassetteState LP2CassetteState { get; set; }
  43. [Subscription("LP2.FoupDoorState")]
  44. public FoupDoorState LP2DoorState { get; set; }
  45. [Subscription("EfemRobot.RobotMoveAction")]
  46. public string EfemRobotMoveAction
  47. {
  48. get;
  49. set;
  50. }
  51. public bool Foup1Present
  52. {
  53. get { return LP1CassetteState == LoadportCassetteState.Normal; }
  54. }
  55. public bool Foup2Present
  56. {
  57. get { return LP2CassetteState == LoadportCassetteState.Normal; }
  58. }
  59. public RobotMoveInfo EfemRobotMoveInfo
  60. {
  61. get
  62. {
  63. RobotMoveInfo _moveInfo = new RobotMoveInfo() { BladeTarget = "System" };
  64. if (!string.IsNullOrEmpty(EfemRobotMoveAction))
  65. {
  66. var action = EfemRobotMoveAction.Split('.');
  67. _moveInfo.BladeTarget = action[0];
  68. _moveInfo.Action = (RobotAction)Enum.Parse(typeof(RobotAction), action[1]);
  69. }
  70. return _moveInfo;
  71. }
  72. }
  73. [Subscription("LP1.WaferSize")]
  74. public string LP1WaferSize { get; set; }
  75. public string WaferSizeLP1
  76. {
  77. get { return LP1CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP1WaferSize) : "--"; }
  78. }
  79. [Subscription("LP2.WaferSize")]
  80. public string LP2WaferSize { get; set; }
  81. public string WaferSizeLP2
  82. {
  83. get { return LP2CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP2WaferSize) : "--"; }
  84. }
  85. [Subscription("Aligner1.WaferSize")]
  86. public string Aligner1WaferSize { get; set; }
  87. public string WaferSizeAligner1
  88. {
  89. get { return GetWaferSize(Aligner1WaferSize); }
  90. }
  91. [Subscription("Aligner2.WaferSize")]
  92. public string Aligner2WaferSize { get; set; }
  93. public string WaferSizeAligner2
  94. {
  95. get { return GetWaferSize(Aligner2WaferSize); }
  96. }
  97. [Subscription("EfemRobot.WaferSize")]
  98. public string EfemRobotWaferSize { get; set; }
  99. public string WaferSizeEfemRobot
  100. {
  101. get { return GetWaferSize(EfemRobotWaferSize); }
  102. }
  103. [Subscription("PMA.WaferSize")]
  104. public string PMAWaferSize { get; set; }
  105. public string WaferSizePMA
  106. {
  107. get { return GetWaferSize(PMAWaferSize); }
  108. }
  109. [Subscription("PMB.WaferSize")]
  110. public string PMBWaferSize { get; set; }
  111. public string WaferSizePMB
  112. {
  113. get { return GetWaferSize(PMBWaferSize); }
  114. }
  115. //[Subscription("EFEM.CassetteDoor")]
  116. //public AITSensorData CassetteDoorStatus
  117. //{
  118. // get;
  119. // set;
  120. //}
  121. [Subscription("EFEM.CassetteDoor")]
  122. public LidState CassetteDoorStatus
  123. {
  124. get;
  125. set;
  126. }
  127. public Dictionary<string, string> _waferSizeMap = new Dictionary<string, string>()
  128. {
  129. {"WS3", "3'"},{"WS4", "4'"},{"WS6", "6'"}
  130. };
  131. private string GetWaferSize(string size)
  132. {
  133. if (size != null && _waferSizeMap.ContainsKey(size))
  134. return _waferSizeMap[size];
  135. return "";
  136. }
  137. public DoorState Chamber1DoorState
  138. {
  139. get { return DoorState.Unknown; }
  140. }
  141. public DoorState Chamber2DoorState
  142. {
  143. get { return DoorState.Unknown; }
  144. }
  145. public bool EnableAuto
  146. {
  147. get { return !IsAutoMode; }
  148. }
  149. public bool EnableManual
  150. {
  151. get { return IsAutoMode; }
  152. }
  153. public bool IsRtInitialized
  154. {
  155. get { return false; }
  156. }
  157. public bool EnableMapLP1
  158. {
  159. get { return Foup1Present; }
  160. }
  161. public bool EnableMapLP2
  162. {
  163. get { return Foup2Present; }
  164. }
  165. public bool EnableJobLP1
  166. {
  167. get { return IsAutoMode; }
  168. }
  169. public bool EnableJobLP2
  170. {
  171. get { return IsAutoMode; }
  172. }
  173. #region Mainframe
  174. public bool ButtonControl { get; set; }
  175. [Subscription("Aligner.Status")]
  176. public string AlignerStatus { get; set; }
  177. [Subscription("EFEM.Status")]
  178. public string EFEMStatus { get; set; }
  179. [Subscription("LP1.Status")]
  180. public string LP1Status { get; set; }
  181. [Subscription("LP2.Status")]
  182. public string LP2Status { get; set; }
  183. #endregion Mainframe
  184. #region PM
  185. [Subscription("PMA.FsmState")]
  186. public string PMAServiceStatus { get; set; }
  187. [Subscription("PMA.RecipeName")]
  188. public string PMARecipeName { get; set; }
  189. [Subscription("PMA.RecipeProcessTime")]
  190. public string PMARemainTime { get; set; }
  191. [Subscription("PMA.StepNo")]
  192. public int PMAStepNo { get; set; }
  193. [Subscription("PMA.RecipeStepName")]
  194. public string PMAStepName { get; set; }
  195. [Subscription("PMA.ChamberPressure")]
  196. public double PMAChamberPressure { get; set; }
  197. [Subscription("PMA.HeaterChamber.Temperature")]
  198. public double PMATemperature { get; set; }
  199. public bool PMASlitValveIsOpen
  200. {
  201. get { return SlitDoorDataA != null && SlitDoorDataA.OpenFeedback && !SlitDoorDataA.CloseFeedback; }
  202. }
  203. [Subscription("PMA.SlitDoor.DeviceData")]
  204. public AITCylinderData SlitDoorDataA
  205. {
  206. get;
  207. set;
  208. }
  209. [Subscription("PMB.FsmState")]
  210. public string PMBServiceStatus { get; set; }
  211. [Subscription("PMB.RecipeName")]
  212. public string PMBRecipeName { get; set; }
  213. [Subscription("PMB.RecipeProcessTime")]
  214. public string PMBRemainTime { get; set; }
  215. [Subscription("PMB.StepNo")]
  216. public string PMBStepNo { get; set; }
  217. [Subscription("PMB.RecipeStepName")]
  218. public string PMBStepName { get; set; }
  219. [Subscription("PMB.ChamberPressure")]
  220. public double PMBChamberPressure { get; set; }
  221. [Subscription("PMB.HeaterChamber.Temperature")]
  222. public double PMBTemperature { get; set; }
  223. public bool PMBSlitValveIsOpen
  224. {
  225. get { return SlitDoorDataB != null && SlitDoorDataB.OpenFeedback && !SlitDoorDataB.CloseFeedback; }
  226. }
  227. [Subscription("PMB.SlitDoor.DeviceData")]
  228. public AITCylinderData SlitDoorDataB
  229. {
  230. get;
  231. set;
  232. }
  233. #endregion PM
  234. #region Scheduler
  235. [Subscription("System.IsAutoMode")]
  236. public bool IsAutoMode { get; set; }
  237. public bool _isCycleMode;
  238. public Visibility IsCycleInfoVisibility
  239. {
  240. get { return _isCycleMode ? Visibility.Visible : Visibility.Hidden; }
  241. }
  242. [Subscription("Scheduler.CycledCount")]
  243. public int CycledCount { get; set; }
  244. [Subscription("Scheduler.CycledWafer")]
  245. public int CycledWafer { get; set; }
  246. [Subscription("Scheduler.CycleSetPoint")]
  247. public int CycleSetPoint { get; set; }
  248. public string CycleCountDisplay
  249. {
  250. get { return (CycleSetPoint > 0 && (CycledCount > CycleSetPoint)) ? $"{CycledCount + 1}/{CycleSetPoint}" : $"{CycledCount}/{CycleSetPoint}"; }
  251. }
  252. [Subscription("LP1.LocalJobName")]
  253. public string LP1JobName { get; set; }
  254. [Subscription("LP1.LocalJobStatus")]
  255. public string LP1JobStatus { get; set; }
  256. [Subscription("LP2.LocalJobName")]
  257. public string LP2JobName { get; set; }
  258. [Subscription("LP2.LocalJobStatus")]
  259. public string LP2JobStatus { get; set; }
  260. #endregion Scheduler
  261. #endregion EFEM
  262. #endregion Property
  263. public OverViewModel()
  264. {
  265. this.DisplayName = "OverView";
  266. }
  267. protected override void OnInitialize()
  268. {
  269. base.OnInitialize();
  270. base.InitModules();
  271. LP1WaferAssociation = new WaferAssociationInfo();
  272. LP1WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP1"];
  273. LP2WaferAssociation = new WaferAssociationInfo();
  274. LP2WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP2"];
  275. }
  276. protected override void OnActivate()
  277. {
  278. base.OnActivate();
  279. _isCycleMode = (bool)QueryDataClient.Instance.Service.GetConfig("System.IsCycleMode");
  280. }
  281. public void Start()
  282. {
  283. InvokeClient.Instance.Service.DoOperation("System.StartAutoRun");
  284. }
  285. public void Stop()
  286. {
  287. //InvokeClient.Instance.Service.DoOperation("System.StartAutoRun");
  288. }
  289. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  290. {
  291. ModuleTemperature["PMA"] = (float)PMATemperature;
  292. ModuleTemperature["PMB"] = (float)PMBTemperature;
  293. LP1WaferAssociation.JobID = LP1JobName;
  294. LP1WaferAssociation.JobStatus = LP1JobStatus;
  295. LP2WaferAssociation.JobID = LP2JobName;
  296. LP2WaferAssociation.JobStatus = LP2JobStatus;
  297. //if (LP1CassetteState != LoadportCassetteState.Normal )
  298. //{
  299. // foreach (var wafer in LP1WaferAssociation.ModuleData.WaferManager.Wafers)
  300. // {
  301. // wafer.SequenceName = "";
  302. // }
  303. //}
  304. //if (LP2CassetteState != LoadportCassetteState.Normal )
  305. //{
  306. // foreach (var wafer in LP2WaferAssociation.ModuleData.WaferManager.Wafers)
  307. // {
  308. // wafer.SequenceName = "";
  309. // }
  310. //}
  311. }
  312. #region LP Operation
  313. public void MapLP(string moduleID)
  314. {
  315. LoadPortProvider.Instance.MapLP(moduleID);
  316. }
  317. public void HomeAll()
  318. {
  319. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  320. }
  321. public void ReturnAllWafer()
  322. {
  323. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer");
  324. }
  325. public void Abort()
  326. {
  327. InvokeClient.Instance.Service.DoOperation("System.Abort");
  328. }
  329. public void Auto()
  330. {
  331. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  332. }
  333. public void Manual()
  334. {
  335. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  336. }
  337. #endregion LP Operation
  338. #region Sequence operation
  339. public void SelectSequence(WaferAssociationInfo info)
  340. {
  341. SequenceDialogViewModel dialog = new SequenceDialogViewModel();
  342. dialog.DisplayName = "Select Sequence";
  343. dialog.Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles(
  344. RecipeClient.Instance.Service.GetSequenceNameList()
  345. ));
  346. WindowManager wm = new WindowManager();
  347. bool? bret = wm.ShowDialog(dialog);
  348. if ((bool)bret)
  349. {
  350. info.SequenceName = dialog.DialogResult;
  351. }
  352. }
  353. public void SetSlot(WaferAssociationInfo info)
  354. {
  355. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  356. AssociateSequence(info, true);
  357. }
  358. public void SkipSlot(WaferAssociationInfo info)
  359. {
  360. if (InputSlotCheck(info.SlotFrom, info.SlotTo))
  361. AssociateSequence(info, false);
  362. }
  363. public void SetAll(WaferAssociationInfo info)
  364. {
  365. info.SlotFrom = 1;
  366. info.SlotTo = 25;
  367. AssociateSequence(info, true);
  368. }
  369. public void DeselectAll(WaferAssociationInfo info)
  370. {
  371. info.SlotFrom = 1;
  372. info.SlotTo = 25;
  373. AssociateSequence(info, false);
  374. }
  375. public void SetSequence(WaferAssociationInfo info, int slotIndex, string seqName)
  376. {
  377. bool flag = string.IsNullOrEmpty(seqName);
  378. AssociateSequence(info, flag, slotIndex - 1);
  379. }
  380. private bool InputSlotCheck(int from, int to)
  381. {
  382. if (from > to)
  383. {
  384. DialogBox.ShowInfo("This index of from slot should be large than the index of to slot.");
  385. return false;
  386. }
  387. if (from < 1 || to > 25)
  388. {
  389. DialogBox.ShowInfo("This input value for from should be between 1 and 25.");
  390. return false;
  391. }
  392. return true;
  393. }
  394. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  395. {
  396. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  397. if (slot >= 0) //by wafer
  398. {
  399. int index = wafers.Count - slot - 1;
  400. if (index < wafers.Count)
  401. {
  402. if (flag && HasWaferOnSlot(wafers, index))
  403. wafers[index].SequenceName = info.SequenceName;
  404. else
  405. wafers[index].SequenceName = string.Empty;
  406. }
  407. }
  408. else //by from-to
  409. {
  410. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  411. {
  412. int index = wafers.Count - i - 1;
  413. if (index < wafers.Count)
  414. {
  415. if (flag && HasWaferOnSlot(wafers, index))
  416. wafers[index].SequenceName = info.SequenceName;
  417. else
  418. wafers[index].SequenceName = string.Empty;
  419. }
  420. }
  421. }
  422. }
  423. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  424. {
  425. if (wafers[index].WaferStatus == 0)
  426. return false;
  427. return true;
  428. }
  429. #endregion Sequence operation
  430. #region Job operation
  431. private bool JobCheck(string jobID)
  432. {
  433. if (jobID.Length == 0)
  434. {
  435. DialogBox.ShowWarning("Please create job first.");
  436. return false;
  437. }
  438. else
  439. return true;
  440. }
  441. public void CreateJob(WaferAssociationInfo info)
  442. {
  443. List<string> slotSequence = new List<string>();
  444. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  445. WaferAssociationProvider.Instance.CreateJob("CJ_Local_" + info.ModuleData.ModuleID, info.ModuleData.ModuleID, slotSequence, true);
  446. }
  447. public void AbortJob(string jobID)
  448. {
  449. if (JobCheck(jobID))
  450. WaferAssociationProvider.Instance.AbortJob(jobID);
  451. }
  452. public void Start(string jobID)
  453. {
  454. if (JobCheck(jobID))
  455. WaferAssociationProvider.Instance.Start(jobID);
  456. }
  457. public void Pause(string jobID)
  458. {
  459. if (JobCheck(jobID))
  460. WaferAssociationProvider.Instance.Pause(jobID);
  461. }
  462. public void Resume(string jobID)
  463. {
  464. if (JobCheck(jobID))
  465. WaferAssociationProvider.Instance.Resume(jobID);
  466. }
  467. public void Stop(string jobID)
  468. {
  469. if (JobCheck(jobID))
  470. WaferAssociationProvider.Instance.Stop(jobID);
  471. }
  472. #endregion Job operation
  473. }
  474. }