OperationOverViewModel.cs 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  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. _pufLayoutRotationDistance = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.PufLayoutRotationDistance");
  695. _robotLayoutPosition = (int)QueryDataClient.Instance.Service.GetConfig("DualPUF.RobotLayoutPosition");
  696. if (!m_RtDataKeys.Contains($"Station.PUF1.Roation"))
  697. {
  698. addStationDataKeys();
  699. }
  700. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  701. if (RtDataValues != null)
  702. {
  703. //目标位置数据获取
  704. Puf1RotationAxis = CommonFunction.GetValue<BeckhoffStationAxis>(RtDataValues, $"Station.PUF1.Rotation");
  705. //Puf1Rotation比例尺计算
  706. var resultRotation = Puf1RotationAxis != null ? CalculatePufMaxMin(Puf1RotationAxis) : (0, 0);
  707. double distance = resultRotation.right - resultRotation.left;
  708. _puf1RotationRatio = distance / _pufLayoutRotationDistance;
  709. _puf1RotationMotorPositionMax = resultRotation.left;
  710. //目标位置数据获取
  711. Puf1FlipAxis = CommonFunction.GetValue<BeckhoffStationAxis>(RtDataValues, $"Station.PUF1.Flip");
  712. _puf1FlipDiff = CalculatePufFlipDiff(Puf1FlipAxis);
  713. }
  714. }
  715. /// <summary>
  716. /// 隐藏
  717. /// </summary>
  718. public void Hide()
  719. {
  720. if (_timer != null)
  721. {
  722. _timer.Stop();
  723. }
  724. if (_timer1 != null)
  725. {
  726. _timer1.Stop();
  727. }
  728. }
  729. private void OnMap(object obj)
  730. {
  731. InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Map");
  732. }
  733. private void OnStart(object obj)
  734. {
  735. var info = obj as WaferAssociationInfo;
  736. InvokeClient.Instance.Service.DoOperation("System.StartJob", info.LotId);
  737. }
  738. private void OnStop(object obj)
  739. {
  740. var info = obj as WaferAssociationInfo;
  741. InvokeClient.Instance.Service.DoOperation("System.PauseJob", info.JobID);
  742. }
  743. private void OnAbort(object obj)
  744. {
  745. var info = obj as WaferAssociationInfo;
  746. InvokeClient.Instance.Service.DoOperation("System.ResumeJob", info.JobID);
  747. }
  748. private void OnHomeAll()
  749. {
  750. InvokeClient.Instance.Service.DoOperation("System.HomeAll");
  751. }
  752. private void OnResumeAllJob()
  753. {
  754. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  755. {
  756. InvokeClient.Instance.Service.DoOperation("System.ResumeAllJob");
  757. }
  758. else
  759. {
  760. InvokeClient.Instance.Service.DoOperation("System.PauseAllJob");
  761. }
  762. }
  763. private void OnAbortAll()
  764. {
  765. InvokeClient.Instance.Service.DoOperation("System.Abort");
  766. }
  767. private void OnReturnAllWafer()
  768. {
  769. //Dialog
  770. WaferDialogView dialog = new WaferDialogView()
  771. {
  772. Owner = Application.Current.MainWindow,
  773. };
  774. dialog.Height = 300;
  775. dialog.Width = 400;
  776. double angel = 0;
  777. double coolingtime = 0;
  778. string message = "Please Confirm Return Wafer";
  779. WaferDialogViewModel vm = new WaferDialogViewModel();
  780. vm.ConfirmText = message;
  781. dialog.DataContext = vm;
  782. if (dialog.ShowDialog() == true)
  783. {
  784. if ((bool)dialog.AlignFlag == true && !string.IsNullOrEmpty(dialog.Angle))
  785. {
  786. angel = Convert.ToDouble(dialog.Angle);
  787. }
  788. if ((bool)dialog.CoolingFlag == true && !string.IsNullOrEmpty(dialog.CoolingTime))
  789. {
  790. coolingtime = Convert.ToDouble(dialog.CoolingTime);
  791. }
  792. InvokeClient.Instance.Service.DoOperation("System.ReturnAllWafer", dialog.CoolingFlag, coolingtime, dialog.AlignFlag, angel);
  793. }
  794. }
  795. private void OnSetSequence(object obj)
  796. {
  797. var info = obj as WaferInfo;
  798. bool flag = info.SequenceName != "" ? false : true;
  799. }
  800. private void OnEnableAuto()
  801. {
  802. InvokeClient.Instance.Service.DoOperation("System.SetAutoMode");
  803. }
  804. private void OnEnableManual()
  805. {
  806. InvokeClient.Instance.Service.DoOperation("System.SetManualMode");
  807. }
  808. private void GotoSrdViewAction(object obj)
  809. {
  810. PunkHPX8_Core.GlobalEvents.OnSwitchFixedTabItem("HardWare", "SRD", $"{obj.ToString()}");
  811. }
  812. #endregion
  813. #region 私有方法
  814. /// <summary>
  815. /// 定时器
  816. /// </summary>
  817. /// <param name="sender"></param>
  818. /// <param name="e"></param>
  819. private void Timer_Tick(object sender, EventArgs e)
  820. {
  821. LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];
  822. LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];
  823. LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];
  824. EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];
  825. SRD1ModuleInfo = ModuleManager.ModuleInfos["SRD1"];
  826. SRD2ModuleInfo = ModuleManager.ModuleInfos["SRD2"];
  827. PUF1ModuleInfo = ModuleManager.ModuleInfos["PUF1"];
  828. Dummy1ModuleInfo = ModuleManager.ModuleInfos["Dummy1"];
  829. Dummy2ModuleInfo = ModuleManager.ModuleInfos["Dummy2"];
  830. LoaderModuleInfo = ModuleManager.ModuleInfos["Loader1"];
  831. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  832. {
  833. BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  834. }
  835. if (EFEMIsInstalled == true)
  836. {
  837. if (ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers.Count != 0)
  838. {
  839. EFEMBladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];
  840. }
  841. if (ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers.Count != 0)
  842. {
  843. Aligner1Wafer = ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];
  844. }
  845. }
  846. if (SRD1ModuleInfo != null&& SRD1ModuleInfo.WaferManager.Wafers.Count!=0)
  847. {
  848. SRD1Wafer = SRD1ModuleInfo.WaferManager.Wafers[0];
  849. }
  850. if (SRD2ModuleInfo != null&& SRD2ModuleInfo.WaferManager.Wafers.Count!=0)
  851. {
  852. SRD2Wafer = SRD2ModuleInfo.WaferManager.Wafers[0];
  853. }
  854. if(PUF1ModuleInfo!=null)
  855. {
  856. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  857. {
  858. PUF1WaferA = PUF1ModuleInfo.WaferManager.Wafers[0];
  859. }
  860. if (PUF1ModuleInfo.WaferManager.Wafers.Count != 0)
  861. {
  862. PUF1WaferB = PUF1ModuleInfo.WaferManager.Wafers[1];
  863. }
  864. }
  865. if(LoaderIsInstalled&&LoaderModuleInfo!=null)
  866. {
  867. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  868. {
  869. LoaderWaferA = LoaderModuleInfo.WaferManager.Wafers[0];
  870. }
  871. if (LoaderModuleInfo.WaferManager.Wafers.Count != 0)
  872. {
  873. LoaderWaferB = LoaderModuleInfo.WaferManager.Wafers[1];
  874. }
  875. }
  876. RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");
  877. EfemRobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");
  878. LP1WaferCount = LP1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  879. LP2WaferCount = LP2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  880. LP3WaferCount = LP3ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  881. //Dummy1WaferCount = 15;
  882. Dummy1WaferCount = Dummy1ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  883. Dummy2WaferCount = Dummy2ModuleInfo.WaferManager.Wafers.Where(x => x.WaferStatus != 0).Count();
  884. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  885. IsLP1Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort1Unable");
  886. IsLP2Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort2Unable");
  887. IsLP3Unable = (bool)QueryDataClient.Instance.Service.GetConfig("EFEM.IsLoadPort3Unable");
  888. if (RtDataValues != null)
  889. {
  890. Puf1IsInRobotStation = CommonFunction.GetValue<bool>(RtDataValues, "PUF1.IsInRobotStation");
  891. if (CommonFunction.GetValue<int>(RtDataValues, "EquipmentStatus") == 4)
  892. {
  893. RouteState = "Resume";
  894. }
  895. else
  896. {
  897. RouteState = "Pause";
  898. }
  899. ControlJobInfo lp1Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP1.CurrentControlJob");
  900. IsLP1HasNoJob = lp1Cj == null ? true : false;
  901. ControlJobInfo lp2Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP2.CurrentControlJob");
  902. IsLP2HasNoJob = lp2Cj == null ? true : false;
  903. ControlJobInfo lp3Cj = CommonFunction.GetValue<ControlJobInfo>(RtDataValues, "LP3.CurrentControlJob");
  904. IsLP3HasNoJob = lp3Cj == null ? true : false;
  905. }
  906. }
  907. int count = 0;
  908. /// <summary>
  909. /// 定时器1
  910. /// </summary>
  911. /// <param name="sender"></param>
  912. /// <param name="e"></param>
  913. private void Timer1_Tick(object sender, EventArgs e)
  914. {
  915. if (m_RtDataKeys.Count != 0)
  916. {
  917. RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
  918. if (RtDataValues != null)
  919. {
  920. Puf1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Rotation.{MOTOR_POSITION}");
  921. Loader1TiltAMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltA.{MOTOR_POSITION}");
  922. Loader1TiltBMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.TiltB.{MOTOR_POSITION}");
  923. Loader1RotationMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"Loader1.Rotation.{MOTOR_POSITION}");
  924. Puf1FlipMotorPosition = CommonFunction.GetValue<double>(RtDataValues, $"PUF1.Flip.{MOTOR_POSITION}");
  925. //计算Puf1 Rotation UI位置
  926. Puf1RotationPosition = _robotLayoutPosition + (Puf1RotationMotorPosition - _puf1RotationMotorPositionMax) / _puf1RotationRatio;
  927. //计Loader Rotation UI位置
  928. Loader1RotationPosition = -Loader1RotationMotorPosition - LOADER_ROTATION_DIFFER;
  929. //计算Puf1 Flip UI位置
  930. Puf1FlipPosition = Puf1FlipMotorPosition - _puf1FlipDiff;
  931. //判断Loader1的TiltA水平状态
  932. LoaderTiltACurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltA.{CURRENT_STATION}"), "Loader1.TiltA");
  933. if (LoaderTiltACurrentStation == "HORI")
  934. {
  935. LoaderWaferVisibleA = true;
  936. }
  937. else if(LoaderTiltACurrentStation == "VERT")
  938. {
  939. LoaderWaferVisibleA = false;
  940. }
  941. //判断Loader1的TiltB水平状态
  942. LoaderTiltBCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(RtDataValues, $"Loader1.TiltB.{CURRENT_STATION}"), "Loader1.TiltB");
  943. if (LoaderTiltBCurrentStation == "HORI")
  944. {
  945. LoaderWaferVisibleB = true;
  946. }
  947. else if (LoaderTiltBCurrentStation == "VERT")
  948. {
  949. LoaderWaferVisibleB = false;
  950. }
  951. }
  952. }
  953. }
  954. private async void RobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  955. {
  956. string RobotTarget;
  957. if (oldValue == null || newValue == null)
  958. {
  959. return;
  960. }
  961. #region Rotating
  962. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))
  963. {
  964. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  965. if (TMRobotMoveActionBladeTarget != null)
  966. {
  967. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  968. }
  969. else
  970. {
  971. return;
  972. }
  973. var values = RobotTarget.Split('.');
  974. var arm = values[0];
  975. var module = values[1];
  976. if (arm == "ArmA")
  977. {
  978. Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  979. }
  980. else if (arm == "ArmB")
  981. {
  982. Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  983. }
  984. }
  985. #endregion
  986. #region pick 和 place LL
  987. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  988. {
  989. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  990. if (TMRobotMoveActionBladeTarget != null)
  991. {
  992. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  993. }
  994. else
  995. {
  996. return;
  997. }
  998. var values = RobotTarget.Split('.');
  999. var arm = values[0];
  1000. var module = values[1];
  1001. if (arm == "ArmA")
  1002. {
  1003. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1004. if (waferRobotTAction != Robot1TAction)
  1005. {
  1006. Robot1TAction = waferRobotTAction;
  1007. }
  1008. else
  1009. {
  1010. //await Task.Delay(100);
  1011. }
  1012. await Task.Delay(600);
  1013. //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1014. //await Task.Delay(600);
  1015. Robot1XAction = WaferRobotXAction.Extend;
  1016. 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))
  1017. {
  1018. await Task.Delay(100);
  1019. }
  1020. Robot1XAction = WaferRobotXAction.Retract;
  1021. }
  1022. else if (arm == "ArmB")
  1023. {
  1024. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1025. if (waferRobotTAction != Robot2TAction)
  1026. {
  1027. Robot2TAction = waferRobotTAction;
  1028. }
  1029. else
  1030. {
  1031. //await Task.Delay(100);
  1032. }
  1033. await Task.Delay(600);
  1034. //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1035. //await Task.Delay(600);
  1036. Robot2XAction = WaferRobotXAction.Extend;
  1037. 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))
  1038. {
  1039. await Task.Delay(100);
  1040. }
  1041. Robot2XAction = WaferRobotXAction.Retract;
  1042. }
  1043. }
  1044. #endregion
  1045. #region pick 和 place pm
  1046. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Extending)
  1047. {
  1048. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1049. if (TMRobotMoveActionBladeTarget != null)
  1050. {
  1051. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1052. }
  1053. else
  1054. {
  1055. return;
  1056. }
  1057. var values = RobotTarget.Split('.');
  1058. var arm = values[0];
  1059. var module = values[1];
  1060. if (arm == "ArmA")
  1061. {
  1062. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1063. if (waferRobotTAction != Robot1TAction)
  1064. {
  1065. Robot1TAction = waferRobotTAction;
  1066. }
  1067. else
  1068. {
  1069. // await Task.Delay(100);
  1070. }
  1071. await Task.Delay(600);
  1072. Robot1XAction = WaferRobotXAction.Extend;
  1073. }
  1074. else if (arm == "ArmB")
  1075. {
  1076. var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1077. if (waferRobotTAction != Robot2TAction)
  1078. {
  1079. Robot2TAction = waferRobotTAction;
  1080. }
  1081. else
  1082. {
  1083. // await Task.Delay(100);
  1084. }
  1085. await Task.Delay(600);
  1086. Robot2XAction = WaferRobotXAction.Extend;
  1087. }
  1088. }
  1089. else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && newValue.Action == RobotAction.Retracting)
  1090. {
  1091. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1092. if (TMRobotMoveActionBladeTarget != null)
  1093. {
  1094. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1095. }
  1096. else
  1097. {
  1098. return;
  1099. }
  1100. var values = RobotTarget.Split('.');
  1101. var arm = values[0];
  1102. if (arm == "ArmA")
  1103. {
  1104. Robot1XAction = WaferRobotXAction.Retract;
  1105. }
  1106. else if (arm == "ArmB")
  1107. {
  1108. Robot2XAction = WaferRobotXAction.Retract;
  1109. }
  1110. }
  1111. #endregion
  1112. #region Home
  1113. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1114. {
  1115. if (Robot1XAction == WaferRobotXAction.Extend)
  1116. {
  1117. Robot1XAction = WaferRobotXAction.Retract;
  1118. }
  1119. if (Robot2XAction == WaferRobotXAction.Extend)
  1120. {
  1121. Robot2XAction = WaferRobotXAction.Retract;
  1122. }
  1123. await Task.Delay(2000);
  1124. if (Robot1TAction != WaferRobotTAction.T_Origin)
  1125. {
  1126. Robot1TAction = WaferRobotTAction.T_Origin;
  1127. }
  1128. if (Robot2TAction != WaferRobotTAction.T_Origin)
  1129. {
  1130. Robot2TAction = WaferRobotTAction.T_Origin;
  1131. }
  1132. }
  1133. #endregion
  1134. }
  1135. private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)
  1136. {
  1137. string RobotTarget;
  1138. if (oldValue == null || newValue == null)
  1139. {
  1140. return;
  1141. }
  1142. #region pick 和 place LL
  1143. if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))
  1144. {
  1145. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1146. if (TMRobotMoveActionBladeTarget != null)
  1147. {
  1148. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1149. }
  1150. else
  1151. {
  1152. return;
  1153. }
  1154. var values = RobotTarget.Split('.');
  1155. var arm = values[0];
  1156. var module = values[1];
  1157. if (arm == "ArmA")
  1158. {
  1159. var robot3Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1160. //await Task.Delay(1000);
  1161. await ChangePosition(robot3Robot3TAction, newValue.Action);
  1162. if (Robot3TAction != robot3Robot3TAction)
  1163. {
  1164. Robot3TAction = robot3Robot3TAction;
  1165. await Task.Delay(600);
  1166. }
  1167. Robot3XAction = WaferRobotXAction.Extend;
  1168. 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))
  1169. {
  1170. await Task.Delay(100);
  1171. }
  1172. Robot3XAction = WaferRobotXAction.Retract;
  1173. if(newValue.Action == RobotAction.Placing)
  1174. {
  1175. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1176. }
  1177. }
  1178. }
  1179. #endregion
  1180. #region pick 和 place pm
  1181. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)
  1182. {
  1183. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1184. if (TMRobotMoveActionBladeTarget != null)
  1185. {
  1186. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1187. }
  1188. else
  1189. {
  1190. return;
  1191. }
  1192. var values = RobotTarget.Split('.');
  1193. var arm = values[0];
  1194. var module = values[1];
  1195. if (arm == "ArmA")
  1196. {
  1197. Robot3TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1198. await Task.Delay(1500);
  1199. //ChangePosition(Robot3TAction);
  1200. //await Task.Delay(2000);
  1201. Robot3XAction = WaferRobotXAction.Extend;
  1202. }
  1203. else if (arm == "ArmB")
  1204. {
  1205. Robot4TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);
  1206. await Task.Delay(1500);
  1207. //ChangePosition(Robot4TAction);
  1208. //await Task.Delay(2000);
  1209. Robot4XAction = WaferRobotXAction.Extend;
  1210. }
  1211. }
  1212. if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)
  1213. {
  1214. var TMRobotMoveActionBladeTarget = newValue.BladeTarget;
  1215. if (TMRobotMoveActionBladeTarget != null)
  1216. {
  1217. RobotTarget = TMRobotMoveActionBladeTarget.ToString();
  1218. }
  1219. else
  1220. {
  1221. return;
  1222. }
  1223. var values = RobotTarget.Split('.');
  1224. var arm = values[0];
  1225. if (arm == "ArmA")
  1226. {
  1227. Robot3XAction = WaferRobotXAction.Retract;
  1228. await Task.Delay(3000);
  1229. //ChangePosition(Robot3TAction);
  1230. //await Task.Delay(2000);
  1231. }
  1232. else if (arm == "ArmB")
  1233. {
  1234. Robot4XAction = WaferRobotXAction.Retract;
  1235. await Task.Delay(3000);
  1236. //ChangePosition(Robot3TAction);
  1237. //await Task.Delay(2000);
  1238. }
  1239. }
  1240. #endregion
  1241. #region Home
  1242. else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)
  1243. {
  1244. if (Robot3XAction == WaferRobotXAction.Extend)
  1245. {
  1246. Robot3XAction = WaferRobotXAction.Retract;
  1247. }
  1248. if (Robot4XAction == WaferRobotXAction.Extend)
  1249. {
  1250. Robot4XAction = WaferRobotXAction.Retract;
  1251. }
  1252. if (Robot3TAction != WaferRobotTAction.T_Origin)
  1253. {
  1254. Robot3TAction = WaferRobotTAction.T_Origin;
  1255. }
  1256. if (Robot4TAction != WaferRobotTAction.T_Origin)
  1257. {
  1258. Robot4TAction = WaferRobotTAction.T_Origin;
  1259. }
  1260. await Task.Delay(1000);
  1261. await ChangePosition(WaferRobotTAction.T_Origin, newValue.Action);
  1262. }
  1263. #endregion
  1264. }
  1265. private void addDataKeys()
  1266. {
  1267. m_RtDataKeys.Add("LP1.IsLoaded");
  1268. m_RtDataKeys.Add("LP2.IsLoaded");
  1269. m_RtDataKeys.Add("LP3.IsLoaded");
  1270. m_RtDataKeys.Add("LP1.CassettePlaced");
  1271. m_RtDataKeys.Add("LP2.CassettePlaced");
  1272. m_RtDataKeys.Add("LP3.CassettePlaced");
  1273. m_RtDataKeys.Add("LP1.CurrentControlJob");
  1274. m_RtDataKeys.Add("LP2.CurrentControlJob");
  1275. m_RtDataKeys.Add("LP3.CurrentControlJob");
  1276. m_RtDataKeys.Add("LP1.WaferSize");
  1277. m_RtDataKeys.Add("LP2.WaferSize");
  1278. m_RtDataKeys.Add("LP3.WaferSize");
  1279. m_RtDataKeys.Add("Dummy1.CassettePlaced");
  1280. m_RtDataKeys.Add("Dummy2.CassettePlaced");
  1281. m_RtDataKeys.Add("Dummy1.WaferSize");
  1282. m_RtDataKeys.Add("Dummy2.WaferSize");
  1283. m_RtDataKeys.Add("System.IsAutoMode");
  1284. m_RtDataKeys.Add("System.IsBusy");
  1285. m_RtDataKeys.Add("Scheduler.CycledCount");
  1286. m_RtDataKeys.Add("Scheduler.CycledWafer");
  1287. m_RtDataKeys.Add("Scheduler.CycleSetPoint");
  1288. m_RtDataKeys.Add("Scheduler.Throughput");
  1289. m_RtDataKeys.Add("EquipmentStatus");
  1290. m_RtDataKeys.Add("Scheduler.PjNameList");
  1291. m_RtDataKeys.Add("PUF1.IsInRobotStation");
  1292. m_RtDataKeys.Add("Scheduler.CjNameList");
  1293. }
  1294. private void addStationDataKeys()
  1295. {
  1296. m_RtDataKeys.Add($"Station.PUF1.Rotation");
  1297. m_RtDataKeys.Add($"Station.PUF1.Flip");
  1298. m_RtDataKeys.Add($"Station.PUF1.Vertical");
  1299. m_RtDataKeys.Add($"Station.Loader1.Rotation");
  1300. m_RtDataKeys.Add($"Station.Loader1.TiltA");
  1301. m_RtDataKeys.Add($"Station.Loader1.TiltB");
  1302. m_RtDataKeys.Add($"PUF1.Rotation.{MOTOR_POSITION}");
  1303. m_RtDataKeys.Add($"PUF1.Flip.{MOTOR_POSITION}");
  1304. m_RtDataKeys.Add($"Loader1.Rotation.{MOTOR_POSITION}");
  1305. m_RtDataKeys.Add($"Loader1.TiltA.{MOTOR_POSITION}");
  1306. m_RtDataKeys.Add($"Loader1.TiltB.{MOTOR_POSITION}");
  1307. m_RtDataKeys.Add($"PUF1.Flip.{CURRENT_STATION}");
  1308. m_RtDataKeys.Add($"Loader1.TiltA.{CURRENT_STATION}");
  1309. m_RtDataKeys.Add($"Loader1.TiltB.{CURRENT_STATION}");
  1310. m_RtDataKeys.Add($"PUF1.Rotation.{MOTION_DATA}");
  1311. }
  1312. private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)
  1313. {
  1314. if (wafers[index].WaferStatus == 0)
  1315. return false;
  1316. return true;
  1317. }
  1318. private async Task ChangePosition(WaferRobotTAction waferRobotTAction, RobotAction robotAction)
  1319. {
  1320. await Task.Delay(500);
  1321. int delay = 500;
  1322. if (robotAction == RobotAction.Placing)
  1323. {
  1324. if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1)
  1325. {
  1326. CurrentRobotPosition = EFEM.RobotPosition.Left_Place;
  1327. await Task.Delay(delay);
  1328. }
  1329. else if (waferRobotTAction == WaferRobotTAction.LP3)
  1330. {
  1331. CurrentRobotPosition = EFEM.RobotPosition.Right_Place;
  1332. await Task.Delay(delay);
  1333. }
  1334. else if (waferRobotTAction == WaferRobotTAction.LP2 )
  1335. {
  1336. CurrentRobotPosition = EFEM.RobotPosition.Middle_Place;
  1337. await Task.Delay(delay);
  1338. }
  1339. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  1340. {
  1341. CurrentRobotPosition = EFEM.RobotPosition.Aligner_Place;
  1342. await Task.Delay(delay);
  1343. }
  1344. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  1345. {
  1346. CurrentRobotPosition = EFEM.RobotPosition.SRD_Place;
  1347. }
  1348. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  1349. {
  1350. CurrentRobotPosition = EFEM.RobotPosition.Dummy_Place;
  1351. }
  1352. else
  1353. {
  1354. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  1355. await Task.Delay(delay);
  1356. }
  1357. }
  1358. else
  1359. {
  1360. if (waferRobotTAction == WaferRobotTAction.LP1 || waferRobotTAction == WaferRobotTAction.PUF1)
  1361. {
  1362. CurrentRobotPosition = EFEM.RobotPosition.Left;
  1363. await Task.Delay(delay);
  1364. }
  1365. else if (waferRobotTAction == WaferRobotTAction.LP3)
  1366. {
  1367. CurrentRobotPosition = EFEM.RobotPosition.Right;
  1368. await Task.Delay(delay);
  1369. }
  1370. else if (waferRobotTAction == WaferRobotTAction.LP2)
  1371. {
  1372. CurrentRobotPosition = EFEM.RobotPosition.Middle;
  1373. await Task.Delay(delay);
  1374. }
  1375. else if (waferRobotTAction == WaferRobotTAction.Aligner1)
  1376. {
  1377. CurrentRobotPosition = EFEM.RobotPosition.Aligner;
  1378. await Task.Delay(delay);
  1379. }
  1380. else if (waferRobotTAction == WaferRobotTAction.SRD1 || waferRobotTAction == WaferRobotTAction.SRD2)
  1381. {
  1382. CurrentRobotPosition = EFEM.RobotPosition.SRD;
  1383. }
  1384. else if (waferRobotTAction == WaferRobotTAction.Dummy1 || waferRobotTAction == WaferRobotTAction.Dummy2)
  1385. {
  1386. CurrentRobotPosition = EFEM.RobotPosition.Dummy;
  1387. }
  1388. else
  1389. {
  1390. CurrentRobotPosition = EFEM.RobotPosition.Origin;
  1391. await Task.Delay(delay);
  1392. }
  1393. }
  1394. }
  1395. /// <summary>
  1396. /// 计算最大值最小值
  1397. /// </summary>
  1398. /// <param name="Puf1RotationAxis"></param>
  1399. /// <returns></returns>
  1400. private (double right, double left) CalculatePufMaxMin(BeckhoffStationAxis pufAxis)
  1401. {
  1402. if (pufAxis == null || pufAxis.Stations.Count == 0) return (-1,-1);
  1403. double max = double.Parse(pufAxis.Stations[0].Position);
  1404. double min = double.Parse(pufAxis.Stations[0].Position);
  1405. double home = 0;
  1406. double pickup = 0;
  1407. foreach (Station item in pufAxis.Stations)
  1408. {
  1409. if (item.Name.ToLower().Contains("home")) home = double.Parse(item.Position);
  1410. if (item.Name.ToLower().Contains("pickup")) pickup = double.Parse(item.Position);
  1411. double position = double.Parse(item.Position);
  1412. if (position > max)
  1413. {
  1414. max = position;
  1415. }
  1416. if (position < min)
  1417. {
  1418. min = position;
  1419. }
  1420. }
  1421. return pickup < home ? (min, max):(max, min);
  1422. }
  1423. /// <summary>
  1424. /// 计算PufFlip差值
  1425. /// </summary>
  1426. /// <param name="pufAxis"></param>
  1427. /// <returns></returns>
  1428. private double CalculatePufFlipDiff(BeckhoffStationAxis pufAxis)
  1429. {
  1430. double sideAangle = 0;
  1431. double sideBangle = 0; ;
  1432. foreach (Station item in pufAxis.Stations)
  1433. {
  1434. if (item.Name.ToLower().Contains("sideA")) sideAangle = double.Parse(item.Position);
  1435. if (item.Name.ToLower().Contains("sideB")) sideBangle = double.Parse(item.Position);
  1436. }
  1437. return sideAangle > sideBangle ? 180 : 0;
  1438. }
  1439. /// <summary>
  1440. /// 判定是否在station位置
  1441. /// </summary>
  1442. private bool JudgeAtStation(double targetPosition, double currentPosition, double tolerance)
  1443. {
  1444. if (Math.Abs(currentPosition - targetPosition) <= tolerance)
  1445. {
  1446. return true;
  1447. }
  1448. else
  1449. {
  1450. return false;
  1451. }
  1452. }
  1453. #endregion
  1454. }
  1455. }