VceEntity.cs 32 KB

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