OperationOverViewModel.cs 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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 CyberX8_Core;
  16. using CyberX8_MainPages.Unity;
  17. using CyberX8_MainPages.Views;
  18. using CyberX8_Themes.CustomControls;
  19. using CyberX8_Themes.Unity;
  20. using CyberX8_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.CommonData.PUF;
  36. using MECF.Framework.Common.Beckhoff.AxisProvider;
  37. using QiHe.CodeLib;
  38. using MECF.Framework.Common.Jobs;
  39. namespace CyberX8_MainPages.ViewModels
  40. {
  41. public class OperationOverViewModel : 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. private const double PUF_FLIP_DIFFER = 180;
  49. #endregion
  50. #region 私有字段
  51. private bool _isLp1Unable;
  52. private bool _isLp2Unable;
  53. private bool _isLp3Unable;
  54. private ModuleInfo _LP1ModuleInfo;
  55. private ModuleInfo _LP2ModuleInfo;
  56. private ModuleInfo _LP3ModuleInfo;
  57. private ModuleInfo _EFEMModuleInfo;
  58. private ModuleInfo _srd1ModuleInfo;
  59. private ModuleInfo _srd2ModuleInfo;
  60. private ModuleInfo _puf1ModuleInfo;
  61. private ModuleInfo _dummy1ModuleInfo;
  62. private ModuleInfo _dummy2ModuleInfo;
  63. private ModuleInfo _loaderModuleInfo;
  64. private WaferRobotTAction m_Robot1TAction;
  65. private WaferRobotXAction m_Robot1XAction;
  66. private WaferRobotTAction m_Robot2TAction;
  67. private WaferRobotXAction m_Robot2XAction;
  68. private WaferRobotTAction m_Robot3TAction;
  69. private WaferRobotXAction m_Robot3XAction;
  70. private WaferRobotTAction m_Robot4TAction;
  71. private WaferRobotXAction m_Robot4XAction;
  72. private RobotMoveInfo m_robotMoveInfo;
  73. private WaferInfo m_srd1Wafer;
  74. private WaferInfo m_srd2Wafer;
  75. private WaferInfo m_puf1WaferA;
  76. private WaferInfo m_puf1WaferB;
  77. private WaferInfo m_loaderWaferA;
  78. private WaferInfo m_loaderWaferB;
  79. private List<string> m_RtDataKeys = new List<string>();
  80. private Dictionary<string, object> m_RtDataValues;
  81. private bool m_EFEMIsInstalled;
  82. private bool m_loaderInstalled;
  83. private bool m_puf1IsInRobotStation;
  84. //private bool m_IsPUFChange;
  85. private WaferInfo m_EFEMBladeAWafer;
  86. private WaferInfo m_EFEMBladeBWafer;
  87. private WaferInfo m_Aligner1Wafer;
  88. private int m_LP1WaferCount;
  89. private int m_LP2WaferCount;
  90. private int m_LP3WaferCount;
  91. private int m_dummy1WaferCount;
  92. private int m_dummy2WaferCount;
  93. private int m_CycledWafer;
  94. private int m_CycleCountDisplay;
  95. private EFEM.RobotPosition m_CurrentRobotPosition;
  96. private PufControl.LoaderXLocation m_loaderAXLoaction = PufControl.LoaderXLocation.Parker;
  97. private PufControl.LoaderXLocation m_loaderBXLoaction = PufControl.LoaderXLocation.Parker;
  98. /// <summary>
  99. /// Loader的sideA开启状态
  100. /// </summary>
  101. private bool m_loaderWaferVisibleA = false;
  102. /// <summary>
  103. /// Loader的sideB开启状态
  104. /// </summary>
  105. private bool m_loaderWaferVisibleB = false;
  106. private WaferInfo m_BladeAWafer;
  107. private WaferInfo m_BladeBWafer;
  108. private string m_ATMModeIsOn;
  109. private string m_RouteState;
  110. /// <summary>
  111. /// puf1 Rotation ui 水平比例
  112. /// </summary>
  113. private double _puf1RotationRatio;
  114. /// <summary>
  115. /// 定时器
  116. /// </summary>
  117. private DispatcherTimer _timer;
  118. /// <summary>
  119. /// 定时器1
  120. /// </summary>
  121. private DispatcherTimer _timer1;
  122. /// <summary>
  123. /// puf Rotation UI水平距离
  124. /// </summary>
  125. private int _pufLayoutRotationDistance;
  126. /// <summary>
  127. /// Efem robot UI位置
  128. /// </summary>
  129. private int _robotLayoutPosition;
  130. /// <summary>
  131. /// Puf1 Rotation实际位置数据
  132. /// </summary>
  133. private double _puf1RotationMotorPosition;
  134. /// <summary>
  135. /// Puf1 Flip实际位置数据
  136. /// </summary>
  137. private double _puf1FlipMotorPosition;
  138. /// <summary>
  139. /// Puf1 Flip UI位置
  140. /// </summary>
  141. private double _puf1FlipPosition;
  142. /// <summary>
  143. /// Puf1 Rotation最左侧的位置
  144. /// </summary>
  145. private double _puf1RotationMotorPositionMax;
  146. /// <summary>
  147. /// Puf1 Rotation UI对应位置
  148. /// </summary>
  149. private double _puf1RotationPosition;
  150. /// <summary>
  151. /// Loader1 Rotation UI对应位置
  152. /// </summary>
  153. private double _loader1RotationPosition;
  154. /// <summary>
  155. /// Puf1 Rotation Axis
  156. /// </summary>
  157. private BeckhoffStationAxis _puf1RotationAxis;
  158. /// <summary>
  159. /// Puf1 Flip Axis
  160. /// </summary>
  161. private BeckhoffStationAxis _puf1FlipAxis;
  162. /// <summary>
  163. /// Loader1 Rotation Axis
  164. /// </summary>
  165. private BeckhoffStationAxis _loader1RotationAxis;
  166. /// <summary>
  167. /// Loader1 TlitA Axis
  168. /// </summary>
  169. private BeckhoffStationAxis _loader1TiltAAxis;
  170. /// <summary>
  171. /// Loader1 TlitB Axis
  172. /// </summary>
  173. private BeckhoffStationAxis _loader1TiltBAxis;
  174. /// <summary>
  175. /// Loader1 Rotation实际位置数据
  176. /// </summary>
  177. private double _loader1RotationMotorPosition;
  178. /// <summary>
  179. /// Loader1 TiltA实际位置数据
  180. /// </summary>
  181. private double _loader1TiltAMotorPosition;
  182. /// <summary>
  183. /// Loader1 TiltB实际位置数据
  184. /// </summary>
  185. private double _loader1TiltBMotorPosition;
  186. /// <summary>
  187. /// Loader Rotation位置
  188. /// </summary>
  189. private LoaderControl.LoaderRotation m_currentLoaderRotation = LoaderControl.LoaderRotation.Load;
  190. /// <summary>
  191. /// Puf1 Flip当前station
  192. /// </summary>
  193. private string _puf1FlipCurrentStation;
  194. /// <summary>
  195. /// Loader1 TiltA当前station
  196. /// </summary>
  197. private string _loaderTiltACurrentStation;
  198. /// <summary>
  199. /// Loader1 TiltB当前station
  200. /// </summary>
  201. private string _loaderTiltBCurrentStation;
  202. /// <summary>
  203. /// 是否存在Job
  204. /// </summary>
  205. private bool _isLp1HasNoJob;
  206. private bool _isLp2HasNoJob;
  207. private bool _isLp3HasNoJob;
  208. #endregion
  209. #region 属性
  210. public bool IsLP1Unable
  211. {
  212. get { return _isLp1Unable; }
  213. set { SetProperty(ref _isLp1Unable, value); }
  214. }
  215. public bool IsLP2Unable
  216. {
  217. get { return _isLp2Unable; }
  218. set { SetProperty(ref _isLp2Unable, value); }
  219. }
  220. public bool IsLP3Unable
  221. {
  222. get { return _isLp3Unable; }
  223. set { SetProperty(ref _isLp3Unable, value); }
  224. }
  225. public ModuleInfo LP1ModuleInfo
  226. {
  227. get { return _LP1ModuleInfo; }
  228. set { SetProperty(ref _LP1ModuleInfo, value); }
  229. }
  230. public ModuleInfo EFEMModuleInfo
  231. {
  232. get { return _EFEMModuleInfo; }
  233. set { SetProperty(ref _EFEMModuleInfo, value); }
  234. }
  235. public ModuleInfo LP2ModuleInfo
  236. {
  237. get { return _LP2ModuleInfo; }
  238. set { SetProperty(ref _LP2ModuleInfo, value); }
  239. }
  240. public ModuleInfo LP3ModuleInfo
  241. {
  242. get { return _LP3ModuleInfo; }
  243. set { SetProperty(ref _LP3ModuleInfo, value); }
  244. }
  245. public ModuleInfo SRD1ModuleInfo
  246. {
  247. get { return _srd1ModuleInfo; }
  248. set { SetProperty(ref _srd1ModuleInfo, value); }
  249. }
  250. public ModuleInfo SRD2ModuleInfo
  251. {
  252. get { return _srd2ModuleInfo; }
  253. set { SetProperty(ref _srd2ModuleInfo, value); }
  254. }
  255. public ModuleInfo PUF1ModuleInfo
  256. {
  257. get { return _puf1ModuleInfo; }
  258. set { SetProperty(ref _puf1ModuleInfo, value); }
  259. }
  260. public ModuleInfo Dummy1ModuleInfo
  261. {
  262. get { return _dummy1ModuleInfo; }
  263. set { SetProperty(ref _dummy1ModuleInfo, value); }
  264. }
  265. public ModuleInfo Dummy2ModuleInfo
  266. {
  267. get { return _dummy2ModuleInfo; }
  268. set { SetProperty(ref _dummy2ModuleInfo, value); }
  269. }
  270. public ModuleInfo LoaderModuleInfo
  271. {
  272. get { return _loaderModuleInfo; }
  273. set { SetProperty(ref _loaderModuleInfo, value); }
  274. }
  275. public WaferRobotTAction Robot1TAction
  276. {
  277. get { return m_Robot1TAction; }
  278. set { SetProperty(ref m_Robot1TAction, value); }
  279. }
  280. public WaferRobotXAction Robot1XAction
  281. {
  282. get { return m_Robot1XAction; }
  283. set { SetProperty(ref m_Robot1XAction, value); }
  284. }
  285. public WaferRobotTAction Robot2TAction
  286. {
  287. get { return m_Robot2TAction; }
  288. set { SetProperty(ref m_Robot2TAction, value); }
  289. }
  290. public WaferRobotXAction Robot2XAction
  291. {
  292. get { return m_Robot2XAction; }
  293. set { SetProperty(ref m_Robot2XAction, value); }
  294. }
  295. public WaferRobotTAction Robot3TAction
  296. {
  297. get { return m_Robot3TAction; }
  298. set { SetProperty(ref m_Robot3TAction, value); }
  299. }
  300. public WaferRobotXAction Robot3XAction
  301. {
  302. get { return m_Robot3XAction; }
  303. set { SetProperty(ref m_Robot3XAction, value); }
  304. }
  305. public WaferRobotTAction Robot4TAction
  306. {
  307. get { return m_Robot4TAction; }
  308. set { SetProperty(ref m_Robot4TAction, value); }
  309. }
  310. public WaferRobotXAction Robot4XAction
  311. {
  312. get { return m_Robot4XAction; }
  313. set { SetProperty(ref m_Robot4XAction, value); }
  314. }
  315. public RobotMoveInfo RobotMoveInfo
  316. {
  317. get { return m_robotMoveInfo; }
  318. set
  319. {
  320. RobotMoveInfoChanged(m_robotMoveInfo, value);
  321. //m_robotMoveInfo = value;
  322. SetProperty(ref m_robotMoveInfo, value);
  323. }
  324. }
  325. public Dictionary<string, object> RtDataValues
  326. {
  327. get { return m_RtDataValues; }
  328. set { SetProperty(ref m_RtDataValues, value); }
  329. }
  330. public bool EFEMIsInstalled
  331. {
  332. get { return m_EFEMIsInstalled; }
  333. set { SetProperty(ref m_EFEMIsInstalled, value); }
  334. }
  335. public WaferInfo EFEMBladeAWafer
  336. {
  337. get { return m_EFEMBladeAWafer; }
  338. set { SetProperty(ref m_EFEMBladeAWafer, value); }
  339. }
  340. public WaferInfo EFEMBladeBWafer
  341. {
  342. get { return m_EFEMBladeBWafer; }
  343. set { SetProperty(ref m_EFEMBladeBWafer, value); }
  344. }
  345. public bool LoaderIsInstalled
  346. {
  347. get { return m_loaderInstalled; }
  348. set { SetProperty(ref m_loaderInstalled, value); }
  349. }
  350. public WaferInfo Aligner1Wafer
  351. {
  352. get { return m_Aligner1Wafer; }
  353. set { SetProperty(ref m_Aligner1Wafer, value); }
  354. }
  355. public WaferInfo SRD1Wafer
  356. {
  357. get { return m_srd1Wafer; }
  358. set { SetProperty(ref m_srd1Wafer, value); }
  359. }
  360. public WaferInfo SRD2Wafer
  361. {
  362. get { return m_srd2Wafer; }
  363. set { SetProperty(ref m_srd2Wafer, value); }
  364. }
  365. public WaferInfo PUF1WaferA
  366. {
  367. get { return m_puf1WaferA; }
  368. set { SetProperty(ref m_puf1WaferA, value); }
  369. }
  370. public WaferInfo PUF1WaferB
  371. {
  372. get { return m_puf1WaferB; }
  373. set { SetProperty(ref m_puf1WaferB, value); }
  374. }
  375. public WaferInfo LoaderWaferA
  376. {
  377. get { return m_loaderWaferA; }
  378. set { SetProperty(ref m_loaderWaferA, value); }
  379. }
  380. public WaferInfo LoaderWaferB
  381. {
  382. get { return m_loaderWaferB; }
  383. set { SetProperty(ref m_loaderWaferB, value); }
  384. }
  385. public int LP1WaferCount
  386. {
  387. get { return m_LP1WaferCount; }
  388. set { SetProperty(ref m_LP1WaferCount, value); }
  389. }
  390. public int LP2WaferCount
  391. {
  392. get { return m_LP2WaferCount; }
  393. set { SetProperty(ref m_LP2WaferCount, value); }
  394. }
  395. public int LP3WaferCount
  396. {
  397. get { return m_LP3WaferCount; }
  398. set { SetProperty(ref m_LP3WaferCount, value); }
  399. }
  400. public int Dummy1WaferCount
  401. {
  402. get { return m_dummy1WaferCount; }
  403. set { SetProperty(ref m_dummy1WaferCount, value); }
  404. }
  405. public int Dummy2WaferCount
  406. {
  407. get { return m_dummy2WaferCount; }
  408. set { SetProperty(ref m_dummy2WaferCount, value); }
  409. }
  410. public int CycledWafer
  411. {
  412. get { return m_CycledWafer; }
  413. set { SetProperty(ref m_CycledWafer, value); }
  414. }
  415. public int CycleCountDisplay
  416. {
  417. get { return m_CycleCountDisplay; }
  418. set { SetProperty(ref m_CycleCountDisplay, value); }
  419. }
  420. public RobotMoveInfo m_EfemRobotMoveInfo;
  421. public RobotMoveInfo EfemRobotMoveInfo
  422. {
  423. get { return m_EfemRobotMoveInfo; }
  424. set
  425. {
  426. EFEMRobotMoveInfoChanged(m_EfemRobotMoveInfo, value);
  427. //m_EfemRobotMoveInfo = value;
  428. SetProperty(ref m_EfemRobotMoveInfo, value);
  429. }
  430. }
  431. public EFEM.RobotPosition CurrentRobotPosition
  432. {
  433. get { return m_CurrentRobotPosition; }
  434. set { SetProperty(ref m_CurrentRobotPosition, value); }
  435. }
  436. public PufControl.LoaderXLocation LoaderAXLocation
  437. {
  438. get { return m_loaderAXLoaction; }
  439. set { SetProperty(ref m_loaderAXLoaction, value); }
  440. }
  441. public PufControl.LoaderXLocation LoaderBXLocation
  442. {
  443. get { return m_loaderBXLoaction; }
  444. set { SetProperty(ref m_loaderBXLoaction, value); }
  445. }
  446. public WaferInfo BladeAWafer
  447. {
  448. get { return m_BladeAWafer; }
  449. set { SetProperty(ref m_BladeAWafer, value); }
  450. }
  451. public WaferInfo BladeBWafer
  452. {
  453. get { return m_BladeBWafer; }
  454. set { SetProperty(ref m_BladeBWafer, value); }
  455. }
  456. public string ATMModeIsOn
  457. {
  458. get { return m_ATMModeIsOn; }
  459. set { SetProperty(ref m_ATMModeIsOn, value); }
  460. }
  461. public string RouteState
  462. {
  463. get { return m_RouteState; }
  464. set { SetProperty(ref m_RouteState, value); }
  465. }
  466. /// <summary>
  467. /// Loader的sideA开启状态
  468. /// </summary>
  469. public bool LoaderWaferVisibleA
  470. {
  471. get { return m_loaderWaferVisibleA; }
  472. set { SetProperty(ref m_loaderWaferVisibleA, value); }
  473. }
  474. /// <summary>
  475. /// Loader的sideB开启状态
  476. /// </summary>
  477. public bool LoaderWaferVisibleB
  478. {
  479. get { return m_loaderWaferVisibleB; }
  480. set { SetProperty(ref m_loaderWaferVisibleB, value); }
  481. }
  482. public bool Puf1IsInRobotStation
  483. {
  484. get { return m_puf1IsInRobotStation; }
  485. set { SetProperty(ref m_puf1IsInRobotStation, value); }
  486. }
  487. /// <summary>
  488. /// Puf1 Rotation实际位置数据
  489. /// </summary>
  490. public double Puf1RotationMotorPosition
  491. {
  492. get { return _puf1RotationMotorPosition; }
  493. set { SetProperty(ref _puf1RotationMotorPosition, value); }
  494. }
  495. /// <summary>
  496. /// Puf1 Flip实际位置数据
  497. /// </summary>
  498. public double Puf1FlipMotorPosition
  499. {
  500. get { return _puf1FlipMotorPosition; }
  501. set { SetProperty(ref _puf1FlipMotorPosition, value); }
  502. }
  503. /// <summary>
  504. /// Puf1 Flip UI位置
  505. /// </summary>
  506. public double Puf1FlipPosition
  507. {
  508. get { return _puf1FlipPosition; }
  509. set { SetProperty(ref _puf1FlipPosition, value); }
  510. }
  511. /// <summary>
  512. /// Puf1 Rotation UI对应位置
  513. /// </summary>
  514. public double Puf1RotationPosition
  515. {
  516. get { return _puf1RotationPosition; }
  517. set { SetProperty(ref _puf1RotationPosition, value); }
  518. }
  519. /// <summary>
  520. /// Loader1 Rotation UI对应位置
  521. /// </summary>
  522. public double Loader1RotationPosition
  523. {
  524. get { return _loader1RotationPosition; }
  525. set { SetProperty(ref _loader1RotationPosition, value); }
  526. }
  527. /// <summary>
  528. /// Puf1 Rotation Axis
  529. /// </summary>
  530. public BeckhoffStationAxis Puf1RotationAxis
  531. {
  532. get { return _puf1RotationAxis; }
  533. set { SetProperty(ref _puf1RotationAxis, value); }
  534. }
  535. /// <summary>
  536. /// Puf1 Flip Axis
  537. /// </summary>
  538. public BeckhoffStationAxis Puf1FlipAxis
  539. {
  540. get { return _puf1FlipAxis; }
  541. set { SetProperty(ref _puf1FlipAxis, value); }
  542. }
  543. /// <summary>
  544. /// Loader1 Rotation Axis
  545. /// </summary>
  546. public BeckhoffStationAxis Loader1RotationAxis
  547. {
  548. get { return _loader1RotationAxis; }
  549. set { SetProperty(ref _loader1RotationAxis, value); }
  550. }
  551. /// <summary>
  552. /// Loader1 TiltA Axis
  553. /// </summary>
  554. public BeckhoffStationAxis Loader1TiltAAxis
  555. {
  556. get { return _loader1TiltAAxis; }
  557. set { SetProperty(ref _loader1TiltAAxis, value); }
  558. }
  559. /// <summary>
  560. /// Loader1 TiltB Axis
  561. /// </summary>
  562. public BeckhoffStationAxis Loader1TiltBAxis
  563. {
  564. get { return _loader1TiltBAxis; }
  565. set { SetProperty(ref _loader1TiltBAxis, value); }
  566. }
  567. /// <summary>
  568. /// Loader1 Rotation实际位置数据
  569. /// </summary>
  570. public double Loader1RotationMotorPosition
  571. {
  572. get { return _loader1RotationMotorPosition; }
  573. set { SetProperty(ref _loader1RotationMotorPosition, value); }
  574. }
  575. /// <summary>
  576. /// Loader1 TiltA实际位置数据
  577. /// </summary>
  578. public double Loader1TiltAMotorPosition
  579. {
  580. get { return _loader1TiltAMotorPosition; }
  581. set { SetProperty(ref _loader1TiltAMotorPosition, value); }
  582. }
  583. /// <summary>
  584. /// Loader1 TiltB实际位置数据
  585. /// </summary>
  586. public double Loader1TiltBMotorPosition
  587. {
  588. get { return _loader1TiltBMotorPosition; }
  589. set { SetProperty(ref _loader1TiltBMotorPosition, value); }
  590. }
  591. /// <summary>
  592. /// Loader Rotation位置
  593. /// </summary>
  594. public LoaderControl.LoaderRotation CurrentLoaderRotation
  595. {
  596. get { return m_currentLoaderRotation; }
  597. set { SetProperty(ref m_currentLoaderRotation, value); }
  598. }
  599. public string LoaderTiltACurrentStation
  600. {
  601. get { return _loaderTiltACurrentStation; }
  602. set { SetProperty(ref _loaderTiltACurrentStation, value); }
  603. }
  604. /// <summary>
  605. /// Loader TiltB当前station
  606. /// </summary>
  607. public string LoaderTiltBCurrentStation
  608. {
  609. get { return _loaderTiltBCurrentStation; }
  610. set { SetProperty(ref _loaderTiltBCurrentStation, value); }
  611. }
  612. public bool IsLP1HasNoJob
  613. {
  614. get { return _isLp1HasNoJob; }
  615. set { SetProperty(ref _isLp1HasNoJob, value); }
  616. }
  617. public bool IsLP2HasNoJob
  618. {
  619. get { return _isLp2HasNoJob; }
  620. set { SetProperty(ref _isLp2HasNoJob, value); }
  621. }
  622. public bool IsLP3HasNoJob
  623. {
  624. get { return _isLp3HasNoJob; }
  625. set { SetProperty(ref _isLp3HasNoJob, value); }
  626. }
  627. #endregion
  628. #region 命令
  629. private DelegateCommand<object> _MapCommand;
  630. public DelegateCommand<object> MapCommand =>
  631. _MapCommand ?? (_MapCommand = new DelegateCommand<object>(OnMap));
  632. private DelegateCommand<object> _StartCommand;
  633. public DelegateCommand<object> StartCommand =>
  634. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  635. private DelegateCommand<object> _StopCommand;
  636. public DelegateCommand<object> StopCommand =>
  637. _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
  638. private DelegateCommand<object> _AbortCommand;
  639. public DelegateCommand<object> AbortCommand =>
  640. _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(OnAbort));
  641. private DelegateCommand _HomeAllCommand;
  642. public DelegateCommand HomeAllCommand =>
  643. _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll));
  644. private DelegateCommand _ResumeAllJobCommand;
  645. public DelegateCommand ResumeAllJobCommand =>
  646. _ResumeAllJobCommand ?? (_ResumeAllJobCommand = new DelegateCommand(OnResumeAllJob));
  647. private DelegateCommand _AbortAllCommand;
  648. public DelegateCommand AbortAllCommand =>
  649. _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll));
  650. private DelegateCommand _ReturnAllWaferCommand;
  651. public DelegateCommand ReturnAllWaferCommand =>
  652. _ReturnAllWaferCommand ?? (_ReturnAllWaferCommand = new DelegateCommand(OnReturnAllWafer));
  653. private DelegateCommand<object> _SetSequenceCommand;
  654. public DelegateCommand<object> SetSequenceCommand =>
  655. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  656. private DelegateCommand _EnableAutoCommand;
  657. public DelegateCommand EnableAutoCommand =>
  658. _EnableAutoCommand ?? (_EnableAutoCommand = new DelegateCommand(OnEnableAuto));
  659. private DelegateCommand _EnableManualCommand;
  660. public DelegateCommand EnableManualCommand =>
  661. _EnableManualCommand ?? (_EnableManualCommand = new DelegateCommand(OnEnableManual));
  662. private DelegateCommand<object> _GotoSrdViewCommond;
  663. public DelegateCommand<object> GotoSrdViewCommond =>
  664. _GotoSrdViewCommond ?? (_GotoSrdViewCommond = new DelegateCommand<object>(GotoSrdViewAction));
  665. public bool SwitchFlag;
  666. #endregion
  667. #region 构造函数
  668. public OperationOverViewModel()
  669. {
  670. addDataKeys();
  671. ATMModeIsOn = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig("System.IsATMMode")) == true ? "ATM Mode On" : "ATM Mode Off";
  672. }
  673. #endregion
  674. #region 命令方法
  675. /// <summary>
  676. /// 加载数据
  677. /// </summary>
  678. public void LoadData(string systemName)
  679. {
  680. Dictionary<string, object> allModulesDictionary = QueryDataClient.Instance.Service.PollData(new List<string>() { "System.InstalledModules" });
  681. if (allModulesDictionary != null)
  682. {
  683. List<string> allModules = CommonFunction.GetValue<List<string>>(allModulesDictionary, "System.InstalledModules");
  684. EFEMIsInstalled = allModules.Contains("EFEM");
  685. LoaderIsInstalled = allModules.Contains(ModuleName.Loader1.ToString());
  686. }
  687. if (_timer == null)
  688. {
  689. _timer = new DispatcherTimer();
  690. _timer.Interval = TimeSpan.FromMilliseconds(100);
  691. _timer.Tick += Timer_Tick;
  692. }
  693. _timer.Start();
  694. if (_timer1 == null)
  695. {
  696. _timer1 = new DispatcherTimer();
  697. _timer1.Interval = TimeSpan.FromMilliseconds(50);
  698. _timer1.Tick += Timer1_Tick;
  699. }
  700. _timer1.Start();
  701. _pufLayoutRotationDistance = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.PufLayoutRotationDistance");
  702. _robotLayoutPosition = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.RobotLayoutPosition");
  703. if (!m_RtDataKeys.Contains($"Station.PUF1.Roation"))
  704. {
  705. addStationDataKeys();
  706. }
  707. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  708. if (RtDataValues != null)
  709. {
  710. //目标位置数据获取
  711. Puf1RotationAxis = CommonFunction.GetValue<BeckhoffStationAxis>(RtDataValues, $"Station.PUF1.Rotation");
  712. //Puf1Rotation比例尺计算
  713. var resultRotation = Puf1RotationAxis != null ? CalculateMaxMin(Puf1RotationAxis) : (0, 0);
  714. double distance = resultRotation.max - resultRotation.min;
  715. _puf1RotationRatio = distance / _pufLayoutRotationDistance;
  716. _puf1RotationMotorPositionMax = resultRotation.max;
  717. }
  718. }
  719. /// <summary>
  720. /// 隐藏
  721. /// </summary>
  722. public void Hide()
  723. {
  724. if (_timer != null)
  725. {
  726. _timer.Stop();
  727. }
  728. if (_timer1 != null)
  729. {
  730. _timer1.Stop();
  731. }
  732. }
  733. private void OnMap(object obj)
  734. {
  735. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Map");
  736. }
  737. private void OnStart(object obj)
  738. {
  739. var info = obj as WaferAssociationInfo;
  740. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId);
  741. }
  742. private void OnStop(object obj)
  743. {
  744. var info = obj as WaferAssociationInfo;
  745. InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID);
  746. }
  747. private void OnAbort(object obj)
  748. {
  749. var info = obj as WaferAssociationInfo;
  750. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID);
  751. }
  752. private void OnHomeAll()
  753. {
  754. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  755. }
  756. private void OnResumeAllJob()
  757. {
  758. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  759. {
  760. InvokeClient.Instance.Service.DoOperation("System.ResumeAllJob");
  761. }
  762. else
  763. {
  764. InvokeClient.Instance.Service.DoOperation("System.PauseAllJob");
  765. }
  766. }
  767. private void OnAbortAll()
  768. {
  769. InvokeClient.Instance.Service.DoOperation("System.Abort");
  770. }
  771. private void OnReturnAllWafer()
  772. {
  773. //Dialog
  774. WaferDialogView dialog = new WaferDialogView()
  775. {
  776. Owner = Application.Current.MainWindow,
  777. };
  778. dialog.Height = 300;
  779. dialog.Width = 400;
  780. double angel = 0;
  781. double coolingtime = 0;
  782. string message = "Please Confirm Return Wafer";
  783. WaferDialogViewModel vm = new WaferDialogViewModel();
  784. vm.ConfirmText = message;
  785. dialog.DataContext = vm;
  786. if (dialog.ShowDialog() == true)
  787. {
  788. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  789. {
  790. angel = Convert.ToDouble(dialog.Angle);
  791. }
  792. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  793. {
  794. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  795. }
  796. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel);
  797. }
  798. }
  799. private void OnSetSequence(object obj)
  800. {
  801. var info = obj as WaferInfo;
  802. bool flag = info.SequenceName != "" ? false : true;
  803. }
  804. private void OnEnableAuto()
  805. {
  806. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  807. }
  808. private void OnEnableManual()
  809. {
  810. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  811. }
  812. private void GotoSrdViewAction(object obj)
  813. {
  814. CyberX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}");
  815. }
  816. #endregion
  817. #region 私有方法
  818. /// <summary>
  819. /// 定时器
  820. /// </summary>
  821. /// <param name="sender"></param>
  822. /// <param name="e"></param>
  823. private void Timer_Tick(object sender, EventArgs e)
  824. {
  825. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  826. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  827. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  828. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  829. SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"];
  830. SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"];
  831. PUF1ModuleInfo = ModuleManager.ModuleInfos["PUF1"];
  832. Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"];
  833. Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"];
  834. LoaderModuleInfo = ModuleManager.ModuleInfos["Loader1"];
  835. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  836. {
  837. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  838. }
  839. if (EFEMIsInstalled == true)
  840. {
  841. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  842. {
  843. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  844. }
  845. if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0)
  846. {
  847. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  848. }
  849. }
  850. if (SRD1ModuleInfo != null&& SRD1ModuleInfo.WaferManager.Wafers.Count!=0)
  851. {
  852. SRD1Wafer = SRD1ModuleInfo.WaferManager.Wafers[0];
  853. }
  854. if (SRD2ModuleInfo != null&& SRD2ModuleInfo.WaferManager.Wafers.Count!=0)
  855. {
  856. SRD2Wafer = SRD2ModuleInfo.WaferManager.Wafers[0];
  857. }
  858. if(PUF1ModuleInfo!=null)
  859. {
  860. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  861. {
  862. PUF1WaferA = PUF1ModuleInfo.WaferManager.Wafers[0];
  863. }
  864. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  865. {
  866. PUF1WaferB = PUF1ModuleInfo.WaferManager.Wafers[1];
  867. }
  868. }
  869. if(LoaderIsInstalled&&LoaderModuleInfo!=null)
  870. {
  871. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  872. {
  873. LoaderWaferA = LoaderModuleInfo.WaferManager.Wafers[0];
  874. }
  875. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  876. {
  877. LoaderWaferB = LoaderModuleInfo.WaferManager.Wafers[1];
  878. }
  879. }
  880. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  881. EfemRobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  882. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  883. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  884. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  885. //Dummy1WaferCount = 15;
  886. Dummy1WaferCount = Dummy1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  887. Dummy2WaferCount = Dummy2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  888. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  889. IsLP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable");
  890. IsLP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable");
  891. IsLP3Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable");
  892. if (RtDataValues != null)
  893. {
  894. Puf1IsInRobotStation = CommonFunction.GetValue<bool>(RtDataValues, "PUF1.IsInRobotStation");
  895. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  896. {
  897. RouteState = "Resume";
  898. }
  899. else
  900. {
  901. RouteState = "Pause";
  902. }
  903. ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
  904. IsLP1HasNoJob = lp1Cj == null ? true : false;
  905. ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
  906. IsLP2HasNoJob = lp2Cj == null ? true : false;
  907. ControlJobInfo lp3Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP3.CurrentControlJob");
  908. IsLP3HasNoJob = lp3Cj == null ? true : false;
  909. }
  910. }
  911. int count = 0;
  912. /// <summary>
  913. /// 定时器1
  914. /// </summary>
  915. /// <param name="sender"></param>
  916. /// <param name="e"></param>
  917. private void Timer1_Tick(object sender, EventArgs e)
  918. {
  919. if (m_RtDataKeys.Count != 0)
  920. {
  921. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  922. if (RtDataValues != null)
  923. {
  924. Puf1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Rotation.{MOTOR_POSITION}");
  925. Loader1TiltAMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltA.{MOTOR_POSITION}");
  926. Loader1TiltBMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltB.{MOTOR_POSITION}");
  927. Loader1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.Rotation.{MOTOR_POSITION}");
  928. Puf1FlipMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Flip.{MOTOR_POSITION}");
  929. //计算Puf1 Rotation UI位置
  930. Puf1RotationPosition = _robotLayoutPosition + (_puf1RotationMotorPositionMax - Puf1RotationMotorPosition) / _puf1RotationRatio;
  931. //计Loader Rotation UI位置
  932. Loader1RotationPosition = -Loader1RotationMotorPosition - LOADER_ROTATION_DIFFER;
  933. //计算Puf1 Flip UI位置
  934. Puf1FlipPosition = Puf1FlipMotorPosition - PUF_FLIP_DIFFER;
  935. //判断Loader1的TiltA水平状态
  936. LoaderTiltACurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltA.{CURRENT_STATION}"), "Loader1.TiltA");
  937. if (LoaderTiltACurrentStation == "HORI")
  938. {
  939. LoaderWaferVisibleA = true;
  940. }
  941. else if(LoaderTiltACurrentStation == "VERT")
  942. {
  943. LoaderWaferVisibleA = false;
  944. }
  945. //判断Loader1的TiltB水平状态
  946. LoaderTiltBCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltB.{CURRENT_STATION}"), "Loader1.TiltB");
  947. if (LoaderTiltBCurrentStation == "HORI")
  948. {
  949. LoaderWaferVisibleB = true;
  950. }
  951. else if (LoaderTiltBCurrentStation == "VERT")
  952. {
  953. LoaderWaferVisibleB = false;
  954. }
  955. }
  956. }
  957. }
  958. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  959. {
  960. string RobotTarget;
  961. if (oldValue == null || newValue == null)
  962. {
  963. return;
  964. }
  965. #region Rotating
  966. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  967. {
  968. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  969. if (TMRobotMoveActionBladeTarget != null)
  970. {
  971. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  972. }
  973. else
  974. {
  975. return;
  976. }
  977. var values = RobotTarget.Split('.');
  978. var arm = values[0];
  979. var module = values[1];
  980. if (arm == "ArmA")
  981. {
  982. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  983. }
  984. else if (arm == "ArmB")
  985. {
  986. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  987. }
  988. }
  989. #endregion
  990. #region pick 和 place LL
  991. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  992. {
  993. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  994. if (TMRobotMoveActionBladeTarget != null)
  995. {
  996. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  997. }
  998. else
  999. {
  1000. return;
  1001. }
  1002. var values = RobotTarget.Split('.');
  1003. var arm = values[0];
  1004. var module = values[1];
  1005. if (arm == "ArmA")
  1006. {
  1007. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1008. if (waferRobotTAction != Robot1TAction)
  1009. {
  1010. Robot1TAction = waferRobotTAction;
  1011. }
  1012. else
  1013. {
  1014. //await Task.Delay(100);
  1015. }
  1016. await Task.Delay(600);
  1017. //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1018. //await Task.Delay(600);
  1019. Robot1XAction = WaferRobotXAction.Extend;
  1020. 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))
  1021. {
  1022. await Task.Delay(100);
  1023. }
  1024. Robot1XAction = WaferRobotXAction.Retract;
  1025. }
  1026. else if (arm == "ArmB")
  1027. {
  1028. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1029. if (waferRobotTAction != Robot2TAction)
  1030. {
  1031. Robot2TAction = waferRobotTAction;
  1032. }
  1033. else
  1034. {
  1035. //await Task.Delay(100);
  1036. }
  1037. await Task.Delay(600);
  1038. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1039. //await Task.Delay(600);
  1040. Robot2XAction = WaferRobotXAction.Extend;
  1041. 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))
  1042. {
  1043. await Task.Delay(100);
  1044. }
  1045. Robot2XAction = WaferRobotXAction.Retract;
  1046. }
  1047. }
  1048. #endregion
  1049. #region pick 和 place pm
  1050. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  1051. {
  1052. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1053. if (TMRobotMoveActionBladeTarget != null)
  1054. {
  1055. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1056. }
  1057. else
  1058. {
  1059. return;
  1060. }
  1061. var values = RobotTarget.Split('.');
  1062. var arm = values[0];
  1063. var module = values[1];
  1064. if (arm == "ArmA")
  1065. {
  1066. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1067. if (waferRobotTAction != Robot1TAction)
  1068. {
  1069. Robot1TAction = waferRobotTAction;
  1070. }
  1071. else
  1072. {
  1073. // await Task.Delay(100);
  1074. }
  1075. await Task.Delay(600);
  1076. Robot1XAction = WaferRobotXAction.Extend;
  1077. }
  1078. else if (arm == "ArmB")
  1079. {
  1080. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1081. if (waferRobotTAction != Robot2TAction)
  1082. {
  1083. Robot2TAction = waferRobotTAction;
  1084. }
  1085. else
  1086. {
  1087. // await Task.Delay(100);
  1088. }
  1089. await Task.Delay(600);
  1090. Robot2XAction = WaferRobotXAction.Extend;
  1091. }
  1092. }
  1093. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  1094. {
  1095. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1096. if (TMRobotMoveActionBladeTarget != null)
  1097. {
  1098. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1099. }
  1100. else
  1101. {
  1102. return;
  1103. }
  1104. var values = RobotTarget.Split('.');
  1105. var arm = values[0];
  1106. if (arm == "ArmA")
  1107. {
  1108. Robot1XAction = WaferRobotXAction.Retract;
  1109. }
  1110. else if (arm == "ArmB")
  1111. {
  1112. Robot2XAction = WaferRobotXAction.Retract;
  1113. }
  1114. }
  1115. #endregion
  1116. #region Home
  1117. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1118. {
  1119. if (Robot1XAction == WaferRobotXAction.Extend)
  1120. {
  1121. Robot1XAction = WaferRobotXAction.Retract;
  1122. }
  1123. if (Robot2XAction == WaferRobotXAction.Extend)
  1124. {
  1125. Robot2XAction = WaferRobotXAction.Retract;
  1126. }
  1127. await Task.Delay(2000);
  1128. if (Robot1TAction != WaferRobotTAction.T_Origin)
  1129. {
  1130. Robot1TAction = WaferRobotTAction.T_Origin;
  1131. }
  1132. if (Robot2TAction != WaferRobotTAction.T_Origin)
  1133. {
  1134. Robot2TAction = WaferRobotTAction.T_Origin;
  1135. }
  1136. }
  1137. #endregion
  1138. }
  1139. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  1140. {
  1141. string RobotTarget;
  1142. if (oldValue == null || newValue == null)
  1143. {
  1144. return;
  1145. }
  1146. #region pick 和 place LL
  1147. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  1148. {
  1149. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1150. if (TMRobotMoveActionBladeTarget != null)
  1151. {
  1152. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1153. }
  1154. else
  1155. {
  1156. return;
  1157. }
  1158. var values = RobotTarget.Split('.');
  1159. var arm = values[0];
  1160. var module = values[1];
  1161. if (arm == "ArmA")
  1162. {
  1163. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1164. //await Task.Delay(1000);
  1165. await ChangePosition(robot3Robot3TAction, newValue.Action);
  1166. if (Robot3TAction != robot3Robot3TAction)
  1167. {
  1168. Robot3TAction = robot3Robot3TAction;
  1169. await Task.Delay(600);
  1170. }
  1171. Robot3XAction = WaferRobotXAction.Extend;
  1172. 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))
  1173. {
  1174. await Task.Delay(100);
  1175. }
  1176. Robot3XAction = WaferRobotXAction.Retract;
  1177. if(newValue.Action == RobotAction.Placing)
  1178. {
  1179. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1180. }
  1181. }
  1182. }
  1183. #endregion
  1184. #region pick 和 place pm
  1185. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  1186. {
  1187. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1188. if (TMRobotMoveActionBladeTarget != null)
  1189. {
  1190. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1191. }
  1192. else
  1193. {
  1194. return;
  1195. }
  1196. var values = RobotTarget.Split('.');
  1197. var arm = values[0];
  1198. var module = values[1];
  1199. if (arm == "ArmA")
  1200. {
  1201. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1202. await Task.Delay(1500);
  1203. //ChangePosition(Robot3TAction);
  1204. //await Task.Delay(2000);
  1205. Robot3XAction = WaferRobotXAction.Extend;
  1206. }
  1207. else if (arm == "ArmB")
  1208. {
  1209. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1210. await Task.Delay(1500);
  1211. //ChangePosition(Robot4TAction);
  1212. //await Task.Delay(2000);
  1213. Robot4XAction = WaferRobotXAction.Extend;
  1214. }
  1215. }
  1216. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  1217. {
  1218. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1219. if (TMRobotMoveActionBladeTarget != null)
  1220. {
  1221. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1222. }
  1223. else
  1224. {
  1225. return;
  1226. }
  1227. var values = RobotTarget.Split('.');
  1228. var arm = values[0];
  1229. if (arm == "ArmA")
  1230. {
  1231. Robot3XAction = WaferRobotXAction.Retract;
  1232. await Task.Delay(3000);
  1233. //ChangePosition(Robot3TAction);
  1234. //await Task.Delay(2000);
  1235. }
  1236. else if (arm == "ArmB")
  1237. {
  1238. Robot4XAction = WaferRobotXAction.Retract;
  1239. await Task.Delay(3000);
  1240. //ChangePosition(Robot3TAction);
  1241. //await Task.Delay(2000);
  1242. }
  1243. }
  1244. #endregion
  1245. #region Home
  1246. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1247. {
  1248. if (Robot3XAction == WaferRobotXAction.Extend)
  1249. {
  1250. Robot3XAction = WaferRobotXAction.Retract;
  1251. }
  1252. if (Robot4XAction == WaferRobotXAction.Extend)
  1253. {
  1254. Robot4XAction = WaferRobotXAction.Retract;
  1255. }
  1256. if (Robot3TAction != WaferRobotTAction.T_Origin)
  1257. {
  1258. Robot3TAction = WaferRobotTAction.T_Origin;
  1259. }
  1260. if (Robot4TAction != WaferRobotTAction.T_Origin)
  1261. {
  1262. Robot4TAction = WaferRobotTAction.T_Origin;
  1263. }
  1264. await Task.Delay(1000);
  1265. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1266. }
  1267. #endregion
  1268. }
  1269. private void addDataKeys()
  1270. {
  1271. m_RtDataKeys.Add("LP1.IsLoaded");
  1272. m_RtDataKeys.Add("LP2.IsLoaded");
  1273. m_RtDataKeys.Add("LP3.IsLoaded");
  1274. m_RtDataKeys.Add("LP1.CassettePlaced");
  1275. m_RtDataKeys.Add("LP2.CassettePlaced");
  1276. m_RtDataKeys.Add("LP3.CassettePlaced");
  1277. m_RtDataKeys.Add("LP1.CurrentControlJob");
  1278. m_RtDataKeys.Add("LP2.CurrentControlJob");
  1279. m_RtDataKeys.Add("LP3.CurrentControlJob");
  1280. m_RtDataKeys.Add("LP1.WaferSize");
  1281. m_RtDataKeys.Add("LP2.WaferSize");
  1282. m_RtDataKeys.Add("LP3.WaferSize");
  1283. m_RtDataKeys.Add("Dummy1.CassettePlaced");
  1284. m_RtDataKeys.Add("Dummy2.CassettePlaced");
  1285. m_RtDataKeys.Add("Dummy1.WaferSize");
  1286. m_RtDataKeys.Add("Dummy2.WaferSize");
  1287. m_RtDataKeys.Add("System.IsAutoMode");
  1288. m_RtDataKeys.Add("System.IsBusy");
  1289. m_RtDataKeys.Add("Scheduler.CycledCount");
  1290. m_RtDataKeys.Add("Scheduler.CycledWafer");
  1291. m_RtDataKeys.Add("Scheduler.CycleSetPoint");
  1292. m_RtDataKeys.Add("Scheduler.Throughput");
  1293. m_RtDataKeys.Add("EquipmentStatus");
  1294. m_RtDataKeys.Add("Scheduler.PjNameList");
  1295. m_RtDataKeys.Add("PUF1.IsInRobotStation");
  1296. m_RtDataKeys.Add("Scheduler.CjNameList");
  1297. }
  1298. private void addStationDataKeys()
  1299. {
  1300. m_RtDataKeys.Add($"Station.PUF1.Rotation");
  1301. m_RtDataKeys.Add($"Station.PUF1.Flip");
  1302. m_RtDataKeys.Add($"Station.PUF1.Vertical");
  1303. m_RtDataKeys.Add($"Station.Loader1.Rotation");
  1304. m_RtDataKeys.Add($"Station.Loader1.TiltA");
  1305. m_RtDataKeys.Add($"Station.Loader1.TiltB");
  1306. m_RtDataKeys.Add($"PUF1.Rotation.{MOTOR_POSITION}");
  1307. m_RtDataKeys.Add($"PUF1.Flip.{MOTOR_POSITION}");
  1308. m_RtDataKeys.Add($"Loader1.Rotation.{MOTOR_POSITION}");
  1309. m_RtDataKeys.Add($"Loader1.TiltA.{MOTOR_POSITION}");
  1310. m_RtDataKeys.Add($"Loader1.TiltB.{MOTOR_POSITION}");
  1311. m_RtDataKeys.Add($"PUF1.Flip.{CURRENT_STATION}");
  1312. m_RtDataKeys.Add($"Loader1.TiltA.{CURRENT_STATION}");
  1313. m_RtDataKeys.Add($"Loader1.TiltB.{CURRENT_STATION}");
  1314. m_RtDataKeys.Add($"PUF1.Rotation.{MOTION_DATA}");
  1315. }
  1316. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  1317. {
  1318. if (wafers[index].WaferStatus == 0)
  1319. return false;
  1320. return true;
  1321. }
  1322. private async Task ChangePosition(WaferRobotTAction waferRobotTAction, RobotAction robotAction)
  1323. {
  1324. await Task.Delay(500);
  1325. int delay = 500;
  1326. if (robotAction == RobotAction.Placing)
  1327. {
  1328. if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1)
  1329. {
  1330. CurrentRobotPosition = EFEM.RobotPosition.Left_Place;
  1331. await Task.Delay(delay);
  1332. }
  1333. else if (waferRobotTAction == WaferRobotTAction.LP3)
  1334. {
  1335. CurrentRobotPosition = EFEM.RobotPosition.Right_Place;
  1336. await Task.Delay(delay);
  1337. }
  1338. else if (waferRobotTAction == WaferRobotTAction.LP2 )
  1339. {
  1340. CurrentRobotPosition = EFEM.RobotPosition.Middle_Place;
  1341. await Task.Delay(delay);
  1342. }
  1343. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  1344. {
  1345. CurrentRobotPosition = EFEM.RobotPosition.Aligner_Place;
  1346. await Task.Delay(delay);
  1347. }
  1348. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  1349. {
  1350. CurrentRobotPosition = EFEM.RobotPosition.SRD_Place;
  1351. }
  1352. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  1353. {
  1354. CurrentRobotPosition = EFEM.RobotPosition.Dummy_Place;
  1355. }
  1356. else
  1357. {
  1358. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  1359. await Task.Delay(delay);
  1360. }
  1361. }
  1362. else
  1363. {
  1364. if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1)
  1365. {
  1366. CurrentRobotPosition = EFEM.RobotPosition.Left;
  1367. await Task.Delay(delay);
  1368. }
  1369. else if (waferRobotTAction == WaferRobotTAction.LP3)
  1370. {
  1371. CurrentRobotPosition = EFEM.RobotPosition.Right;
  1372. await Task.Delay(delay);
  1373. }
  1374. else if (waferRobotTAction == WaferRobotTAction.LP2)
  1375. {
  1376. CurrentRobotPosition = EFEM.RobotPosition.Middle;
  1377. await Task.Delay(delay);
  1378. }
  1379. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  1380. {
  1381. CurrentRobotPosition = EFEM.RobotPosition.Aligner;
  1382. await Task.Delay(delay);
  1383. }
  1384. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  1385. {
  1386. CurrentRobotPosition = EFEM.RobotPosition.SRD;
  1387. }
  1388. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  1389. {
  1390. CurrentRobotPosition = EFEM.RobotPosition.Dummy;
  1391. }
  1392. else
  1393. {
  1394. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  1395. await Task.Delay(delay);
  1396. }
  1397. }
  1398. }
  1399. /// <summary>
  1400. /// 计算最大值最小值
  1401. /// </summary>
  1402. /// <param name="Puf1RotationAxis"></param>
  1403. /// <returns></returns>
  1404. private (double max, double min) CalculateMaxMin(BeckhoffStationAxis pufAxis)
  1405. {
  1406. double max = 0;
  1407. double min = 0;
  1408. foreach (Station item in pufAxis.Stations)
  1409. {
  1410. double position = double.Parse(item.Position);
  1411. if (position > max)
  1412. {
  1413. max = position;
  1414. }
  1415. if (position < min)
  1416. {
  1417. min = position;
  1418. }
  1419. }
  1420. foreach (Station item in pufAxis.Stations)
  1421. {
  1422. double position = double.Parse(item.Position);
  1423. if (position > max)
  1424. {
  1425. max = position;
  1426. }
  1427. if (position < min)
  1428. {
  1429. min = position;
  1430. }
  1431. }
  1432. return (max, min);
  1433. }
  1434. /// <summary>
  1435. /// 判定是否在station位置
  1436. /// </summary>
  1437. private bool JudgeAtStation(double targetPosition, double currentPosition, double tolerance)
  1438. {
  1439. if (Math.Abs(currentPosition - targetPosition) <= tolerance)
  1440. {
  1441. return true;
  1442. }
  1443. else
  1444. {
  1445. return false;
  1446. }
  1447. }
  1448. #endregion
  1449. }
  1450. }