Operation4LPViewModel.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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 MECF.Framework.Common.DataCenter;
  15. using MECF.Framework.Common.Equipment;
  16. using MECF.Framework.Common.RecipeCenter;
  17. namespace Aitex.Sorter.UI.ViewModel
  18. {
  19. class Operation4LPViewModel : UIViewModelBase
  20. {
  21. private WaferInfo[] foupAWaferInfo;
  22. private WaferInfo[] foupBWaferInfo;
  23. private WaferInfo[] foupCWaferInfo;
  24. private WaferInfo[] foupDWaferInfo;
  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.TotalWaferCount, SystemStateModule)]
  83. public int TotalWaferCount
  84. {
  85. get;
  86. set;
  87. }
  88. [Subscription(ParamName.RTStatus, SystemStateModule)]
  89. public int RoutManagerState
  90. {
  91. get;
  92. set;
  93. }
  94. [Subscription(ParamName.WaferInfoFoupA, "System")]
  95. public WaferInfo[] FoupAWaferInfo
  96. {
  97. get
  98. {
  99. return foupAWaferInfo;
  100. }
  101. set
  102. {
  103. foupAWaferInfo = value.Reverse().ToArray();
  104. }
  105. }
  106. [Subscription(ParamName.WaferInfoFoupB, "System")]
  107. public WaferInfo[] FoupBWaferInfo
  108. {
  109. get
  110. {
  111. return foupBWaferInfo;
  112. }
  113. set
  114. {
  115. foupBWaferInfo = value.Reverse().ToArray();
  116. }
  117. }
  118. [Subscription(ParamName.WaferInfoFoupC, "System")]
  119. public WaferInfo[] FoupCWaferInfo
  120. {
  121. get
  122. {
  123. return foupCWaferInfo;
  124. }
  125. set
  126. {
  127. foupCWaferInfo = value.Reverse().ToArray();
  128. }
  129. }
  130. [Subscription(ParamName.WaferInfoFoupD, "System")]
  131. public WaferInfo[] FoupDWaferInfo
  132. {
  133. get
  134. {
  135. return foupDWaferInfo;
  136. }
  137. set
  138. {
  139. foupDWaferInfo = value.Reverse().ToArray();
  140. }
  141. }
  142. [Subscription(ParamName.WaferInfoRobotSlot01, "System")]
  143. public WaferInfo RobotWaferInfo1
  144. {
  145. get;
  146. set;
  147. }
  148. [Subscription(ParamName.WaferInfoRobotSlot02, "System")]
  149. public WaferInfo RobotWaferInfo2
  150. {
  151. get;
  152. set;
  153. }
  154. [Subscription(ParamName.WaferInfoRobotAligner01, "System")]
  155. public WaferInfo AlignerWaferInfo
  156. {
  157. get;
  158. set;
  159. }
  160. [Subscription(ParamName.LoadportState, DeviceName.LoadportA)]
  161. public string LoadportAState
  162. {
  163. get;
  164. set;
  165. }
  166. [Subscription(ParamName.LoadportState, DeviceName.LoadportB)]
  167. public string LoadportBState
  168. {
  169. get;
  170. set;
  171. }
  172. [Subscription(ParamName.LoadportState, DeviceName.LoadportC)]
  173. public string LoadportCState
  174. {
  175. get;
  176. set;
  177. }
  178. [Subscription(ParamName.LoadportState, DeviceName.LoadportD)]
  179. public string LoadportDState
  180. {
  181. get;
  182. set;
  183. }
  184. [Subscription(ParamName.AlignerState, DeviceName.Aligner)]
  185. public string AlignerState
  186. {
  187. get;
  188. set;
  189. }
  190. [Subscription(ParamName.RobotState, DeviceName.Robot)]
  191. public string RobotState
  192. {
  193. get;
  194. set;
  195. }
  196. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderA)]
  197. public string FoupAID
  198. {
  199. get;
  200. set;
  201. }
  202. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderB)]
  203. public string FoupBID
  204. {
  205. get;
  206. set;
  207. }
  208. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderC)]
  209. public string FoupCID
  210. {
  211. get;
  212. set;
  213. }
  214. [Subscription(ParamName.FoupID, DeviceName.RFIDReaderD)]
  215. public string FoupDID
  216. {
  217. get;
  218. set;
  219. }
  220. [Subscription(ParamName.RobotSpeed, DeviceName.Robot)]
  221. public string RobotSpeed
  222. {
  223. get;
  224. set;
  225. }
  226. [Subscription(ParamName.CassetteState, DeviceName.LoadportA)]
  227. public LoadportCassetteState LPACassetteState
  228. {
  229. get;
  230. set;
  231. }
  232. [Subscription(ParamName.CassetteState, DeviceName.LoadportB)]
  233. public LoadportCassetteState LPBCassetteState
  234. {
  235. get;
  236. set;
  237. }
  238. [Subscription(ParamName.CassetteState, DeviceName.LoadportC)]
  239. public LoadportCassetteState LPCCassetteState
  240. {
  241. get;
  242. set;
  243. }
  244. [Subscription(ParamName.CassetteState, DeviceName.LoadportD)]
  245. public LoadportCassetteState LPDCassetteState
  246. {
  247. get;
  248. set;
  249. }
  250. [Subscription(DeviceName.SensorPreAlignerWaferOn, SystemDeviceModule)]
  251. public AITSensorData SensorPreAlignerWaferOn
  252. {
  253. get;
  254. set;
  255. }
  256. [Subscription(DeviceName.SensorRobotFork2WaferOn, SystemDeviceModule)]
  257. public AITSensorData SensorRobotFork2WaferOn
  258. {
  259. get;
  260. set;
  261. }
  262. [Subscription(DeviceName.SensorRobotFork1WaferOn, SystemDeviceModule)]
  263. public AITSensorData SensorRobotFork1WaferOn
  264. {
  265. get;
  266. set;
  267. }
  268. public ICommand LoadPortACommand
  269. {
  270. get; set;
  271. }
  272. public ICommand LoadPortBCommand
  273. {
  274. get; set;
  275. }
  276. public ICommand LoadPortCCommand
  277. {
  278. get; set;
  279. }
  280. public ICommand LoadPortDCommand
  281. {
  282. get; set;
  283. }
  284. [Subscription(ParamName.IsAutoMode, SystemStateModule)]
  285. public bool IsAutoMode { get; set; }
  286. [Subscription(ParamName.LocalControlJob, SystemStateModule)]
  287. public SorterRecipeXml LocalControlJob { get; set; }
  288. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportA)]
  289. public FoupDoorState LPADoorState
  290. {
  291. get;
  292. set;
  293. }
  294. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportB)]
  295. public FoupDoorState LPBDoorState
  296. {
  297. get;
  298. set;
  299. }
  300. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportC)]
  301. public FoupDoorState LPCDoorState
  302. {
  303. get;
  304. set;
  305. }
  306. [Subscription(ParamName.FoupDoorState, DeviceName.LoadportD)]
  307. public FoupDoorState LPDDoorState
  308. {
  309. get;
  310. set;
  311. }
  312. [Subscription(ParamName.FoupClampState, DeviceName.LoadportA)]
  313. public FoupClampState FoupAClampState
  314. {
  315. get;
  316. set;
  317. }
  318. [Subscription(ParamName.FoupClampState, DeviceName.LoadportB)]
  319. public FoupClampState FoupBClampState
  320. {
  321. get;
  322. set;
  323. }
  324. [Subscription(ParamName.FoupClampState, DeviceName.LoadportC)]
  325. public FoupClampState FoupCClampState
  326. {
  327. get;
  328. set;
  329. }
  330. [Subscription(ParamName.FoupClampState, DeviceName.LoadportD)]
  331. public FoupClampState FoupDClampState
  332. {
  333. get;
  334. set;
  335. }
  336. #endregion
  337. #region Logic
  338. public Visibility CycleVisibility { get; set; }
  339. public bool IsHomeAllButtonEnabled
  340. {
  341. get
  342. {
  343. return !IsAutoMode;
  344. }
  345. }
  346. public bool IsAbortHomeAllButtonEnabled
  347. {
  348. get
  349. {
  350. return !IsAutoMode;
  351. }
  352. }
  353. public bool IsStartCycleButtonEnabled
  354. {
  355. get
  356. {
  357. return IsAutoMode;
  358. }
  359. }
  360. public bool IsReturnWaferButtonEnabled
  361. {
  362. get
  363. {
  364. return !IsAutoMode;
  365. }
  366. }
  367. public bool IsStopCycleButtonEnabled
  368. {
  369. get
  370. {
  371. return IsAutoMode;
  372. }
  373. }
  374. public bool IsManualMode
  375. {
  376. get
  377. {
  378. return !IsAutoMode;
  379. }
  380. }
  381. [IgnorePropertyChange]
  382. public string SelectedRecipeName
  383. {
  384. get;
  385. set;
  386. }
  387. public bool IsProcessing
  388. {
  389. get
  390. {
  391. return (RtState)RoutManagerState == RtState.PauseProcess || (RtState)RoutManagerState == RtState.Processing;
  392. }
  393. }
  394. public string RtStatus
  395. {
  396. get { return ((RtState)RoutManagerState).ToString(); }
  397. }
  398. public bool IsManualButtonEnabled
  399. {
  400. get
  401. {
  402. return IsAutoMode;
  403. }
  404. }
  405. public bool IsAutoButtonEnabled
  406. {
  407. get
  408. {
  409. return !IsAutoMode;
  410. }
  411. }
  412. public bool IsEnableSelectRecipe
  413. {
  414. get
  415. {
  416. return IsAutoMode && !IsProcessing;
  417. }
  418. }
  419. public bool IsEnableStartRecipe
  420. {
  421. get
  422. {
  423. return IsAutoMode && !string.IsNullOrEmpty(SelectedRecipeName) && !IsProcessing;
  424. }
  425. }
  426. public bool IsEnablePauseRecipe
  427. {
  428. get
  429. {
  430. return IsAutoMode && IsProcessing;
  431. }
  432. }
  433. public bool IsEnableResumeRecipe
  434. {
  435. get
  436. {
  437. return IsAutoMode && IsProcessing;
  438. }
  439. }
  440. public bool IsEnableStopRecipe
  441. {
  442. get
  443. {
  444. return IsAutoMode && IsProcessing;
  445. }
  446. }
  447. #endregion
  448. public Operation4LPViewModel() : base("OperationViewModal")
  449. {
  450. OperationCommand = new DelegateCommand<string>(Operation);
  451. LoadPortACommand = new DelegateCommand<string>(DoLoadPortACmd, x =>
  452. {
  453. bool result = (LoadportAState == DeviceState.Idle.ToString());
  454. if (result)
  455. {
  456. switch (x)
  457. {
  458. case OperationName.ReadFoupID:
  459. result = (LPACassetteState == LoadportCassetteState.Normal && FoupAClampState!= FoupClampState.Close);
  460. break;
  461. case OperationName.LoadFoup:
  462. result = (FoupAClampState == FoupClampState.Close && LPADoorState != FoupDoorState.Open);
  463. break;
  464. case OperationName.UnloadFoup:
  465. result = (LPACassetteState == LoadportCassetteState.Normal && FoupAClampState == FoupClampState.Close);
  466. break;
  467. default:
  468. result = false;
  469. break;
  470. }
  471. }
  472. return result;
  473. });
  474. LoadPortBCommand = new DelegateCommand<string>(DoLoadPortBCmd, x =>
  475. {
  476. bool result = (LoadportBState == DeviceState.Idle.ToString());
  477. if (result)
  478. {
  479. switch (x)
  480. {
  481. case OperationName.ReadFoupID:
  482. result = (LPBCassetteState == LoadportCassetteState.Normal && FoupBClampState == FoupClampState.Open);
  483. break;
  484. case OperationName.LoadFoup:
  485. result = (FoupBClampState == FoupClampState.Close && LPBDoorState == FoupDoorState.Close);
  486. break;
  487. case OperationName.UnloadFoup:
  488. result = (LPBCassetteState == LoadportCassetteState.Normal && FoupBClampState== FoupClampState.Close);
  489. break;
  490. default:
  491. result = false;
  492. break;
  493. }
  494. }
  495. return result;
  496. });
  497. LoadPortCCommand = new DelegateCommand<string>(DoLoadPortCCmd, x =>
  498. {
  499. bool result = (LoadportCState == DeviceState.Idle.ToString());
  500. if (result)
  501. {
  502. switch (x)
  503. {
  504. case OperationName.ReadFoupID:
  505. result = (LPCCassetteState == LoadportCassetteState.Normal && FoupCClampState == FoupClampState.Open);
  506. break;
  507. case OperationName.LoadFoup:
  508. result = (FoupCClampState == FoupClampState.Close && LPCDoorState == FoupDoorState.Close);
  509. break;
  510. case OperationName.UnloadFoup:
  511. result = (LPCCassetteState == LoadportCassetteState.Normal && FoupCClampState == FoupClampState.Close);
  512. break;
  513. default:
  514. result = false;
  515. break;
  516. }
  517. }
  518. return result;
  519. });
  520. LoadPortDCommand = new DelegateCommand<string>(DoLoadPortDCmd, x =>
  521. {
  522. bool result = (LoadportDState == DeviceState.Idle.ToString());
  523. if (result)
  524. {
  525. switch (x)
  526. {
  527. case OperationName.ReadFoupID:
  528. result = (LPDCassetteState == LoadportCassetteState.Normal && FoupDClampState == FoupClampState.Open);
  529. break;
  530. case OperationName.LoadFoup:
  531. result = (FoupDClampState == FoupClampState.Close && LPDDoorState == FoupDoorState.Close);
  532. break;
  533. case OperationName.UnloadFoup:
  534. result = (LPDCassetteState == LoadportCassetteState.Normal && FoupDClampState == FoupClampState.Close);
  535. break;
  536. default:
  537. result = false;
  538. break;
  539. }
  540. }
  541. return result;
  542. });
  543. RecipeSelectCommand = new DelegateCommand<object>(SelectRecipe);
  544. RecipeStartCommand = new DelegateCommand<object>(StartRecipe);
  545. RecipePauseCommand = new DelegateCommand<object>(PauseRecipe);
  546. RecipeResumeCommand = new DelegateCommand<object>(ResumeRecipe);
  547. RecipeStopCommand = new DelegateCommand<object>(StopRecipe);
  548. }
  549. private void DoLoadPortACmd(string cmd)
  550. {
  551. var deviceName = ModuleName.LP1;
  552. var param = new object[] { deviceName };
  553. DeviceOperation(cmd, param);
  554. }
  555. private void DoLoadPortBCmd(string cmd)
  556. {
  557. var deviceName = ModuleName.LP2;
  558. var param = new object[] { deviceName };
  559. DeviceOperation(cmd, param);
  560. }
  561. private void DoLoadPortCCmd(string cmd)
  562. {
  563. var deviceName = ModuleName.LP3;
  564. var param = new object[] { deviceName };
  565. DeviceOperation(cmd, param);
  566. }
  567. private void DoLoadPortDCmd(string cmd)
  568. {
  569. var deviceName = ModuleName.LP4;
  570. var param = new object[] { deviceName };
  571. DeviceOperation(cmd, param);
  572. }
  573. private void DeviceOperation(string cmd, object[] param)
  574. {
  575. InvokeClient.Instance.Service.DoOperation(cmd, param);
  576. }
  577. void Operation(string param)
  578. {
  579. InvokeClient.Instance.Service.DoOperation(param);
  580. }
  581. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  582. {
  583. CycleVisibility = ((bool) QueryDataClient.Instance.Service.GetConfig(SorterCommon.ScPathName.Process_CycleEnable) )? Visibility.Visible : Visibility.Hidden;
  584. //data[UIKey(UnitName.LoadportA.ToString(), ParamName.FoupDoorState)] = FoupDoorState.Close;
  585. }
  586. #region recipe
  587. private void SelectRecipe(object param)
  588. {
  589. RecipeSelectDialog dialog = new RecipeSelectDialog(RecipeClient.Instance.Service.GetXmlRecipeList(ModuleName.System, false))
  590. {
  591. Owner = Application.Current.MainWindow
  592. };
  593. var ret = dialog.ShowDialog();
  594. if (ret.HasValue && ret.Value)
  595. {
  596. SelectedRecipeName = dialog.SelectedRecipe;
  597. InvokePropertyChanged("SelectedRecipeName");
  598. InvokeClient.Instance.Service.DoOperation(OperationName.SelectRecipe, SelectedRecipeName);
  599. }
  600. }
  601. private void SelectLDULDRecipe(object param)
  602. {
  603. RecipeSelectDialog dialog = new RecipeSelectDialog(RecipeClient.Instance.Service.GetXmlRecipeList(ModuleName.LDULD, false))
  604. {
  605. Owner = Application.Current.MainWindow
  606. };
  607. var ret = dialog.ShowDialog();
  608. if (ret.HasValue && ret.Value)
  609. {
  610. SelectedRecipeName = dialog.SelectedRecipe;
  611. InvokePropertyChanged("SelectedRecipeName");
  612. InvokeClient.Instance.Service.DoOperation(OperationName.SelectRecipe, SelectedRecipeName);
  613. }
  614. }
  615. private void StartRecipe(object param)
  616. {
  617. if (string.IsNullOrEmpty(SelectedRecipeName))
  618. {
  619. return;
  620. }
  621. InvokeClient.Instance.Service.DoOperation(OperationName.StartRecipe, SelectedRecipeName);
  622. }
  623. private void PauseRecipe(object param)
  624. {
  625. if (MessageBox.Show("Are you sure you want to pause the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  626. {
  627. InvokeClient.Instance.Service.DoOperation(OperationName.PauseRecipe);
  628. }
  629. }
  630. private void ResumeRecipe(object param)
  631. {
  632. if (MessageBox.Show("Are you sure you want to resume the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  633. {
  634. InvokeClient.Instance.Service.DoOperation(OperationName.ResumeRecipe);
  635. }
  636. }
  637. private void StopRecipe(object param)
  638. {
  639. if (MessageBox.Show("Are you sure you want to stop the process?", "Sorter", MessageBoxButton.YesNo) ==
  640. MessageBoxResult.Yes)
  641. {
  642. InvokeClient.Instance.Service.DoOperation(OperationName.StopRecipe);
  643. }
  644. }
  645. #endregion
  646. }
  647. }