VceEntity.cs 28 KB

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