SunWayRobot.cs 48 KB

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