JobOperationViewModel.cs 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  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.Windows.Threading;
  12. using CyberX8_MainPages.Unity;
  13. using MECF.Framework.Common.Utilities;
  14. using MECF.Framework.Common.Jobs;
  15. using CyberX8_MainPages.PMs;
  16. using MECF.Framework.Common.RecipeCenter;
  17. using System.Collections.ObjectModel;
  18. using System.Windows.Media.Animation;
  19. namespace CyberX8_MainPages.ViewModels
  20. {
  21. internal class JobOperationViewModel : BindableBase
  22. {
  23. #region 私有字段
  24. /// <summary>
  25. /// LP1的Wafer相关信息
  26. /// </summary>
  27. private WaferAssociationInfo _lp1WaferAssociation;
  28. /// <summary>
  29. /// LP2的Wafer相关信息
  30. /// </summary>
  31. private WaferAssociationInfo _lp2WaferAssociation;
  32. /// <summary>
  33. /// LP3的Wafer相关信息
  34. /// </summary>
  35. private WaferAssociationInfo _lp3WaferAssociation;
  36. /// <summary>
  37. /// LP1的Wafer数量
  38. /// </summary>
  39. private int m_LP1WaferCount;
  40. /// <summary>
  41. /// LP2的Wafer数量
  42. /// </summary>
  43. private int m_LP2WaferCount;
  44. /// <summary>
  45. /// LP3的Wafer数量
  46. /// </summary>
  47. private int m_LP3WaferCount;
  48. /// <summary>
  49. /// RT查询数据字典
  50. /// </summary>
  51. private Dictionary<string, object> m_RtDataValues;
  52. /// <summary>
  53. /// RT查询Key列表
  54. /// </summary>
  55. private List<string> m_RtDataKeys = new List<string>();
  56. /// <summary>
  57. /// Sequence数据列表 LP1
  58. /// </summary>
  59. private ObservableCollection<string> m_SequenceSelectedItemsSource1 = new ObservableCollection<string>();
  60. /// <summary>
  61. /// Sequence数据列表 LP2
  62. /// </summary>
  63. private ObservableCollection<string> m_SequenceSelectedItemsSource2 = new ObservableCollection<string>();
  64. /// <summary>
  65. /// Sequence数据列表 LP3
  66. /// </summary>
  67. private ObservableCollection<string> m_SequenceSelectedItemsSource3 = new ObservableCollection<string>();
  68. /// <summary>
  69. /// LP1Sequence名称
  70. /// </summary>
  71. private string m_LP1SequenceName;
  72. /// <summary>
  73. /// LP2Sequence名称
  74. /// </summary>
  75. private string m_LP2SequenceName;
  76. /// <summary>
  77. /// LP3Sequence名称
  78. /// </summary>
  79. private string m_LP3SequenceName;
  80. /// <summary>
  81. /// UiRecipeManager
  82. /// </summary>
  83. private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
  84. /// <summary>
  85. /// 定时器
  86. /// </summary>
  87. DispatcherTimer _timer;
  88. /// <summary>
  89. /// LP1界面Enable
  90. /// </summary>
  91. private bool m_ButtonIsEnableLP1;
  92. /// <summary>
  93. /// LP2界面Enable
  94. /// </summary>
  95. private bool m_ButtonIsEnableLP2;
  96. /// <summary>
  97. /// LP3界面Enable
  98. /// </summary>
  99. private bool m_ButtonIsEnableLP3;
  100. /// <summary>
  101. /// LP1 SequenceName Buffer
  102. /// </summary>
  103. private string _LP1SequenceNameBuffer;
  104. /// <summary>
  105. /// LP2 SequenceName Buffer
  106. /// </summary>
  107. private string _LP2SequenceNameBuffer;
  108. /// <summary>
  109. /// LP3 SequenceName Buffer
  110. /// </summary>
  111. private string _LP3SequenceNameBuffer;
  112. private bool _isLp1Unable;
  113. private bool _isLp2Unable;
  114. private bool _isLp3Unable;
  115. private bool _lp1Unable;
  116. private bool _lp2Unable;
  117. private bool _lp3Unable;
  118. private bool _isLP1AutoStoped = true;
  119. private bool _isLP2AutoStoped = true;
  120. private bool _isLP3AutoStoped = true;
  121. private bool _isLP1AutoStarted = false;
  122. private bool _isLP2AutoStarted = false;
  123. private bool _isLP3AutoStarted = false;
  124. private bool _isLP1CanCreatedJob = false;
  125. private bool _isLP2CanCreatedJob = false;
  126. private bool _isLP3CanCreatedJob = false;
  127. /// <summary>
  128. /// LP1 RecipeMode
  129. /// </summary>
  130. private bool _lp1RecipeMode;
  131. /// <summary>
  132. /// LP2 RecipeMode
  133. /// </summary>
  134. private bool _lp2RecipeMode;
  135. /// <summary>
  136. /// LP3 RecipeMode
  137. /// </summary>
  138. private bool _lp3RecipeMode;
  139. /// <summary>
  140. /// LP1 Docked
  141. /// </summary>
  142. private bool _isLP1Docked;
  143. /// <summary>
  144. /// LP2 Docked
  145. /// </summary>
  146. private bool _isLP2Docked;
  147. /// <summary>
  148. /// LP3 Docked
  149. /// </summary>
  150. private bool _isLP3Docked;
  151. #endregion
  152. #region 属性
  153. /// <summary>
  154. /// RT查询数据字典
  155. /// </summary>
  156. public Dictionary<string, object> RtDataValues
  157. {
  158. get { return m_RtDataValues; }
  159. set { SetProperty(ref m_RtDataValues, value); }
  160. }
  161. /// <summary>
  162. /// LP1的Wafer相关信息
  163. /// </summary>
  164. public WaferAssociationInfo LP1WaferAssociation
  165. {
  166. get { return _lp1WaferAssociation; }
  167. set { SetProperty(ref _lp1WaferAssociation, value); }
  168. }
  169. /// <summary>
  170. /// LP2的Wafer相关信息
  171. /// </summary>
  172. public WaferAssociationInfo LP2WaferAssociation
  173. {
  174. get { return _lp2WaferAssociation; }
  175. set { SetProperty(ref _lp2WaferAssociation, value); }
  176. }
  177. /// <summary>
  178. /// LP3的Wafer相关信息
  179. /// </summary>
  180. public WaferAssociationInfo LP3WaferAssociation
  181. {
  182. get { return _lp3WaferAssociation; }
  183. set { SetProperty(ref _lp3WaferAssociation, value); }
  184. }
  185. /// <summary>
  186. /// LP1的Wafer数量
  187. /// </summary>
  188. public int LP1WaferCount
  189. {
  190. get { return m_LP1WaferCount; }
  191. set { SetProperty(ref m_LP1WaferCount, value); }
  192. }
  193. /// <summary>
  194. /// LP2的Wafer数量
  195. /// </summary>
  196. public int LP2WaferCount
  197. {
  198. get { return m_LP2WaferCount; }
  199. set { SetProperty(ref m_LP2WaferCount, value); }
  200. }
  201. /// <summary>
  202. /// LP3的Wafer数量
  203. /// </summary>
  204. public int LP3WaferCount
  205. {
  206. get { return m_LP3WaferCount; }
  207. set { SetProperty(ref m_LP3WaferCount, value); }
  208. }
  209. /// <summary>
  210. /// Sequence数据列表 LP1
  211. /// </summary>
  212. public ObservableCollection<string> SequenceSelectedItemsSource1
  213. {
  214. get { return m_SequenceSelectedItemsSource1; }
  215. set { SetProperty(ref m_SequenceSelectedItemsSource1, value); }
  216. }
  217. /// <summary>
  218. /// Sequence数据列表 LP2
  219. /// </summary>
  220. public ObservableCollection<string> SequenceSelectedItemsSource2
  221. {
  222. get { return m_SequenceSelectedItemsSource2; }
  223. set { SetProperty(ref m_SequenceSelectedItemsSource2, value); }
  224. }
  225. /// <summary>
  226. /// Sequence数据列表 LP3
  227. /// </summary>
  228. public ObservableCollection<string> SequenceSelectedItemsSource3
  229. {
  230. get { return m_SequenceSelectedItemsSource3; }
  231. set { SetProperty(ref m_SequenceSelectedItemsSource3, value); }
  232. }
  233. /// <summary>
  234. /// LP1Sequence名称
  235. /// </summary>
  236. public string LP1SequenceName
  237. {
  238. get { return m_LP1SequenceName; }
  239. set { SetProperty(ref m_LP1SequenceName, value); }
  240. }
  241. /// <summary>
  242. /// LP2Sequence名称
  243. /// </summary>
  244. public string LP2SequenceName
  245. {
  246. get { return m_LP2SequenceName; }
  247. set { SetProperty(ref m_LP2SequenceName, value); }
  248. }
  249. /// <summary>
  250. /// LP3Sequence名称
  251. /// </summary>
  252. public string LP3SequenceName
  253. {
  254. get { return m_LP3SequenceName; }
  255. set { SetProperty(ref m_LP3SequenceName, value); }
  256. }
  257. /// <summary>
  258. /// LP1界面Enable
  259. /// </summary>
  260. public bool ButtonIsEnableLP1
  261. {
  262. get { return m_ButtonIsEnableLP1; }
  263. set { SetProperty(ref m_ButtonIsEnableLP1, value); }
  264. }
  265. /// <summary>
  266. /// LP2界面Enable
  267. /// </summary>
  268. public bool ButtonIsEnableLP2
  269. {
  270. get { return m_ButtonIsEnableLP2; }
  271. set { SetProperty(ref m_ButtonIsEnableLP2, value); }
  272. }
  273. /// <summary>
  274. /// LP3界面Enable
  275. /// </summary>
  276. public bool ButtonIsEnableLP3
  277. {
  278. get { return m_ButtonIsEnableLP3; }
  279. set { SetProperty(ref m_ButtonIsEnableLP3, value); }
  280. }
  281. /// <summary>
  282. /// Created job 按钮可用性
  283. /// </summary>
  284. public bool IsLP1CanCreatedJob
  285. {
  286. get { return _isLP1CanCreatedJob; }
  287. set { SetProperty(ref _isLP1CanCreatedJob, value); }
  288. }
  289. public bool IsLP2CanCreatedJob
  290. {
  291. get { return _isLP2CanCreatedJob; }
  292. set { SetProperty(ref _isLP2CanCreatedJob, value); }
  293. }
  294. public bool IsLP3CanCreatedJob
  295. {
  296. get { return _isLP3CanCreatedJob; }
  297. set { SetProperty(ref _isLP3CanCreatedJob, value); }
  298. }
  299. public bool IsLP1AutoStoped
  300. {
  301. get { return _isLP1AutoStoped; }
  302. set { SetProperty(ref _isLP1AutoStoped, value); }
  303. }
  304. public bool IsLP2AutoStoped
  305. {
  306. get { return _isLP2AutoStoped; }
  307. set { SetProperty(ref _isLP2AutoStoped, value); }
  308. }
  309. public bool IsLP3AutoStoped
  310. {
  311. get { return _isLP3AutoStoped; }
  312. set { SetProperty(ref _isLP3AutoStoped, value); }
  313. }
  314. public bool IsLP1AutoStarted
  315. {
  316. get { return _isLP1AutoStarted; }
  317. set { SetProperty(ref _isLP1AutoStarted, value); }
  318. }
  319. public bool IsLP2AutoStarted
  320. {
  321. get { return _isLP2AutoStarted; }
  322. set { SetProperty(ref _isLP2AutoStarted, value); }
  323. }
  324. public bool IsLP3AutoStarted
  325. {
  326. get { return _isLP3AutoStarted; }
  327. set { SetProperty(ref _isLP3AutoStarted, value); }
  328. }
  329. public bool IsLP1Unable
  330. {
  331. get { return _isLp1Unable; }
  332. set { SetProperty(ref _isLp1Unable, value); }
  333. }
  334. public bool IsLP2Unable
  335. {
  336. get { return _isLp2Unable; }
  337. set { SetProperty(ref _isLp2Unable, value); }
  338. }
  339. public bool IsLP3Unable
  340. {
  341. get { return _isLp3Unable; }
  342. set { SetProperty(ref _isLp3Unable, value); }
  343. }
  344. public bool LP1Unable
  345. {
  346. get { return _lp1Unable; }
  347. set { SetProperty(ref _lp1Unable, value); }
  348. }
  349. public bool LP2Unable
  350. {
  351. get { return _lp2Unable; }
  352. set { SetProperty(ref _lp2Unable, value); }
  353. }
  354. public bool LP3Unable
  355. {
  356. get { return _lp3Unable; }
  357. set { SetProperty(ref _lp3Unable, value); }
  358. }
  359. /// <summary>
  360. /// LP1 RecipeMode(Engineering:true, Production:false)
  361. /// </summary>
  362. public bool LP1RecipeMode
  363. {
  364. get { return _lp1RecipeMode; }
  365. set { SetProperty(ref _lp1RecipeMode, value); }
  366. }
  367. /// <summary>
  368. /// LP2 RecipeMode(Engineering:true, Production:false)
  369. /// </summary>
  370. public bool LP2RecipeMode
  371. {
  372. get { return _lp2RecipeMode; }
  373. set { SetProperty(ref _lp2RecipeMode, value); }
  374. }
  375. /// <summary>
  376. /// LP3 RecipeMode(Engineering:true, Production:false)
  377. /// </summary>
  378. public bool LP3RecipeMode
  379. {
  380. get { return _lp3RecipeMode; }
  381. set { SetProperty(ref _lp3RecipeMode, value); }
  382. }
  383. #endregion
  384. #region 命令
  385. private DelegateCommand<object> _SelectAllCommand;
  386. public DelegateCommand<object> SelectAllCommand =>
  387. _SelectAllCommand ?? (_SelectAllCommand = new DelegateCommand<object>(OnSelectAll));
  388. private DelegateCommand<object> _UnSelectAllCommand;
  389. public DelegateCommand<object> UnSelectAllCommand =>
  390. _UnSelectAllCommand ?? (_UnSelectAllCommand = new DelegateCommand<object>(OnUnSelectAll));
  391. private DelegateCommand<object> _CreateJobCommand;
  392. public DelegateCommand<object> CreateJobCommand =>
  393. _CreateJobCommand ?? (_CreateJobCommand = new DelegateCommand<object>(OnCreateJob));
  394. private DelegateCommand<object> _AbortJobCommand;
  395. public DelegateCommand<object> AbortJobCommand =>
  396. _AbortJobCommand ?? (_AbortJobCommand = new DelegateCommand<object>(OnAbortJob));
  397. private DelegateCommand<object> _StartCommand;
  398. public DelegateCommand<object> StartCommand =>
  399. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  400. private DelegateCommand<object> _StopCommand;
  401. public DelegateCommand<object> StopCommand =>
  402. _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
  403. private DelegateCommand<object> _AbortCommand;
  404. public DelegateCommand<object> AbortCommand =>
  405. _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(OnAbort));
  406. private DelegateCommand<object> _SelectionChangedCommand;
  407. public DelegateCommand<object> SelectionChangedCommand
  408. =>
  409. _SelectionChangedCommand ?? (_SelectionChangedCommand = new DelegateCommand<object>(OnSelectionChanged));
  410. private DelegateCommand<object> _SetSequenceCommand;
  411. public DelegateCommand<object> SetSequenceCommand =>
  412. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  413. private DelegateCommand<object> _LPLoadCommand;
  414. public DelegateCommand<object> LPLoadCommand =>
  415. _LPLoadCommand ?? (_LPLoadCommand = new DelegateCommand<object>(OnLPLoad));
  416. private DelegateCommand<object> _LPUnLoadCommand;
  417. public DelegateCommand<object> LPUnLoadCommand =>
  418. _LPUnLoadCommand ?? (_LPUnLoadCommand = new DelegateCommand<object>(OnLPUnLoad));
  419. private DelegateCommand<object> _SeqTypeChangeCommand;
  420. public DelegateCommand<object> SeqTypeChangeCommand =>
  421. _SeqTypeChangeCommand ?? (_SeqTypeChangeCommand = new DelegateCommand<object>(OnSeqTypeChange));
  422. #endregion
  423. #region
  424. /// <summary>
  425. /// 构造函数
  426. /// </summary>
  427. public JobOperationViewModel()
  428. {
  429. LP1WaferAssociation = new WaferAssociationInfo();
  430. LP3WaferAssociation = new WaferAssociationInfo();
  431. LP2WaferAssociation = new WaferAssociationInfo();
  432. SequenceSelectedItemsSource1 = new ObservableCollection<string>();
  433. SequenceSelectedItemsSource2 = new ObservableCollection<string>();
  434. SequenceSelectedItemsSource3 = new ObservableCollection<string>();
  435. LP1WaferCount = 0;
  436. LP2WaferCount = 0;
  437. LP3WaferCount = 0;
  438. _LP1SequenceNameBuffer = null;
  439. _LP2SequenceNameBuffer = null;
  440. _LP3SequenceNameBuffer = null;
  441. LP1RecipeMode = true;
  442. LP2RecipeMode = true;
  443. LP3RecipeMode = true;
  444. addDataKeys();
  445. }
  446. #endregion
  447. #region 方法
  448. /// <summary>
  449. /// 加载数据
  450. /// </summary>
  451. public void LoadData(string systemName)
  452. {
  453. if (_timer == null)
  454. {
  455. _timer = new DispatcherTimer();
  456. _timer.Interval = TimeSpan.FromMilliseconds(100);
  457. _timer.Tick += Timer_Tick; ;
  458. }
  459. _timer.Start();
  460. LP1WaferAssociation.SequenceType = LP1RecipeMode ? "Production" : "Engineering";
  461. LP2WaferAssociation.SequenceType = LP2RecipeMode ? "Production" : "Engineering";
  462. LP3WaferAssociation.SequenceType = LP3RecipeMode ? "Production" : "Engineering";
  463. //获取Sequence列表
  464. var seqitems1 = RecipeClient.Instance.Service.GetSequenceList("seq", LP1WaferAssociation.SequenceType);
  465. SequenceSelectedItemsSource1.Clear();
  466. foreach (var seqitem in seqitems1)
  467. {
  468. SequenceSelectedItemsSource1.Add(seqitem);
  469. }
  470. var seqitems2 = RecipeClient.Instance.Service.GetSequenceList("seq", LP2WaferAssociation.SequenceType);
  471. SequenceSelectedItemsSource2.Clear();
  472. foreach (var seqitem in seqitems2)
  473. {
  474. SequenceSelectedItemsSource2.Add(seqitem);
  475. }
  476. var seqitems3 = RecipeClient.Instance.Service.GetSequenceList("seq", LP3WaferAssociation.SequenceType);
  477. SequenceSelectedItemsSource3.Clear();
  478. foreach (var seqitem in seqitems3)
  479. {
  480. SequenceSelectedItemsSource3.Add(seqitem);
  481. }
  482. }
  483. /// <summary>
  484. /// 隐藏
  485. /// </summary>
  486. public void Hide()
  487. {
  488. _timer.Stop();
  489. }
  490. /// <summary>
  491. /// 定时器执行
  492. /// </summary>
  493. private void Timer_Tick(object sender, EventArgs e)
  494. {
  495. LP1WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP1"];
  496. LP2WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP2"];
  497. LP3WaferAssociation.ModuleData = ModuleManager.ModuleInfos["LP3"];
  498. IsLP1Unable = !(bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable") && ButtonIsEnableLP1;
  499. IsLP2Unable = !(bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable") && ButtonIsEnableLP2;
  500. IsLP3Unable = !(bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable") && ButtonIsEnableLP3;
  501. LP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable");
  502. LP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable");
  503. LP3Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable");
  504. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  505. if (RtDataValues == null || RtDataValues.Count == 0)
  506. {
  507. return;
  508. }
  509. ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
  510. if (lp1Cj == null)
  511. {
  512. ButtonIsEnableLP1 = true;
  513. LP1WaferAssociation.JobStatus = "";
  514. }
  515. else
  516. {
  517. ButtonIsEnableLP1 = false;
  518. UPdateWaferAssociation(LP1WaferAssociation, lp1Cj);
  519. }
  520. ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
  521. if (lp2Cj == null)
  522. {
  523. ButtonIsEnableLP2 = true;
  524. LP2WaferAssociation.JobStatus = "";
  525. }
  526. else
  527. {
  528. ButtonIsEnableLP2 = false;
  529. UPdateWaferAssociation(LP2WaferAssociation, lp2Cj);
  530. }
  531. ControlJobInfo lp3Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP3.CurrentControlJob");
  532. if (lp3Cj == null)
  533. {
  534. ButtonIsEnableLP3 = true;
  535. LP3WaferAssociation.JobStatus = "";
  536. }
  537. else
  538. {
  539. ButtonIsEnableLP3 = false;
  540. UPdateWaferAssociation(LP3WaferAssociation, lp3Cj);
  541. }
  542. LP1WaferCount = LP1WaferAssociation.ModuleData.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  543. LP2WaferCount = LP2WaferAssociation.ModuleData.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  544. LP3WaferCount = LP3WaferAssociation.ModuleData.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  545. _isLP1Docked = CommonFunction.GetValue<bool>(RtDataValues, "LP1.IsDocked");
  546. if (!_isLP1Docked)
  547. {
  548. LP1WaferAssociation.SlotFrom = 1;
  549. LP1WaferAssociation.SlotTo = 25;
  550. LP1WaferAssociation.LotId = "";
  551. LP1WaferAssociation.JobID = "";
  552. LP1SequenceName = null;
  553. _LP1SequenceNameBuffer = null;
  554. LP1WaferAssociation.CycleNumber = 1;
  555. LP1WaferAssociation.IsEnableCycle = false;
  556. AssociateSequence(LP1WaferAssociation, false);
  557. }
  558. _isLP2Docked = CommonFunction.GetValue<bool>(RtDataValues, "LP2.IsDocked");
  559. if (!_isLP2Docked)
  560. {
  561. LP2WaferAssociation.SlotFrom = 1;
  562. LP2WaferAssociation.SlotTo = 25;
  563. LP2WaferAssociation.LotId = "";
  564. LP2WaferAssociation.JobID = "";
  565. LP2SequenceName = null;
  566. _LP2SequenceNameBuffer = null;
  567. LP2WaferAssociation.CycleNumber = 1;
  568. LP2WaferAssociation.IsEnableCycle = false;
  569. AssociateSequence(LP2WaferAssociation, false);
  570. }
  571. _isLP3Docked = CommonFunction.GetValue<bool>(RtDataValues, "LP3.IsDocked");
  572. if (!_isLP3Docked)
  573. {
  574. LP3WaferAssociation.SlotFrom = 1;
  575. LP3WaferAssociation.SlotTo = 25;
  576. LP3WaferAssociation.LotId = "";
  577. LP3WaferAssociation.JobID = "";
  578. LP3SequenceName = null;
  579. _LP3SequenceNameBuffer = null;
  580. LP3WaferAssociation.CycleNumber = 1;
  581. LP3WaferAssociation.IsEnableCycle = false;
  582. AssociateSequence(LP3WaferAssociation, false);
  583. }
  584. LP1WaferAssociation.SequenceType = LP1RecipeMode ? "Production" : "Engineering";
  585. LP2WaferAssociation.SequenceType = LP2RecipeMode ? "Production" : "Engineering";
  586. LP3WaferAssociation.SequenceType = LP3RecipeMode ? "Production" : "Engineering";
  587. if ("Executing".Equals(LP1WaferAssociation.JobStatus))
  588. {
  589. IsLP1AutoStoped = false;
  590. IsLP1AutoStarted = true;
  591. }
  592. else if ("WaitingForStart".Equals(LP1WaferAssociation.JobStatus))
  593. {
  594. IsLP1AutoStoped = true;
  595. IsLP1AutoStarted = false;
  596. }
  597. else if (string.IsNullOrEmpty(LP1WaferAssociation.JobStatus))
  598. {
  599. IsLP1AutoStoped = false;
  600. IsLP1AutoStarted = false;
  601. }
  602. if ("Executing".Equals(LP2WaferAssociation.JobStatus))
  603. {
  604. IsLP2AutoStoped = false;
  605. IsLP2AutoStarted = true;
  606. }
  607. else if ("WaitingForStart".Equals(LP2WaferAssociation.JobStatus))
  608. {
  609. IsLP2AutoStoped = true;
  610. IsLP2AutoStarted = false;
  611. }
  612. else if (string.IsNullOrEmpty(LP2WaferAssociation.JobStatus))
  613. {
  614. IsLP2AutoStoped = false;
  615. IsLP2AutoStarted = false;
  616. }
  617. if ("Executing".Equals(LP3WaferAssociation.JobStatus))
  618. {
  619. IsLP3AutoStoped = false;
  620. IsLP3AutoStarted = true;
  621. }
  622. else if ("WaitingForStart".Equals(LP3WaferAssociation.JobStatus))
  623. {
  624. IsLP3AutoStoped = true;
  625. IsLP3AutoStarted = false;
  626. }
  627. else if (string.IsNullOrEmpty(LP3WaferAssociation.JobStatus))
  628. {
  629. IsLP3AutoStoped = false;
  630. IsLP3AutoStarted = false;
  631. }
  632. if (string.IsNullOrEmpty(LP1WaferAssociation.JobStatus))
  633. {
  634. IsLP1CanCreatedJob = true;
  635. }
  636. else
  637. {
  638. IsLP1CanCreatedJob = false;
  639. }
  640. if (string.IsNullOrEmpty(LP2WaferAssociation.JobStatus))
  641. {
  642. IsLP2CanCreatedJob = true;
  643. }
  644. else
  645. {
  646. IsLP2CanCreatedJob = false;
  647. }
  648. if (string.IsNullOrEmpty(LP3WaferAssociation.JobStatus))
  649. {
  650. IsLP3CanCreatedJob = true;
  651. }
  652. else
  653. {
  654. IsLP3CanCreatedJob = false;
  655. }
  656. }
  657. /// <summary>
  658. /// 选择所有Wafer
  659. /// </summary>
  660. private void OnSelectAll(object obj)
  661. {
  662. var info = obj as WaferAssociationInfo;
  663. var module = info.ModuleData.ModuleID;
  664. if (CommonFunction.GetValue<bool>(RtDataValues, $"{module}.IsLoaded"))
  665. {
  666. info.SlotFrom = 1;
  667. info.SlotTo = 25;
  668. AssociateSequence(info, true);
  669. }
  670. }
  671. /// <summary>
  672. /// 取消选择所有Wafer
  673. /// </summary>
  674. private void OnUnSelectAll(object obj)
  675. {
  676. var info = obj as WaferAssociationInfo;
  677. var module = info.ModuleData.ModuleID;
  678. info.SlotFrom = 1;
  679. info.SlotTo = 25;
  680. AssociateSequence(info, false);
  681. }
  682. /// <summary>
  683. /// 创建任务
  684. /// </summary>
  685. private void OnCreateJob(object obj)
  686. {
  687. var info = obj as WaferAssociationInfo;
  688. List<string> slotSequence = new List<string>();
  689. info.ModuleData.WaferManager.Wafers.ForEach(key => { slotSequence.Insert(0, key.SequenceName); });
  690. if (info.LotId == "" && info.JobID != "") info.LotId = info.JobID;
  691. if (info.LotId != "" && info.JobID == "") info.JobID = info.LotId;
  692. info.LotIdSaved = true;
  693. Dictionary<string, object> param = new Dictionary<string, object>()
  694. {
  695. {"JobId", info.JobID},
  696. {"LotId", info.LotId},
  697. {"Module", info.ModuleData.ModuleID},
  698. {"SlotSequence", slotSequence.ToArray()},
  699. {"AutoStart", true},
  700. {"CycleNumber",info.CycleNumber},
  701. {"SequenceType", info.SequenceType}
  702. };
  703. if(info.JobID != "" || info.LotId != "")
  704. {
  705. InvokeClient.Instance.Service.DoOperation("System.CreateJob", param);
  706. }
  707. }
  708. /// <summary>
  709. /// 取消任务
  710. /// </summary>
  711. private void OnAbortJob(object obj)
  712. {
  713. InvokeClient.Instance.Service.DoOperation("System.AbortJob", obj.ToString());
  714. }
  715. /// <summary>
  716. /// 开始
  717. /// </summary>
  718. private void OnStart(object obj)
  719. {
  720. var info = obj as WaferAssociationInfo;
  721. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.JobID);
  722. //LOG.Info("System,Start Job");
  723. }
  724. /// <summary>
  725. /// 停止
  726. /// </summary>
  727. private void OnStop(object obj)
  728. {
  729. var info = obj as WaferAssociationInfo;
  730. InvokeClient.Instance.Service.DoOperation("System.StopJob", info.JobID);
  731. //LOG.Info($"System,Stop Job{info.JobID}");
  732. }
  733. /// <summary>
  734. /// 取消
  735. /// </summary>
  736. private void OnAbort(object obj)
  737. {
  738. var info = obj as WaferAssociationInfo;
  739. InvokeClient.Instance.Service.DoOperation("System.AbortJob", info.JobID);
  740. //LOG.Info($"System,Stop Job{info.JobID}");
  741. }
  742. /// <summary>
  743. /// Sequence Combox的SelectionChanged事件
  744. /// </summary>
  745. private void OnSelectionChanged(object obj)
  746. {
  747. var moduleName = obj.ToString();
  748. switch (moduleName)
  749. {
  750. case "LP1":
  751. if (!string.IsNullOrEmpty(_LP1SequenceNameBuffer) && LP1SequenceName == null) LP1SequenceName = _LP1SequenceNameBuffer;
  752. _LP1SequenceNameBuffer = LP1SequenceName;
  753. LP1WaferAssociation.SequenceName = LP1SequenceName;
  754. break;
  755. case "LP2":
  756. if (!string.IsNullOrEmpty(_LP2SequenceNameBuffer) && LP2SequenceName == null) LP2SequenceName = _LP2SequenceNameBuffer;
  757. _LP2SequenceNameBuffer = LP2SequenceName;
  758. LP2WaferAssociation.SequenceName = LP2SequenceName;
  759. break;
  760. case "LP3":
  761. if (!string.IsNullOrEmpty(_LP3SequenceNameBuffer) && LP3SequenceName == null) LP3SequenceName = _LP3SequenceNameBuffer;
  762. _LP3SequenceNameBuffer = LP3SequenceName;
  763. LP3WaferAssociation.SequenceName = LP3SequenceName;
  764. break;
  765. default:
  766. break;
  767. }
  768. }
  769. /// <summary>
  770. /// ListBox中设置单个Wafer的Sequence
  771. /// </summary>
  772. /// <param name="obj"></param>
  773. private void OnSetSequence(object obj)
  774. {
  775. var info = obj as WaferInfo;
  776. bool flag = info.SequenceName != "" ? false : true;
  777. if (info.ModuleID == "LP1" && (CommonFunction.GetValue<bool>(RtDataValues, "LP1.IsLoaded")))
  778. {
  779. AssociateSequence(LP1WaferAssociation, flag, info.SlotID);
  780. }
  781. else if (info.ModuleID == "LP2" && (CommonFunction.GetValue<bool>(RtDataValues, "LP2.IsLoaded")))
  782. {
  783. AssociateSequence(LP2WaferAssociation, flag, info.SlotID);
  784. }
  785. else if (info.ModuleID == "LP3" && (CommonFunction.GetValue<bool>(RtDataValues, "LP3.IsLoaded")))
  786. {
  787. AssociateSequence(LP3WaferAssociation, flag, info.SlotID);
  788. }
  789. }
  790. /// <summary>
  791. /// Sequence设置
  792. /// </summary>
  793. /// <param name="info"></param>
  794. /// <param name="flag"></param>
  795. /// <param name="slot"></param>
  796. private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)
  797. {
  798. List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;
  799. if (slot >= 0) //by wafer
  800. {
  801. int index = wafers.Count - slot - 1;
  802. if (index < wafers.Count)
  803. {
  804. if (flag && HasWaferOnSlot(wafers, index))
  805. wafers[index].SequenceName = info.SequenceName;
  806. else
  807. wafers[index].SequenceName = string.Empty;
  808. }
  809. }
  810. else //by from-to
  811. {
  812. for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)
  813. {
  814. int index = wafers.Count - i - 1;
  815. if (index < wafers.Count)
  816. {
  817. if (flag && HasWaferOnSlot(wafers, index))
  818. wafers[index].SequenceName = info.SequenceName;
  819. else
  820. wafers[index].SequenceName = string.Empty;
  821. }
  822. }
  823. }
  824. switch (info.ModuleData.ModuleID)
  825. {
  826. case "LP1":
  827. LP1WaferAssociation = info;
  828. break;
  829. case "LP2":
  830. LP2WaferAssociation = info;
  831. break;
  832. case "LP3":
  833. LP3WaferAssociation = info;
  834. break;
  835. }
  836. }
  837. /// <summary>
  838. /// 检查Slot中的Wafer是否存在
  839. /// </summary>
  840. /// <param name="wafers"></param>
  841. /// <param name="index"></param>
  842. /// <returns></returns>
  843. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  844. {
  845. if (wafers[index].WaferStatus == 0)
  846. return false;
  847. return true;
  848. }
  849. /// <summary>
  850. /// 添加RT查询key
  851. /// </summary>
  852. private void addDataKeys()
  853. {
  854. m_RtDataKeys.Add("LP1.IsLoaded");
  855. m_RtDataKeys.Add("LP2.IsLoaded");
  856. m_RtDataKeys.Add("LP3.IsLoaded");
  857. m_RtDataKeys.Add("LP1.CassettePlaced");
  858. m_RtDataKeys.Add("LP2.CassettePlaced");
  859. m_RtDataKeys.Add("LP3.CassettePlaced");
  860. m_RtDataKeys.Add("LP1.CurrentControlJob");
  861. m_RtDataKeys.Add("LP2.CurrentControlJob");
  862. m_RtDataKeys.Add("LP3.CurrentControlJob");
  863. m_RtDataKeys.Add("System.IsAutoMode");
  864. m_RtDataKeys.Add("System.IsBusy");
  865. m_RtDataKeys.Add("LP1.CycledCount");
  866. m_RtDataKeys.Add("LP1.CycledWafer");
  867. m_RtDataKeys.Add("LP1.CycleSetPoint");
  868. m_RtDataKeys.Add("LP1.Throughput");
  869. m_RtDataKeys.Add("LP2.CycledCount");
  870. m_RtDataKeys.Add("LP2.CycledWafer");
  871. m_RtDataKeys.Add("LP2.CycleSetPoint");
  872. m_RtDataKeys.Add("LP2.Throughput");
  873. m_RtDataKeys.Add("LP3.CycledCount");
  874. m_RtDataKeys.Add("LP3.CycledWafer");
  875. m_RtDataKeys.Add("LP3.CycleSetPoint");
  876. m_RtDataKeys.Add("LP3.Throughput");
  877. m_RtDataKeys.Add("LP1.IsDocked");
  878. m_RtDataKeys.Add("LP2.IsDocked");
  879. m_RtDataKeys.Add("LP3.IsDocked");
  880. }
  881. /// <summary>
  882. /// 更新Wafer情况
  883. /// </summary>
  884. /// <param name="info"></param>
  885. /// <param name="cjInfo"></param>
  886. private void UPdateWaferAssociation(WaferAssociationInfo info, ControlJobInfo cjInfo)
  887. {
  888. if (info == null)
  889. {
  890. return;
  891. }
  892. if (cjInfo != null)
  893. {
  894. info.LotId = cjInfo.LotName;
  895. info.JobID = cjInfo.Name;
  896. info.JobStatus = cjInfo.State.ToString();
  897. if (cjInfo.SequenceNameList != null)
  898. {
  899. for (int i = 0; i < cjInfo.SequenceNameList.Length; i++)
  900. {
  901. info.ModuleData.WaferManager.Wafers[24 - i].SequenceName = cjInfo.SequenceNameList[i];
  902. }
  903. }
  904. }
  905. else
  906. {
  907. if (!string.IsNullOrEmpty(info.JobID))
  908. {
  909. info.LotId = "";
  910. info.JobID = "";
  911. info.JobStatus = "";
  912. AssociateSequence(info, false);
  913. }
  914. }
  915. }
  916. private void OnLPLoad(object obj)
  917. {
  918. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Load");
  919. }
  920. private void OnLPUnLoad(object obj)
  921. {
  922. var info = obj as WaferAssociationInfo;
  923. var module = info.ModuleData.ModuleID;
  924. InvokeClient.Instance.Service.DoOperation($"{module}.Unload");
  925. }
  926. private void OnSeqTypeChange(object obj)
  927. {
  928. var info = obj as WaferAssociationInfo;
  929. //获取Sequence列表
  930. List<string> seqitems;
  931. switch (info.ModuleData.ModuleID)
  932. {
  933. case "LP1":
  934. info.SequenceType = LP1RecipeMode ? "Production" : "Engineering";
  935. seqitems = RecipeClient.Instance.Service.GetSequenceList("seq", info.SequenceType);
  936. SequenceSelectedItemsSource1.Clear();
  937. foreach (var seqitem in seqitems)
  938. {
  939. SequenceSelectedItemsSource1.Add(seqitem);
  940. }
  941. break;
  942. case "LP2":
  943. info.SequenceType = LP2RecipeMode ? "Production" : "Engineering";
  944. seqitems = RecipeClient.Instance.Service.GetSequenceList("seq", info.SequenceType);
  945. SequenceSelectedItemsSource2.Clear();
  946. foreach (var seqitem in seqitems)
  947. {
  948. SequenceSelectedItemsSource2.Add(seqitem);
  949. }
  950. break;
  951. case "LP3":
  952. info.SequenceType = LP3RecipeMode ? "Production" : "Engineering";
  953. seqitems = RecipeClient.Instance.Service.GetSequenceList("seq", info.SequenceType);
  954. SequenceSelectedItemsSource3.Clear();
  955. foreach (var seqitem in seqitems)
  956. {
  957. SequenceSelectedItemsSource3.Add(seqitem);
  958. }
  959. break;
  960. default:
  961. break;
  962. }
  963. }
  964. #endregion
  965. }
  966. }