OperationOverViewModel.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578
  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> _LoadWaferCommand;
  630. public DelegateCommand<object> LoadWaferCommand =>
  631. _LoadWaferCommand ?? (_LoadWaferCommand = new DelegateCommand<object>(OnLoadWafer));
  632. private DelegateCommand<object> _UnLoadWaferCommand;
  633. public DelegateCommand<object> UnLoadWaferCommand =>
  634. _UnLoadWaferCommand ?? (_UnLoadWaferCommand = new DelegateCommand<object>(OnUnLoadWafer));
  635. private DelegateCommand<object> _StartCommand;
  636. public DelegateCommand<object> StartCommand =>
  637. _StartCommand ?? (_StartCommand = new DelegateCommand<object>(OnStart));
  638. private DelegateCommand<object> _StopCommand;
  639. public DelegateCommand<object> StopCommand =>
  640. _StopCommand ?? (_StopCommand = new DelegateCommand<object>(OnStop));
  641. private DelegateCommand<object> _AbortCommand;
  642. public DelegateCommand<object> AbortCommand =>
  643. _AbortCommand ?? (_AbortCommand = new DelegateCommand<object>(OnAbort));
  644. private DelegateCommand _HomeAllCommand;
  645. public DelegateCommand HomeAllCommand =>
  646. _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll));
  647. private DelegateCommand _ResumeAllJobCommand;
  648. public DelegateCommand ResumeAllJobCommand =>
  649. _ResumeAllJobCommand ?? (_ResumeAllJobCommand = new DelegateCommand(OnResumeAllJob));
  650. private DelegateCommand _AbortAllCommand;
  651. public DelegateCommand AbortAllCommand =>
  652. _AbortAllCommand ?? (_AbortAllCommand = new DelegateCommand(OnAbortAll));
  653. private DelegateCommand _ReturnAllWaferCommand;
  654. public DelegateCommand ReturnAllWaferCommand =>
  655. _ReturnAllWaferCommand ?? (_ReturnAllWaferCommand = new DelegateCommand(OnReturnAllWafer));
  656. private DelegateCommand<object> _SetSequenceCommand;
  657. public DelegateCommand<object> SetSequenceCommand =>
  658. _SetSequenceCommand ?? (_SetSequenceCommand = new DelegateCommand<object>(OnSetSequence));
  659. private DelegateCommand _EnableAutoCommand;
  660. public DelegateCommand EnableAutoCommand =>
  661. _EnableAutoCommand ?? (_EnableAutoCommand = new DelegateCommand(OnEnableAuto));
  662. private DelegateCommand _EnableManualCommand;
  663. public DelegateCommand EnableManualCommand =>
  664. _EnableManualCommand ?? (_EnableManualCommand = new DelegateCommand(OnEnableManual));
  665. private DelegateCommand<object> _GotoSrdViewCommond;
  666. public DelegateCommand<object> GotoSrdViewCommond =>
  667. _GotoSrdViewCommond ?? (_GotoSrdViewCommond = new DelegateCommand<object>(GotoSrdViewAction));
  668. public bool SwitchFlag;
  669. #endregion
  670. #region 构造函数
  671. public OperationOverViewModel()
  672. {
  673. addDataKeys();
  674. ATMModeIsOn = Convert.ToBoolean(QueryDataClient.Instance.Service.GetConfig("System.IsATMMode")) == true ? "ATM Mode On" : "ATM Mode Off";
  675. }
  676. #endregion
  677. #region 命令方法
  678. /// <summary>
  679. /// 加载数据
  680. /// </summary>
  681. public void LoadData(string systemName)
  682. {
  683. Dictionary<string, object> allModulesDictionary = QueryDataClient.Instance.Service.PollData(new List<string>() { "System.InstalledModules" });
  684. if (allModulesDictionary != null)
  685. {
  686. List<string> allModules = CommonFunction.GetValue<List<string>>(allModulesDictionary, "System.InstalledModules");
  687. EFEMIsInstalled = allModules.Contains("EFEM");
  688. LoaderIsInstalled = allModules.Contains(ModuleName.Loader1.ToString());
  689. }
  690. if (_timer == null)
  691. {
  692. _timer = new DispatcherTimer();
  693. _timer.Interval = TimeSpan.FromMilliseconds(100);
  694. _timer.Tick += Timer_Tick;
  695. }
  696. _timer.Start();
  697. if (_timer1 == null)
  698. {
  699. _timer1 = new DispatcherTimer();
  700. _timer1.Interval = TimeSpan.FromMilliseconds(50);
  701. _timer1.Tick += Timer1_Tick;
  702. }
  703. _timer1.Start();
  704. _pufLayoutRotationDistance = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.PufLayoutRotationDistance");
  705. _robotLayoutPosition = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.RobotLayoutPosition");
  706. if (!m_RtDataKeys.Contains($"Station.PUF1.Roation"))
  707. {
  708. addStationDataKeys();
  709. }
  710. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  711. if (RtDataValues != null)
  712. {
  713. //目标位置数据获取
  714. Puf1RotationAxis = CommonFunction.GetValue<BeckhoffStationAxis>(RtDataValues, $"Station.PUF1.Rotation");
  715. //Puf1Rotation比例尺计算
  716. var resultRotation = Puf1RotationAxis != null ? CalculateMaxMin(Puf1RotationAxis) : (0, 0);
  717. double distance = resultRotation.max - resultRotation.min;
  718. _puf1RotationRatio = distance / _pufLayoutRotationDistance;
  719. _puf1RotationMotorPositionMax = resultRotation.max;
  720. }
  721. }
  722. /// <summary>
  723. /// 隐藏
  724. /// </summary>
  725. public void Hide()
  726. {
  727. if (_timer != null)
  728. {
  729. _timer.Stop();
  730. }
  731. if (_timer1 != null)
  732. {
  733. _timer1.Stop();
  734. }
  735. }
  736. private void OnLoadWafer(object obj)
  737. {
  738. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Load", ModuleManager.ModuleInfos[obj.ToString()].ModuleID);
  739. }
  740. private void OnUnLoadWafer(object obj)
  741. {
  742. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Unload", ModuleManager.ModuleInfos[obj.ToString()].ModuleID);
  743. }
  744. private void OnStart(object obj)
  745. {
  746. var info = obj as WaferAssociationInfo;
  747. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId);
  748. }
  749. private void OnStop(object obj)
  750. {
  751. var info = obj as WaferAssociationInfo;
  752. InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID);
  753. }
  754. private void OnAbort(object obj)
  755. {
  756. var info = obj as WaferAssociationInfo;
  757. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID);
  758. }
  759. private void OnHomeAll()
  760. {
  761. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  762. }
  763. private void OnResumeAllJob()
  764. {
  765. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  766. {
  767. InvokeClient.Instance.Service.DoOperation("System.ResumeAllJob");
  768. }
  769. else
  770. {
  771. InvokeClient.Instance.Service.DoOperation("System.PauseAllJob");
  772. }
  773. }
  774. private void OnAbortAll()
  775. {
  776. InvokeClient.Instance.Service.DoOperation("System.Abort");
  777. }
  778. private void OnReturnAllWafer()
  779. {
  780. //Dialog
  781. WaferDialogView dialog = new WaferDialogView()
  782. {
  783. Owner = Application.Current.MainWindow,
  784. };
  785. dialog.Height = 300;
  786. dialog.Width = 400;
  787. double angel = 0;
  788. double coolingtime = 0;
  789. string message = "Please Confirm Return Wafer";
  790. WaferDialogViewModel vm = new WaferDialogViewModel();
  791. vm.ConfirmText = message;
  792. dialog.DataContext = vm;
  793. if (dialog.ShowDialog() == true)
  794. {
  795. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  796. {
  797. angel = Convert.ToDouble(dialog.Angle);
  798. }
  799. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  800. {
  801. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  802. }
  803. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel);
  804. }
  805. }
  806. private void OnSetSequence(object obj)
  807. {
  808. var info = obj as WaferInfo;
  809. bool flag = info.SequenceName != "" ? false : true;
  810. }
  811. private void OnEnableAuto()
  812. {
  813. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  814. }
  815. private void OnEnableManual()
  816. {
  817. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  818. }
  819. private void GotoSrdViewAction(object obj)
  820. {
  821. CyberX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}");
  822. }
  823. #endregion
  824. #region 私有方法
  825. /// <summary>
  826. /// 定时器
  827. /// </summary>
  828. /// <param name="sender"></param>
  829. /// <param name="e"></param>
  830. private void Timer_Tick(object sender, EventArgs e)
  831. {
  832. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  833. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  834. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  835. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  836. SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"];
  837. SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"];
  838. PUF1ModuleInfo = ModuleManager.ModuleInfos["PUF1"];
  839. Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"];
  840. Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"];
  841. LoaderModuleInfo = ModuleManager.ModuleInfos["Loader1"];
  842. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  843. {
  844. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  845. }
  846. if (EFEMIsInstalled == true)
  847. {
  848. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  849. {
  850. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  851. }
  852. if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0)
  853. {
  854. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  855. }
  856. }
  857. if (SRD1ModuleInfo != null&& SRD1ModuleInfo.WaferManager.Wafers.Count!=0)
  858. {
  859. SRD1Wafer = SRD1ModuleInfo.WaferManager.Wafers[0];
  860. }
  861. if (SRD2ModuleInfo != null&& SRD2ModuleInfo.WaferManager.Wafers.Count!=0)
  862. {
  863. SRD2Wafer = SRD2ModuleInfo.WaferManager.Wafers[0];
  864. }
  865. if(PUF1ModuleInfo!=null)
  866. {
  867. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  868. {
  869. PUF1WaferA = PUF1ModuleInfo.WaferManager.Wafers[0];
  870. }
  871. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  872. {
  873. PUF1WaferB = PUF1ModuleInfo.WaferManager.Wafers[1];
  874. }
  875. }
  876. if(LoaderIsInstalled&&LoaderModuleInfo!=null)
  877. {
  878. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  879. {
  880. LoaderWaferA = LoaderModuleInfo.WaferManager.Wafers[0];
  881. }
  882. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  883. {
  884. LoaderWaferB = LoaderModuleInfo.WaferManager.Wafers[1];
  885. }
  886. }
  887. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  888. EfemRobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  889. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  890. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  891. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  892. //Dummy1WaferCount = 15;
  893. Dummy1WaferCount = Dummy1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  894. Dummy2WaferCount = Dummy2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  895. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  896. IsLP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable");
  897. IsLP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable");
  898. IsLP3Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable");
  899. if (RtDataValues != null)
  900. {
  901. Puf1IsInRobotStation = CommonFunction.GetValue<bool>(RtDataValues, "PUF1.IsInRobotStation");
  902. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  903. {
  904. RouteState = "Resume";
  905. }
  906. else
  907. {
  908. RouteState = "Pause";
  909. }
  910. ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
  911. IsLP1HasNoJob = lp1Cj == null ? true : false;
  912. ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
  913. IsLP2HasNoJob = lp2Cj == null ? true : false;
  914. ControlJobInfo lp3Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP3.CurrentControlJob");
  915. IsLP3HasNoJob = lp3Cj == null ? true : false;
  916. }
  917. }
  918. int count = 0;
  919. /// <summary>
  920. /// 定时器1
  921. /// </summary>
  922. /// <param name="sender"></param>
  923. /// <param name="e"></param>
  924. private void Timer1_Tick(object sender, EventArgs e)
  925. {
  926. if (m_RtDataKeys.Count != 0)
  927. {
  928. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  929. if (RtDataValues != null)
  930. {
  931. Puf1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Rotation.{MOTOR_POSITION}");
  932. Loader1TiltAMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltA.{MOTOR_POSITION}");
  933. Loader1TiltBMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltB.{MOTOR_POSITION}");
  934. Loader1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.Rotation.{MOTOR_POSITION}");
  935. Puf1FlipMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Flip.{MOTOR_POSITION}");
  936. //计算Puf1 Rotation UI位置
  937. Puf1RotationPosition = _robotLayoutPosition + (_puf1RotationMotorPositionMax - Puf1RotationMotorPosition) / _puf1RotationRatio;
  938. //计Loader Rotation UI位置
  939. Loader1RotationPosition = -Loader1RotationMotorPosition - LOADER_ROTATION_DIFFER;
  940. //计算Puf1 Flip UI位置
  941. Puf1FlipPosition = Puf1FlipMotorPosition - PUF_FLIP_DIFFER;
  942. //判断Loader1的TiltA水平状态
  943. LoaderTiltACurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltA.{CURRENT_STATION}"), "Loader1.TiltA");
  944. if (LoaderTiltACurrentStation == "HORI")
  945. {
  946. LoaderWaferVisibleA = true;
  947. }
  948. else if(LoaderTiltACurrentStation == "VERT")
  949. {
  950. LoaderWaferVisibleA = false;
  951. }
  952. //判断Loader1的TiltB水平状态
  953. LoaderTiltBCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltB.{CURRENT_STATION}"), "Loader1.TiltB");
  954. if (LoaderTiltBCurrentStation == "HORI")
  955. {
  956. LoaderWaferVisibleB = true;
  957. }
  958. else if (LoaderTiltBCurrentStation == "VERT")
  959. {
  960. LoaderWaferVisibleB = false;
  961. }
  962. }
  963. }
  964. }
  965. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  966. {
  967. string RobotTarget;
  968. if (oldValue == null || newValue == null)
  969. {
  970. return;
  971. }
  972. #region Rotating
  973. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  974. {
  975. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  976. if (TMRobotMoveActionBladeTarget != null)
  977. {
  978. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  979. }
  980. else
  981. {
  982. return;
  983. }
  984. var values = RobotTarget.Split('.');
  985. var arm = values[0];
  986. var module = values[1];
  987. if (arm == "ArmA")
  988. {
  989. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  990. }
  991. else if (arm == "ArmB")
  992. {
  993. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  994. }
  995. }
  996. #endregion
  997. #region pick 和 place LL
  998. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  999. {
  1000. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1001. if (TMRobotMoveActionBladeTarget != null)
  1002. {
  1003. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1004. }
  1005. else
  1006. {
  1007. return;
  1008. }
  1009. var values = RobotTarget.Split('.');
  1010. var arm = values[0];
  1011. var module = values[1];
  1012. if (arm == "ArmA")
  1013. {
  1014. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1015. if (waferRobotTAction != Robot1TAction)
  1016. {
  1017. Robot1TAction = waferRobotTAction;
  1018. }
  1019. else
  1020. {
  1021. //await Task.Delay(100);
  1022. }
  1023. await Task.Delay(600);
  1024. //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1025. //await Task.Delay(600);
  1026. Robot1XAction = WaferRobotXAction.Extend;
  1027. 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))
  1028. {
  1029. await Task.Delay(100);
  1030. }
  1031. Robot1XAction = WaferRobotXAction.Retract;
  1032. }
  1033. else if (arm == "ArmB")
  1034. {
  1035. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1036. if (waferRobotTAction != Robot2TAction)
  1037. {
  1038. Robot2TAction = waferRobotTAction;
  1039. }
  1040. else
  1041. {
  1042. //await Task.Delay(100);
  1043. }
  1044. await Task.Delay(600);
  1045. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1046. //await Task.Delay(600);
  1047. Robot2XAction = WaferRobotXAction.Extend;
  1048. 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))
  1049. {
  1050. await Task.Delay(100);
  1051. }
  1052. Robot2XAction = WaferRobotXAction.Retract;
  1053. }
  1054. }
  1055. #endregion
  1056. #region pick 和 place pm
  1057. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  1058. {
  1059. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1060. if (TMRobotMoveActionBladeTarget != null)
  1061. {
  1062. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1063. }
  1064. else
  1065. {
  1066. return;
  1067. }
  1068. var values = RobotTarget.Split('.');
  1069. var arm = values[0];
  1070. var module = values[1];
  1071. if (arm == "ArmA")
  1072. {
  1073. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1074. if (waferRobotTAction != Robot1TAction)
  1075. {
  1076. Robot1TAction = waferRobotTAction;
  1077. }
  1078. else
  1079. {
  1080. // await Task.Delay(100);
  1081. }
  1082. await Task.Delay(600);
  1083. Robot1XAction = WaferRobotXAction.Extend;
  1084. }
  1085. else if (arm == "ArmB")
  1086. {
  1087. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1088. if (waferRobotTAction != Robot2TAction)
  1089. {
  1090. Robot2TAction = waferRobotTAction;
  1091. }
  1092. else
  1093. {
  1094. // await Task.Delay(100);
  1095. }
  1096. await Task.Delay(600);
  1097. Robot2XAction = WaferRobotXAction.Extend;
  1098. }
  1099. }
  1100. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  1101. {
  1102. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1103. if (TMRobotMoveActionBladeTarget != null)
  1104. {
  1105. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1106. }
  1107. else
  1108. {
  1109. return;
  1110. }
  1111. var values = RobotTarget.Split('.');
  1112. var arm = values[0];
  1113. if (arm == "ArmA")
  1114. {
  1115. Robot1XAction = WaferRobotXAction.Retract;
  1116. }
  1117. else if (arm == "ArmB")
  1118. {
  1119. Robot2XAction = WaferRobotXAction.Retract;
  1120. }
  1121. }
  1122. #endregion
  1123. #region Home
  1124. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1125. {
  1126. if (Robot1XAction == WaferRobotXAction.Extend)
  1127. {
  1128. Robot1XAction = WaferRobotXAction.Retract;
  1129. }
  1130. if (Robot2XAction == WaferRobotXAction.Extend)
  1131. {
  1132. Robot2XAction = WaferRobotXAction.Retract;
  1133. }
  1134. await Task.Delay(2000);
  1135. if (Robot1TAction != WaferRobotTAction.T_Origin)
  1136. {
  1137. Robot1TAction = WaferRobotTAction.T_Origin;
  1138. }
  1139. if (Robot2TAction != WaferRobotTAction.T_Origin)
  1140. {
  1141. Robot2TAction = WaferRobotTAction.T_Origin;
  1142. }
  1143. }
  1144. #endregion
  1145. }
  1146. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  1147. {
  1148. string RobotTarget;
  1149. if (oldValue == null || newValue == null)
  1150. {
  1151. return;
  1152. }
  1153. #region pick 和 place LL
  1154. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  1155. {
  1156. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1157. if (TMRobotMoveActionBladeTarget != null)
  1158. {
  1159. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1160. }
  1161. else
  1162. {
  1163. return;
  1164. }
  1165. var values = RobotTarget.Split('.');
  1166. var arm = values[0];
  1167. var module = values[1];
  1168. if (arm == "ArmA")
  1169. {
  1170. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1171. //await Task.Delay(1000);
  1172. await ChangePosition(robot3Robot3TAction, newValue.Action);
  1173. if (Robot3TAction != robot3Robot3TAction)
  1174. {
  1175. Robot3TAction = robot3Robot3TAction;
  1176. await Task.Delay(600);
  1177. }
  1178. Robot3XAction = WaferRobotXAction.Extend;
  1179. 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))
  1180. {
  1181. await Task.Delay(100);
  1182. }
  1183. Robot3XAction = WaferRobotXAction.Retract;
  1184. if(newValue.Action == RobotAction.Placing)
  1185. {
  1186. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1187. }
  1188. }
  1189. }
  1190. #endregion
  1191. #region pick 和 place pm
  1192. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  1193. {
  1194. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1195. if (TMRobotMoveActionBladeTarget != null)
  1196. {
  1197. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1198. }
  1199. else
  1200. {
  1201. return;
  1202. }
  1203. var values = RobotTarget.Split('.');
  1204. var arm = values[0];
  1205. var module = values[1];
  1206. if (arm == "ArmA")
  1207. {
  1208. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1209. await Task.Delay(1500);
  1210. //ChangePosition(Robot3TAction);
  1211. //await Task.Delay(2000);
  1212. Robot3XAction = WaferRobotXAction.Extend;
  1213. }
  1214. else if (arm == "ArmB")
  1215. {
  1216. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1217. await Task.Delay(1500);
  1218. //ChangePosition(Robot4TAction);
  1219. //await Task.Delay(2000);
  1220. Robot4XAction = WaferRobotXAction.Extend;
  1221. }
  1222. }
  1223. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  1224. {
  1225. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1226. if (TMRobotMoveActionBladeTarget != null)
  1227. {
  1228. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1229. }
  1230. else
  1231. {
  1232. return;
  1233. }
  1234. var values = RobotTarget.Split('.');
  1235. var arm = values[0];
  1236. if (arm == "ArmA")
  1237. {
  1238. Robot3XAction = WaferRobotXAction.Retract;
  1239. await Task.Delay(3000);
  1240. //ChangePosition(Robot3TAction);
  1241. //await Task.Delay(2000);
  1242. }
  1243. else if (arm == "ArmB")
  1244. {
  1245. Robot4XAction = WaferRobotXAction.Retract;
  1246. await Task.Delay(3000);
  1247. //ChangePosition(Robot3TAction);
  1248. //await Task.Delay(2000);
  1249. }
  1250. }
  1251. #endregion
  1252. #region Home
  1253. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1254. {
  1255. if (Robot3XAction == WaferRobotXAction.Extend)
  1256. {
  1257. Robot3XAction = WaferRobotXAction.Retract;
  1258. }
  1259. if (Robot4XAction == WaferRobotXAction.Extend)
  1260. {
  1261. Robot4XAction = WaferRobotXAction.Retract;
  1262. }
  1263. if (Robot3TAction != WaferRobotTAction.T_Origin)
  1264. {
  1265. Robot3TAction = WaferRobotTAction.T_Origin;
  1266. }
  1267. if (Robot4TAction != WaferRobotTAction.T_Origin)
  1268. {
  1269. Robot4TAction = WaferRobotTAction.T_Origin;
  1270. }
  1271. await Task.Delay(1000);
  1272. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1273. }
  1274. #endregion
  1275. }
  1276. private void addDataKeys()
  1277. {
  1278. m_RtDataKeys.Add("LP1.IsLoaded");
  1279. m_RtDataKeys.Add("LP2.IsLoaded");
  1280. m_RtDataKeys.Add("LP3.IsLoaded");
  1281. m_RtDataKeys.Add("LP1.CassettePlaced");
  1282. m_RtDataKeys.Add("LP2.CassettePlaced");
  1283. m_RtDataKeys.Add("LP3.CassettePlaced");
  1284. m_RtDataKeys.Add("LP1.CurrentControlJob");
  1285. m_RtDataKeys.Add("LP2.CurrentControlJob");
  1286. m_RtDataKeys.Add("LP3.CurrentControlJob");
  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. }