SunWayRobot.cs 48 KB

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