SunWayRobot.cs 56 KB

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