VceEntity.cs 27 KB

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