OperationOverNewViewModel.cs 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  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.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Threading;
  15. using PunkHPX8_Core;
  16. using PunkHPX8_MainPages.Unity;
  17. using PunkHPX8_MainPages.Views;
  18. using PunkHPX8_Themes.CustomControls;
  19. using PunkHPX8_Themes.Unity;
  20. using PunkHPX8_Themes.UserControls;
  21. using Aitex.Core.RT.Log;
  22. using MECF.Framework.Common.Reservior;
  23. using MECF.Framework.Common.ProcessCell;
  24. using MECF.Framework.Common.Utilities;
  25. using Aitex.Sorter.Common;
  26. using MECF.Framework.Common.Schedulers;
  27. using MECF.Framework.Common.Beckhoff.Station;
  28. using MECF.Framework.Common.Layout;
  29. using Aitex.Core.RT.Routine;
  30. using Aitex.Core.RT.Device;
  31. using System.Reflection;
  32. using MECF.Framework.Common.Beckhoff.IOAxis;
  33. using MECF.Framework.Common.TwinCat;
  34. using LiveCharts.Wpf;
  35. using MECF.Framework.Common.Beckhoff.AxisProvider;
  36. using QiHe.CodeLib;
  37. using MECF.Framework.Common.Jobs;
  38. using ExcelLibrary.BinaryFileFormat;
  39. namespace PunkHPX8_MainPages.ViewModels
  40. {
  41. public class OperationOverNewViewModel : BindableBase
  42. {
  43. #region 常量
  44. private const string CURRENT_STATION = "CurrentStation";
  45. private const string MOTOR_POSITION = "MotorPosition";
  46. private const string MOTION_DATA = "MotionData";
  47. private const double LOADER_ROTATION_DIFFER = 90;
  48. #endregion
  49. #region 私有字段
  50. private bool _isLp1Unable;
  51. private bool _isLp2Unable;
  52. private ModuleInfo _LP1ModuleInfo;
  53. private ModuleInfo _LP2ModuleInfo;
  54. private ModuleInfo _EFEMModuleInfo;
  55. private ModuleInfo _srd1ModuleInfo;
  56. private ModuleInfo _srd2ModuleInfo;
  57. private ModuleInfo _dummy1ModuleInfo;
  58. private ModuleInfo _dummy2ModuleInfo;
  59. private WaferRobotTAction m_Robot1TAction;
  60. private WaferRobotXAction m_Robot1XAction;
  61. private WaferRobotTAction m_Robot2TAction;
  62. private WaferRobotXAction m_Robot2XAction;
  63. private WaferRobotTAction m_Robot3TAction;
  64. private WaferRobotXAction m_Robot3XAction;
  65. private WaferRobotTAction m_Robot4TAction;
  66. private WaferRobotXAction m_Robot4XAction;
  67. private RobotMoveInfo m_robotMoveInfo;
  68. private WaferInfo m_srd1Wafer;
  69. private WaferInfo m_srd2Wafer;
  70. private List<string> m_RtDataKeys = new List<string>();
  71. private Dictionary<string, object> m_RtDataValues;
  72. private bool m_EFEMIsInstalled;
  73. private WaferInfo m_EFEMBladeAWafer;
  74. private WaferInfo m_EFEMBladeBWafer;
  75. private WaferInfo m_Aligner1Wafer;
  76. private WaferInfo m_vpw1Wafer;
  77. private WaferInfo m_vpw2Wafer;
  78. private WaferInfo m_platingCell1Wafer;
  79. private WaferInfo m_platingCell2Wafer;
  80. private WaferInfo m_platingCell3Wafer;
  81. private WaferInfo m_platingCell4Wafer;
  82. private int m_LP1WaferCount;
  83. private int m_LP2WaferCount;
  84. private int m_dummy1WaferCount;
  85. private int m_dummy2WaferCount;
  86. private int m_CycledWafer;
  87. private int m_CycleCountDisplay;
  88. private EFEM.RobotPosition m_CurrentRobotPosition;
  89. private WaferInfo m_BladeAWafer;
  90. private WaferInfo m_BladeBWafer;
  91. private string m_RouteState;
  92. /// <summary>
  93. /// 定时器
  94. /// </summary>
  95. private DispatcherTimer _timer;
  96. /// <summary>
  97. /// 是否存在Job
  98. /// </summary>
  99. private bool _isLp1HasNoJob;
  100. private bool _isLp2HasNoJob;
  101. #endregion
  102. #region 属性
  103. public bool IsLP1Unable
  104. {
  105. get { return _isLp1Unable; }
  106. set { SetProperty(ref _isLp1Unable, value); }
  107. }
  108. public bool IsLP2Unable
  109. {
  110. get { return _isLp2Unable; }
  111. set { SetProperty(ref _isLp2Unable, value); }
  112. }
  113. public ModuleInfo LP1ModuleInfo
  114. {
  115. get { return _LP1ModuleInfo; }
  116. set { SetProperty(ref _LP1ModuleInfo, value); }
  117. }
  118. public ModuleInfo EFEMModuleInfo
  119. {
  120. get { return _EFEMModuleInfo; }
  121. set { SetProperty(ref _EFEMModuleInfo, value); }
  122. }
  123. public ModuleInfo LP2ModuleInfo
  124. {
  125. get { return _LP2ModuleInfo; }
  126. set { SetProperty(ref _LP2ModuleInfo, value); }
  127. }
  128. public ModuleInfo SRD1ModuleInfo
  129. {
  130. get { return _srd1ModuleInfo; }
  131. set { SetProperty(ref _srd1ModuleInfo, value); }
  132. }
  133. public ModuleInfo SRD2ModuleInfo
  134. {
  135. get { return _srd2ModuleInfo; }
  136. set { SetProperty(ref _srd2ModuleInfo, value); }
  137. }
  138. public ModuleInfo Dummy1ModuleInfo
  139. {
  140. get { return _dummy1ModuleInfo; }
  141. set { SetProperty(ref _dummy1ModuleInfo, value); }
  142. }
  143. public ModuleInfo Dummy2ModuleInfo
  144. {
  145. get { return _dummy2ModuleInfo; }
  146. set { SetProperty(ref _dummy2ModuleInfo, value); }
  147. }
  148. public WaferRobotTAction Robot1TAction
  149. {
  150. get { return m_Robot1TAction; }
  151. set { SetProperty(ref m_Robot1TAction, value); }
  152. }
  153. public WaferRobotXAction Robot1XAction
  154. {
  155. get { return m_Robot1XAction; }
  156. set { SetProperty(ref m_Robot1XAction, value); }
  157. }
  158. public WaferRobotTAction Robot2TAction
  159. {
  160. get { return m_Robot2TAction; }
  161. set { SetProperty(ref m_Robot2TAction, value); }
  162. }
  163. public WaferRobotXAction Robot2XAction
  164. {
  165. get { return m_Robot2XAction; }
  166. set { SetProperty(ref m_Robot2XAction, value); }
  167. }
  168. public WaferRobotTAction Robot3TAction
  169. {
  170. get { return m_Robot3TAction; }
  171. set { SetProperty(ref m_Robot3TAction, value); }
  172. }
  173. public WaferRobotXAction Robot3XAction
  174. {
  175. get { return m_Robot3XAction; }
  176. set { SetProperty(ref m_Robot3XAction, value); }
  177. }
  178. public WaferRobotTAction Robot4TAction
  179. {
  180. get { return m_Robot4TAction; }
  181. set { SetProperty(ref m_Robot4TAction, value); }
  182. }
  183. public WaferRobotXAction Robot4XAction
  184. {
  185. get { return m_Robot4XAction; }
  186. set { SetProperty(ref m_Robot4XAction, value); }
  187. }
  188. public RobotMoveInfo RobotMoveInfo
  189. {
  190. get { return m_robotMoveInfo; }
  191. set
  192. {
  193. RobotMoveInfoChanged(m_robotMoveInfo, value);
  194. //m_robotMoveInfo = value;
  195. SetProperty(ref m_robotMoveInfo, value);
  196. }
  197. }
  198. public Dictionary<string, object> RtDataValues
  199. {
  200. get { return m_RtDataValues; }
  201. set { SetProperty(ref m_RtDataValues, value); }
  202. }
  203. public bool EFEMIsInstalled
  204. {
  205. get { return m_EFEMIsInstalled; }
  206. set { SetProperty(ref m_EFEMIsInstalled, value); }
  207. }
  208. public WaferInfo EFEMBladeAWafer
  209. {
  210. get { return m_EFEMBladeAWafer; }
  211. set { SetProperty(ref m_EFEMBladeAWafer, value); }
  212. }
  213. public WaferInfo EFEMBladeBWafer
  214. {
  215. get { return m_EFEMBladeBWafer; }
  216. set { SetProperty(ref m_EFEMBladeBWafer, value); }
  217. }
  218. public WaferInfo Aligner1Wafer
  219. {
  220. get { return m_Aligner1Wafer; }
  221. set { SetProperty(ref m_Aligner1Wafer, value); }
  222. }
  223. public WaferInfo VPW1Wafer
  224. {
  225. get { return m_vpw1Wafer; }
  226. set { SetProperty(ref m_vpw1Wafer, value); }
  227. }
  228. public WaferInfo VPW2Wafer
  229. {
  230. get { return m_vpw2Wafer; }
  231. set { SetProperty(ref m_vpw2Wafer, value); }
  232. }
  233. public WaferInfo PlatingCell1Wafer
  234. {
  235. get { return m_platingCell1Wafer; }
  236. set { SetProperty(ref m_platingCell1Wafer, value); }
  237. }
  238. public WaferInfo PlatingCell2Wafer
  239. {
  240. get { return m_platingCell2Wafer; }
  241. set { SetProperty(ref m_platingCell2Wafer, value); }
  242. }
  243. public WaferInfo PlatingCell3Wafer
  244. {
  245. get { return m_platingCell3Wafer; }
  246. set { SetProperty(ref m_platingCell3Wafer, value); }
  247. }
  248. public WaferInfo PlatingCell4Wafer
  249. {
  250. get { return m_platingCell4Wafer; }
  251. set { SetProperty(ref m_platingCell4Wafer, value); }
  252. }
  253. public WaferInfo SRD1Wafer
  254. {
  255. get { return m_srd1Wafer; }
  256. set { SetProperty(ref m_srd1Wafer, value); }
  257. }
  258. public WaferInfo SRD2Wafer
  259. {
  260. get { return m_srd2Wafer; }
  261. set { SetProperty(ref m_srd2Wafer, value); }
  262. }
  263. public int LP1WaferCount
  264. {
  265. get { return m_LP1WaferCount; }
  266. set { SetProperty(ref m_LP1WaferCount, value); }
  267. }
  268. public int LP2WaferCount
  269. {
  270. get { return m_LP2WaferCount; }
  271. set { SetProperty(ref m_LP2WaferCount, value); }
  272. }
  273. public int Dummy1WaferCount
  274. {
  275. get { return m_dummy1WaferCount; }
  276. set { SetProperty(ref m_dummy1WaferCount, value); }
  277. }
  278. public int Dummy2WaferCount
  279. {
  280. get { return m_dummy2WaferCount; }
  281. set { SetProperty(ref m_dummy2WaferCount, value); }
  282. }
  283. public int CycledWafer
  284. {
  285. get { return m_CycledWafer; }
  286. set { SetProperty(ref m_CycledWafer, value); }
  287. }
  288. public int CycleCountDisplay
  289. {
  290. get { return m_CycleCountDisplay; }
  291. set { SetProperty(ref m_CycleCountDisplay, value); }
  292. }
  293. public RobotMoveInfo m_EfemRobotMoveInfo;
  294. public RobotMoveInfo EfemRobotMoveInfo
  295. {
  296. get { return m_EfemRobotMoveInfo; }
  297. set
  298. {
  299. EFEMRobotMoveInfoChanged(m_EfemRobotMoveInfo, value);
  300. //m_EfemRobotMoveInfo = value;
  301. SetProperty(ref m_EfemRobotMoveInfo, value);
  302. }
  303. }
  304. public EFEM.RobotPosition CurrentRobotPosition
  305. {
  306. get { return m_CurrentRobotPosition; }
  307. set { SetProperty(ref m_CurrentRobotPosition, value); }
  308. }
  309. public WaferInfo BladeAWafer
  310. {
  311. get { return m_BladeAWafer; }
  312. set { SetProperty(ref m_BladeAWafer, value); }
  313. }
  314. public WaferInfo BladeBWafer
  315. {
  316. get { return m_BladeBWafer; }
  317. set { SetProperty(ref m_BladeBWafer, value); }
  318. }
  319. public string RouteState
  320. {
  321. get { return m_RouteState; }
  322. set { SetProperty(ref m_RouteState, value); }
  323. }
  324. public bool IsLP1HasNoJob
  325. {
  326. get { return _isLp1HasNoJob; }
  327. set { SetProperty(ref _isLp1HasNoJob, value); }
  328. }
  329. public bool IsLP2HasNoJob
  330. {
  331. get { return _isLp2HasNoJob; }
  332. set { SetProperty(ref _isLp2HasNoJob, value); }
  333. }
  334. #endregion
  335. #region 命令
  336. private DelegateCommand<object> _MapCommand;
  337. public DelegateCommand<object> MapCommand =>
  338. _MapCommand ?? (_MapCommand = new DelegateCommand<object>(OnMap));
  339. private DelegateCommand<object> _StartCommand;
  340. public DelegateCommand<object> StartCommand =>
  341. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  342. private DelegateCommand<object> _StopCommand;
  343. public DelegateCommand<object> StopCommand =>
  344. _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
  345. private DelegateCommand<object> _AbortCommand;
  346. public DelegateCommand<object> AbortCommand =>
  347. _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(OnAbort));
  348. private DelegateCommand _HomeAllCommand;
  349. public DelegateCommand HomeAllCommand =>
  350. _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll));
  351. private DelegateCommand _ResumeAllJobCommand;
  352. public DelegateCommand ResumeAllJobCommand =>
  353. _ResumeAllJobCommand ?? (_ResumeAllJobCommand = new DelegateCommand(OnResumeAllJob));
  354. private DelegateCommand _AbortAllCommand;
  355. public DelegateCommand AbortAllCommand =>
  356. _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll));
  357. private DelegateCommand _ReturnAllWaferCommand;
  358. public DelegateCommand ReturnAllWaferCommand =>
  359. _ReturnAllWaferCommand ?? (_ReturnAllWaferCommand = new DelegateCommand(OnReturnAllWafer));
  360. private DelegateCommand<object> _SetSequenceCommand;
  361. public DelegateCommand<object> SetSequenceCommand =>
  362. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  363. private DelegateCommand _EnableAutoCommand;
  364. public DelegateCommand EnableAutoCommand =>
  365. _EnableAutoCommand ?? (_EnableAutoCommand = new DelegateCommand(OnEnableAuto));
  366. private DelegateCommand _EnableManualCommand;
  367. public DelegateCommand EnableManualCommand =>
  368. _EnableManualCommand ?? (_EnableManualCommand = new DelegateCommand(OnEnableManual));
  369. private DelegateCommand<object> _GotoSrdViewCommond;
  370. public DelegateCommand<object> GotoSrdViewCommond =>
  371. _GotoSrdViewCommond ?? (_GotoSrdViewCommond = new DelegateCommand<object>(GotoSrdViewAction));
  372. public bool SwitchFlag;
  373. #endregion
  374. #region 构造函数
  375. public OperationOverNewViewModel()
  376. {
  377. addDataKeys();
  378. }
  379. #endregion
  380. #region 命令方法
  381. /// <summary>
  382. /// 加载数据
  383. /// </summary>
  384. public void LoadData(string systemName)
  385. {
  386. Dictionary<string, object> allModulesDictionary = QueryDataClient.Instance.Service.PollData(new List<string>() { "System.InstalledModules" });
  387. if (allModulesDictionary != null)
  388. {
  389. List<string> allModules = CommonFunction.GetValue<List<string>>(allModulesDictionary, "System.InstalledModules");
  390. EFEMIsInstalled = allModules.Contains("EFEM");
  391. }
  392. if (_timer == null)
  393. {
  394. _timer = new DispatcherTimer();
  395. _timer.Interval = TimeSpan.FromMilliseconds(100);
  396. _timer.Tick += Timer_Tick;
  397. }
  398. _timer.Start();
  399. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  400. }
  401. /// <summary>
  402. /// 隐藏
  403. /// </summary>
  404. public void Hide()
  405. {
  406. if (_timer != null)
  407. {
  408. _timer.Stop();
  409. }
  410. }
  411. private void OnMap(object obj)
  412. {
  413. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Map");
  414. }
  415. private void OnStart(object obj)
  416. {
  417. var info = obj as WaferAssociationInfo;
  418. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId);
  419. }
  420. private void OnStop(object obj)
  421. {
  422. var info = obj as WaferAssociationInfo;
  423. InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID);
  424. }
  425. private void OnAbort(object obj)
  426. {
  427. var info = obj as WaferAssociationInfo;
  428. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID);
  429. }
  430. private void OnHomeAll()
  431. {
  432. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  433. }
  434. private void OnResumeAllJob()
  435. {
  436. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  437. {
  438. InvokeClient.Instance.Service.DoOperation("System.ResumeAllJob");
  439. }
  440. else
  441. {
  442. InvokeClient.Instance.Service.DoOperation("System.PauseAllJob");
  443. }
  444. }
  445. private void OnAbortAll()
  446. {
  447. InvokeClient.Instance.Service.DoOperation("System.Abort");
  448. }
  449. private void OnReturnAllWafer()
  450. {
  451. //Dialog
  452. WaferDialogView dialog = new WaferDialogView()
  453. {
  454. Owner = Application.Current.MainWindow,
  455. };
  456. dialog.Height = 300;
  457. dialog.Width = 400;
  458. double angel = 0;
  459. double coolingtime = 0;
  460. string message = "Please Confirm Return Wafer";
  461. WaferDialogViewModel vm = new WaferDialogViewModel();
  462. vm.ConfirmText = message;
  463. dialog.DataContext = vm;
  464. if (dialog.ShowDialog() == true)
  465. {
  466. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  467. {
  468. angel = Convert.ToDouble(dialog.Angle);
  469. }
  470. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  471. {
  472. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  473. }
  474. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel);
  475. }
  476. }
  477. private void OnSetSequence(object obj)
  478. {
  479. var info = obj as WaferInfo;
  480. bool flag = info.SequenceName != "" ? false : true;
  481. }
  482. private void OnEnableAuto()
  483. {
  484. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  485. }
  486. private void OnEnableManual()
  487. {
  488. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  489. }
  490. private void GotoSrdViewAction(object obj)
  491. {
  492. PunkHPX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}");
  493. }
  494. #endregion
  495. #region 私有方法
  496. /// <summary>
  497. /// 定时器
  498. /// </summary>
  499. /// <param name="sender"></param>
  500. /// <param name="e"></param>
  501. private void Timer_Tick(object sender, EventArgs e)
  502. {
  503. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  504. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  505. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  506. SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"];
  507. SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"];
  508. Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"];
  509. Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"];
  510. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  511. {
  512. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  513. }
  514. if (EFEMIsInstalled == true)
  515. {
  516. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  517. {
  518. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  519. }
  520. if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0)
  521. {
  522. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  523. }
  524. }
  525. if (ModuleManager.ModuleInfos["VPW1"].WaferManager.Wafers.Count != 0)
  526. {
  527. VPW1Wafer = ModuleManager.ModuleInfos["VPW1"].WaferManager.Wafers[0];
  528. }
  529. if (ModuleManager.ModuleInfos["VPW2"].WaferManager.Wafers.Count != 0)
  530. {
  531. VPW2Wafer = ModuleManager.ModuleInfos["VPW2"].WaferManager.Wafers[0];
  532. }
  533. if (ModuleManager.ModuleInfos["PlatingCell1"].WaferManager.Wafers.Count!=0)
  534. {
  535. PlatingCell1Wafer = ModuleManager.ModuleInfos["PlatingCell1"].WaferManager.Wafers[0];
  536. }
  537. if (ModuleManager.ModuleInfos["PlatingCell2"].WaferManager.Wafers.Count != 0)
  538. {
  539. PlatingCell2Wafer = ModuleManager.ModuleInfos["PlatingCell2"].WaferManager.Wafers[0];
  540. }
  541. if (ModuleManager.ModuleInfos["PlatingCell3"].WaferManager.Wafers.Count != 0)
  542. {
  543. PlatingCell3Wafer = ModuleManager.ModuleInfos["PlatingCell3"].WaferManager.Wafers[0];
  544. }
  545. if (ModuleManager.ModuleInfos["PlatingCell4"].WaferManager.Wafers.Count != 0)
  546. {
  547. PlatingCell4Wafer = ModuleManager.ModuleInfos["PlatingCell4"].WaferManager.Wafers[0];
  548. }
  549. if (SRD1ModuleInfo != null&& SRD1ModuleInfo.WaferManager.Wafers.Count!=0)
  550. {
  551. SRD1Wafer = SRD1ModuleInfo.WaferManager.Wafers[0];
  552. }
  553. if (SRD2ModuleInfo != null&& SRD2ModuleInfo.WaferManager.Wafers.Count!=0)
  554. {
  555. SRD2Wafer = SRD2ModuleInfo.WaferManager.Wafers[0];
  556. }
  557. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  558. EfemRobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  559. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  560. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  561. //Dummy1WaferCount = 15;
  562. Dummy1WaferCount = Dummy1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  563. Dummy2WaferCount = Dummy2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  564. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  565. IsLP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable");
  566. IsLP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable");
  567. if (RtDataValues != null)
  568. {
  569. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  570. {
  571. RouteState = "Resume";
  572. }
  573. else
  574. {
  575. RouteState = "Pause";
  576. }
  577. ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
  578. IsLP1HasNoJob = lp1Cj == null ? true : false;
  579. ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
  580. IsLP2HasNoJob = lp2Cj == null ? true : false;
  581. }
  582. }
  583. int count = 0;
  584. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  585. {
  586. string RobotTarget;
  587. if (oldValue == null || newValue == null)
  588. {
  589. return;
  590. }
  591. #region Rotating
  592. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  593. {
  594. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  595. if (TMRobotMoveActionBladeTarget != null)
  596. {
  597. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  598. }
  599. else
  600. {
  601. return;
  602. }
  603. var values = RobotTarget.Split('.');
  604. var arm = values[0];
  605. var module = values[1];
  606. if (arm == "ArmA")
  607. {
  608. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  609. }
  610. else if (arm == "ArmB")
  611. {
  612. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  613. }
  614. }
  615. #endregion
  616. #region pick 和 place LL
  617. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  618. {
  619. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  620. if (TMRobotMoveActionBladeTarget != null)
  621. {
  622. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  623. }
  624. else
  625. {
  626. return;
  627. }
  628. var values = RobotTarget.Split('.');
  629. var arm = values[0];
  630. var module = values[1];
  631. if (arm == "ArmA")
  632. {
  633. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  634. if (waferRobotTAction != Robot1TAction)
  635. {
  636. Robot1TAction = waferRobotTAction;
  637. }
  638. else
  639. {
  640. //await Task.Delay(100);
  641. }
  642. await Task.Delay(600);
  643. //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  644. //await Task.Delay(600);
  645. Robot1XAction = WaferRobotXAction.Extend;
  646. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  647. {
  648. await Task.Delay(100);
  649. }
  650. Robot1XAction = WaferRobotXAction.Retract;
  651. }
  652. else if (arm == "ArmB")
  653. {
  654. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  655. if (waferRobotTAction != Robot2TAction)
  656. {
  657. Robot2TAction = waferRobotTAction;
  658. }
  659. else
  660. {
  661. //await Task.Delay(100);
  662. }
  663. await Task.Delay(600);
  664. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  665. //await Task.Delay(600);
  666. Robot2XAction = WaferRobotXAction.Extend;
  667. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))
  668. {
  669. await Task.Delay(100);
  670. }
  671. Robot2XAction = WaferRobotXAction.Retract;
  672. }
  673. }
  674. #endregion
  675. #region pick 和 place pm
  676. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  677. {
  678. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  679. if (TMRobotMoveActionBladeTarget != null)
  680. {
  681. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  682. }
  683. else
  684. {
  685. return;
  686. }
  687. var values = RobotTarget.Split('.');
  688. var arm = values[0];
  689. var module = values[1];
  690. if (arm == "ArmA")
  691. {
  692. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  693. if (waferRobotTAction != Robot1TAction)
  694. {
  695. Robot1TAction = waferRobotTAction;
  696. }
  697. else
  698. {
  699. // await Task.Delay(100);
  700. }
  701. await Task.Delay(600);
  702. Robot1XAction = WaferRobotXAction.Extend;
  703. }
  704. else if (arm == "ArmB")
  705. {
  706. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  707. if (waferRobotTAction != Robot2TAction)
  708. {
  709. Robot2TAction = waferRobotTAction;
  710. }
  711. else
  712. {
  713. // await Task.Delay(100);
  714. }
  715. await Task.Delay(600);
  716. Robot2XAction = WaferRobotXAction.Extend;
  717. }
  718. }
  719. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  720. {
  721. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  722. if (TMRobotMoveActionBladeTarget != null)
  723. {
  724. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  725. }
  726. else
  727. {
  728. return;
  729. }
  730. var values = RobotTarget.Split('.');
  731. var arm = values[0];
  732. if (arm == "ArmA")
  733. {
  734. Robot1XAction = WaferRobotXAction.Retract;
  735. }
  736. else if (arm == "ArmB")
  737. {
  738. Robot2XAction = WaferRobotXAction.Retract;
  739. }
  740. }
  741. #endregion
  742. #region Home
  743. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  744. {
  745. if (Robot1XAction == WaferRobotXAction.Extend)
  746. {
  747. Robot1XAction = WaferRobotXAction.Retract;
  748. }
  749. if (Robot2XAction == WaferRobotXAction.Extend)
  750. {
  751. Robot2XAction = WaferRobotXAction.Retract;
  752. }
  753. await Task.Delay(2000);
  754. if (Robot1TAction != WaferRobotTAction.T_Origin)
  755. {
  756. Robot1TAction = WaferRobotTAction.T_Origin;
  757. }
  758. if (Robot2TAction != WaferRobotTAction.T_Origin)
  759. {
  760. Robot2TAction = WaferRobotTAction.T_Origin;
  761. }
  762. }
  763. #endregion
  764. }
  765. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  766. {
  767. string RobotTarget;
  768. if (oldValue == null || newValue == null)
  769. {
  770. return;
  771. }
  772. #region pick 和 place LL
  773. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  774. {
  775. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  776. if (TMRobotMoveActionBladeTarget != null)
  777. {
  778. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  779. }
  780. else
  781. {
  782. return;
  783. }
  784. var values = RobotTarget.Split('.');
  785. var arm = values[0];
  786. var module = values[1];
  787. if (arm == "ArmA")
  788. {
  789. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  790. //await Task.Delay(1000);
  791. await ChangePosition(robot3Robot3TAction, newValue.Action);
  792. if (Robot3TAction != robot3Robot3TAction)
  793. {
  794. Robot3TAction = robot3Robot3TAction;
  795. await Task.Delay(600);
  796. }
  797. Robot3XAction = WaferRobotXAction.Extend;
  798. while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus == 0))
  799. {
  800. await Task.Delay(100);
  801. }
  802. Robot3XAction = WaferRobotXAction.Retract;
  803. if(newValue.Action == RobotAction.Placing)
  804. {
  805. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  806. }
  807. }
  808. }
  809. #endregion
  810. #region pick 和 place pm
  811. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  812. {
  813. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  814. if (TMRobotMoveActionBladeTarget != null)
  815. {
  816. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  817. }
  818. else
  819. {
  820. return;
  821. }
  822. var values = RobotTarget.Split('.');
  823. var arm = values[0];
  824. var module = values[1];
  825. if (arm == "ArmA")
  826. {
  827. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  828. await Task.Delay(1500);
  829. //ChangePosition(Robot3TAction);
  830. //await Task.Delay(2000);
  831. Robot3XAction = WaferRobotXAction.Extend;
  832. }
  833. else if (arm == "ArmB")
  834. {
  835. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  836. await Task.Delay(1500);
  837. //ChangePosition(Robot4TAction);
  838. //await Task.Delay(2000);
  839. Robot4XAction = WaferRobotXAction.Extend;
  840. }
  841. }
  842. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  843. {
  844. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  845. if (TMRobotMoveActionBladeTarget != null)
  846. {
  847. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  848. }
  849. else
  850. {
  851. return;
  852. }
  853. var values = RobotTarget.Split('.');
  854. var arm = values[0];
  855. if (arm == "ArmA")
  856. {
  857. Robot3XAction = WaferRobotXAction.Retract;
  858. await Task.Delay(3000);
  859. //ChangePosition(Robot3TAction);
  860. //await Task.Delay(2000);
  861. }
  862. else if (arm == "ArmB")
  863. {
  864. Robot4XAction = WaferRobotXAction.Retract;
  865. await Task.Delay(3000);
  866. //ChangePosition(Robot3TAction);
  867. //await Task.Delay(2000);
  868. }
  869. }
  870. #endregion
  871. #region Home
  872. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  873. {
  874. if (Robot3XAction == WaferRobotXAction.Extend)
  875. {
  876. Robot3XAction = WaferRobotXAction.Retract;
  877. }
  878. if (Robot4XAction == WaferRobotXAction.Extend)
  879. {
  880. Robot4XAction = WaferRobotXAction.Retract;
  881. }
  882. if (Robot3TAction != WaferRobotTAction.T_Origin)
  883. {
  884. Robot3TAction = WaferRobotTAction.T_Origin;
  885. }
  886. if (Robot4TAction != WaferRobotTAction.T_Origin)
  887. {
  888. Robot4TAction = WaferRobotTAction.T_Origin;
  889. }
  890. await Task.Delay(1000);
  891. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  892. }
  893. #endregion
  894. }
  895. private void addDataKeys()
  896. {
  897. m_RtDataKeys.Add("LP1.IsLoaded");
  898. m_RtDataKeys.Add("LP2.IsLoaded");
  899. m_RtDataKeys.Add("LP1.CassettePlaced");
  900. m_RtDataKeys.Add("LP2.CassettePlaced");
  901. m_RtDataKeys.Add("LP1.CurrentControlJob");
  902. m_RtDataKeys.Add("LP2.CurrentControlJob");
  903. m_RtDataKeys.Add("LP1.WaferSize");
  904. m_RtDataKeys.Add("LP2.WaferSize");
  905. m_RtDataKeys.Add("Dummy1.CassettePlaced");
  906. m_RtDataKeys.Add("Dummy2.CassettePlaced");
  907. m_RtDataKeys.Add("Dummy1.WaferSize");
  908. m_RtDataKeys.Add("Dummy2.WaferSize");
  909. m_RtDataKeys.Add("System.IsAutoMode");
  910. m_RtDataKeys.Add("System.IsBusy");
  911. m_RtDataKeys.Add("Scheduler.CycledCount");
  912. m_RtDataKeys.Add("Scheduler.CycledWafer");
  913. m_RtDataKeys.Add("Scheduler.CycleSetPoint");
  914. m_RtDataKeys.Add("Scheduler.Throughput");
  915. m_RtDataKeys.Add("EquipmentStatus");
  916. m_RtDataKeys.Add("Scheduler.PjNameList");
  917. m_RtDataKeys.Add("Scheduler.CjNameList");
  918. }
  919. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  920. {
  921. if (wafers[index].WaferStatus == 0)
  922. return false;
  923. return true;
  924. }
  925. private async Task ChangePosition(WaferRobotTAction waferRobotTAction, RobotAction robotAction)
  926. {
  927. await Task.Delay(500);
  928. int delay = 500;
  929. if (robotAction == RobotAction.Placing)
  930. {
  931. if (waferRobotTAction == WaferRobotTAction.LP1)
  932. {
  933. CurrentRobotPosition = EFEM.RobotPosition.Left_Place;
  934. await Task.Delay(delay);
  935. }
  936. else if (waferRobotTAction == WaferRobotTAction.LP3)
  937. {
  938. CurrentRobotPosition = EFEM.RobotPosition.Right_Place;
  939. await Task.Delay(delay);
  940. }
  941. else if (waferRobotTAction == WaferRobotTAction.LP2 )
  942. {
  943. CurrentRobotPosition = EFEM.RobotPosition.Middle_Place;
  944. await Task.Delay(delay);
  945. }
  946. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  947. {
  948. CurrentRobotPosition = EFEM.RobotPosition.Aligner_Place;
  949. await Task.Delay(delay);
  950. }
  951. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  952. {
  953. CurrentRobotPosition = EFEM.RobotPosition.SRD_Place;
  954. }
  955. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  956. {
  957. CurrentRobotPosition = EFEM.RobotPosition.Dummy_Place;
  958. }
  959. else
  960. {
  961. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  962. await Task.Delay(delay);
  963. }
  964. }
  965. else
  966. {
  967. if (waferRobotTAction == WaferRobotTAction.LP1)
  968. {
  969. CurrentRobotPosition = EFEM.RobotPosition.Left;
  970. await Task.Delay(delay);
  971. }
  972. else if (waferRobotTAction == WaferRobotTAction.LP3)
  973. {
  974. CurrentRobotPosition = EFEM.RobotPosition.Right;
  975. await Task.Delay(delay);
  976. }
  977. else if (waferRobotTAction == WaferRobotTAction.LP2)
  978. {
  979. CurrentRobotPosition = EFEM.RobotPosition.Middle;
  980. await Task.Delay(delay);
  981. }
  982. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  983. {
  984. CurrentRobotPosition = EFEM.RobotPosition.Aligner;
  985. await Task.Delay(delay);
  986. }
  987. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  988. {
  989. CurrentRobotPosition = EFEM.RobotPosition.SRD;
  990. }
  991. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  992. {
  993. CurrentRobotPosition = EFEM.RobotPosition.Dummy;
  994. }
  995. else
  996. {
  997. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  998. await Task.Delay(delay);
  999. }
  1000. }
  1001. }
  1002. /// <summary>
  1003. /// 计算最大值最小值
  1004. /// </summary>
  1005. /// <param name="Puf1RotationAxis"></param>
  1006. /// <returns></returns>
  1007. private (double right, double left) CalculatePufMaxMin(BeckhoffStationAxis pufAxis)
  1008. {
  1009. if (pufAxis == null || pufAxis.Stations.Count == 0) return (-1,-1);
  1010. double max = double.Parse(pufAxis.Stations[0].Position);
  1011. double min = double.Parse(pufAxis.Stations[0].Position);
  1012. double home = 0;
  1013. double pickup = 0;
  1014. foreach (Station item in pufAxis.Stations)
  1015. {
  1016. if (item.Name.ToLower().Contains("home")) home = double.Parse(item.Position);
  1017. if (item.Name.ToLower().Contains("pickup")) pickup = double.Parse(item.Position);
  1018. double position = double.Parse(item.Position);
  1019. if (position > max)
  1020. {
  1021. max = position;
  1022. }
  1023. if (position < min)
  1024. {
  1025. min = position;
  1026. }
  1027. }
  1028. return pickup < home ? (min, max):(max, min);
  1029. }
  1030. /// <summary>
  1031. /// 计算PufFlip差值
  1032. /// </summary>
  1033. /// <param name="pufAxis"></param>
  1034. /// <returns></returns>
  1035. private double CalculatePufFlipDiff(BeckhoffStationAxis pufAxis)
  1036. {
  1037. double sideAangle = 0;
  1038. double sideBangle = 0; ;
  1039. return sideAangle > sideBangle ? 180 : 0;
  1040. }
  1041. /// <summary>
  1042. /// 判定是否在station位置
  1043. /// </summary>
  1044. private bool JudgeAtStation(double targetPosition, double currentPosition, double tolerance)
  1045. {
  1046. if (Math.Abs(currentPosition - targetPosition) <= tolerance)
  1047. {
  1048. return true;
  1049. }
  1050. else
  1051. {
  1052. return false;
  1053. }
  1054. }
  1055. #endregion
  1056. }
  1057. }