SunWayRobot.cs 49 KB

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