OperationOverViewModel.cs 51 KB

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