VceEntity.cs 35 KB

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