VceEntity.cs 32 KB

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