SunWayRobot.cs 49 KB

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