OperationOverViewModel.cs 60 KB

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