SunWayRobot.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections;
  7. using CyberX8_Core;
  8. using CyberX8_RT.Modules;
  9. using MECF.Framework.Common.CommonData;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using Aitex.Sorter.Common;
  13. using Aitex.Core.Common;
  14. using Aitex.Core.RT.SCCore;
  15. using Aitex.Core.RT.Log;
  16. using Aitex.Core.Util;
  17. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  18. using CyberX8_RT.Devices.YASKAWA;
  19. using System.Collections.Concurrent;
  20. using System.Diagnostics;
  21. using System.Data.SqlTypes;
  22. using System.Windows.Media.Media3D;
  23. using System.ComponentModel;
  24. using MECF.Framework.Common.Beckhoff.Station;
  25. using System.Runtime.Remoting.Contexts;
  26. using System.Windows.Markup;
  27. using CyberX8_RT.Modules.LPs;
  28. using MECF.Framework.Common.ToolLayout;
  29. namespace CyberX8_RT.Devices.EFEM
  30. {
  31. public class SunWayRobot : EfemBase
  32. {
  33. #region 常量
  34. private const string NONE = "None";
  35. #endregion
  36. private RState _status;
  37. private bool _IsHomed;
  38. private bool _bIsUnloadClamp;
  39. private RobotMoveInfo _robotMoveInfo = new RobotMoveInfo();
  40. private readonly SignalTower _signalT = new SignalTower();
  41. private readonly AsyncSocket _socket;
  42. private EfemMessage _currentMessage;
  43. private string _error;
  44. private bool _LiftIsUp = false;
  45. private bool _LiftIsDown = false;
  46. private R_TRIG _busyTrig = new R_TRIG();
  47. private Stopwatch _busyWatch = new Stopwatch();
  48. private Dictionary<string, int> _moduleStationNumberDictionary = new Dictionary<string, int>();
  49. private Dictionary<Hand, string> _armString = new Dictionary<Hand, string>
  50. {
  51. [Hand.Blade1] = "A",
  52. [Hand.Blade2] = "B"
  53. };
  54. public override RState Status
  55. {
  56. get
  57. {
  58. _busyTrig.CLK = _status == RState.Running;
  59. if (_busyTrig.Q)
  60. {
  61. _busyWatch.Restart();
  62. }
  63. else if (_busyTrig.M)
  64. {
  65. int timeOut = 5000;
  66. if (
  67. _currentMessage.Operation == EfemOperation.Home ||
  68. _currentMessage.Operation == EfemOperation.Map ||
  69. _currentMessage.Operation == EfemOperation.Pick ||
  70. _currentMessage.Operation == EfemOperation.Place)
  71. {
  72. timeOut = 30000;
  73. }
  74. if (_busyWatch.ElapsedMilliseconds > timeOut)
  75. {
  76. _busyWatch.Stop();
  77. _status = RState.Timeout;
  78. }
  79. }
  80. return _status;
  81. }
  82. }
  83. public override bool IsHomed { get { return _IsHomed; } }
  84. public override RobotMoveInfo TMRobotMoveInfo { get { return _robotMoveInfo; } }
  85. public override bool LiftIsUp { get { return _LiftIsUp; } }
  86. public override bool LiftIsDown { get { return _LiftIsDown; } }
  87. private BlockingCollection<RobotAnimationData> blockingCollection = new BlockingCollection<RobotAnimationData>();
  88. private string _address = "";
  89. public override bool IsResumeRDYReceived { get; set; }
  90. public SunWayRobot()
  91. {
  92. _socket = new AsyncSocket("","",DataType.Ascii,true);
  93. try
  94. {
  95. _address = SC.GetStringValue($"EFEM.IPAddress");
  96. _socket.Connect(_address);
  97. _socket.OnConnect += Socket_OnConnect;
  98. _socket.OnDataChanged += OnReceiveMessage;
  99. _socket.OnErrorHappened += OnErrorHappen;
  100. }
  101. catch(Exception ex)
  102. {
  103. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, "EFEM", ex.Message);
  104. }
  105. _status = RState.Init;
  106. _IsHomed = false;
  107. _busyTrig.RST = true;
  108. InitializeModuleStation(ModuleName.LP1);
  109. InitializeModuleStation(ModuleName.LP2);
  110. InitializeModuleStation(ModuleName.LP3);
  111. InitializeModuleStation(ModuleName.Dummy1);
  112. InitializeModuleStation(ModuleName.Dummy2);
  113. InitializeModuleStation(ModuleName.Aligner1);
  114. InitializeModuleStation(ModuleName.SRD1);
  115. InitializeModuleStation(ModuleName.SRD2);
  116. InitializeModuleStation(ModuleName.PUF1);
  117. CarrierManager.Instance.SubscribeLocation(ModuleName.LP1.ToString(), 1);
  118. CarrierManager.Instance.SubscribeLocation(ModuleName.LP2.ToString(), 1);
  119. CarrierManager.Instance.SubscribeLocation(ModuleName.LP3.ToString(), 1);
  120. WaferManager.Instance.SubscribeLocation(ModuleName.EfemRobot, 2);
  121. WaferManager.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
  122. WaferManager.Instance.SubscribeLocation(ModuleName.LP1, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
  123. WaferManager.Instance.SubscribeLocation(ModuleName.LP2, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
  124. WaferManager.Instance.SubscribeLocation(ModuleName.LP3, SC.GetValue<int>("EFEM.LoadPort.SlotNumber"));
  125. Task.Run(() =>
  126. {
  127. foreach (var data in blockingCollection.GetConsumingEnumerable())
  128. {
  129. _robotMoveInfo.Action = data.Action;
  130. _robotMoveInfo.ArmTarget = data.Hand == Hand.Blade1 ? RobotArm.ArmA : (data.Hand == Hand.Both ? RobotArm.Both : RobotArm.ArmB);
  131. _robotMoveInfo.BladeTarget = $"{_robotMoveInfo.ArmTarget}.{data.Target}";
  132. System.Threading.Thread.Sleep(600);
  133. }
  134. });
  135. }
  136. /// <summary>
  137. /// 初始化Module Station
  138. /// </summary>
  139. /// <param name="module"></param>
  140. private void InitializeModuleStation(ModuleName module)
  141. {
  142. int cassete200Station = SC.GetValue<int>($"EFEM.{module}.Cassete200Station");
  143. _moduleStationNumberDictionary[$"{module}_200"] = cassete200Station;
  144. int cassete150Station = SC.GetValue<int>($"EFEM.{module}.Cassete150Station");
  145. _moduleStationNumberDictionary[$"{module}_150"] = cassete150Station;
  146. int cassete100Station = SC.GetValue<int>($"EFEM.{module}.Cassete100Station");
  147. _moduleStationNumberDictionary[$"{module}_100"]=cassete100Station;
  148. }
  149. private void Socket_OnConnect()
  150. {
  151. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.CommReady);
  152. LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), $"connect {_address} success");
  153. }
  154. private void OnErrorHappen(ErrorEventArgs args)
  155. {
  156. _status = RState.Failed;
  157. if (_error != args.Reason)
  158. {
  159. _error = args.Reason;
  160. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"{Module} {_error}");
  161. }
  162. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error);
  163. }
  164. public override void Monitor()
  165. {
  166. }
  167. public override void Terminate()
  168. {
  169. }
  170. public override void Reset()
  171. {
  172. _status = RState.End;
  173. _currentMessage = null;
  174. }
  175. public override void SetOnline(bool online)
  176. {
  177. }
  178. public override void SetOnline(ModuleName mod, bool online)
  179. {
  180. }
  181. public override void SetBusy(ModuleName mod, bool online)
  182. {
  183. _status = RState.Running;
  184. }
  185. public override bool HomeAll()
  186. {
  187. if (_status == RState.Running&&_currentMessage!=null)
  188. {
  189. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot home All");
  190. return false;
  191. }
  192. //判断socket是否链接
  193. if (!_socket.IsConnected)
  194. {
  195. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  196. return false ;
  197. }
  198. _status = RState.Running;
  199. string data = "HOME ALL\r";
  200. _currentMessage =new EfemMessage(){
  201. Operation= EfemOperation.Home,
  202. Module=ModuleName.EFEM
  203. };
  204. //SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
  205. return WriteCommand(data);
  206. }
  207. public override bool Home(ModuleName mod)
  208. {
  209. if (_status == RState.Running && _currentMessage!= null)
  210. {
  211. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot home {mod}");
  212. return false;
  213. }
  214. if (mod != ModuleName.Aligner1&&mod!=ModuleName.EfemRobot)
  215. {
  216. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{mod} can not support home method");
  217. return false;
  218. }
  219. //判断socket是否链接
  220. if (!_socket.IsConnected)
  221. {
  222. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  223. return false;
  224. }
  225. if(mod == ModuleName.EfemRobot) SetRobotMovingInfo(RobotAction.Homing, Hand.Blade1, ModuleName.EfemRobot);
  226. _status = RState.Running;
  227. string cmd = "Home ALL\r";
  228. if (mod == ModuleName.Aligner1)
  229. {
  230. cmd = "ALIGNER HOME\r";
  231. }
  232. _currentMessage = new EfemMessage()
  233. {
  234. Operation = EfemOperation.Home,
  235. Module = ModuleName.Aligner1
  236. };
  237. return WriteCommand(cmd);
  238. }
  239. public override bool OriginalSearch(ModuleName mod)
  240. {
  241. return true;
  242. }
  243. public override bool CheckWaferPresence()
  244. {
  245. if (_status == RState.Running && _currentMessage != null)
  246. {
  247. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot check wafer");
  248. return false;
  249. }
  250. //判断socket是否链接
  251. if (!_socket.IsConnected)
  252. {
  253. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  254. return false;
  255. }
  256. if (!CheckEfemStatus())
  257. return false;
  258. _currentMessage = new EfemMessage()
  259. {
  260. Operation = EfemOperation.StateTrack,
  261. Module = ModuleName.EfemRobot
  262. };
  263. _status = RState.Running;
  264. string cmd = $"RQ LOAD {_armString[Hand.Blade1]}\r";
  265. return WriteCommand(cmd);
  266. }
  267. public override string GetWaferPresence()
  268. {
  269. return "";
  270. }
  271. public override bool Halt()
  272. {
  273. //判断socket是否链接
  274. if (!_socket.IsConnected)
  275. {
  276. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  277. return false;
  278. }
  279. _currentMessage = new EfemMessage()
  280. {
  281. Operation = EfemOperation.Abort,
  282. Module = ModuleName.EfemRobot
  283. };
  284. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EFEM);
  285. string cmd = "HALT\r";
  286. return WriteCommand(cmd);
  287. }
  288. public override bool Pause()
  289. {
  290. //判断socket是否链接
  291. if (!_socket.IsConnected)
  292. {
  293. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  294. return false;
  295. }
  296. _currentMessage = new EfemMessage()
  297. {
  298. Operation = EfemOperation.Pause,
  299. Module = ModuleName.EfemRobot
  300. };
  301. _status = RState.Running;
  302. string cmd = "PAUSE\r";
  303. return WriteCommand(cmd);
  304. }
  305. public override bool Resume()
  306. {
  307. //判断socket是否链接
  308. if (!_socket.IsConnected)
  309. {
  310. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  311. return false;
  312. }
  313. _currentMessage = new EfemMessage()
  314. {
  315. Operation = EfemOperation.Resume,
  316. Module = ModuleName.EfemRobot
  317. };
  318. _status = RState.Running;
  319. string cmd = "RESUME\r";
  320. return WriteCommand(cmd);
  321. }
  322. public override bool ClearError()
  323. {
  324. return true;
  325. }
  326. public override bool CloseBuzzer()
  327. {
  328. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.TurnOffBuzzer]}");
  329. return false;
  330. }
  331. public override bool PickExtend(ModuleName chamber, int slot, Hand hand)
  332. {
  333. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
  334. return false;
  335. }
  336. public override bool PickRetract(ModuleName chamber, int slot, Hand hand)
  337. {
  338. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
  339. return false;
  340. }
  341. public override bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
  342. {
  343. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
  344. return false;
  345. }
  346. public override bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
  347. {
  348. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Extend]}");
  349. return false;
  350. }
  351. public override bool Pick(ModuleName station, int slot, Hand hand)
  352. {
  353. if (_status == RState.Running && _currentMessage != null)
  354. {
  355. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot pick");
  356. return false;
  357. }
  358. //判断socket是否链接
  359. if (!_socket.IsConnected)
  360. {
  361. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  362. return false;
  363. }
  364. //判断Loadport的门是否打开
  365. //if (ModuleHelper.IsLoadPort(station) && !GetLoadPort(station).IsDoorOpened)
  366. //{
  367. // LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s Door is Closed, Cannot Execute Pick Action");
  368. // return false;
  369. //}
  370. if (!CheckEfemStatus())
  371. return false;
  372. int waferSize = GetModuleSlotWaferSize(station,slot);
  373. if (waferSize == 0)
  374. {
  375. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station} slot {slot} wafer size is 0, Cannot Execute Pick Action");
  376. return false;
  377. }
  378. string strModuleWaferSize = $"{station}_{waferSize}";
  379. if (!_moduleStationNumberDictionary.ContainsKey(strModuleWaferSize))
  380. {
  381. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s number is not exist, Cannot Execute Pick Action");
  382. return false;
  383. }
  384. int stationNumber= _moduleStationNumberDictionary[strModuleWaferSize];
  385. string cmd = $"PICK {stationNumber} SLOT {slot+1} ARM {_armString[hand]}\r";
  386. if(ModuleHelper.IsPUF(station)||ModuleHelper.IsAligner(station)||ModuleHelper.IsSRD(station))
  387. {
  388. cmd = $"PICK {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
  389. }
  390. _currentMessage = new EfemMessage()
  391. {
  392. Operation=EfemOperation.Pick
  393. };
  394. _status = RState.Running;
  395. SetRobotMovingInfo(RobotAction.Picking, hand, station);
  396. return WriteCommand(cmd);
  397. }
  398. private Loadport GetLoadPort(ModuleName station)
  399. {
  400. LoadPortModule loadPortModule = Singleton<RouteManager>.Instance.EFEM.GetLoadportModule(station - ModuleName.LP1);
  401. return loadPortModule.LPDevice;
  402. }
  403. public override bool Place(ModuleName station, int slot, Hand hand)
  404. {
  405. if (_status == RState.Running && _currentMessage != null)
  406. {
  407. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot place");
  408. return false;
  409. }
  410. //判断socket是否链接
  411. if (!_socket.IsConnected)
  412. {
  413. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  414. return false;
  415. }
  416. //判断Loadport的门是否打开
  417. //if (ModuleHelper.IsLoadPort(station) && !GetLoadPort(station).IsDoorOpened)
  418. //{
  419. // LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s Door is Closed, Cannot Execute Pick Action");
  420. // return false;
  421. //}
  422. if (!CheckEfemStatus())
  423. return false;
  424. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, (int)hand);
  425. if (waferSize == 0)
  426. {
  427. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station} slot {slot} wafer size is 0, Cannot Execute Place Action");
  428. return false;
  429. }
  430. string strModuleWaferSize = $"{station}_{waferSize}";
  431. _currentMessage = new EfemMessage()
  432. {
  433. Operation = EfemOperation.Place
  434. };
  435. _status = RState.Running;
  436. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  437. string cmd = $"PLACE {stationNumber} SLOT {slot+1} ARM {_armString[hand]}\r";
  438. if (ModuleHelper.IsPUF(station)||ModuleHelper.IsSRD(station))
  439. {
  440. cmd = $"PLACE {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
  441. }
  442. if (ModuleHelper.IsAligner(station))
  443. {
  444. cmd = $"PLACE {stationNumber} PHOME\r";
  445. }
  446. SetRobotMovingInfo(RobotAction.Placing, hand, station);
  447. return WriteCommand(cmd);
  448. }
  449. public override bool Goto(ModuleName station, Hand hand, string updown = "UP")
  450. {
  451. if (_status == RState.Running && _currentMessage != null)
  452. {
  453. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto");
  454. return false;
  455. }
  456. if (!CheckEfemStatus())
  457. return false;
  458. //判断socket是否链接
  459. if (!_socket.IsConnected)
  460. {
  461. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  462. return false;
  463. }
  464. _currentMessage = new EfemMessage()
  465. {
  466. Operation = EfemOperation.Goto
  467. };
  468. int waferSize = GetModuleNameWaferSize(station);
  469. if (waferSize == 0)
  470. {
  471. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  472. return false;
  473. }
  474. string strModuleWaferSize = $"{station}_{waferSize}";
  475. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  476. string cmd = $"GOTO N {stationNumber} R EX Z {updown} ARM SLOT 1 {_armString[hand]}\r";
  477. _status = RState.Running;
  478. return WriteCommand(cmd);
  479. }
  480. public override bool Grip(Hand blade, bool isGrip)
  481. {
  482. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Grip]}");
  483. return false;
  484. }
  485. public override bool GotoMap(ModuleName mod,Hand hand,string extend="EX")
  486. {
  487. if (_status == RState.Running && _currentMessage != null)
  488. {
  489. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto map");
  490. return false;
  491. }
  492. //判断socket是否链接
  493. if (!_socket.IsConnected)
  494. {
  495. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  496. return false;
  497. }
  498. if (!CheckEfemStatus())
  499. return false;
  500. int waferSize = GetModuleNameWaferSize(mod);
  501. if (waferSize == 0)
  502. {
  503. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  504. return false;
  505. }
  506. string strModuleWaferSize = $"{mod}_{waferSize}";
  507. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  508. string cmd = $"GOTO N {stationNumber} MAP {extend} ARM {_armString[hand]}\r";
  509. _currentMessage = new EfemMessage()
  510. {
  511. Operation = EfemOperation.Goto,
  512. Module= mod
  513. };
  514. _status = RState.Running;
  515. return WriteCommand(cmd);
  516. }
  517. public override bool Map(ModuleName mod)
  518. {
  519. if (_status == RState.Running && _currentMessage != null)
  520. {
  521. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot map");
  522. return false;
  523. }
  524. //判断socket是否链接
  525. if (!_socket.IsConnected)
  526. {
  527. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  528. return false;
  529. }
  530. if (!CheckEfemStatus())
  531. return false;
  532. int waferSize = GetModuleNameWaferSize(mod);
  533. if (waferSize == 0)
  534. {
  535. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  536. return false;
  537. }
  538. string strModuleWaferSize = $"{mod}_{waferSize}";
  539. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  540. _currentMessage = new EfemMessage()
  541. {
  542. Operation = EfemOperation.Map,
  543. Module = mod
  544. };
  545. string cmd = $"MAP {stationNumber} ARM {_armString[Hand.Blade1]}\r";
  546. _status = RState.Running;
  547. return WriteCommand(cmd);
  548. }
  549. public override bool RequestMapResult(ModuleName mod)
  550. {
  551. if (_status == RState.Running && _currentMessage != null)
  552. {
  553. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot request map");
  554. return false;
  555. }
  556. //判断socket是否链接
  557. if (!_socket.IsConnected)
  558. {
  559. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  560. return false;
  561. }
  562. if (!CheckEfemStatus())
  563. return false;
  564. int waferSize = GetModuleNameWaferSize(mod);
  565. if (waferSize == 0)
  566. {
  567. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  568. return false;
  569. }
  570. string strModuleWaferSize = $"{mod}_{waferSize}";
  571. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  572. _currentMessage = new EfemMessage()
  573. {
  574. Operation = EfemOperation.RequestMapResult,
  575. Module = mod
  576. };
  577. string cmd = $"RSR {stationNumber} ARM {_armString[Hand.Blade1]}\r";
  578. _status = RState.Running;
  579. return WriteCommand(cmd);
  580. }
  581. public override bool Vacuum(ModuleName mod,bool VacuumState)
  582. {
  583. if (_status == RState.Running && _currentMessage != null)
  584. {
  585. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot vacuum");
  586. return false;
  587. }
  588. //判断socket是否链接
  589. if (!_socket.IsConnected)
  590. {
  591. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  592. return false;
  593. }
  594. _currentMessage = new EfemMessage()
  595. {
  596. Operation = EfemOperation.Vacuum,
  597. Module = mod
  598. };
  599. _status = RState.Running;
  600. string strVacuum = VacuumState ? "ON" : "OFF";
  601. string cmd = "";
  602. if (ModuleName.Aligner1 == mod)
  603. {
  604. cmd = $"ALIGNER VAC {strVacuum}\r";
  605. }
  606. else
  607. {
  608. cmd = $"VAC {strVacuum} ARM {_armString[Hand.Blade1]}\r";
  609. }
  610. return WriteCommand(cmd);
  611. }
  612. public override bool GetWaferSize(ModuleName mod)
  613. {
  614. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support GetWaferSize");
  615. return false;
  616. }
  617. public override bool SetWaferSize(ModuleName mod, int WaferSize)
  618. {
  619. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support SetWaferSize");
  620. return false;
  621. }
  622. public override bool SetPinUp(ModuleName mod)
  623. {
  624. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Lift]}");
  625. return false;
  626. }
  627. public override bool SetPinDown(ModuleName mod)
  628. {
  629. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Lift]}");
  630. return false;
  631. }
  632. public override bool SetAlignWaferSize()
  633. {
  634. if (_status == RState.Running && _currentMessage != null)
  635. {
  636. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Wafer Size");
  637. return false;
  638. }
  639. if (!CheckEfemStatus())
  640. return false;
  641. if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  642. {
  643. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
  644. return false;
  645. }
  646. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
  647. if (waferSize == 0)
  648. {
  649. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
  650. return false;
  651. }
  652. //判断socket是否链接
  653. if (!_socket.IsConnected)
  654. {
  655. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  656. return false;
  657. }
  658. _currentMessage = new EfemMessage()
  659. {
  660. Operation = EfemOperation.AlignWaferSize
  661. };
  662. string cmd = $"SET ALIGNER WAFERSIZE {waferSize}\r";
  663. _status = RState.Running;
  664. return WriteCommand(cmd);
  665. }
  666. public override bool SetAlignFlatType(int flatType)
  667. {
  668. if (_status == RState.Running && _currentMessage != null)
  669. {
  670. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
  671. return false;
  672. }
  673. if (!CheckEfemStatus())
  674. return false;
  675. //判断socket是否链接
  676. if (!_socket.IsConnected)
  677. {
  678. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  679. return false;
  680. }
  681. _currentMessage = new EfemMessage()
  682. {
  683. Operation = EfemOperation.AlignFlatType
  684. };
  685. string cmd = $"SET ALIGNER WAFERTYPE {flatType}\r";
  686. _status = RState.Running;
  687. return WriteCommand(cmd);
  688. }
  689. public override bool SetAlignDistance()
  690. {
  691. int distance200 = SC.GetValue<int>("EFEM.Aligner1.Aligner200Distance");
  692. int distance150 = SC.GetValue<int>("EFEM.Aligner1.Aligner150Distance");
  693. int distance100 = SC.GetValue<int>("EFEM.Aligner1.Aligner100Distance");
  694. if (_status == RState.Running && _currentMessage != null)
  695. {
  696. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
  697. return false;
  698. }
  699. if (!CheckEfemStatus())
  700. return false;
  701. //判断socket是否链接
  702. if (!_socket.IsConnected)
  703. {
  704. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  705. return false;
  706. }
  707. if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  708. {
  709. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
  710. return false;
  711. }
  712. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
  713. if (waferSize == 0)
  714. {
  715. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
  716. return false;
  717. }
  718. _currentMessage = new EfemMessage()
  719. {
  720. Operation = EfemOperation.AlignDistance
  721. };
  722. int distance = distance200;
  723. if (waferSize == (int)WaferSize.WS6)
  724. {
  725. distance = distance150;
  726. }
  727. else if (waferSize == (int)WaferSize.WS4)
  728. {
  729. distance = distance100;
  730. }
  731. string cmd = $"SET ALIGNER WAFERDISTANCE {distance}\r";
  732. _status = RState.Running;
  733. return WriteCommand(cmd);
  734. }
  735. public override bool SetAlignAngle(ModuleName mod, double angle)
  736. {
  737. if (_status == RState.Running && _currentMessage != null)
  738. {
  739. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Angle");
  740. return false;
  741. }
  742. if (!CheckEfemStatus())
  743. return false;
  744. //判断socket是否链接
  745. if (!_socket.IsConnected)
  746. {
  747. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  748. return false;
  749. }
  750. _currentMessage = new EfemMessage()
  751. {
  752. Operation = EfemOperation.Align,
  753. };
  754. string cmd = $"SET ALIGNER POSTPOS 1 POS {angle*1000}\r";
  755. _status = RState.Running;
  756. return WriteCommand(cmd);
  757. }
  758. public override bool SetRobotSpeed(ModuleName mod, int speed)
  759. {
  760. if (_status == RState.Running && _currentMessage != null)
  761. {
  762. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Speed");
  763. return false;
  764. }
  765. //判断socket是否链接
  766. if (!_socket.IsConnected)
  767. {
  768. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  769. return false;
  770. }
  771. _currentMessage = new EfemMessage()
  772. {
  773. Operation = EfemOperation.Speed
  774. };
  775. string cmd = $"SET ACTION SPEEDS {speed}\r";
  776. _status = RState.Running;
  777. return WriteCommand(cmd);
  778. }
  779. public override bool RobotPowerOn(ModuleName mod, bool Status)
  780. {
  781. if (_status == RState.Running && _currentMessage != null)
  782. {
  783. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot PowerOn");
  784. return false;
  785. }
  786. //判断socket是否链接
  787. if (!_socket.IsConnected)
  788. {
  789. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  790. return false;
  791. }
  792. string status = Status? "ON":"OFF";
  793. _currentMessage = new EfemMessage()
  794. {
  795. Operation = EfemOperation.PowerOn
  796. };
  797. string cmd = $"SET SERVOS {status}\r";
  798. _status = RState.Running;
  799. return WriteCommand(cmd);
  800. }
  801. public override bool Align(ModuleName mod, double angle, float delayTime, WaferSize size)
  802. {
  803. if (_status == RState.Running && _currentMessage != null)
  804. {
  805. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align");
  806. return false;
  807. }
  808. //判断socket是否链接
  809. if (!_socket.IsConnected)
  810. {
  811. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  812. return false;
  813. }
  814. if (!CheckEfemStatus())
  815. return false;
  816. _currentMessage = new EfemMessage()
  817. {
  818. Operation = EfemOperation.Align
  819. };
  820. _status = RState.Running;
  821. string cmd = "ALIGNER ALGN\r";
  822. return WriteCommand(cmd);
  823. }
  824. public override bool SetLamp(LightType light, LightStatus status)
  825. {
  826. return false;
  827. }
  828. public override bool Load(ModuleName mod)
  829. {
  830. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Load");
  831. return false;
  832. }
  833. public override bool Unload(ModuleName mod)
  834. {
  835. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unload");
  836. return false;
  837. }
  838. public override bool ReadCarrierId(ModuleName mod)
  839. {
  840. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support ReadCarrierId");
  841. return false;
  842. }
  843. public override bool WriteCarrierId(ModuleName mod, string id)
  844. {
  845. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support WriteCarrierId");
  846. return false;
  847. }
  848. public override bool ReadTagData(ModuleName mod)
  849. {
  850. return ReadCarrierId(mod);
  851. }
  852. public override bool WriteTagData(ModuleName mod, string tagData)
  853. {
  854. return WriteCarrierId(mod, tagData);
  855. }
  856. public override bool Dock(ModuleName mod)
  857. {
  858. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Dock");
  859. return false;
  860. }
  861. public override bool Undock(ModuleName mod)
  862. {
  863. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Undock");
  864. return false;
  865. }
  866. public override bool Clamp(ModuleName mod, bool isUnloadClamp)
  867. {
  868. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Clamp");
  869. return false;
  870. }
  871. public override bool Unclamp(ModuleName mod)
  872. {
  873. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unclamp");
  874. return false;
  875. }
  876. public override bool SetThickness(ModuleName mod, string thickness)
  877. {
  878. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.SetThickness]}");
  879. return false;
  880. }
  881. public override void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
  882. {
  883. blockingCollection.Add(new RobotAnimationData(action, hand, target));
  884. }
  885. private void OnReceiveMessage(string msg)
  886. {
  887. LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), msg.Replace("\r",""));
  888. if (_currentMessage == null)
  889. {
  890. return;
  891. }
  892. if(msg.Contains("_ERR"))
  893. {
  894. string error = msg.Replace("_ERR", "").Trim();
  895. OnErrorOccurred(error);
  896. _currentMessage = null;
  897. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EFEM);
  898. return;
  899. }
  900. else if (msg.StartsWith("ACTION_RDY"))
  901. {
  902. _status = RState.End;
  903. IsResumeRDYReceived = false;
  904. }
  905. else if (msg.Contains("_RDY"))
  906. {
  907. _status = RState.End;
  908. switch (_currentMessage.Operation)
  909. {
  910. case EfemOperation.Home:
  911. SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
  912. break;
  913. case EfemOperation.Map:
  914. case EfemOperation.GotoMap:
  915. if (ModuleHelper.IsLoadPort(_currentMessage.Module))
  916. {
  917. GetLoadPort(_currentMessage.Module).OnMaped();
  918. }
  919. break;
  920. case EfemOperation.Pick:
  921. case EfemOperation.Place:
  922. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
  923. break;
  924. case EfemOperation.Pause:
  925. //SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
  926. break;
  927. case EfemOperation.Resume:
  928. _status = RState.Running; //开始执行恢复动作
  929. IsResumeRDYReceived = true;
  930. break;
  931. }
  932. }
  933. else
  934. {
  935. switch (_currentMessage.Operation)
  936. {
  937. case EfemOperation.StateTrack:
  938. DealStateTrack(msg);
  939. break;
  940. case EfemOperation.RequestMapResult:
  941. DealMapResult(msg);
  942. break;
  943. }
  944. _status = RState.End;
  945. _currentMessage = null;
  946. }
  947. }
  948. /// <summary>
  949. /// 处理StateTrack结果
  950. /// </summary>
  951. /// <param name="msg"></param>
  952. private void DealStateTrack(string msg)
  953. {
  954. if (msg.StartsWith("LOAD"))
  955. {
  956. string[] strAry = msg.Trim().Split(' ');
  957. if (strAry.Length >= 2)
  958. {
  959. bool hasWafer = strAry[2] == "ON" ? true : false;
  960. if (strAry[1] == _armString[Hand.Blade1])
  961. {
  962. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0)&& hasWafer)
  963. {
  964. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 0, WaferStatus.Normal);
  965. }
  966. }
  967. else if (strAry[1] == _armString[Hand.Blade2])
  968. {
  969. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1) && hasWafer)
  970. {
  971. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 1, WaferStatus.Normal);
  972. }
  973. }
  974. }
  975. }
  976. }
  977. /// <summary>
  978. /// 处理Map结果
  979. /// </summary>
  980. /// <param name="msg"></param>
  981. private void DealMapResult(string msg)
  982. {
  983. if (_currentMessage.Operation != EfemOperation.RequestMapResult)
  984. {
  985. return;
  986. }
  987. if(!msg.StartsWith("MAP"))
  988. {
  989. return;
  990. }
  991. string[] sWaferInfo = msg.Split(new char[] { ' ', '\r', '\n' });
  992. if (sWaferInfo.Length <= 2)
  993. {
  994. return;
  995. }
  996. int slotMap = SC.GetValue<int>("EFEM.LoadPort.SlotNumber");
  997. WaferType waferType = WaferType.Production;
  998. if (ModuleHelper.IsDummy(_currentMessage.Module))
  999. {
  1000. DummyCassetteItem item = DummyCasseteItemManager.Instance.GetDummyCassetteItem(_currentMessage.Module.ToString());
  1001. if (item != null)
  1002. {
  1003. slotMap = item.MaxNumberOfSlots;
  1004. }
  1005. waferType = WaferType.Assit;
  1006. }
  1007. int waferSize = GetModuleNameWaferSize(_currentMessage.Module);
  1008. //Map 结果(1 1 1 1 1 1 1 ...0)
  1009. int startIndex = 1;
  1010. int count = slotMap >= sWaferInfo.Length-startIndex? sWaferInfo.Length-startIndex : slotMap;
  1011. bool result = true;
  1012. for (int index = startIndex; index <= count; index++)
  1013. {
  1014. string strState = sWaferInfo[index];
  1015. int waferState = 0;
  1016. //合理的映射到内部支持的叠片/交叉片
  1017. if (strState == "1") waferState = (int)WaferStatus.Normal;
  1018. else if (strState == "2") waferState = (int)WaferStatus.Double;
  1019. else if (strState == "3") waferState = (int)WaferStatus.Crossed;
  1020. else if (strState == "5") waferState = (int)WaferStatus.Thin;
  1021. else if(strState=="?") waferState=(int)WaferStatus.Unknown;
  1022. WaferStatus st = (WaferStatus)waferState;
  1023. if (st != WaferStatus.Empty)
  1024. {
  1025. WaferManager.Instance.CreateWafer(_currentMessage.Module, index-startIndex, st,(WaferSize)waferSize,waferType);
  1026. if (st != WaferStatus.Normal)
  1027. {
  1028. result = false;
  1029. }
  1030. }
  1031. else
  1032. {
  1033. WaferManager.Instance.DeleteWafer(_currentMessage.Module, index-startIndex);
  1034. }
  1035. }
  1036. if (!result)
  1037. {
  1038. LOG.WriteLog(eEvent.ERROR_EFEM_ERROR_WAFER, Module.ToString(), $"{_currentMessage.Module} slot map failed {msg}");
  1039. }
  1040. if (ModuleHelper.IsLoadPort(_currentMessage.Module))
  1041. {
  1042. GetLoadPort(_currentMessage.Module).UpdateMapResult(result);
  1043. }
  1044. }
  1045. private void OnErrorOccurred(string errorCode)
  1046. {
  1047. _status = RState.Failed;
  1048. string description = errorCode;
  1049. if (SumWayRobotErrorCode.ErrorCodeDescription.ContainsKey(errorCode))
  1050. {
  1051. description=SumWayRobotErrorCode.ErrorCodeDescription[errorCode];
  1052. }
  1053. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, description);
  1054. if (_currentMessage != null)
  1055. {
  1056. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, $"current operation {_currentMessage.Operation} failed,{description}");
  1057. }
  1058. _currentMessage=null;
  1059. }
  1060. private bool WriteCommand(string cmd)
  1061. {
  1062. LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), cmd.Replace("\r", ""));
  1063. return _socket.Write(cmd);
  1064. }
  1065. /// <summary>
  1066. /// 获取模块Wafer尺寸
  1067. /// </summary>
  1068. /// <param name="moduleName"></param>
  1069. /// <returns></returns>
  1070. private int GetModuleNameWaferSize(ModuleName moduleName)
  1071. {
  1072. if (ModuleHelper.IsLoadPort(moduleName))
  1073. {
  1074. Loadport loadport = GetLoadPort(moduleName);
  1075. if (!loadport.HasCassette)
  1076. {
  1077. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
  1078. return 0;
  1079. }
  1080. return (int)loadport.WaferSize;
  1081. }
  1082. else if (ModuleHelper.IsDummy(moduleName))
  1083. {
  1084. DummyDevice dummyDevice = Singleton<RouteManager>.Instance.EFEM.GetDummyDevice(moduleName - ModuleName.Dummy1);
  1085. if (!dummyDevice.HasCassette)
  1086. {
  1087. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
  1088. return 0;
  1089. }
  1090. return (int)dummyDevice.WaferSize;
  1091. }
  1092. return 0;
  1093. }
  1094. /// <summary>
  1095. /// 获取模块尺寸
  1096. /// </summary>
  1097. /// <param name="moduleName"></param>
  1098. /// <returns></returns>
  1099. private int GetModuleSlotWaferSize(ModuleName moduleName,int slotNumber)
  1100. {
  1101. if(WaferManager.Instance.CheckHasWafer(moduleName,slotNumber))
  1102. {
  1103. WaferInfo waferInfo=WaferManager.Instance.GetWafer(moduleName, slotNumber);
  1104. return (int)waferInfo.Size;
  1105. }
  1106. else
  1107. {
  1108. return 0;
  1109. }
  1110. }
  1111. }
  1112. }