RorzeEfemHandler.cs 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Sorter.Common;
  4. using MECF.Framework.Common.Communications;
  5. using MECF.Framework.Common.Device.Bases;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Threading.Tasks;
  11. using Aitex.Core.RT.Device;
  12. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
  13. {
  14. public abstract class RorzeEfemHandler : HandlerBase
  15. {
  16. public static Dictionary<string, ModuleName> ParameterModuleMap = new Dictionary<string, ModuleName>()
  17. {
  18. {"SYSTEM", ModuleName.System},
  19. {"System", ModuleName.System},
  20. {"ROB", ModuleName.EfemRobot},
  21. {"P1", ModuleName.LP1},
  22. {"P2", ModuleName.LP2},
  23. {"P3", ModuleName.LP3},
  24. {"P4", ModuleName.LP4},
  25. {"LLA", ModuleName.LL1},
  26. {"LLB", ModuleName.LL2},
  27. {"BF1", ModuleName.Buffer},
  28. {"ALIGN", ModuleName.Aligner},
  29. };
  30. public RorzeEfem Device { get; }
  31. public ModuleName Module
  32. {
  33. get { return _module; }
  34. }
  35. private ModuleName _module;
  36. private RorzeEfemMessageType _type;
  37. private RorzeEfemBasicMessage _basicMessage;
  38. private string _parameter;
  39. private bool _waitInfo;
  40. protected RorzeEfemHandler(RorzeEfem device, ModuleName module,
  41. RorzeEfemMessageType type, RorzeEfemBasicMessage basicMessage, string parameter, bool waitInfo)
  42. : base(BuildMessage(type, basicMessage, parameter))
  43. {
  44. Device = device;
  45. _module = module;
  46. _waitInfo = waitInfo;
  47. _basicMessage = basicMessage;
  48. _parameter = parameter;
  49. _type = type;
  50. }
  51. public static string BuildMessage(RorzeEfemMessageType type, RorzeEfemBasicMessage basicMessage, string parameter)
  52. {
  53. return string.IsNullOrEmpty(parameter) ? $"{type}:{basicMessage};\r" : $"{type}:{basicMessage}/{parameter};\r";
  54. }
  55. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  56. {
  57. transactionComplete = false;
  58. RorzeEfemMessage message = baseMessage as RorzeEfemMessage;
  59. if (!MatchMessage(message))
  60. return false;
  61. bool test = message.RawMessage.Contains("LIFT");
  62. if (message.MessageType == RorzeEfemMessageType.ACK)
  63. {
  64. OnAcked();
  65. if (!_waitInfo)
  66. {
  67. OnComplete();
  68. transactionComplete = true;
  69. }
  70. return true;
  71. }
  72. if (message.MessageType == RorzeEfemMessageType.INF)
  73. {
  74. transactionComplete = true;
  75. ProceedInfo(message);
  76. OnComplete();
  77. }
  78. if (message.MessageType == RorzeEfemMessageType.ABS)
  79. {
  80. transactionComplete = true;
  81. ProceedAbs(message);
  82. OnComplete();
  83. }
  84. if (message.MessageType == RorzeEfemMessageType.NAK)
  85. {
  86. transactionComplete = true;
  87. ProceedNak(message);
  88. OnComplete();
  89. }
  90. if (message.MessageType == RorzeEfemMessageType.CAN)
  91. {
  92. transactionComplete = true;
  93. ProceedCancel(message);
  94. OnComplete();
  95. }
  96. if(message.MessageType == RorzeEfemMessageType.EVT)
  97. {
  98. transactionComplete = true;
  99. ProceedEvent(message);
  100. }
  101. return true;
  102. }
  103. protected virtual void ProceedNak(RorzeEfemMessage message)
  104. {
  105. Device.NoteCancel(Module, $"Can not {Name}, " + RorzeEfemAbsError.GetError(message.NakFactor));
  106. }
  107. protected virtual void ProceedCancel(RorzeEfemMessage message)
  108. {
  109. Device.NoteCancel(Module, $"Can not {Name}, " + RorzeEfemAbsError.GetError(message.CanError));
  110. }
  111. protected virtual void ProceedAbs(RorzeEfemMessage message)
  112. {
  113. Device.NoteFailed(Module, $"Failed {Name}, " + RorzeEfemAbsError.GetError(message.AbsError));
  114. }
  115. protected virtual bool ProceedInfo(RorzeEfemMessage msg)
  116. {
  117. Device.NoteComplete(Module);
  118. return true;
  119. }
  120. protected virtual bool ProceedEvent(RorzeEfemMessage msg)
  121. {
  122. if (msg.IsEvent && ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  123. {
  124. if(msg.MessagePart[1] == "MAPDT")
  125. Device.NoteWaferMapResult(target, msg.MessagePart[3]);
  126. else
  127. Device.NoteStateEvent(target, msg.MessagePart[3], msg.MessagePart[4]);
  128. }
  129. return true;
  130. }
  131. protected bool MatchMessage(RorzeEfemMessage msg)
  132. {
  133. if (msg.BasicMessage != _basicMessage || !msg.Parameter.Contains(_parameter))
  134. return false;
  135. return true;
  136. }
  137. public static string ConvertModuleToParameter(ModuleName module)
  138. {
  139. if (ParameterModuleMap.Values.Contains(module))
  140. {
  141. foreach (var moduleName in ParameterModuleMap)
  142. {
  143. if (moduleName.Value == module)
  144. return moduleName.Key;
  145. }
  146. }
  147. return "";
  148. }
  149. public static bool ConvertParameterToModule(string parameter, out ModuleName module)
  150. {
  151. if (ParameterModuleMap.ContainsKey(parameter))
  152. {
  153. module = ParameterModuleMap[parameter];
  154. return true;
  155. }
  156. module = ModuleName.System;
  157. return false;
  158. }
  159. }
  160. //READY
  161. public class RorzeEfemHandlerReady : RorzeEfemHandler
  162. {
  163. public RorzeEfemHandlerReady(RorzeEfem device, ModuleName module)
  164. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.READY, ConvertModuleToParameter(module), true)
  165. {
  166. Name = $"Ready {module}";
  167. MutexId = -1;
  168. }
  169. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  170. {
  171. Device.NoteCommunicationReady();
  172. transactionComplete = true;
  173. return true;
  174. }
  175. }
  176. //INIT
  177. public class RorzeEfemHandlerInit : RorzeEfemHandler
  178. {
  179. public RorzeEfemHandlerInit(RorzeEfem device, ModuleName module)
  180. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.INIT, ConvertModuleToParameter(module), true)
  181. {
  182. Name = $"Initialize {module}";
  183. MutexId = (int)module;
  184. }
  185. protected override bool ProceedInfo(RorzeEfemMessage msg)
  186. {
  187. if (Module == ModuleName.System)
  188. Device.NoteInitialized();
  189. Device.NoteComplete(Module);
  190. return true;
  191. }
  192. }
  193. //ORGSH
  194. public class RorzeEfemHandlerOrgsh : RorzeEfemHandler
  195. {
  196. public RorzeEfemHandlerOrgsh(RorzeEfem device, ModuleName module)
  197. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ORGSH, ConvertModuleToParameter(module), true)
  198. {
  199. Name = $"Home {module}";
  200. MutexId = (int)module;
  201. }
  202. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  203. {
  204. return base.HandleMessage(baseMessage, out transactionComplete);
  205. }
  206. }
  207. //LOCK
  208. public class RorzeEfemHandlerLock : RorzeEfemHandler
  209. {
  210. public RorzeEfemHandlerLock(RorzeEfem device, ModuleName module)
  211. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.LOCK, ConvertModuleToParameter(module), true)
  212. {
  213. Name = RorzeEfemBasicMessage.LOCK.ToString();
  214. MutexId = (int)module;
  215. }
  216. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  217. {
  218. return base.HandleMessage(baseMessage, out transactionComplete);
  219. }
  220. }
  221. //UNLOCK
  222. public class RorzeEfemHandlerUnlock : RorzeEfemHandler
  223. {
  224. public RorzeEfemHandlerUnlock(RorzeEfem device, ModuleName module)
  225. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNLOCK, ConvertModuleToParameter(module), true)
  226. {
  227. Name = RorzeEfemBasicMessage.UNLOCK.ToString();
  228. MutexId = (int)module;
  229. }
  230. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  231. {
  232. return base.HandleMessage(baseMessage, out transactionComplete);
  233. }
  234. }
  235. //DOCK
  236. public class RorzeEfemHandlerDock : RorzeEfemHandler
  237. {
  238. public RorzeEfemHandlerDock(RorzeEfem device, ModuleName module)
  239. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.DOCK, ConvertModuleToParameter(module), true)
  240. {
  241. Name = RorzeEfemBasicMessage.DOCK.ToString();
  242. MutexId = (int)module;
  243. }
  244. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  245. {
  246. return base.HandleMessage(baseMessage, out transactionComplete);
  247. }
  248. }
  249. //UNDOCK
  250. public class RorzeEfemHandlerUndock : RorzeEfemHandler
  251. {
  252. public RorzeEfemHandlerUndock(RorzeEfem device, ModuleName module)
  253. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNDOCK, ConvertModuleToParameter(module), true)
  254. {
  255. Name = RorzeEfemBasicMessage.UNDOCK.ToString();
  256. MutexId = (int)module;
  257. }
  258. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  259. {
  260. return base.HandleMessage(baseMessage, out transactionComplete);
  261. }
  262. }
  263. //OPEN
  264. public class RorzeEfemHandlerOpen : RorzeEfemHandler
  265. {
  266. public RorzeEfemHandlerOpen(RorzeEfem device, ModuleName module)
  267. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.OPEN, ConvertModuleToParameter(module), true)
  268. {
  269. Name = RorzeEfemBasicMessage.OPEN.ToString();
  270. MutexId = (int)module;
  271. }
  272. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  273. {
  274. return base.HandleMessage(baseMessage, out transactionComplete);
  275. }
  276. }
  277. //CLOSE
  278. public class RorzeEfemHandlerClose : RorzeEfemHandler
  279. {
  280. public RorzeEfemHandlerClose(RorzeEfem device, ModuleName module)
  281. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.CLOSE, ConvertModuleToParameter(module), true)
  282. {
  283. Name = RorzeEfemBasicMessage.CLOSE.ToString();
  284. MutexId = (int)module;
  285. }
  286. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  287. {
  288. return base.HandleMessage(baseMessage, out transactionComplete);
  289. }
  290. }
  291. //WAFSH
  292. public class RorzeEfemHandlerWafsh : RorzeEfemHandler
  293. {
  294. public RorzeEfemHandlerWafsh(RorzeEfem device, ModuleName target, bool mapByRobot)
  295. : base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WAFSH, ConvertModuleToParameter(target), true)
  296. {
  297. Name = $"Map wafer of {target}";
  298. MutexId = mapByRobot ? (int)ModuleName.EfemRobot : (int)target;
  299. }
  300. public RorzeEfemHandlerWafsh(RorzeEfem device, ModuleName target, bool mapByRobot, int thicknessIndex)
  301. : base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WAFSH, BuildParameter(target, thicknessIndex), true)
  302. {
  303. Name = $"Map wafer of {target}";
  304. MutexId = mapByRobot ? (int)ModuleName.EfemRobot : (int)target;
  305. }
  306. public static string BuildParameter(ModuleName target, int thicknessIndex)
  307. {
  308. string para1 = ConvertModuleToParameter(target);
  309. return $"{para1}/{thicknessIndex}";
  310. }
  311. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  312. {
  313. return base.HandleMessage(baseMessage, out transactionComplete);
  314. }
  315. }
  316. //MAPDT
  317. public class RorzeEfemHandlerMapdt : RorzeEfemHandler
  318. {
  319. private ModuleName _target;
  320. public RorzeEfemHandlerMapdt(RorzeEfem device, ModuleName target, bool mapByRobot)
  321. : base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.MAPDT, ConvertModuleToParameter(target), true)
  322. {
  323. Name = $"Get wafer map result of {target}";
  324. _target = target;
  325. MutexId = mapByRobot ? (int)ModuleName.EfemRobot : (int)target;
  326. }
  327. protected override bool ProceedInfo(RorzeEfemMessage msg)
  328. {
  329. if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  330. {
  331. Device.NoteWaferMapResult(target, msg.MessagePart[3]);
  332. }
  333. if (!msg.IsEvent)
  334. {
  335. Device.NoteComplete(Module);
  336. }
  337. return true;
  338. }
  339. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  340. {
  341. return base.HandleMessage(baseMessage, out transactionComplete);
  342. }
  343. }
  344. //GOTO
  345. public class RorzeEfemHandlerGoto : RorzeEfemHandler
  346. {
  347. public RorzeEfemHandlerGoto(RorzeEfem device, ModuleName target, int slot, Hand blade, bool isPick)
  348. : base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.GOTO, BuildParameter(target, slot, blade, isPick), true)
  349. {
  350. Name = $"Goto from {target} slot {slot + 1}";
  351. MutexId = (int)ModuleName.EfemRobot;
  352. }
  353. public static string BuildParameter(ModuleName target, int slot, Hand blade, bool isPick)
  354. {
  355. string para1 = ConvertModuleToParameter(target);
  356. string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
  357. string para3 = isPick ? "DOWN":"UP";
  358. return $"{para1}{slot + 1:D2}/{para2}/{para3}";
  359. }
  360. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  361. {
  362. return base.HandleMessage(baseMessage, out transactionComplete);
  363. }
  364. }
  365. //LOAD
  366. public class RorzeEfemHandlerLoad : RorzeEfemHandler
  367. {
  368. public RorzeEfemHandlerLoad(RorzeEfem device, ModuleName target, int slot, Hand blade, WaferSize waferSize)
  369. : base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.LOAD, BuildParameter(target, slot, blade, waferSize), true)
  370. {
  371. Name = $"Pick from {target} slot {slot + 1}";
  372. MutexId = (int)ModuleName.EfemRobot;
  373. }
  374. public static string BuildParameter(ModuleName target, int slot, Hand blade, WaferSize waferSize)
  375. {
  376. string para1 = ConvertModuleToParameter(target);
  377. string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
  378. string para3 = waferSize.ToString();
  379. if (ModuleHelper.IsAligner(target)|| ModuleHelper.IsCooling(target))
  380. {
  381. return $"{para1}/{para2}/{para3}";
  382. }
  383. return $"{para1}{slot + 1:D2}/{para2}/{para3}";
  384. }
  385. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  386. {
  387. return base.HandleMessage(baseMessage, out transactionComplete);
  388. }
  389. }
  390. //UNLOAD
  391. public class RorzeEfemHandlerUnload : RorzeEfemHandler
  392. {
  393. public RorzeEfemHandlerUnload(RorzeEfem device, ModuleName target, int slot, Hand blade, WaferSize waferSize)
  394. : base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNLOAD, BuildParameter(target, slot, blade, waferSize), true)
  395. {
  396. Name = $"Place to {target} slot {slot + 1}";
  397. MutexId = (int)ModuleName.EfemRobot;
  398. }
  399. public static string BuildParameter(ModuleName target, int slot, Hand blade, WaferSize waferSize)
  400. {
  401. string para1 = ConvertModuleToParameter(target);
  402. string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
  403. string para3 = waferSize.ToString();
  404. if (ModuleHelper.IsAligner(target) || ModuleHelper.IsCooling(target))
  405. {
  406. return $"{para1}/{para2}/{para3}";
  407. }
  408. return $"{para1}{slot + 1:D2}/{para2}/{para3}";
  409. }
  410. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  411. {
  412. return base.HandleMessage(baseMessage, out transactionComplete);
  413. }
  414. }
  415. //Grip
  416. public class RorzeEfemHandlerGrip : RorzeEfemHandler
  417. {
  418. public RorzeEfemHandlerGrip(RorzeEfem device, Hand blade, bool isGrip)
  419. : base(device, ModuleName.EfemRobot, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.CLAMP, BuildParameter(blade, isGrip), true)
  420. {
  421. Name = $" EfemRobot {blade} Grip";
  422. MutexId = (int)ModuleName.EfemRobot;
  423. }
  424. public static string BuildParameter(Hand blade, bool isGrip)
  425. {
  426. string para1 = isGrip ? "ON" : "OFF";
  427. string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
  428. return $"{para2}/{para1}";
  429. }
  430. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  431. {
  432. return base.HandleMessage(baseMessage, out transactionComplete);
  433. }
  434. }
  435. //TRANS
  436. public class RorzeEfemHandlerTrans : RorzeEfemHandler
  437. {
  438. public RorzeEfemHandlerTrans(RorzeEfem device, ModuleName module)
  439. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.TRANS, ConvertModuleToParameter(module), true)
  440. {
  441. Name = RorzeEfemBasicMessage.TRANS.ToString();
  442. MutexId = (int)ModuleName.EfemRobot;
  443. }
  444. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  445. {
  446. return base.HandleMessage(baseMessage, out transactionComplete);
  447. }
  448. }
  449. //CHANGE
  450. public class RorzeEfemHandlerChange : RorzeEfemHandler
  451. {
  452. public RorzeEfemHandlerChange(RorzeEfem device, ModuleName module)
  453. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.CHANGE, ConvertModuleToParameter(module), true)
  454. {
  455. Name = RorzeEfemBasicMessage.CHANGE.ToString();
  456. MutexId = (int)ModuleName.EfemRobot;
  457. }
  458. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  459. {
  460. return base.HandleMessage(baseMessage, out transactionComplete);
  461. }
  462. }
  463. //ALIGN
  464. public class RorzeEfemHandlerAlign : RorzeEfemHandler
  465. {
  466. public RorzeEfemHandlerAlign(RorzeEfem device, ModuleName module, double angle)
  467. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ALIGN, $"A{angle.ToString("F1")}", true)
  468. {
  469. Name = RorzeEfemBasicMessage.ALIGN.ToString();
  470. MutexId = (int)ModuleName.Aligner;
  471. }
  472. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  473. {
  474. return base.HandleMessage(baseMessage, out transactionComplete);
  475. }
  476. }
  477. //LIFT
  478. public class RorzeEfemHandlerLift : RorzeEfemHandler
  479. {
  480. public RorzeEfemHandlerLift(RorzeEfem device, ModuleName module, string Position)
  481. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.LIFT, $"{ConvertModuleToParameter(module)}/{Position}", true)
  482. {
  483. Name = RorzeEfemBasicMessage.LIFT.ToString();
  484. MutexId = (int)module;
  485. }
  486. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  487. {
  488. return base.HandleMessage(baseMessage, out transactionComplete);
  489. }
  490. }
  491. //HOME
  492. public class RorzeEfemHandlerHome : RorzeEfemHandler
  493. {
  494. public RorzeEfemHandlerHome(RorzeEfem device, ModuleName module)
  495. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.HOME, ConvertModuleToParameter(module), true)
  496. {
  497. Name = RorzeEfemBasicMessage.HOME.ToString();
  498. MutexId = (int)module;
  499. }
  500. }
  501. //HOLD
  502. public class RorzeEfemHandlerHold : RorzeEfemHandler
  503. {
  504. public RorzeEfemHandlerHold(RorzeEfem device, ModuleName module)
  505. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.HOLD, ConvertModuleToParameter(module), true)
  506. {
  507. Name = RorzeEfemBasicMessage.HOLD.ToString();
  508. MutexId = (int)module;
  509. }
  510. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  511. {
  512. return base.HandleMessage(baseMessage, out transactionComplete);
  513. }
  514. }
  515. //RESTR
  516. public class RorzeEfemHandlerRestr : RorzeEfemHandler
  517. {
  518. public RorzeEfemHandlerRestr(RorzeEfem device, ModuleName module)
  519. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.RESTR, ConvertModuleToParameter(module), false)
  520. {
  521. Name = RorzeEfemBasicMessage.RESTR.ToString();
  522. }
  523. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  524. {
  525. return base.HandleMessage(baseMessage, out transactionComplete);
  526. }
  527. }
  528. //ABORT
  529. public class RorzeEfemHandlerAbort : RorzeEfemHandler
  530. {
  531. public RorzeEfemHandlerAbort(RorzeEfem device, ModuleName module)
  532. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ABORT, ConvertModuleToParameter(module), true)
  533. {
  534. Name = RorzeEfemBasicMessage.ABORT.ToString();
  535. MutexId = (int)module;
  536. }
  537. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  538. {
  539. return base.HandleMessage(baseMessage, out transactionComplete);
  540. }
  541. }
  542. //EMS
  543. public class RorzeEfemHandlerEms : RorzeEfemHandler
  544. {
  545. public RorzeEfemHandlerEms(RorzeEfem device, ModuleName module)
  546. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.EMS, ConvertModuleToParameter(module), true)
  547. {
  548. Name = RorzeEfemBasicMessage.EMS.ToString();
  549. MutexId = (int)module;
  550. }
  551. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  552. {
  553. return base.HandleMessage(baseMessage, out transactionComplete);
  554. }
  555. }
  556. //ERROR
  557. public class RorzeEfemHandlerError : RorzeEfemHandler
  558. {
  559. public RorzeEfemHandlerError(RorzeEfem device, bool isQuery)
  560. : base(device, ModuleName.System, isQuery ? RorzeEfemMessageType.GET : RorzeEfemMessageType.SET, RorzeEfemBasicMessage.ERROR, isQuery ? "" : "CLEAR", isQuery)
  561. {
  562. Name = RorzeEfemBasicMessage.ERROR.ToString();
  563. }
  564. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  565. {
  566. return base.HandleMessage(baseMessage, out transactionComplete);
  567. }
  568. }
  569. //CLAMP
  570. public class RorzeEfemHandlerClamp : RorzeEfemHandler
  571. {
  572. public RorzeEfemHandlerClamp(RorzeEfem device, ModuleName module)
  573. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.CLAMP, ConvertModuleToParameter(module), true)
  574. {
  575. Name = RorzeEfemBasicMessage.CLAMP.ToString();
  576. MutexId = (int)module;
  577. }
  578. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  579. {
  580. return base.HandleMessage(baseMessage, out transactionComplete);
  581. }
  582. }
  583. //STATE
  584. public class RorzeEfemHandlerState : RorzeEfemHandler
  585. {
  586. private RorzeEfemStateType _state;
  587. public RorzeEfemHandlerState(RorzeEfem device, RorzeEfemStateType state)
  588. : base(device, ModuleName.System, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.STATE, state.ToString(), true)
  589. {
  590. Name = "Query State";
  591. _state = state;
  592. MutexId = (int)ModuleName.System;
  593. }
  594. protected override bool ProceedInfo(RorzeEfemMessage msg)
  595. {
  596. if (_state == RorzeEfemStateType.TRACK)
  597. {
  598. Device.NoteWaferTrack(msg.MessagePart[3]);
  599. }
  600. //Device.NoteComplete(Module);
  601. return true;
  602. }
  603. }
  604. //LED
  605. public class RorzeEfemHandlerLed : RorzeEfemHandler
  606. {
  607. public RorzeEfemHandlerLed(RorzeEfem device, ModuleName module)
  608. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.LED, ConvertModuleToParameter(module), true)
  609. {
  610. Name = RorzeEfemBasicMessage.LED.ToString();
  611. }
  612. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  613. {
  614. return base.HandleMessage(baseMessage, out transactionComplete);
  615. }
  616. }
  617. //WORKCHK
  618. public class RorzeEfemHandlerWorkChk : RorzeEfemHandler
  619. {
  620. public RorzeEfemHandlerWorkChk(RorzeEfem device, ModuleName module)
  621. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WORKCHK, ConvertModuleToParameter(module), true)
  622. {
  623. Name = RorzeEfemBasicMessage.WORKCHK.ToString();
  624. }
  625. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  626. {
  627. return base.HandleMessage(baseMessage, out transactionComplete);
  628. }
  629. }
  630. //FFU
  631. public class RorzeEfemHandlerFfu : RorzeEfemHandler
  632. {
  633. public RorzeEfemHandlerFfu(RorzeEfem device, ModuleName module)
  634. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.FFU, ConvertModuleToParameter(module), true)
  635. {
  636. Name = RorzeEfemBasicMessage.FFU.ToString();
  637. MutexId = (int)module;
  638. }
  639. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  640. {
  641. return base.HandleMessage(baseMessage, out transactionComplete);
  642. }
  643. }
  644. //WTYPE
  645. public class RorzeEfemHandlerWType : RorzeEfemHandler
  646. {
  647. public RorzeEfemHandlerWType(RorzeEfem device, ModuleName module)
  648. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.WTYPE, ConvertModuleToParameter(module), true)
  649. {
  650. Name = RorzeEfemBasicMessage.WTYPE.ToString();
  651. }
  652. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  653. {
  654. return base.HandleMessage(baseMessage, out transactionComplete);
  655. }
  656. }
  657. //PURGE
  658. public class RorzeEfemHandlerPurge : RorzeEfemHandler
  659. {
  660. public RorzeEfemHandlerPurge(RorzeEfem device, ModuleName module)
  661. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.PURGE, ConvertModuleToParameter(module), true)
  662. {
  663. Name = RorzeEfemBasicMessage.PURGE.ToString();
  664. }
  665. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  666. {
  667. return base.HandleMessage(baseMessage, out transactionComplete);
  668. }
  669. }
  670. //ADPLOCK
  671. public class RorzeEfemHandlerAdpLock : RorzeEfemHandler
  672. {
  673. public RorzeEfemHandlerAdpLock(RorzeEfem device, ModuleName module)
  674. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ADPLOCK, ConvertModuleToParameter(module), true)
  675. {
  676. Name = RorzeEfemBasicMessage.ADPLOCK.ToString();
  677. }
  678. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  679. {
  680. return base.HandleMessage(baseMessage, out transactionComplete);
  681. }
  682. }
  683. //ADPUNLOCK
  684. public class RorzeEfemHandlerAdpUnlock : RorzeEfemHandler
  685. {
  686. public RorzeEfemHandlerAdpUnlock(RorzeEfem device, ModuleName module)
  687. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ADPUNLOCK, ConvertModuleToParameter(module), true)
  688. {
  689. Name = RorzeEfemBasicMessage.ADPUNLOCK.ToString();
  690. }
  691. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  692. {
  693. return base.HandleMessage(baseMessage, out transactionComplete);
  694. }
  695. }
  696. //MODE
  697. public class RorzeEfemHandlerMode : RorzeEfemHandler
  698. {
  699. public RorzeEfemHandlerMode(RorzeEfem device, ModuleName module)
  700. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.MODE, ConvertModuleToParameter(module), true)
  701. {
  702. Name = RorzeEfemBasicMessage.MODE.ToString();
  703. MutexId = (int)module;
  704. }
  705. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  706. {
  707. return base.HandleMessage(baseMessage, out transactionComplete);
  708. }
  709. }
  710. //TRANSREQ
  711. public class RorzeEfemHandlerTransReq : RorzeEfemHandler
  712. {
  713. public RorzeEfemHandlerTransReq(RorzeEfem device, ModuleName module)
  714. : base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.TRANSREQ, ConvertModuleToParameter(module), true)
  715. {
  716. Name = RorzeEfemBasicMessage.TRANSREQ.ToString();
  717. MutexId = (int)module;
  718. }
  719. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  720. {
  721. return base.HandleMessage(baseMessage, out transactionComplete);
  722. }
  723. }
  724. //SIGOUT
  725. public class RorzeEfemHandlerSigout : RorzeEfemHandler
  726. {
  727. public RorzeEfemHandlerSigout(RorzeEfem device, ModuleName module, IndicatorType type, IndicatorState state)
  728. : base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.SIGOUT, BuildParameter(module, type, state), false)
  729. {
  730. Name = $"Set Signal Tower";
  731. MutexId = -1;
  732. }
  733. public RorzeEfemHandlerSigout(RorzeEfem device, ModuleName module, LightType type, TowerLightStatus state)
  734. : base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.SIGOUT, BuildParameter(module, type, state), false)
  735. {
  736. Name = $"Set Signal Tower";
  737. MutexId = -1;
  738. }
  739. public static string BuildParameter(ModuleName target, IndicatorType type, IndicatorState state)
  740. {
  741. Dictionary<IndicatorType, string> mapLightType = new Dictionary<IndicatorType, string>()
  742. {
  743. {IndicatorType.AccessAuto, "AUTO"},
  744. {IndicatorType.AccessManual, "MANUAL"},
  745. {IndicatorType.Load, "LOAD"},
  746. {IndicatorType.Unload, "UNLOAD"},
  747. {IndicatorType.Presence, "PRESENCE"},
  748. {IndicatorType.Placement, "PLACEMENT"},
  749. {IndicatorType.Error, "ERROR"},
  750. {IndicatorType.Busy, "BUSY"},
  751. {IndicatorType.Complete, "COMPLETE"},
  752. };
  753. Dictionary<IndicatorState, string> mapLightState = new Dictionary<IndicatorState, string>()
  754. {
  755. {IndicatorState.ON, "ON"},
  756. {IndicatorState.OFF, "OFF"},
  757. {IndicatorState.BLINK, "BLINK"},
  758. };
  759. string par1 = ConvertModuleToParameter(target);
  760. string par2 = mapLightType[type];
  761. string par3 = mapLightState[state];
  762. return $"{par1}/{par2}/{par3}";
  763. }
  764. public static string BuildParameter(ModuleName target, LightType type, TowerLightStatus state)
  765. {
  766. if (type == LightType.Buzzer)
  767. {
  768. type = state == TowerLightStatus.Blinking ? LightType.Buzzer2 : LightType.Buzzer1;
  769. state = state == TowerLightStatus.Off ? TowerLightStatus.Off : TowerLightStatus.On;
  770. }
  771. Dictionary<LightType, string> mapLightType = new Dictionary<LightType, string>()
  772. {
  773. {LightType.Red, "RED"},
  774. {LightType.Yellow, "YELLOW"},
  775. {LightType.Green, "GREEN"},
  776. {LightType.Blue, "BLUE"},
  777. {LightType.White, "WHITE"},
  778. {LightType.Buzzer1, "BUZZER1"},
  779. {LightType.Buzzer2, "BUZZER2"},
  780. };
  781. Dictionary<TowerLightStatus, string> mapLightState = new Dictionary<TowerLightStatus, string>()
  782. {
  783. {TowerLightStatus.On, "ON"},
  784. {TowerLightStatus.Off, "OFF"},
  785. {TowerLightStatus.Blinking, "BLINK"},
  786. };
  787. string par1 = "STOWER";
  788. string par2 = mapLightType[type];
  789. string par3 = mapLightState[state];
  790. return $"{par1}/{par2}/{par3}";
  791. }
  792. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  793. {
  794. return base.HandleMessage(baseMessage, out transactionComplete);
  795. }
  796. protected override bool ProceedInfo(RorzeEfemMessage msg)
  797. {
  798. return true;
  799. }
  800. }
  801. /// <summary>
  802. /// SIGSTAT
  803. /// EVT:/SIGSTAT/PARAMETER/DATA1/DATA2
  804. /// </summary>
  805. public class RorzeEfemHandlerSigStat : RorzeEfemHandler
  806. {
  807. public RorzeEfemHandlerSigStat(RorzeEfem device, ModuleName module)
  808. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.SIGSTAT, ConvertModuleToParameter(module), true)
  809. {
  810. Name = RorzeEfemBasicMessage.SIGSTAT.ToString();
  811. MutexId = (int)module;
  812. }
  813. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  814. {
  815. if (baseMessage.IsEvent)
  816. {
  817. var msg = baseMessage as RorzeEfemMessage;
  818. if (!ConvertParameterToModule(msg.MessagePart[2], out ModuleName module))
  819. {
  820. EV.PostWarningLog(Device.Module, $"Parameter unrecognized, {msg.RawMessage}");
  821. }
  822. else
  823. {
  824. Task.Delay(1000).ContinueWith(x=> Device.NoteStateEvent(module, msg.MessagePart[3], msg.MessagePart[4]));
  825. }
  826. transactionComplete = true;
  827. return true;
  828. }
  829. return base.HandleMessage(baseMessage, out transactionComplete);
  830. }
  831. protected override bool ProceedInfo(RorzeEfemMessage msg)
  832. {
  833. if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  834. {
  835. Task.Delay(1000).ContinueWith(x => Device.NoteStateEvent(target, msg.MessagePart[3], msg.MessagePart[4]));
  836. }
  837. if (!msg.IsEvent && ModuleHelper.IsLoadPort(Module))
  838. {
  839. Device.NoteComplete(Module);
  840. }
  841. return true;
  842. }
  843. }
  844. //CSTID
  845. public class RorzeEfemHandlerReadCstid : RorzeEfemHandler
  846. {
  847. public RorzeEfemHandlerReadCstid(RorzeEfem device, ModuleName module)
  848. : base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.CSTID, ConvertModuleToParameter(module), true)
  849. {
  850. Name = RorzeEfemBasicMessage.CSTID.ToString();
  851. MutexId = (int)module;
  852. }
  853. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  854. {
  855. return base.HandleMessage(baseMessage, out transactionComplete);
  856. }
  857. protected override bool ProceedInfo(RorzeEfemMessage msg)
  858. {
  859. if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  860. {
  861. Device.NoteCarrierIDReadResult(target, string.Join(":", msg.MessagePart.Skip(3)));
  862. }
  863. if (!msg.IsEvent)
  864. {
  865. Device.NoteComplete(Module);
  866. }
  867. return true;
  868. }
  869. }
  870. public class RorzeEfemHandlerSetCstid : RorzeEfemHandler
  871. {
  872. public RorzeEfemHandlerSetCstid(RorzeEfem device, ModuleName module,string cstid)
  873. : base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.CSTID, $"{ConvertModuleToParameter(module)}/{cstid}", true)
  874. {
  875. Name = RorzeEfemBasicMessage.CSTID.ToString();
  876. MutexId = (int)module;
  877. }
  878. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  879. {
  880. return base.HandleMessage(baseMessage, out transactionComplete);
  881. }
  882. protected override bool ProceedInfo(RorzeEfemMessage msg)
  883. {
  884. if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  885. {
  886. Device.NoteWRITETAGResult(target, string.Join(":", msg.MessagePart.Skip(3)));
  887. }
  888. if (!msg.IsEvent)
  889. {
  890. Device.NoteComplete(Module);
  891. }
  892. return true;
  893. }
  894. }
  895. //EVENT
  896. public class RorzeEfemHandlerEvent : RorzeEfemHandler
  897. {
  898. public RorzeEfemHandlerEvent(RorzeEfem device, ModuleName module, bool isSet = true)
  899. : base(device, module, isSet ? RorzeEfemMessageType.SET : RorzeEfemMessageType.GET, RorzeEfemBasicMessage.EVENT, ConvertModuleToParameter(module), true)
  900. {
  901. Name = RorzeEfemBasicMessage.EVENT.ToString();
  902. MutexId = (int)module;
  903. }
  904. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  905. {
  906. return base.HandleMessage(baseMessage, out transactionComplete);
  907. }
  908. }
  909. public class RorzeEfemHandlerGetMode : RorzeEfemHandler
  910. {
  911. public RorzeEfemHandlerGetMode(RorzeEfem device, ModuleName module) :
  912. base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.MODE, ConvertModuleToParameter(module), true)
  913. {
  914. Name = RorzeEfemBasicMessage.MODE.ToString();
  915. MutexId = (int)module;
  916. }
  917. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  918. {
  919. return base.HandleMessage(baseMessage, out transactionComplete);
  920. }
  921. protected override bool ProceedInfo(RorzeEfemMessage msg)
  922. {
  923. if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
  924. {
  925. Device.LoadPortAccessMode(target, string.Join(":", msg.MessagePart.Skip(3)));
  926. }
  927. if (!msg.IsEvent)
  928. {
  929. Device.NoteComplete(Module);
  930. }
  931. return true;
  932. }
  933. }
  934. public class RorzeEfemHandlerSetMode : RorzeEfemHandler
  935. {
  936. public RorzeEfemHandlerSetMode(RorzeEfem device, ModuleName module,string mode) :
  937. base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.MODE, $"{ConvertModuleToParameter(module)}/{mode}", false)
  938. {
  939. Name = RorzeEfemBasicMessage.MODE.ToString();
  940. MutexId = (int)module;
  941. }
  942. public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
  943. {
  944. bool result= base.HandleMessage(baseMessage, out transactionComplete);
  945. if(result)
  946. {
  947. Device.WriteLoadPortAccessSuccess(this.Module);
  948. }
  949. return result;
  950. }
  951. protected override bool ProceedInfo(RorzeEfemMessage msg)
  952. {
  953. return true;
  954. }
  955. }
  956. }