SunWayRobot.cs 49 KB

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