SunWayRobot.cs 49 KB

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