SunWayRobot.cs 54 KB

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