SunWayRobot.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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.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, Flip flip)
  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 strFlip = flip == Flip.Flip ? " Flip" : "";
  389. string cmd = $"PICK {stationNumber} SLOT {slot+1} ARM {_armString[hand]}{strFlip}\r";
  390. if(ModuleHelper.IsPUF(station)||ModuleHelper.IsAligner(station)||ModuleHelper.IsSRD(station))
  391. {
  392. cmd = $"PICK {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
  393. }
  394. _currentMessage = new EfemMessage()
  395. {
  396. Operation=EfemOperation.Pick
  397. };
  398. _status = RState.Running;
  399. SetRobotMovingInfo(RobotAction.Picking, hand, station);
  400. return WriteCommand(cmd);
  401. }
  402. private Loadport GetLoadPort(ModuleName station)
  403. {
  404. LoadPortModule loadPortModule = Singleton<RouteManager>.Instance.EFEM.GetLoadportModule(station - ModuleName.LP1);
  405. return loadPortModule.LPDevice;
  406. }
  407. public override bool Place(ModuleName station, int slot, Hand hand,Flip flip)
  408. {
  409. if (_status == RState.Running && _currentMessage != null)
  410. {
  411. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot place");
  412. return false;
  413. }
  414. //判断socket是否链接
  415. if (!_socket.IsConnected)
  416. {
  417. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  418. return false;
  419. }
  420. //判断Loadport的门是否打开
  421. //if (ModuleHelper.IsLoadPort(station) && !GetLoadPort(station).IsDoorOpened)
  422. //{
  423. // LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station}'s Door is Closed, Cannot Execute Pick Action");
  424. // return false;
  425. //}
  426. if (!CheckEfemStatus())
  427. return false;
  428. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, (int)hand);
  429. if (waferSize == 0)
  430. {
  431. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{station} slot {slot} wafer size is 0, Cannot Execute Place Action");
  432. return false;
  433. }
  434. string strModuleWaferSize = $"{station}_{waferSize}";
  435. _currentMessage = new EfemMessage()
  436. {
  437. Operation = EfemOperation.Place
  438. };
  439. _status = RState.Running;
  440. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  441. string strFlip = flip == Flip.Flip ? " Flip" : "";
  442. string cmd = $"PLACE {stationNumber} SLOT {slot+1} ARM {_armString[hand]}{strFlip}\r";
  443. if (ModuleHelper.IsPUF(station)||ModuleHelper.IsSRD(station))
  444. {
  445. cmd = $"PLACE {stationNumber} SLOT 1 ARM {_armString[hand]}\r";
  446. }
  447. if (ModuleHelper.IsAligner(station))
  448. {
  449. cmd = $"PLACE {stationNumber} PHOME\r";
  450. }
  451. SetRobotMovingInfo(RobotAction.Placing, hand, station);
  452. return WriteCommand(cmd);
  453. }
  454. public override bool Goto(ModuleName station, Hand hand, string updown = "UP")
  455. {
  456. if (_status == RState.Running && _currentMessage != null)
  457. {
  458. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto");
  459. return false;
  460. }
  461. if (!CheckEfemStatus())
  462. return false;
  463. //判断socket是否链接
  464. if (!_socket.IsConnected)
  465. {
  466. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  467. return false;
  468. }
  469. _currentMessage = new EfemMessage()
  470. {
  471. Operation = EfemOperation.Goto
  472. };
  473. int waferSize = GetModuleNameWaferSize(station);
  474. if (waferSize == 0)
  475. {
  476. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  477. return false;
  478. }
  479. string strModuleWaferSize = $"{station}_{waferSize}";
  480. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  481. string cmd = $"GOTO N {stationNumber} R EX Z {updown} ARM SLOT 1 {_armString[hand]}\r";
  482. _status = RState.Running;
  483. return WriteCommand(cmd);
  484. }
  485. public override bool Grip(Hand blade, bool isGrip)
  486. {
  487. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Grip]}");
  488. return false;
  489. }
  490. public override bool GotoMap(ModuleName mod,Hand hand,string extend="EX")
  491. {
  492. if (_status == RState.Running && _currentMessage != null)
  493. {
  494. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot goto map");
  495. return false;
  496. }
  497. //判断socket是否链接
  498. if (!_socket.IsConnected)
  499. {
  500. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  501. return false;
  502. }
  503. if (!CheckEfemStatus())
  504. return false;
  505. int waferSize = GetModuleNameWaferSize(mod);
  506. if (waferSize == 0)
  507. {
  508. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  509. return false;
  510. }
  511. string strModuleWaferSize = $"{mod}_{waferSize}";
  512. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  513. string cmd = $"GOTO N {stationNumber} MAP {extend} ARM {_armString[hand]}\r";
  514. _currentMessage = new EfemMessage()
  515. {
  516. Operation = EfemOperation.Goto,
  517. Module= mod
  518. };
  519. _status = RState.Running;
  520. return WriteCommand(cmd);
  521. }
  522. public override bool Map(ModuleName mod)
  523. {
  524. if (_status == RState.Running && _currentMessage != null)
  525. {
  526. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot map");
  527. return false;
  528. }
  529. //判断socket是否链接
  530. if (!_socket.IsConnected)
  531. {
  532. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  533. return false;
  534. }
  535. if (!CheckEfemStatus())
  536. return false;
  537. int waferSize = GetModuleNameWaferSize(mod);
  538. if (waferSize == 0)
  539. {
  540. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  541. return false;
  542. }
  543. string strModuleWaferSize = $"{mod}_{waferSize}";
  544. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  545. _currentMessage = new EfemMessage()
  546. {
  547. Operation = EfemOperation.Map,
  548. Module = mod
  549. };
  550. string cmd = $"MAP {stationNumber} ARM {_armString[Hand.Blade1]}\r";
  551. _status = RState.Running;
  552. return WriteCommand(cmd);
  553. }
  554. public override bool RequestMapResult(ModuleName mod)
  555. {
  556. if (_status == RState.Running && _currentMessage != null)
  557. {
  558. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot request map");
  559. return false;
  560. }
  561. //判断socket是否链接
  562. if (!_socket.IsConnected)
  563. {
  564. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  565. return false;
  566. }
  567. if (!CheckEfemStatus())
  568. return false;
  569. int waferSize = GetModuleNameWaferSize(mod);
  570. if (waferSize == 0)
  571. {
  572. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"wafersize is 0");
  573. return false;
  574. }
  575. string strModuleWaferSize = $"{mod}_{waferSize}";
  576. int stationNumber = _moduleStationNumberDictionary[strModuleWaferSize];
  577. _currentMessage = new EfemMessage()
  578. {
  579. Operation = EfemOperation.RequestMapResult,
  580. Module = mod
  581. };
  582. string cmd = $"RSR {stationNumber} ARM {_armString[Hand.Blade1]}\r";
  583. _status = RState.Running;
  584. return WriteCommand(cmd);
  585. }
  586. public override bool Vacuum(ModuleName mod,bool VacuumState)
  587. {
  588. if (_status == RState.Running && _currentMessage != null)
  589. {
  590. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot vacuum");
  591. return false;
  592. }
  593. //判断socket是否链接
  594. if (!_socket.IsConnected)
  595. {
  596. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  597. return false;
  598. }
  599. _currentMessage = new EfemMessage()
  600. {
  601. Operation = EfemOperation.Vacuum,
  602. Module = mod
  603. };
  604. _status = RState.Running;
  605. string strVacuum = VacuumState ? "ON" : "OFF";
  606. string cmd = "";
  607. if (ModuleName.Aligner1 == mod)
  608. {
  609. cmd = $"ALIGNER VAC {strVacuum}\r";
  610. }
  611. else
  612. {
  613. cmd = $"VAC {strVacuum} ARM {_armString[Hand.Blade1]}\r";
  614. }
  615. return WriteCommand(cmd);
  616. }
  617. public override bool GetWaferSize(ModuleName mod)
  618. {
  619. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support GetWaferSize");
  620. return false;
  621. }
  622. public override bool SetWaferSize(ModuleName mod, int WaferSize)
  623. {
  624. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support SetWaferSize");
  625. return false;
  626. }
  627. public override bool SetPinUp(ModuleName mod)
  628. {
  629. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.Lift]}");
  630. return false;
  631. }
  632. public override bool SetPinDown(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 SetAlignWaferSize()
  638. {
  639. if (_status == RState.Running && _currentMessage != null)
  640. {
  641. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Wafer Size");
  642. return false;
  643. }
  644. if (!CheckEfemStatus())
  645. return false;
  646. if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  647. {
  648. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
  649. return false;
  650. }
  651. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
  652. if (waferSize == 0)
  653. {
  654. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
  655. return false;
  656. }
  657. //判断socket是否链接
  658. if (!_socket.IsConnected)
  659. {
  660. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  661. return false;
  662. }
  663. _currentMessage = new EfemMessage()
  664. {
  665. Operation = EfemOperation.AlignWaferSize
  666. };
  667. string cmd = $"SET ALIGNER WAFERSIZE {waferSize}\r";
  668. _status = RState.Running;
  669. return WriteCommand(cmd);
  670. }
  671. public override bool SetAlignFlatType(int flatType)
  672. {
  673. if (_status == RState.Running && _currentMessage != null)
  674. {
  675. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
  676. return false;
  677. }
  678. if (!CheckEfemStatus())
  679. return false;
  680. //判断socket是否链接
  681. if (!_socket.IsConnected)
  682. {
  683. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  684. return false;
  685. }
  686. _currentMessage = new EfemMessage()
  687. {
  688. Operation = EfemOperation.AlignFlatType
  689. };
  690. string cmd = $"SET ALIGNER WAFERTYPE {flatType}\r";
  691. _status = RState.Running;
  692. return WriteCommand(cmd);
  693. }
  694. public override bool SetAlignDistance()
  695. {
  696. int distance200 = SC.GetValue<int>("EFEM.Aligner1.Aligner200Distance");
  697. int distance150 = SC.GetValue<int>("EFEM.Aligner1.Aligner150Distance");
  698. int distance100 = SC.GetValue<int>("EFEM.Aligner1.Aligner100Distance");
  699. if (_status == RState.Running && _currentMessage != null)
  700. {
  701. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align flat type");
  702. return false;
  703. }
  704. if (!CheckEfemStatus())
  705. return false;
  706. //判断socket是否链接
  707. if (!_socket.IsConnected)
  708. {
  709. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  710. return false;
  711. }
  712. if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
  713. {
  714. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} has no wafer, Cannot Execute Set aligner wafersize");
  715. return false;
  716. }
  717. int waferSize = GetModuleSlotWaferSize(ModuleName.EfemRobot, 0);
  718. if (waferSize == 0)
  719. {
  720. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{ModuleName.EfemRobot} wafer size is 0, Cannot Execute Set aligner wafersize");
  721. return false;
  722. }
  723. _currentMessage = new EfemMessage()
  724. {
  725. Operation = EfemOperation.AlignDistance
  726. };
  727. int distance = distance200;
  728. if (waferSize == (int)WaferSize.WS6)
  729. {
  730. distance = distance150;
  731. }
  732. else if (waferSize == (int)WaferSize.WS4)
  733. {
  734. distance = distance100;
  735. }
  736. string cmd = $"SET ALIGNER WAFERDISTANCE {distance}\r";
  737. _status = RState.Running;
  738. return WriteCommand(cmd);
  739. }
  740. public override bool SetAlignAngle(ModuleName mod, double angle)
  741. {
  742. if (_status == RState.Running && _currentMessage != null)
  743. {
  744. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align Angle");
  745. return false;
  746. }
  747. if (!CheckEfemStatus())
  748. return false;
  749. //判断socket是否链接
  750. if (!_socket.IsConnected)
  751. {
  752. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  753. return false;
  754. }
  755. _currentMessage = new EfemMessage()
  756. {
  757. Operation = EfemOperation.Align,
  758. };
  759. string cmd = $"SET ALIGNER POSTPOS 1 POS {angle*1000}\r";
  760. _status = RState.Running;
  761. return WriteCommand(cmd);
  762. }
  763. public override bool SetRobotSpeed(ModuleName mod, int speed)
  764. {
  765. if (_status == RState.Running && _currentMessage != null)
  766. {
  767. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Speed");
  768. return false;
  769. }
  770. //判断socket是否链接
  771. if (!_socket.IsConnected)
  772. {
  773. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  774. return false;
  775. }
  776. _currentMessage = new EfemMessage()
  777. {
  778. Operation = EfemOperation.Speed
  779. };
  780. string cmd = $"SET ACTION SPEEDS {speed}\r";
  781. _status = RState.Running;
  782. return WriteCommand(cmd);
  783. }
  784. public override bool RobotPowerOn(ModuleName mod, bool Status)
  785. {
  786. if (_status == RState.Running && _currentMessage != null)
  787. {
  788. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot PowerOn");
  789. return false;
  790. }
  791. //判断socket是否链接
  792. if (!_socket.IsConnected)
  793. {
  794. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  795. return false;
  796. }
  797. string status = Status? "ON":"OFF";
  798. _currentMessage = new EfemMessage()
  799. {
  800. Operation = EfemOperation.PowerOn
  801. };
  802. string cmd = $"SET SERVOS {status}\r";
  803. _status = RState.Running;
  804. return WriteCommand(cmd);
  805. }
  806. public override bool Align(ModuleName mod, double angle, float delayTime, WaferSize size)
  807. {
  808. if (_status == RState.Running && _currentMessage != null)
  809. {
  810. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"Current Msg {_currentMessage.Operation} is Running,cannot Align");
  811. return false;
  812. }
  813. //判断socket是否链接
  814. if (!_socket.IsConnected)
  815. {
  816. LOG.WriteLog(eEvent.ERROR_EFEM_COMMUNICATION, Module.ToString(), $"Socket is not Conntected");
  817. return false;
  818. }
  819. if (!CheckEfemStatus())
  820. return false;
  821. _currentMessage = new EfemMessage()
  822. {
  823. Operation = EfemOperation.Align
  824. };
  825. _status = RState.Running;
  826. string cmd = "ALIGNER ALGN\r";
  827. return WriteCommand(cmd);
  828. }
  829. public override bool SetLamp(LightType light, LightStatus status)
  830. {
  831. return false;
  832. }
  833. public override bool Load(ModuleName mod)
  834. {
  835. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Load");
  836. return false;
  837. }
  838. public override bool Unload(ModuleName mod)
  839. {
  840. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unload");
  841. return false;
  842. }
  843. public override bool ReadCarrierId(ModuleName mod)
  844. {
  845. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support ReadCarrierId");
  846. return false;
  847. }
  848. public override bool WriteCarrierId(ModuleName mod, string id)
  849. {
  850. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support WriteCarrierId");
  851. return false;
  852. }
  853. public override bool ReadTagData(ModuleName mod)
  854. {
  855. return ReadCarrierId(mod);
  856. }
  857. public override bool WriteTagData(ModuleName mod, string tagData)
  858. {
  859. return WriteCarrierId(mod, tagData);
  860. }
  861. public override bool Dock(ModuleName mod)
  862. {
  863. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Dock");
  864. return false;
  865. }
  866. public override bool Undock(ModuleName mod)
  867. {
  868. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Undock");
  869. return false;
  870. }
  871. public override bool Clamp(ModuleName mod, bool isUnloadClamp)
  872. {
  873. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Clamp");
  874. return false;
  875. }
  876. public override bool Unclamp(ModuleName mod)
  877. {
  878. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support Unclamp");
  879. return false;
  880. }
  881. public override bool SetThickness(ModuleName mod, string thickness)
  882. {
  883. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"System cannot support {EfemConstant.OperationString[EfemOperation.SetThickness]}");
  884. return false;
  885. }
  886. public override void SetRobotMovingInfo(RobotAction action, Hand hand, ModuleName target)
  887. {
  888. blockingCollection.Add(new RobotAnimationData(action, hand, target));
  889. }
  890. private void OnReceiveMessage(string msg)
  891. {
  892. LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), msg.Replace("\r",""));
  893. if (_currentMessage == null)
  894. {
  895. return;
  896. }
  897. if(msg.Contains("_ERR"))
  898. {
  899. string error = msg.Replace("_ERR", "").Trim();
  900. OnErrorOccurred(error);
  901. _currentMessage = null;
  902. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EFEM);
  903. return;
  904. }
  905. else if (msg.StartsWith("ACTION_RDY"))
  906. {
  907. _status = RState.End;
  908. IsResumeRDYReceived = false;
  909. IsPauseRDYReceived = false;
  910. IsActionRDYReceived = true;
  911. }
  912. else if (msg.StartsWith("_RDY"))
  913. {
  914. _status = RState.End;
  915. switch (_currentMessage.Operation)
  916. {
  917. case EfemOperation.Home:
  918. SetRobotMovingInfo(RobotAction.Homing, Hand.Both, ModuleName.EFEM);
  919. break;
  920. case EfemOperation.Map:
  921. case EfemOperation.GotoMap:
  922. if (ModuleHelper.IsLoadPort(_currentMessage.Module))
  923. {
  924. GetLoadPort(_currentMessage.Module).OnMaped();
  925. }
  926. break;
  927. case EfemOperation.Pick:
  928. case EfemOperation.Place:
  929. SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
  930. break;
  931. }
  932. }
  933. else if (msg.Contains("PAUSE_RDY") || msg.Contains("RESUME_RDY"))
  934. {
  935. switch (_currentMessage.Operation)
  936. {
  937. case EfemOperation.Pause:
  938. //SetRobotMovingInfo(RobotAction.None, Hand.Both, ModuleName.EfemRobot);
  939. IsPauseRDYReceived = true;
  940. break;
  941. case EfemOperation.Resume:
  942. IsResumeRDYReceived = true;
  943. break;
  944. }
  945. }
  946. else
  947. {
  948. switch (_currentMessage.Operation)
  949. {
  950. case EfemOperation.StateTrack:
  951. DealStateTrack(msg);
  952. break;
  953. case EfemOperation.RequestMapResult:
  954. DealMapResult(msg);
  955. break;
  956. }
  957. _status = RState.End;
  958. _currentMessage = null;
  959. }
  960. }
  961. /// <summary>
  962. /// 处理StateTrack结果
  963. /// </summary>
  964. /// <param name="msg"></param>
  965. private void DealStateTrack(string msg)
  966. {
  967. if (msg.StartsWith("LOAD"))
  968. {
  969. string[] strAry = msg.Trim().Split(' ');
  970. if (strAry.Length >= 2)
  971. {
  972. bool hasWafer = strAry[2] == "ON" ? true : false;
  973. if (strAry[1] == _armString[Hand.Blade1])
  974. {
  975. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0)&& hasWafer)
  976. {
  977. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 0, WaferStatus.Normal);
  978. }
  979. }
  980. else if (strAry[1] == _armString[Hand.Blade2])
  981. {
  982. if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1) && hasWafer)
  983. {
  984. WaferManager.Instance.CreateWafer(ModuleName.EfemRobot, 1, WaferStatus.Normal);
  985. }
  986. }
  987. }
  988. }
  989. }
  990. /// <summary>
  991. /// 处理Map结果
  992. /// </summary>
  993. /// <param name="msg"></param>
  994. private void DealMapResult(string msg)
  995. {
  996. if (_currentMessage.Operation != EfemOperation.RequestMapResult)
  997. {
  998. return;
  999. }
  1000. if(!msg.StartsWith("MAP"))
  1001. {
  1002. return;
  1003. }
  1004. string[] sWaferInfo = msg.Split(new char[] { ' ', '\r', '\n' });
  1005. if (sWaferInfo.Length <= 2)
  1006. {
  1007. return;
  1008. }
  1009. int slotMap = SC.GetValue<int>("EFEM.LoadPort.SlotNumber");
  1010. WaferType waferType = WaferType.Production;
  1011. if (ModuleHelper.IsDummy(_currentMessage.Module))
  1012. {
  1013. DummyCassetteItem item = DummyCasseteItemManager.Instance.GetDummyCassetteItem(_currentMessage.Module.ToString());
  1014. if (item != null)
  1015. {
  1016. slotMap = item.MaxNumberOfSlots;
  1017. }
  1018. waferType = WaferType.Assit;
  1019. }
  1020. int waferSize = GetModuleNameWaferSize(_currentMessage.Module);
  1021. //Map 结果(1 1 1 1 1 1 1 ...0)
  1022. int startIndex = 1;
  1023. int count = slotMap >= sWaferInfo.Length-startIndex? sWaferInfo.Length-startIndex : slotMap;
  1024. bool result = true;
  1025. for (int index = startIndex; index <= count; index++)
  1026. {
  1027. string strState = sWaferInfo[index];
  1028. int waferState = 0;
  1029. //合理的映射到内部支持的叠片/交叉片
  1030. if (strState == "1") waferState = (int)WaferStatus.Normal;
  1031. else if (strState == "2") waferState = (int)WaferStatus.Double;
  1032. else if (strState == "3") waferState = (int)WaferStatus.Crossed;
  1033. else if (strState == "5") waferState = (int)WaferStatus.Thin;
  1034. else if(strState=="?") waferState=(int)WaferStatus.Unknown;
  1035. WaferStatus st = (WaferStatus)waferState;
  1036. if (st != WaferStatus.Empty)
  1037. {
  1038. WaferManager.Instance.CreateWafer(_currentMessage.Module, index-startIndex, st,(WaferSize)waferSize,waferType);
  1039. if (st != WaferStatus.Normal)
  1040. {
  1041. result = false;
  1042. }
  1043. }
  1044. else
  1045. {
  1046. WaferManager.Instance.DeleteWafer(_currentMessage.Module, index-startIndex);
  1047. }
  1048. }
  1049. if (!result)
  1050. {
  1051. LOG.WriteLog(eEvent.ERROR_EFEM_ERROR_WAFER, Module.ToString(), $"{_currentMessage.Module} slot map failed {msg}");
  1052. }
  1053. if (ModuleHelper.IsLoadPort(_currentMessage.Module))
  1054. {
  1055. GetLoadPort(_currentMessage.Module).UpdateMapResult(result);
  1056. }
  1057. }
  1058. private void OnErrorOccurred(string errorCode)
  1059. {
  1060. _status = RState.Failed;
  1061. string description = errorCode;
  1062. if (SumWayRobotErrorCode.ErrorCodeDescription.ContainsKey(errorCode))
  1063. {
  1064. description=SumWayRobotErrorCode.ErrorCodeDescription[errorCode];
  1065. }
  1066. Singleton<RouteManager>.Instance.EFEM.PostMsg(EfemEntity.MSG.Error, description);
  1067. if (_currentMessage != null)
  1068. {
  1069. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, $"current operation {_currentMessage.Operation} failed,{description}");
  1070. }
  1071. _currentMessage=null;
  1072. }
  1073. private bool WriteCommand(string cmd)
  1074. {
  1075. LOG.WriteLog(eEvent.EV_EFEM_COMMON_INFO, Module.ToString(), cmd.Replace("\r", ""));
  1076. return _socket.Write(cmd);
  1077. }
  1078. /// <summary>
  1079. /// 获取模块Wafer尺寸
  1080. /// </summary>
  1081. /// <param name="moduleName"></param>
  1082. /// <returns></returns>
  1083. private int GetModuleNameWaferSize(ModuleName moduleName)
  1084. {
  1085. if (ModuleHelper.IsLoadPort(moduleName))
  1086. {
  1087. Loadport loadport = GetLoadPort(moduleName);
  1088. if (!loadport.HasCassette)
  1089. {
  1090. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
  1091. return 0;
  1092. }
  1093. return (int)loadport.WaferSize;
  1094. }
  1095. else if (ModuleHelper.IsDummy(moduleName))
  1096. {
  1097. DummyDevice dummyDevice = Singleton<RouteManager>.Instance.EFEM.GetDummyDevice(moduleName - ModuleName.Dummy1);
  1098. if (!dummyDevice.HasCassette)
  1099. {
  1100. LOG.WriteLog(eEvent.ERR_EFEM_COMMON_FAILED, Module.ToString(), $"{moduleName} does not have cassete.");
  1101. return 0;
  1102. }
  1103. return (int)dummyDevice.WaferSize;
  1104. }
  1105. return 0;
  1106. }
  1107. /// <summary>
  1108. /// 获取模块尺寸
  1109. /// </summary>
  1110. /// <param name="moduleName"></param>
  1111. /// <returns></returns>
  1112. private int GetModuleSlotWaferSize(ModuleName moduleName,int slotNumber)
  1113. {
  1114. if(WaferManager.Instance.CheckHasWafer(moduleName,slotNumber))
  1115. {
  1116. WaferInfo waferInfo=WaferManager.Instance.GetWafer(moduleName, slotNumber);
  1117. return (int)waferInfo.Size;
  1118. }
  1119. else
  1120. {
  1121. return 0;
  1122. }
  1123. }
  1124. }
  1125. }