VceEntity.cs 26 KB

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