VceEntity.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Fsm;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using Aitex.Core.Utilities;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Schedulers;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using MECF.Framework.RT.ModuleLibrary.VceModules;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Reflection;
  17. using System.Runtime.InteropServices;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows;
  21. using Venus_Core;
  22. using Venus_RT.Devices;
  23. using Venus_RT.Devices.SMIF;
  24. using Venus_RT.Devices.TM;
  25. using Venus_RT.Devices.VCE;
  26. using Venus_RT.Modules.PMs;
  27. using Venus_RT.Modules.TM;
  28. using Venus_RT.Modules.TM.VenusEntity;
  29. namespace Venus_RT.Modules.VCE
  30. {
  31. #region 状态和消息
  32. public enum VceMSG
  33. {
  34. Home,
  35. Error,
  36. DoorOpen,
  37. DoorClose,
  38. Map,
  39. ReadMap,
  40. Load,
  41. UnLoad,
  42. LoadPrepare,
  43. LoadWithSMIF,
  44. UnLoadWithSMIF,
  45. Reset,
  46. Goto,
  47. GotoLP,
  48. SafeLoad,
  49. SafeUnload,
  50. Pump,
  51. Vent,
  52. LeakCheck,
  53. Abort,
  54. None,
  55. ClearError
  56. }
  57. #endregion
  58. public static class VCE2LP
  59. {
  60. public static Dictionary<ModuleName, ModuleName> dVce2LP = new Dictionary<ModuleName, ModuleName>()
  61. {
  62. {ModuleName.LP1,ModuleName.VCEA},
  63. {ModuleName.LP2,ModuleName.VCEB},
  64. };
  65. public static Dictionary<ModuleName, ModuleName> sVce2LP = new Dictionary<ModuleName, ModuleName>()
  66. {
  67. {ModuleName.LP1,ModuleName.VCE1},
  68. };
  69. public static Dictionary<ModuleName, ModuleName> LP2Vce = new Dictionary<ModuleName, ModuleName>();
  70. public static ModuleName QueryLP2VCE(ModuleName lpname)
  71. {
  72. switch (Singleton<RouteManager>.Instance.seTM.Module)
  73. {
  74. case ModuleName.SETM:
  75. if (sVce2LP.ContainsKey(lpname))
  76. {
  77. return sVce2LP[lpname];
  78. }
  79. else
  80. return ModuleName.System;
  81. case ModuleName.DETM:
  82. if (sVce2LP.ContainsKey(lpname))
  83. {
  84. return dVce2LP[lpname];
  85. }
  86. else
  87. return ModuleName.System;
  88. default:
  89. return ModuleName.System;
  90. }
  91. }
  92. }
  93. public class VceEntity : Entity, IEntity, IModuleEntity
  94. {
  95. private ModuleName _modulename;
  96. private readonly VCEModuleBase _vce;
  97. private readonly ISMIF _smif;
  98. private bool _CassetteArrive;
  99. private bool _IsOnline = false;
  100. public bool IsOnline => _IsOnline;
  101. public bool IsIdle => fsm.State == (int)VceSTATE.Idle;
  102. public bool IsInit => fsm.State == (int)VceSTATE.Init || fsm.State == (int)VceSTATE.Unknown;
  103. public bool IsBusy => !IsInit && !IsError && !IsIdle;
  104. public bool IsError => fsm.State == (int)VceSTATE.Error;
  105. public bool VCEOutDoorClosed => !_vce.OutDoorIsOpen;
  106. public bool CassetteArrive => _CassetteArrive;
  107. public int CurrentSlot => currentSlot;
  108. private int currentSlot;
  109. private int targetSlot;
  110. private LoadRoutine _loadRoutine;
  111. private LoadPrepareRoutine _prepareRoutine;
  112. private UnloadRoutine _unloadRoutine;
  113. private LoadWithSMIFRoutine _loadwithSMIFRoutine;
  114. private UnloadWithSMIFRoutine _unloadwithSMIFRoutine;
  115. private readonly SEMFPumpRoutine _pumpRoutine;
  116. private readonly SEMFVentRoutine _ventRoutine;
  117. private readonly SEMFLeakCheckRoutine _leakcheckRoutine;
  118. public VceEntity(ModuleName moduleName)
  119. {
  120. currentSlot = 0;
  121. _modulename = moduleName;
  122. _vce = new HongHuVce(25, _modulename);
  123. _smif = new FortrendPLUS500(_modulename);
  124. _loadRoutine = new LoadRoutine(_modulename, _vce);
  125. _prepareRoutine = new LoadPrepareRoutine(_modulename, _vce);
  126. _unloadRoutine = new UnloadRoutine(_modulename, _vce);
  127. _loadwithSMIFRoutine = new LoadWithSMIFRoutine(_modulename, _vce, _smif);
  128. _unloadwithSMIFRoutine = new UnloadWithSMIFRoutine(_modulename, _vce, _smif);
  129. if (moduleName == ModuleName.VCE1)
  130. {
  131. _pumpRoutine = new SEMFPumpRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), _modulename);
  132. _ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), _modulename);
  133. _leakcheckRoutine = new SEMFLeakCheckRoutine(DEVICE.GetDevice<HongHuTM>("SETM"),_modulename);
  134. }
  135. else
  136. {
  137. _pumpRoutine = new SEMFPumpRoutine(DEVICE.GetDevice<HongHuDETM>("DETM"), _modulename);
  138. _ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuDETM>("DETM"), _modulename);
  139. _leakcheckRoutine = new SEMFLeakCheckRoutine(DEVICE.GetDevice<HongHuDETM>("DETM"), _modulename);
  140. }
  141. InitFsmMap();
  142. }
  143. protected override bool Init()
  144. {
  145. DATA.Subscribe($"{_modulename}.VCEOutDoorClosed", () => !VCEOutDoorClosed);
  146. DATA.Subscribe($"{_modulename}.CurrentSlot", () => currentSlot);
  147. DATA.Subscribe($"{_modulename}.FsmState", () => ((VceSTATE)fsm.State).ToString());
  148. DATA.Subscribe($"{_modulename}.CassetteArrive", () => CassetteArrive);
  149. DATA.Subscribe($"{_modulename}.IsOnline", () => IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  150. DATA.Subscribe($"{_modulename}.IsOffline", () => !IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  151. OP.Subscribe($"{_modulename}.HOME", (cmd, args) => { PostMsg(VceMSG.Home); return true; });
  152. OP.Subscribe($"{_modulename}.DoorOpen", (cmd, args) => { PostMsg(VceMSG.DoorOpen); return true; });
  153. OP.Subscribe($"{_modulename}.DoorClose", (cmd, args) => { PostMsg(VceMSG.DoorClose); return true; });
  154. OP.Subscribe($"{_modulename}.Map", (cmd, args) => { PostMsg(VceMSG.Map); return true; });
  155. OP.Subscribe($"{_modulename}.ReadMap", (cmd, args) => { PostMsg(VceMSG.ReadMap); return true; });
  156. OP.Subscribe($"{_modulename}.Load", (cmd, args) => { PostMsg(VceMSG.Load); return true; });
  157. OP.Subscribe($"{_modulename}.UnLoad", (cmd, args) => { PostMsg(VceMSG.UnLoad); return true; });
  158. OP.Subscribe($"{_modulename}.Reset", (cmd, args) => { PostMsg(VceMSG.Reset); return true; });
  159. OP.Subscribe($"{_modulename}.Goto", (cmd, args) => { PostMsg(VceMSG.Goto, args[0]); return true; });
  160. OP.Subscribe($"{_modulename}.GotoLP", (cmd, args) => { PostMsg(VceMSG.GotoLP); return true; });
  161. OP.Subscribe($"{_modulename}.Abort", (cmd, args) => { PostMsg(VceMSG.Abort); return true; });
  162. OP.Subscribe($"{_modulename}.PumpDown", (cmd, args) => { PostMsg(VceMSG.Pump); return true; });
  163. OP.Subscribe($"{_modulename}.Vent", (cmd, args) => { PostMsg(VceMSG.Vent); return true; });
  164. OP.Subscribe($"{_modulename}.LeakCheck", (cmd, args) => { PostMsg(VceMSG.LeakCheck); return true; });
  165. OP.Subscribe($"{_modulename}.ClearError", (cmd, args) => { PostMsg(VceMSG.ClearError); return true; });
  166. OP.Subscribe($"{_modulename}.LoadPrepare", (cmd, args) => { PostMsg(VceMSG.LoadPrepare); return true; });
  167. OP.Subscribe($"{_modulename}.SafeLoad", (cmd, args) => { PostMsg(VceMSG.SafeLoad); return true; });
  168. OP.Subscribe($"{_modulename}.SafeUnload", (cmd, args) => { PostMsg(VceMSG.SafeUnload); return true; });
  169. OP.Subscribe($"{_modulename}.LoadWithSMIF", (cmd, args) => { PostMsg(VceMSG.LoadWithSMIF); return true; });
  170. OP.Subscribe($"{_modulename}.UnLoadWithSMIF", (cmd, args) => { PostMsg(VceMSG.UnLoadWithSMIF); return true; });
  171. OP.Subscribe($"{_modulename}.Online", (cmd, args) =>
  172. {
  173. if (IsIdle)
  174. _IsOnline = true;
  175. else
  176. LOG.Write(eEvent.WARN_TM, _modulename, $"cannot Set Online as {_modulename} is not idle");
  177. return true;
  178. });
  179. OP.Subscribe($"{_modulename}.Offline", (cmd, args) =>
  180. {
  181. _IsOnline = false;
  182. return true;
  183. });
  184. return true;
  185. }
  186. /// <summary>
  187. /// 定义状态机的迁移表
  188. /// </summary>
  189. private void InitFsmMap()
  190. {
  191. fsm = new StateMachine<VceEntity>(_modulename.ToString(), (int)VceSTATE.Init, 50);
  192. fsm.EnableRepeatedMsg(true);
  193. AnyStateTransition(VceMSG.Error, fnError, VceSTATE.Error);
  194. //AnyStateTransition(VceMSG.Abort, fnAbort, VceSTATE.Init);
  195. AnyStateTransition(VceMSG.Home, fnStartHome, VceSTATE.Homing);
  196. AnyStateTransition(VceMSG.DoorOpen, fnStartOpenDoor, VceSTATE.DoorOpenning);
  197. //HOME init->homing idle->homing
  198. Transition(VceSTATE.Init, VceMSG.Home, fnStartHome, VceSTATE.Homing);
  199. Transition(VceSTATE.Idle, VceMSG.Home, fnStartHome, VceSTATE.Homing);
  200. Transition(VceSTATE.Error, VceMSG.Home, fnStartHome, VceSTATE.Homing);
  201. Transition(VceSTATE.Homing, FSM_MSG.TIMER, fnHomeTimeout, VceSTATE.Idle);
  202. Transition(VceSTATE.Homing, VceMSG.Abort, fnAbort, VceSTATE.Init);
  203. //clear Error
  204. Transition(VceSTATE.Error, VceMSG.ClearError, fnStartClearError,VceSTATE.ClearError);
  205. Transition(VceSTATE.ClearError, FSM_MSG.TIMER, fnClearErrorTimeout, VceSTATE.Idle);
  206. //Open Door 开门
  207. Transition(VceSTATE.Idle, VceMSG.DoorOpen, fnStartOpenDoor, VceSTATE.DoorOpenning);
  208. Transition(VceSTATE.DoorOpenning, FSM_MSG.TIMER, fnOpenDoorTimeout, VceSTATE.Idle);
  209. Transition(VceSTATE.DoorOpenning, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  210. //Close Door 关门
  211. Transition(VceSTATE.Idle, VceMSG.DoorClose, fnStartCloseDoor, VceSTATE.DoorClosing);
  212. Transition(VceSTATE.DoorClosing, FSM_MSG.TIMER, fnCloseDoorTimeout, VceSTATE.Idle);
  213. Transition(VceSTATE.DoorClosing, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  214. //Map 扫片
  215. Transition(VceSTATE.Idle, VceMSG.Map, fnStartMapping, VceSTATE.Mapping);
  216. Transition(VceSTATE.Mapping, FSM_MSG.TIMER, fnMappingTimeout, VceSTATE.Idle);
  217. Transition(VceSTATE.Mapping, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  218. //Load 取cassette
  219. Transition(VceSTATE.Idle, VceMSG.Load, fnStartLoading, VceSTATE.Loading);
  220. Transition(VceSTATE.Loading, FSM_MSG.TIMER, fnLoadingTimeout, VceSTATE.Idle);
  221. Transition(VceSTATE.Loading, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  222. //UnLoad 放cassette
  223. Transition(VceSTATE.Idle, VceMSG.UnLoad, fnStartUnLoading, VceSTATE.UnLoading);
  224. Transition(VceSTATE.UnLoading, FSM_MSG.TIMER, fnUnLoadingTimeout, VceSTATE.Idle);
  225. Transition(VceSTATE.UnLoading, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  226. //Goto 指定槽对准窗口
  227. Transition(VceSTATE.Idle, VceMSG.Goto, fnStartGoto, VceSTATE.Goting);
  228. Transition(VceSTATE.Goting, FSM_MSG.TIMER, fnGotingTimeout, VceSTATE.Idle);
  229. Transition(VceSTATE.Goting, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  230. //ReadMap
  231. Transition(VceSTATE.Idle, VceMSG.ReadMap, fnStartReadingMap, VceSTATE.ReadingMap);
  232. Transition(VceSTATE.ReadingMap, FSM_MSG.TIMER, fnReadingMapTimeout, VceSTATE.Idle);
  233. Transition(VceSTATE.ReadingMap, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  234. //Load Prepare
  235. Transition(VceSTATE.Idle, VceMSG.LoadPrepare, fnStartLoadPrepare, VceSTATE.LoadPreparing);
  236. Transition(VceSTATE.LoadPreparing, FSM_MSG.TIMER, fnLoadingPrepareTimeout, VceSTATE.Idle);
  237. Transition(VceSTATE.LoadPreparing, VceMSG.Abort, fnLoadingPrepareAbort, VceSTATE.Idle);
  238. //Safe Load
  239. Transition(VceSTATE.Idle, VceMSG.SafeLoad, fnStartSafeLoad, VceSTATE.SafeLoading);
  240. Transition(VceSTATE.SafeLoading, FSM_MSG.TIMER, fnSafeLoadTimeout, VceSTATE.Idle);
  241. Transition(VceSTATE.SafeLoading, VceMSG.Abort, fnSafeLoadAbort, VceSTATE.Idle);
  242. //LoadWithSMIF => LoadPrepare & SMIF Load & Load
  243. Transition(VceSTATE.Idle, VceMSG.LoadWithSMIF, fnStartLoadWithSMIF, VceSTATE.LoadingWithSMIF);
  244. Transition(VceSTATE.LoadingWithSMIF, FSM_MSG.TIMER, fnLoadWithSMIFTimeout, VceSTATE.Idle);
  245. Transition(VceSTATE.LoadingWithSMIF, VceMSG.Abort, fnLoadWithSMIFAbort, VceSTATE.Idle);
  246. //Safe UnLoad
  247. Transition(VceSTATE.Idle, VceMSG.SafeUnload, fnStartSafeUnLoad, VceSTATE.SafeUnloading);
  248. Transition(VceSTATE.SafeUnloading, FSM_MSG.TIMER, fnSafeUnLoadTimeout, VceSTATE.Idle);
  249. Transition(VceSTATE.SafeUnloading, VceMSG.Abort, fnSafeUnLoadAbort, VceSTATE.Idle);
  250. //UnLoad With SMIF => UnLoad with smif
  251. Transition(VceSTATE.Idle, VceMSG.UnLoadWithSMIF, fnStartUnLoadWithSMIF, VceSTATE.UnLoadingWithSMIF);
  252. Transition(VceSTATE.UnLoadingWithSMIF, FSM_MSG.TIMER, fnUnLoadWithSMIFTimeout, VceSTATE.Idle);
  253. Transition(VceSTATE.UnLoadingWithSMIF, VceMSG.Abort, fnUnLoadWithSMIFAbort, VceSTATE.Idle);
  254. //Goto LP
  255. Transition(VceSTATE.Idle, VceMSG.GotoLP, fnStartGotoLP, VceSTATE.GotingLP);
  256. Transition(VceSTATE.GotingLP, FSM_MSG.TIMER, fnGotoLPTimeout, VceSTATE.Idle);
  257. Transition(VceSTATE.GotingLP, VceMSG.Abort, fnAbort, VceSTATE.Idle);
  258. //Pump
  259. Transition(VceSTATE.Idle, VceMSG.Pump, fnStartPump, VceSTATE.Pumping);
  260. Transition(VceSTATE.Pumping, FSM_MSG.TIMER, fnPumpTimeout, VceSTATE.Idle);
  261. Transition(VceSTATE.Pumping, VceMSG.Abort, fnAbortPump, VceSTATE.Idle);
  262. //Vent
  263. Transition(VceSTATE.Idle, VceMSG.Vent, fnStartVent, VceSTATE.Venting);
  264. Transition(VceSTATE.Venting, FSM_MSG.TIMER, fnVentTimeout, VceSTATE.Idle);
  265. Transition(VceSTATE.Venting, VceMSG.Abort, fnAbortVent, VceSTATE.Idle);
  266. //LeakCheck
  267. Transition(VceSTATE.Idle, VceMSG.LeakCheck, FnStartLeakCheck, VceSTATE.LeakChecking);
  268. Transition(VceSTATE.LeakChecking, FSM_MSG.TIMER, FnLeakCheckTimeout, VceSTATE.Idle);
  269. Transition(VceSTATE.LeakChecking, VceMSG.Abort, FnAbortLeakCheck, VceSTATE.Idle);
  270. EnumLoop<VceSTATE>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
  271. EnumLoop<VceMSG>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
  272. Running = true;
  273. }
  274. private bool fnAbortVent(object[] param)
  275. {
  276. _ventRoutine.Abort();
  277. return true;
  278. }
  279. private bool fnVentTimeout(object[] param)
  280. {
  281. RState ret = _ventRoutine.Monitor();
  282. if (ret == RState.Timeout || ret == RState.Failed)
  283. {
  284. PostMsg(VceMSG.Error);
  285. return false;
  286. }
  287. return ret == RState.End;
  288. }
  289. private bool fnStartVent(object[] param)
  290. {
  291. return _ventRoutine.Start(param) == RState.Running;
  292. }
  293. private bool FnStartLeakCheck(object[] param)
  294. {
  295. return _leakcheckRoutine.Start(param) == RState.Running;
  296. }
  297. private bool FnLeakCheckTimeout(object[] param)
  298. {
  299. RState ret = _leakcheckRoutine.Monitor();
  300. if (ret == RState.Failed || ret == RState.Timeout)
  301. {
  302. PostMsg(VceMSG.Error);
  303. return false;
  304. }
  305. return ret == RState.End;
  306. }
  307. private bool FnAbortLeakCheck(object[] param)
  308. {
  309. _leakcheckRoutine.Abort();
  310. return true;
  311. }
  312. private bool fnAbortPump(object[] param)
  313. {
  314. _pumpRoutine.Abort();
  315. return true;
  316. }
  317. private bool fnPumpTimeout(object[] param)
  318. {
  319. RState ret = _pumpRoutine.Monitor();
  320. if (ret == RState.Timeout || ret == RState.Failed)
  321. {
  322. PostMsg(VceMSG.Error);
  323. return false;
  324. }
  325. return ret == RState.End;
  326. }
  327. private bool fnStartPump(object[] param)
  328. {
  329. return _pumpRoutine.Start(param) == RState.Running;
  330. }
  331. private bool fnGotoLPTimeout(object[] param)
  332. {
  333. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  334. {
  335. PostMsg(VceMSG.Error);
  336. return false;
  337. }
  338. if (_vce.Status == RState.End)
  339. {
  340. currentSlot = targetSlot;
  341. }
  342. return _vce.Status == RState.End;
  343. }
  344. private bool fnStartGotoLP(object[] param)
  345. {
  346. if (_vce.GotoLP())
  347. {
  348. targetSlot = -1;
  349. return true;
  350. }
  351. else
  352. return false;
  353. }
  354. private bool fnSafeUnLoadAbort(object[] param)
  355. {
  356. _unloadRoutine.Abort();
  357. return true;
  358. }
  359. private bool fnSafeUnLoadTimeout(object[] param)
  360. {
  361. RState ret = _unloadRoutine.Monitor();
  362. if (ret == RState.Timeout || ret == RState.Failed)
  363. {
  364. PostMsg(VceMSG.Error);
  365. return false;
  366. }
  367. if (ret == RState.End)
  368. {
  369. _CassetteArrive = false;
  370. WaferManager.Instance.DeleteWafer(_modulename, 0, 25);
  371. }
  372. return ret == RState.End;
  373. }
  374. private bool fnStartClearError(object[] param)
  375. {
  376. if (_vce.ClearError())
  377. {
  378. return true;
  379. }
  380. else
  381. return false;
  382. }
  383. private bool fnClearErrorTimeout(object[] param)
  384. {
  385. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  386. {
  387. PostMsg(VceMSG.Error);
  388. return false;
  389. }
  390. if (_vce.Status == RState.End)
  391. {
  392. currentSlot = targetSlot;
  393. }
  394. return _vce.Status == RState.End;
  395. }
  396. private bool fnStartSafeUnLoad(object[] param)
  397. {
  398. return _unloadRoutine.Start(param) == RState.Running;
  399. }
  400. private bool fnSafeLoadTimeout(object[] param)
  401. {
  402. RState ret = _loadRoutine.Monitor();
  403. if (ret == RState.Timeout || ret == RState.Failed)
  404. {
  405. PostMsg(VceMSG.Error);
  406. return false;
  407. }
  408. if (ret == RState.End)
  409. {
  410. _CassetteArrive = true;
  411. }
  412. return ret == RState.End;
  413. }
  414. private bool fnStartLoadWithSMIF(object[] param)
  415. {
  416. return _loadwithSMIFRoutine.Start(param) == RState.Running;
  417. }
  418. private bool fnLoadWithSMIFAbort(object[] param)
  419. {
  420. _loadwithSMIFRoutine.Abort();
  421. return true;
  422. }
  423. private bool fnLoadWithSMIFTimeout(object[] param)
  424. {
  425. RState ret = _loadwithSMIFRoutine.Monitor();
  426. if (ret == RState.Timeout || ret == RState.Failed)
  427. {
  428. PostMsg(VceMSG.Error);
  429. return false;
  430. }
  431. if (ret == RState.End)
  432. {
  433. _CassetteArrive = true;
  434. }
  435. return ret == RState.End;
  436. }
  437. private bool fnStartUnLoadWithSMIF(object[] param)
  438. {
  439. return _unloadwithSMIFRoutine.Start(param) == RState.Running;
  440. }
  441. private bool fnUnLoadWithSMIFAbort(object[] param)
  442. {
  443. _unloadwithSMIFRoutine.Abort();
  444. return true;
  445. }
  446. private bool fnUnLoadWithSMIFTimeout(object[] param)
  447. {
  448. RState ret = _unloadwithSMIFRoutine.Monitor();
  449. if (ret == RState.Timeout || ret == RState.Failed)
  450. {
  451. PostMsg(VceMSG.Error);
  452. return false;
  453. }
  454. if (ret == RState.End)
  455. {
  456. _CassetteArrive = false;
  457. WaferManager.Instance.DeleteWafer(_modulename, 0, 25);
  458. }
  459. return ret == RState.End;
  460. }
  461. private bool fnStartSafeLoad(object[] param)
  462. {
  463. return _loadRoutine.Start(param) == RState.Running;
  464. }
  465. private bool fnSafeLoadAbort(object[] param)
  466. {
  467. _loadRoutine.Abort();
  468. return true;
  469. }
  470. private bool fnLoadingPrepareAbort(object[] param)
  471. {
  472. _prepareRoutine.Abort();
  473. return true;
  474. }
  475. private bool fnLoadingPrepareTimeout(object[] param)
  476. {
  477. RState ret = _prepareRoutine.Monitor();
  478. if (ret == RState.Timeout || ret == RState.Failed)
  479. {
  480. PostMsg(VceMSG.Error);
  481. return false;
  482. }
  483. return ret == RState.End;
  484. }
  485. private bool fnStartLoadPrepare(object[] param)
  486. {
  487. return _prepareRoutine.Start(param) == RState.Running;
  488. }
  489. private bool fnReadingMapTimeout(object[] param)
  490. {
  491. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  492. {
  493. PostMsg(VceMSG.Error);
  494. return false;
  495. }
  496. return _vce.Status == RState.End;
  497. }
  498. private bool fnStartReadingMap(object[] param)
  499. {
  500. return _vce.ReadMap();
  501. }
  502. //急停
  503. private bool fnAbort(object[] param)
  504. {
  505. return true;
  506. }
  507. //升降到槽位
  508. private bool fnStartGoto(object[] param)
  509. {
  510. if (_vce.Goto(Convert.ToInt32(param[0])))
  511. {
  512. targetSlot = Convert.ToInt32(param[0]);
  513. return true;
  514. }
  515. else
  516. return false;
  517. }
  518. private bool fnGotingTimeout(object[] param)
  519. {
  520. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  521. {
  522. PostMsg(VceMSG.Error);
  523. return false;
  524. }
  525. if(_vce.Status == RState.End)
  526. currentSlot = targetSlot;
  527. return _vce.Status == RState.End;
  528. }
  529. private bool fnError(object[] param)
  530. {
  531. return true;
  532. }
  533. private bool fnStartHome(object[] param)
  534. {
  535. return _vce.HomeALL();
  536. }
  537. private bool fnHomeTimeout(object[] param)
  538. {
  539. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  540. {
  541. PostMsg(VceMSG.Error);
  542. return false;
  543. }
  544. return _vce.Status == RState.End;
  545. }
  546. private bool fnStartOpenDoor(object[] param)
  547. {
  548. //卡压差
  549. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(_modulename) &&
  550. Singleton<RouteManager>.Instance.seTM.VCEPressure(_modulename) >= SC.GetValue<int>($"{_modulename}.OutDoorOpenPressure"))
  551. {
  552. //卡状态
  553. if (IsIdle || IsError && _vce.IsDashWaferError)
  554. return _vce.OpenDoor();
  555. else
  556. {
  557. LOG.Write(eEvent.WARN_VCE_COMMON_WARN,_modulename,$"Current Status is {(VceSTATE)fsm.State} && not Dash Wafer Error Cannot Open Door.");
  558. return false;
  559. }
  560. }
  561. else
  562. {
  563. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _modulename, $"{_modulename} is not ATM or Pressure not arrive {SC.GetValue<int>($"{_modulename}.OutDoorOpenPressure")}");
  564. return false;
  565. }
  566. }
  567. private bool fnOpenDoorTimeout(object[] param)
  568. {
  569. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  570. {
  571. PostMsg(VceMSG.Error);
  572. return false;
  573. }
  574. return _vce.Status == RState.End;
  575. }
  576. private bool fnStartCloseDoor(object[] param)
  577. {
  578. return _vce.CloseDoor();
  579. }
  580. private bool fnCloseDoorTimeout(object[] param)
  581. {
  582. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  583. {
  584. PostMsg(VceMSG.Error);
  585. return false;
  586. }
  587. return _vce.Status == RState.End;
  588. }
  589. private bool fnStartMapping(object[] param)
  590. {
  591. return _vce.Map();
  592. }
  593. private bool fnMappingTimeout(object[] param)
  594. {
  595. if(_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  596. {
  597. PostMsg(VceMSG.Error);
  598. return false;
  599. }
  600. return _vce.Status == RState.End;
  601. }
  602. private bool fnStartLoading(object[] param)
  603. {
  604. return _vce.Load();
  605. }
  606. private bool fnLoadingTimeout(object[] param)
  607. {
  608. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  609. {
  610. PostMsg(VceMSG.Error);
  611. return false;
  612. }
  613. return _vce.Status == RState.End;
  614. }
  615. private bool fnStartUnLoading(object[] param)
  616. {
  617. return _vce.UnLoad();
  618. }
  619. private bool fnUnLoadingTimeout(object[] param)
  620. {
  621. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  622. {
  623. PostMsg(VceMSG.Error);
  624. return false;
  625. }
  626. return _vce.Status == RState.End;
  627. }
  628. public bool Check(int msg, out string reason, params object[] args)
  629. {
  630. reason = "";
  631. return true;
  632. }
  633. public int Invoke(string function, params object[] args)
  634. {
  635. switch (function)
  636. {
  637. case "Home":
  638. CheckToPostMessage((int)VceMSG.Home);
  639. return (int)VceMSG.Home;
  640. }
  641. return (int)VceMSG.None;
  642. }
  643. public bool CheckToPostMessage(int msg, params object[] args)
  644. {
  645. if (!fsm.FindTransition(fsm.State, msg))
  646. {
  647. LOG.Write(eEvent.WARN_FSM_WARN, _modulename, $"{_modulename} is in {(VceSTATE)fsm.State} state,can not do {(VceMSG)msg}");
  648. return false;
  649. }
  650. Running = true;
  651. fsm.PostMsg(msg, args);
  652. return true;
  653. }
  654. public bool CheckAcked(int msg)
  655. {
  656. return fsm.CheckExecuted(msg);
  657. }
  658. public bool IsPrepareTransferReady(ModuleName module, EnumTransferType transferType, int slot)
  659. {
  660. return false;
  661. }
  662. }
  663. }