OperationMultiLPViewModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. using Aitex.Core.Common;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.UI.Dialog;
  4. using Aitex.Core.UI.MVVM;
  5. using Aitex.Core.Util;
  6. using Aitex.Core.Utilities;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.OperationCenter;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Windows;
  12. using System.Windows.Input;
  13. using Aitex.Core.RT.SCCore;
  14. using System.Collections.ObjectModel;
  15. using Aitex.Sorter.UI.Controls;
  16. using Aitex.Sorter.UI.Controls.Common;
  17. using MECF.Framework.Common.DataCenter;
  18. using MECF.Framework.Common.Equipment;
  19. using MECF.Framework.Common.RecipeCenter;
  20. namespace Aitex.Sorter.UI.ViewModel
  21. {
  22. public abstract class OperationMultiLPViewModel : FoupListViewModelBase
  23. {
  24. public string FoupType { get; set; }
  25. #region command
  26. public ICommand OperationCommand
  27. {
  28. get;
  29. private set;
  30. }
  31. public ICommand RecipeSelectCommand
  32. {
  33. get;
  34. private set;
  35. }
  36. public ICommand RecipeStartCommand
  37. {
  38. get;
  39. private set;
  40. }
  41. public ICommand RecipePauseCommand
  42. {
  43. get;
  44. private set;
  45. }
  46. public ICommand RecipeResumeCommand
  47. {
  48. get;
  49. private set;
  50. }
  51. public ICommand RecipeStopCommand
  52. {
  53. get;
  54. private set;
  55. }
  56. #endregion
  57. #region Subscription
  58. [Subscription(ParamName.TranserThroughput, SystemStateModule)]
  59. public int TranserThroughput
  60. {
  61. get;
  62. set;
  63. }
  64. [Subscription(ParamName.TransferCount, SystemStateModule)]
  65. public int TransferCount
  66. {
  67. get;
  68. set;
  69. }
  70. [Subscription(ParamName.CycleCount, SystemStateModule)]
  71. public int CycleCount
  72. {
  73. get;
  74. set;
  75. }
  76. [Subscription(ParamName.TransferTime, SystemStateModule)]
  77. public int TransferTime
  78. {
  79. get;
  80. set;
  81. }
  82. [Subscription(ParamName.TotalCycleCount, SystemStateModule)]
  83. public int TotalCycleCount
  84. {
  85. get;
  86. set;
  87. }
  88. [Subscription(ParamName.TotalWaferCount, SystemStateModule)]
  89. public int TotalWaferCount
  90. {
  91. get;
  92. set;
  93. }
  94. [Subscription(ParamName.RTStatus, SystemStateModule)]
  95. public int RoutManagerState
  96. {
  97. get;
  98. set;
  99. }
  100. [Subscription(ParamName.WaferInfoRobotSlot01, "System")]
  101. public WaferInfo RobotWaferInfo1
  102. {
  103. get;
  104. set;
  105. }
  106. [Subscription(ParamName.WaferInfoRobotSlot02, "System")]
  107. public WaferInfo RobotWaferInfo2
  108. {
  109. get;
  110. set;
  111. }
  112. [Subscription(ParamName.ModuleWaferList, DeviceName.Aligner)]
  113. public WaferInfo[] AlignerWafers
  114. {
  115. get;
  116. set;
  117. }
  118. [Subscription(ParamName.ModuleWaferList, DeviceName.LL1)]
  119. public WaferInfo[] LLWaferInfos
  120. {
  121. get;
  122. set;
  123. }
  124. public WaferInfo AlignerWafer
  125. {
  126. get
  127. {
  128. if(AlignerWafers!=null)
  129. {
  130. return AlignerWafers[0];
  131. }
  132. else
  133. {
  134. return null;
  135. }
  136. }
  137. }
  138. public WaferInfo Loadlock1Wafer
  139. {
  140. get
  141. {
  142. if (LLWaferInfos != null)
  143. {
  144. return LLWaferInfos[0];
  145. }
  146. else
  147. {
  148. return null;
  149. }
  150. }
  151. }
  152. [Subscription(ParamName.AlignerState, DeviceName.Aligner)]
  153. public string AlignerState
  154. {
  155. get;
  156. set;
  157. }
  158. [Subscription(ParamName.RobotState, DeviceName.Robot)]
  159. public string RobotState
  160. {
  161. get;
  162. set;
  163. }
  164. [Subscription("State", DeviceName.Robot)]
  165. public string RobotFsmState
  166. {
  167. get;
  168. set;
  169. }
  170. [Subscription(ParamName.RobotSpeed, DeviceName.Robot)]
  171. public string RobotSpeed
  172. {
  173. get;
  174. set;
  175. }
  176. [Subscription("System.SensorPreAlignerWaferOn.DeviceData")]
  177. public AITSensorData SensorPreAlignerWaferOn
  178. {
  179. get;
  180. set;
  181. }
  182. [Subscription("System.SensorRobotFork2WaferOn.DeviceData")]
  183. public AITSensorData SensorRobotFork2WaferOn
  184. {
  185. get;
  186. set;
  187. }
  188. [Subscription("System.SensorRobotFork1WaferOn.DeviceData")]
  189. public AITSensorData SensorRobotFork1WaferOn
  190. {
  191. get;
  192. set;
  193. }
  194. [Subscription("System.SensorBufferWaferOn.DeviceData")]
  195. public AITSensorData SensorBufferWaferOn
  196. {
  197. get;
  198. set;
  199. }
  200. [Subscription("System.SensorCoolingStageSLOT1WaferON.DeviceData")]
  201. public AITSensorData SensorCoolingStageSLOT1WaferON
  202. {
  203. get;
  204. set;
  205. }
  206. [Subscription("System.SensorCoolingStageSLOT2WaferON.DeviceData")]
  207. public AITSensorData SensorCoolingStageSLOT2WaferON
  208. {
  209. get;
  210. set;
  211. }
  212. [Subscription("System.SensorCoolingStageSLOT3WaferON.DeviceData")]
  213. public AITSensorData SensorCoolingStageSLOT3WaferON
  214. {
  215. get;
  216. set;
  217. }
  218. [Subscription("System.SensorCoolingStageSLOT4WaferON.DeviceData")]
  219. public AITSensorData SensorCoolingStageSLOT4WaferON
  220. {
  221. get;
  222. set;
  223. }
  224. [Subscription("System.SensorCoolingStageSLOT5WaferON.DeviceData")]
  225. public AITSensorData SensorCoolingStageSLOT5WaferON
  226. {
  227. get;
  228. set;
  229. }
  230. [Subscription("System.SensorCoolingStageSLOT6WaferON.DeviceData")]
  231. public AITSensorData SensorCoolingStageSLOT6WaferON
  232. {
  233. get;
  234. set;
  235. }
  236. [Subscription("System.DiffPressure")]
  237. public double DiffPressure
  238. {
  239. get;
  240. set;
  241. }
  242. [Subscription("System.FFURpm")]
  243. public double FfuRpm
  244. {
  245. get;
  246. set;
  247. }
  248. // [Subscription(ParamName.IsAutoMode, SystemStateModule)]
  249. //public bool IsAutoMode { get; set; }
  250. [Subscription(ParamName.LocalControlJob, SystemStateModule)]
  251. public SorterRecipeXml LocalControlJob { get; set; }
  252. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportA)]
  253. public FoupDoorState LPADoorState
  254. {
  255. get;
  256. set;
  257. }
  258. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportB)]
  259. public FoupDoorState LPBDoorState
  260. {
  261. get;
  262. set;
  263. }
  264. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportC)]
  265. public FoupDoorState LPCDoorState
  266. {
  267. get;
  268. set;
  269. }
  270. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportD)]
  271. public FoupDoorState LPDDoorState
  272. {
  273. get;
  274. set;
  275. }
  276. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportE)]
  277. public FoupDoorState LPEDoorState
  278. {
  279. get;
  280. set;
  281. }
  282. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportF)]
  283. public FoupDoorState LPFDoorState
  284. {
  285. get;
  286. set;
  287. }
  288. [Subscription(ParamName.FoupClampState, DeviceName.LoadportA)]
  289. public FoupClampState FoupAClampState
  290. {
  291. get;
  292. set;
  293. }
  294. [Subscription(ParamName.FoupClampState, DeviceName.LoadportB)]
  295. public FoupClampState FoupBClampState
  296. {
  297. get;
  298. set;
  299. }
  300. [Subscription(ParamName.FoupClampState, DeviceName.LoadportC)]
  301. public FoupClampState FoupCClampState
  302. {
  303. get;
  304. set;
  305. }
  306. [Subscription(ParamName.FoupClampState, DeviceName.LoadportD)]
  307. public FoupClampState FoupDClampState
  308. {
  309. get;
  310. set;
  311. }
  312. [Subscription(ParamName.FoupClampState, DeviceName.LoadportE)]
  313. public FoupClampState FoupEClampState
  314. {
  315. get;
  316. set;
  317. }
  318. [Subscription(ParamName.FoupClampState, DeviceName.LoadportF)]
  319. public FoupClampState FoupFClampState
  320. {
  321. get;
  322. set;
  323. }
  324. private WaferInfo[] robotWafers;
  325. [Subscription(ParamName.ModuleWaferList, DeviceName.Robot)]
  326. public WaferInfo[] RobotWafers
  327. {
  328. get
  329. {
  330. return robotWafers;
  331. }
  332. set
  333. {
  334. robotWafers = value;
  335. RobotWafer1 = value[0];
  336. RobotWafer2 = value[1];
  337. }
  338. }
  339. public WaferInfo RobotWafer1
  340. {
  341. get;
  342. set;
  343. }
  344. public WaferInfo RobotWafer2
  345. {
  346. get;
  347. set;
  348. }
  349. #endregion
  350. #region Logic
  351. public Visibility CycleVisibility { get; set; }
  352. public string CycleCountDisplay
  353. {
  354. get { return $"{CycleCount}/{TotalCycleCount}"; }
  355. }
  356. public bool IsHomeAllButtonEnabled
  357. {
  358. get
  359. {
  360. return !IsAutoMode;
  361. }
  362. }
  363. public bool IsAbortHomeAllButtonEnabled
  364. {
  365. get
  366. {
  367. switch (RoutManagerState)
  368. {
  369. case (int)RtState.Init:
  370. return false;
  371. case (int)RtState.Initializing:
  372. case (int)RtState.ManualTransfer:
  373. case (int)RtState.Transfer:
  374. case (int)RtState.Cycle:
  375. case (int)RtState.PrepareCycle:
  376. case (int)RtState.PostCycle:
  377. case (int)RtState.Reset:
  378. case (int)RtState.Processing:
  379. case (int)RtState.PostProcess:
  380. case (int)RtState.PauseProcess:
  381. case (int)RtState.SetSpeed:
  382. return true;
  383. case (int)RtState.Error:
  384. case (int)RtState.Maintenance:
  385. return false;
  386. case (int)RtState.Idle:
  387. return false;
  388. default:
  389. return false;
  390. }
  391. }
  392. }
  393. public bool IsStartCycleButtonEnabled
  394. {
  395. get
  396. {
  397. return IsAutoMode;
  398. }
  399. }
  400. public bool IsReturnWaferButtonEnabled
  401. {
  402. get
  403. {
  404. return !IsAutoMode;
  405. }
  406. }
  407. public bool IsStopCycleButtonEnabled
  408. {
  409. get
  410. {
  411. return IsAutoMode;
  412. }
  413. }
  414. public bool IsManualMode
  415. {
  416. get
  417. {
  418. return !IsAutoMode;
  419. }
  420. }
  421. [IgnorePropertyChange]
  422. public string SelectedRecipeName
  423. {
  424. get;
  425. set;
  426. }
  427. public bool IsProcessing
  428. {
  429. get
  430. {
  431. return (RtState)RoutManagerState == RtState.PauseProcess || (RtState)RoutManagerState == RtState.Processing;
  432. }
  433. }
  434. public string RtStatus
  435. {
  436. get { return ((RtState)RoutManagerState).ToString(); }
  437. }
  438. public bool IsManualButtonEnabled
  439. {
  440. get
  441. {
  442. return IsAutoMode;
  443. }
  444. }
  445. public bool IsAutoButtonEnabled
  446. {
  447. get
  448. {
  449. return !IsAutoMode;
  450. }
  451. }
  452. public virtual bool IsEnableSelectRecipe
  453. {
  454. get
  455. {
  456. return IsAutoMode && !IsProcessing;
  457. }
  458. }
  459. public virtual bool IsEnableStartRecipe
  460. {
  461. get
  462. {
  463. return IsAutoMode && !string.IsNullOrEmpty(SelectedRecipeName) && !IsProcessing;
  464. }
  465. }
  466. public bool IsEnablePauseRecipe
  467. {
  468. get
  469. {
  470. return true ; ;//IsAutoMode && IsProcessing;
  471. }
  472. }
  473. public bool IsEnableResumeRecipe
  474. {
  475. get
  476. {
  477. return true;//IsAutoMode && IsProcessing;
  478. }
  479. }
  480. public bool IsEnableStopRecipe
  481. {
  482. get
  483. {
  484. return true; ;//IsAutoMode && IsProcessing;
  485. }
  486. }
  487. #endregion
  488. public OperationMultiLPViewModel(int foupCount) : base("OperationViewModal", foupCount)
  489. {
  490. OperationCommand = new DelegateCommand<string>(Operation);
  491. RecipeSelectCommand = new DelegateCommand<object>(SelectRecipe);
  492. RecipeStartCommand = new DelegateCommand<object>(StartRecipe);
  493. RecipePauseCommand = new DelegateCommand<object>(PauseRecipe);
  494. RecipeResumeCommand = new DelegateCommand<object>(ResumeRecipe);
  495. RecipeStopCommand = new DelegateCommand<object>(StopRecipe);
  496. }
  497. private void DeviceOperation(string cmd, object[] param)
  498. {
  499. InvokeClient.Instance.Service.DoOperation(cmd, param);
  500. }
  501. void Operation(string param)
  502. {
  503. InvokeClient.Instance.Service.DoOperation(param);
  504. }
  505. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  506. {
  507. base.InvokeBeforeUpdateProperty(data);
  508. }
  509. #region recipe
  510. private void SelectRecipe(object param)
  511. {
  512. RecipeSelectDialog dialog = new RecipeSelectDialog(RecipeClient.Instance.Service.GetXmlRecipeList(ModuleName.System, false))
  513. {
  514. Owner = Application.Current.MainWindow
  515. };
  516. var ret = dialog.ShowDialog();
  517. if (ret.HasValue && ret.Value)
  518. {
  519. SelectedRecipeName = dialog.SelectedRecipe;
  520. InvokePropertyChanged("SelectedRecipeName");
  521. InvokeClient.Instance.Service.DoOperation(OperationName.SelectRecipe, SelectedRecipeName);
  522. }
  523. }
  524. private void StartRecipe(object param)
  525. {
  526. if (string.IsNullOrEmpty(SelectedRecipeName))
  527. {
  528. return;
  529. }
  530. InvokeClient.Instance.Service.DoOperation(OperationName.StartRecipe, SelectedRecipeName);
  531. }
  532. private void PauseRecipe(object param)
  533. {
  534. if (MessageBox.Show("Are you sure you want to pause the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  535. {
  536. InvokeClient.Instance.Service.DoOperation(OperationName.PauseRecipe);
  537. }
  538. }
  539. private void ResumeRecipe(object param)
  540. {
  541. if (MessageBox.Show("Are you sure you want to resume the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  542. {
  543. InvokeClient.Instance.Service.DoOperation(OperationName.ResumeRecipe);
  544. }
  545. }
  546. private void StopRecipe(object param)
  547. {
  548. if (MessageBox.Show("Are you sure you want to abort the process?", "Sorter", MessageBoxButton.YesNo) ==
  549. MessageBoxResult.Yes)
  550. {
  551. InvokeClient.Instance.Service.DoOperation(OperationName.StopRecipe);
  552. }
  553. }
  554. #endregion
  555. }
  556. }