EfemAction.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.Util;
  6. using Aitex.Sorter.Common;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.SubstrateTrackings;
  9. using Virgo_DCommon;
  10. using Virgo_DRT.Device;
  11. using Virgo_DRT.Device.YASKAWA;
  12. using System.Diagnostics;
  13. namespace Virgo_DRT.Devices
  14. {
  15. /// <summary>
  16. /// Base action
  17. /// </summary>
  18. abstract class EfemActionBase : ActionBase
  19. {
  20. protected readonly EfemBase _efem;
  21. public EfemOperation Type { get; protected set; }
  22. protected EfemActionBase() : this(null) { }
  23. protected EfemActionBase(EfemBase efem) : base(ModuleName.EFEM)
  24. {
  25. _efem = efem;
  26. }
  27. }
  28. class DelayAction : ActionBase
  29. {
  30. private readonly DeviceTimer _timer = new DeviceTimer();
  31. private readonly ushort _delayTime;
  32. public bool IsDone => _timer.IsTimeout();
  33. public DelayAction(ushort delaytime) : base(ModuleName.System)
  34. {
  35. this._delayTime = delaytime;
  36. }
  37. public override void Execute()
  38. {
  39. _timer.Start(this._delayTime * 1000);
  40. }
  41. public override void OnPostWork(string data)
  42. {
  43. EV.PostInfoLog(ModuleName.EFEM.ToString(), $"Delay time [{_delayTime}]");
  44. }
  45. }
  46. }
  47. namespace Virgo_DRT.Devices.YASKAWA
  48. {
  49. class EfemAction : EfemActionBase
  50. {
  51. public EfemAction(EfemBase device, ModuleName mod) : base(device)
  52. { }
  53. public override void Execute()
  54. {
  55. _efem.MsgHandler.Send(new EfemMessage
  56. {
  57. Operation = this.Type,
  58. Head = EfemMessage.MsgHead.MOV,
  59. Parameters = new List<string> { Constant.ModuleString[this.Module] }
  60. });
  61. base.Execute();
  62. _efem.Status = DeviceState.Busy;
  63. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  64. }
  65. public override void OnPostWork(string data = null)
  66. {
  67. _efem.Status = DeviceState.Idle;
  68. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} End");
  69. }
  70. }
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. class HomeAllAction : EfemAction
  75. {
  76. public HomeAllAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  77. {
  78. Type = EfemOperation.Home;
  79. this.Module = mod;
  80. }
  81. }
  82. class HomeModuleAction : EfemAction
  83. {
  84. public HomeModuleAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  85. {
  86. Type = EfemOperation.Home;
  87. this.Module = mod;
  88. }
  89. }
  90. class OrgshAction : EfemAction
  91. {
  92. public OrgshAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  93. {
  94. Type = EfemOperation.Orgsh;
  95. this.Module = mod;
  96. }
  97. }
  98. class ClearErrorAction : EfemAction
  99. {
  100. public ClearErrorAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  101. {
  102. Type = EfemOperation.ClearError;
  103. }
  104. public override void Execute()
  105. {
  106. _efem.MsgHandler.Send(new EfemMessage
  107. {
  108. Operation = this.Type,
  109. Head = EfemMessage.MsgHead.SET,
  110. Parameters = new List<string> { "CLEAR" }
  111. });
  112. EV.PostInfoLog(this.Module.ToString(), "清除 EFEM 所有错误");
  113. }
  114. }
  115. class MapAction : EfemAction
  116. {
  117. public MapAction(EfemBase efem, ModuleName mod) : base(efem, mod)
  118. {
  119. Type = EfemOperation.Map;
  120. this.Module = mod;
  121. }
  122. public override void OnPostWork(string data)
  123. {
  124. _efem[Module].Status = DeviceState.Idle;
  125. }
  126. }
  127. class PickAction : EfemAction
  128. {
  129. private MoveParam MoveParam { get; }
  130. public PickAction(EfemBase efem, MoveParam mp) : base(efem, ModuleName.EFEM)
  131. {
  132. Type = EfemOperation.Pick;
  133. MoveParam = mp;
  134. }
  135. public override void Execute()
  136. {
  137. //MOV:LOAD/P113/ARM2;
  138. _efem.MsgHandler.Send(new EfemMessage
  139. {
  140. Operation = this.Type,
  141. Head = EfemMessage.MsgHead.MOV,
  142. Parameters = new List<string>
  143. {
  144. MoveParam.SrcPos.ToHWString(),
  145. Constant.ArmString[MoveParam.Arm],
  146. MoveParam.WaferSize.ToString()
  147. }
  148. });
  149. this.Status = ActionStatus.SendCmd;
  150. _efem.Status = DeviceState.Busy;
  151. }
  152. public override void OnPostWork(string data)
  153. {
  154. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  155. _efem.Status = DeviceState.Idle;
  156. //_bladeTarget = ModuleName.EfemRobot;
  157. }
  158. }
  159. // MOV:GOTO/P113/ARM2/DOWN;
  160. // MOV:UNLOAD/P225/ARM2;
  161. class PlaceAction : EfemAction
  162. {
  163. private MoveParam MoveParam { get; }
  164. public PlaceAction(EfemBase device, MoveParam mp) : base(device, ModuleName.EFEM)
  165. {
  166. Type = EfemOperation.Place;
  167. MoveParam = mp;
  168. }
  169. public override void Execute()
  170. {
  171. _efem.MsgHandler.Send(new EfemMessage
  172. {
  173. Operation = this.Type,
  174. Head = EfemMessage.MsgHead.MOV,
  175. Parameters = new List<string>
  176. {
  177. MoveParam.DestPos.ToHWString(),
  178. Constant.ArmString[MoveParam.Arm],
  179. MoveParam.WaferSize.ToString()
  180. }
  181. });
  182. this.Status = ActionStatus.SendCmd;
  183. _efem.Status = DeviceState.Busy;
  184. }
  185. public override void OnPostWork(string data)
  186. {
  187. WaferManager.Instance.WaferMoved(MoveParam.SrcModule, MoveParam.SrcSlot, MoveParam.DestModule, MoveParam.DestSlot);
  188. _efem.Status = DeviceState.Idle;
  189. }
  190. }
  191. class ExtendAction : EfemAction
  192. {
  193. private ExtendParam ExtParam { get; }
  194. public ExtendPos TargetPosition => ExtParam.Pos;
  195. public ExtendAction(EfemBase efem, ExtendParam ep)
  196. : base(efem, ModuleName.EFEM)
  197. {
  198. Type = EfemOperation.Extend;
  199. ExtParam = ep;
  200. ExtParam.Arm = Hand.Blade1;
  201. }
  202. public override void Execute()
  203. {
  204. //MOV:EXTEND/LLA03/ARM2;
  205. _efem.MsgHandler.Send(new EfemMessage
  206. {
  207. Operation = this.Type,
  208. Head = EfemMessage.MsgHead.MOV,
  209. Parameters = new List<string>
  210. {
  211. ExtParam.Module.ToHWString(),
  212. //Constant.ExtendPosString[ExtParam.Pos],
  213. ExtParam.Pos.ToString(),
  214. Constant.ArmString[ExtParam.Arm]
  215. }
  216. });
  217. this.Status = ActionStatus.SendCmd;
  218. _efem.Status = DeviceState.Busy;
  219. }
  220. public override void OnPostWork(string data)
  221. {
  222. _efem.Status = DeviceState.Idle;
  223. switch (TargetPosition)
  224. {
  225. case ExtendPos.PB:
  226. WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)ExtParam.Arm, ExtParam.Module, 0);
  227. break;
  228. case ExtendPos.G4:
  229. WaferManager.Instance.WaferMoved(ExtParam.Module, 0, ModuleName.EfemRobot, (int)ExtParam.Arm);
  230. break;
  231. default:
  232. Debug.WriteLine($"MNPT:{TargetPosition} 不需要更新 WaferManager 信息");
  233. break;
  234. }
  235. }
  236. }
  237. class LiftAction : EfemAction
  238. {
  239. // MOV:LIFT/ALIGN1;
  240. public LiftAction(EfemBase device, ModuleName mod) : base(device, mod)
  241. {
  242. Type = EfemOperation.Lift;
  243. Module = mod;
  244. }
  245. public override void OnPostWork(string data)
  246. { }
  247. }
  248. class AlignAction : EfemAction
  249. {
  250. private WaferSize _ws { get; }
  251. public AlignAction(EfemBase device, ModuleName mod, WaferSize size) : base(device, mod)
  252. {
  253. Type = EfemOperation.Align;
  254. this.Module = mod;
  255. this._ws = size;
  256. }
  257. public override void Execute()
  258. {
  259. _efem.MsgHandler.Send(new EfemMessage
  260. {
  261. Operation = this.Type,
  262. Head = EfemMessage.MsgHead.MOV,
  263. Parameters = new List<string> { Module.ToHWString(), this._ws.ToString() }
  264. });
  265. this.Status = ActionStatus.SendCmd;
  266. }
  267. public override void OnPostWork(string data) { }
  268. }
  269. class LedAction : EfemAction
  270. {
  271. private LightType Light { get; }
  272. private LightStatus LtStatus { get; }
  273. public LedAction(EfemBase device, LightType lt, LightStatus st) : base(device, ModuleName.EFEM)
  274. {
  275. Type = EfemOperation.Light;
  276. Light = lt;
  277. LtStatus = st;
  278. }
  279. public override void Execute()
  280. {
  281. _efem.MsgHandler.Send(new EfemMessage
  282. {
  283. Operation = this.Type,
  284. Head = EfemMessage.MsgHead.SET,
  285. Parameters = new List<string> { Constant.STOWER, Light.ToString(), LtStatus.ToString() }
  286. });
  287. _efem.Status = DeviceState.Busy;
  288. EV.PostInfoLog(this.Module.ToString(), $"Cmd {this.ID} {this.Type} Start");
  289. }
  290. public override void OnPostWork(string data)
  291. {
  292. }
  293. }
  294. class AbortAction: EfemAction
  295. {
  296. public AbortAction(EfemBase efem) : base(efem, ModuleName.EFEM)
  297. {
  298. Type = EfemOperation.Abort;
  299. }
  300. public override void Execute()
  301. {
  302. _efem.MsgHandler.Send(new EfemMessage
  303. {
  304. Operation = this.Type,
  305. Head = EfemMessage.MsgHead.MOV
  306. });
  307. }
  308. }
  309. }