VceEntity.cs 35 KB

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