EfemEntity.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. using System;
  2. using System.Diagnostics;
  3. using System.Collections.Generic;
  4. using Aitex.Core.Common;
  5. using Aitex.Core.RT.DataCenter;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.Fsm;
  8. using Aitex.Core.RT.OperationCenter;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.Utilities;
  11. using Aitex.Core.Util;
  12. using Aitex.Core.RT.Log;
  13. using Aitex.Sorter.Common;
  14. using MECF.Framework.Common.Equipment;
  15. using MECF.Framework.Common.Schedulers;
  16. using MECF.Framework.Common.SubstrateTrackings;
  17. using CyberX8_Core;
  18. using CyberX8_RT;
  19. using CyberX8_RT.Devices;
  20. using CyberX8_RT.Devices.YASKAWA;
  21. using CyberX8_RT.Devices.EFEM;
  22. using CyberX8_RT.Modules.LPs;
  23. using CyberX8_RT.Modules.EFEM;
  24. using System.Reflection;
  25. using CyberX8_RT.Modules.Transporter;
  26. using MECF.Framework.Common.Alarm;
  27. using MECF.Framework.Common.CommonData;
  28. using CyberX8_RT.Modules.Loader;
  29. namespace CyberX8_RT.Modules
  30. {
  31. class EfemEntity : Entity, IEntity, IModuleEntity
  32. {
  33. //private int _bigWafer = 0;
  34. //private int _midWafer = 0;
  35. //private int _smallWafer = 0;
  36. private bool _isVacuume = false;
  37. public enum STATE
  38. {
  39. Unknown, // 0
  40. Initializing, // 1
  41. Idle, // 2
  42. Error, // 3
  43. Picking, // 4
  44. Placing, // 5
  45. Aligning, // 6
  46. Mapping, // 7
  47. Init, // 8
  48. Orgshing, // 9
  49. Lifting, // 10
  50. InitingAL, // 11
  51. InitingRB, // 12
  52. Extending, // 13
  53. Retracting, // 14
  54. //SettingLamp, // 15
  55. Swapping,
  56. Gotoing,
  57. Gripping,
  58. Ungripping,
  59. Fliping,
  60. Vacuuming,
  61. Retrying,
  62. ConfirmCompleting,
  63. ErrorPicking,
  64. ErrorPlacing
  65. }
  66. public enum MSG
  67. {
  68. HomeAll, // 0
  69. Pick, // 1
  70. Place, // 2
  71. Align, // 3
  72. ActionDone, // 4
  73. MoveCmd, // 6
  74. Recover, // 8
  75. Goto, // 9
  76. Error, // 10
  77. Online, // 11
  78. CommReady, // 12
  79. Lift, // 13
  80. HomeAL, // 14
  81. HomeRB, // 15
  82. Extend, // 16
  83. Retract, // 17
  84. PMLiftPinUp, // 18
  85. PMLiftPinDown, // 19
  86. TurnOffBuzzer,
  87. Abort,
  88. GotoMap,
  89. Map,
  90. ToInit,
  91. Cool,
  92. Swap,
  93. Grip,
  94. Ungrip,
  95. Flip,
  96. LiftActionDone,
  97. Offline,
  98. SetRobotSpeed,
  99. MapDummy,
  100. Vacuum,
  101. CloseBuzzer,
  102. RobotPowerOn,
  103. Retry,
  104. ConfirmComplete,
  105. BackroundCmd=999,
  106. Load,
  107. Unload,
  108. Dock,
  109. Undock,
  110. Clamp,
  111. Unclamp,
  112. ReadCarrierId,
  113. WriteCarrierID,
  114. ReadTagData,
  115. WriteTagData
  116. }
  117. public enum EfemType
  118. {
  119. FutureEfem = 1,
  120. SunWayEFEM =2
  121. }
  122. public bool IsIdle
  123. {
  124. get { return fsm.State == (int)STATE.Idle; }
  125. }
  126. public bool IsError
  127. {
  128. get { return fsm.State == (int)STATE.Error; }
  129. }
  130. public bool IsInit
  131. {
  132. get { return fsm.State == (int)STATE.Unknown || fsm.State == (int)STATE.Init; }
  133. }
  134. public bool IsBusy
  135. {
  136. get { return !IsInit && !IsError && !IsIdle; }
  137. }
  138. public bool IsAuto { get; } = true;
  139. /// <summary>
  140. /// 是否为工程模式
  141. /// </summary>
  142. public bool IsEngineering { get; } = false;
  143. /// <summary>
  144. /// 是否为产品模式
  145. /// </summary>
  146. public bool IsProduction { get; } = true;
  147. /// <summary>
  148. /// 模块名称
  149. /// </summary>
  150. public ModuleName Module { get; private set; }
  151. public bool IsHomed
  152. {
  153. get { return _isHomed; }
  154. }
  155. public bool IsOnline { get; internal set; }
  156. public bool IsDisable { get; internal set; }
  157. public RState RobotStatus
  158. {
  159. get
  160. {
  161. if (_efem.Status != RState.Running)
  162. {
  163. if (_robotWatch.ElapsedMilliseconds < 200)
  164. return RState.Running;
  165. else
  166. return _efem.Status;
  167. }
  168. else
  169. return RState.Running;
  170. }
  171. }
  172. public bool Check(int msg, out string reason, params object[] args)
  173. {
  174. throw new NotImplementedException();
  175. }
  176. // Fields
  177. private readonly string Name;
  178. private readonly EfemBase _efem;
  179. private readonly LoadPortModule[] _lpms = new LoadPortModule[3];
  180. private readonly DummyDevice[] _dummies = new DummyDevice[2];
  181. private readonly EfemType _efemType;
  182. public EfemBase EfemDevice => _efem;
  183. public EfemType EFEMType => _efemType;
  184. // routine
  185. private readonly EfemPickRoutine _pickRoutine;
  186. private readonly EfemPlaceRoutine _placeRoutine;
  187. private readonly EfemSwapRoutine _swapRoutine;
  188. private readonly EfemHomeRoutine _homeRoutine;
  189. private readonly EFEMAlignRoutine _alignRoutine;
  190. private readonly EfemMapDummyRoutine _mapDummyRoutine;
  191. private readonly EfemRobotMapRoutine _robotMapRoutine;
  192. private readonly EfemVacuumRoutine _vacuumRoutine;
  193. private string LiftMessage;
  194. private Stopwatch _robotWatch = new Stopwatch();
  195. private R_TRIG _robotIdleTrigger = new R_TRIG();
  196. private bool _isHomed = false;
  197. private EfemAutoMessageProcessor _autoMessageProcessor;
  198. private STATE _errorPreState;
  199. // Constructor
  200. public EfemEntity()
  201. {
  202. Module = ModuleName.EFEM;
  203. Name = ModuleName.EFEM.ToString();
  204. InitFsmMap();
  205. _efemType = (EfemType)SC.GetValue<int>($"EFEM.EfemType");
  206. _efem = new SunWayRobot();
  207. _homeRoutine = new EfemHomeRoutine(_efem);
  208. _pickRoutine = new EfemPickRoutine(_efem);
  209. _placeRoutine = new EfemPlaceRoutine(_efem);
  210. _swapRoutine = new EfemSwapRoutine(_efem);
  211. _alignRoutine = new EFEMAlignRoutine(_efem);
  212. _mapDummyRoutine = new EfemMapDummyRoutine(_efem);
  213. _vacuumRoutine = new EfemVacuumRoutine(_efem);
  214. _autoMessageProcessor =new EfemAutoMessageProcessor(_efem);
  215. }
  216. public LoadPortModule GetLoadportModule(int lpNumber)
  217. {
  218. if (lpNumber < 0|| _lpms.Length<=lpNumber)
  219. {
  220. return null;
  221. }
  222. return _lpms[lpNumber];
  223. }
  224. public DummyDevice GetDummyDevice(int dummyNumber)
  225. {
  226. if (dummyNumber < 0||_dummies.Length<=dummyNumber)
  227. {
  228. return null;
  229. }
  230. return _dummies[dummyNumber];
  231. }
  232. protected override bool Init()
  233. {
  234. _lpms[0] = new LoadPortModule(ModuleName.LP1, _efem);
  235. _lpms[1] = new LoadPortModule(ModuleName.LP2, _efem);
  236. _lpms[2] = new LoadPortModule(ModuleName.LP3, _efem);
  237. _dummies[0] = new DummyDevice(ModuleName.Dummy1);
  238. _dummies[1] = new DummyDevice(ModuleName.Dummy2);
  239. _lpms[0].Initialize();
  240. _lpms[1].Initialize();
  241. _lpms[2].Initialize();
  242. OP.Subscribe($"{ModuleName.EFEM}.{EfemOperation.Home}", (cmd, args) => { PostMsg(MSG.HomeAll); return true; });
  243. OP.Subscribe($"{ModuleName.EFEM}.{EfemOperation.ClearError}", (cmd, args) => { PostMsg(MSG.Recover); return true; });
  244. OP.Subscribe($"{ModuleName.EFEM}.{EfemOperation.TurnOffBuzzer}", (cmd, args) => { PostMsg(MSG.CloseBuzzer); return true; });
  245. OP.Subscribe($"{ModuleName.EFEM}.Online", (cmd, args) =>
  246. {
  247. PostMsg(MSG.Online, args[0]); return true;
  248. });
  249. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Pick}", (cmd, args) => { CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_COMMON_FAILED,"EFEM",(int)MSG.Pick, args[0]); return true; });
  250. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Place}", (cmd, args) => { CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_COMMON_FAILED, "EFEM", (int)MSG.Place, args[0]); return true; });
  251. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Swap}", (cmd, args) => { PostMsg(MSG.Swap, args[0]); return true; });
  252. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.DummyMap}", (cmd, args) => { CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_COMMON_FAILED, "EFEM", (int)MSG.MapDummy); return true; });
  253. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Speed}", (cmd, args) => {
  254. return _efem.SetRobotSpeed(ModuleName.EfemRobot, (int)args[0]); });
  255. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Vacuum}", (cmd, args) => {
  256. return _efem.Vacuum(ModuleName.EfemRobot, (bool)args[1]); });
  257. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.PowerOn}", (cmd, args) => {
  258. return _efem.RobotPowerOn(ModuleName.EfemRobot, (bool)args[0]); });
  259. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Abort}", (cmd, args) => { PostMsg(MSG.Abort); return true; });
  260. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Home}", (cmd, args) => { PostMsg(MSG.HomeRB); return true; });
  261. OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Grip}", (cmd, args) =>
  262. {
  263. bool isGrip = ((string)args[0]).ToLower() == "on";
  264. PostMsg(isGrip ? MSG.Grip : MSG.Ungrip, args[1]);
  265. return true;
  266. });
  267. //OP.Subscribe($"{ModuleName.EfemRobot}.{EfemOperation.Flip}", (cmd, args) => { PostMsg(MSG.Flip, args[0]); return true; });
  268. OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Home}", (cmd, args) => { PostMsg(MSG.HomeAL, ModuleName.Aligner1); return true; });
  269. OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Align}", (cmd, args) => { CheckToPostMessage<STATE,MSG>(eEvent.ERR_EFEM_COMMON_FAILED,ModuleName.EFEM.ToString(),(int)MSG.Align, ModuleName.Aligner1, args[0], args[1]); return true; });
  270. //OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}", (cmd, args) => { CheckToPostMessage<STATE,MSG>(eEvent.ERR_EFEM_COMMON_FAILED,ModuleName.EFEM.ToString(),(int)MSG.Vacuum, args); return true; });
  271. OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}", (cmd, args) => { return VacuumAction(args); });
  272. DATA.Subscribe($"{Name}.FsmState", () => ((STATE)fsm.State).ToString(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
  273. DATA.Subscribe($"{Name}.FsmPrevState", () => ((STATE)fsm.PrevState).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  274. DATA.Subscribe($"{Name}.FsmLastMessage", GetFsmLastMessage, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  275. DATA.Subscribe($"{Name}.RobotMoveAction", () => (_efem.TMRobotMoveInfo), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  276. DATA.Subscribe($"{Name}.State", () => ((STATE)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  277. DATA.Subscribe($"{Name}.IsAlarm", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  278. DATA.Subscribe($"{Name}.IsInit", () => IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  279. DATA.Subscribe($"{Name}.IsIdle", () => IsIdle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  280. DATA.Subscribe($"{Name}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  281. DATA.Subscribe($"{Name}.IsOnline", () => IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  282. DATA.Subscribe($"{Name}.IsHomed", () => _isHomed, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  283. DATA.Subscribe($"{Name}.RobotSpeed",()=>IsIdle?SC.GetValue<int>("EFEM.DefaultMoveSpeedInPercent"):0);
  284. _robotWatch.Restart();
  285. return true;
  286. }
  287. private void InitFsmMap()
  288. {
  289. fsm = new StateMachine<EfemEntity>("EFEM", (int)STATE.Unknown, 50);
  290. fsm.EnableRepeatedMsg(true);
  291. AnyStateTransition(FSM_MSG.TIMER, fnMonitor, FSM_STATE.SAME);
  292. AnyStateTransition(MSG.TurnOffBuzzer, fnTurnOffBuzzer, FSM_STATE.SAME);
  293. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  294. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  295. AnyStateTransition(MSG.Abort, fnAbortRobot, FSM_STATE.SAME);
  296. AnyStateTransition(MSG.ToInit, fnToInit, STATE.Init);
  297. AnyStateTransition(MSG.BackroundCmd, fnBackroundCommand, FSM_STATE.SAME);
  298. AnyStateTransition(MSG.CloseBuzzer, fnCloseBuzzer, FSM_STATE.SAME);
  299. Transition(STATE.Unknown,MSG.CommReady, fnCommReady, STATE.Init);
  300. //Error
  301. Transition(STATE.Error, MSG.Recover, fnRecover, STATE.Idle);
  302. // Home
  303. Transition(STATE.Init, MSG.HomeAll, fnHomeAll, STATE.Initializing);
  304. Transition(STATE.Idle, MSG.HomeAll, fnHomeAll, STATE.Initializing);
  305. Transition(STATE.Error, MSG.HomeAll, fnHomeAll, STATE.Initializing);
  306. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHomingTimeout, STATE.Idle);
  307. // Home Robot
  308. Transition(STATE.Error, MSG.HomeRB, fnHomeRobot, STATE.InitingRB);
  309. Transition(STATE.Idle, MSG.HomeRB, fnHomeRobot, STATE.InitingRB);
  310. Transition(STATE.InitingRB, FSM_MSG.TIMER, fnHomingRobotTimeout, STATE.Idle);
  311. // Home Aligner
  312. Transition(STATE.Idle, MSG.HomeAL, fnHomeAligner, STATE.InitingAL);
  313. Transition(STATE.InitingAL, FSM_MSG.TIMER, fnHomingAlignTimeout, STATE.Idle);
  314. // Pick wafer
  315. Transition(STATE.Idle, MSG.Pick, FnStartPick, STATE.Picking);
  316. Transition(STATE.Picking, FSM_MSG.TIMER, FnPickTimeout, STATE.Idle);
  317. Transition(STATE.Picking, MSG.Abort, FnAbortPick, STATE.Idle);
  318. Transition(STATE.Error, MSG.Pick, FnErrorStartPick, STATE.ErrorPicking);
  319. Transition(STATE.ErrorPicking, FSM_MSG.TIMER, FnErrorPickTimeout, STATE.Error);
  320. Transition(STATE.ErrorPicking, MSG.Abort, FnErrorAbortPick, STATE.Error);
  321. // Place wafer
  322. Transition(STATE.Idle, MSG.Place, FnStartPlace, STATE.Placing);
  323. Transition(STATE.Placing, FSM_MSG.TIMER, FnPlaceTimeout, STATE.Idle);
  324. Transition(STATE.Placing, MSG.Abort, FnAbortPlace, STATE.Idle);
  325. Transition(STATE.Error, MSG.Place, FnErrorStartPlace, STATE.ErrorPlacing);
  326. Transition(STATE.ErrorPlacing, FSM_MSG.TIMER, FnErrorPlaceTimeout, STATE.Error);
  327. Transition(STATE.ErrorPlacing, MSG.Abort, FnErrorAbortPlace, STATE.Error);
  328. // Swap wafer with LL sequence
  329. Transition(STATE.Idle, MSG.Swap, FnStartSwap, STATE.Swapping);
  330. Transition(STATE.Swapping, FSM_MSG.TIMER, FnSwapTimeout, STATE.Idle);
  331. Transition(STATE.Swapping, MSG.Abort, FnAbortSwap, STATE.Idle);
  332. // Goto
  333. Transition(STATE.Idle, MSG.Goto, fnGoto, STATE.Gotoing);
  334. Transition(STATE.Gotoing, MSG.ActionDone, fnActionDone, STATE.Idle);
  335. // Map
  336. Transition(STATE.Idle, MSG.Map, fnMap, STATE.Mapping);
  337. Transition(STATE.Mapping, MSG.ActionDone, fnActionDone, STATE.Idle);
  338. // Grip
  339. Transition(STATE.Idle, MSG.Grip, fnGrip, STATE.Gripping);
  340. Transition(STATE.Gripping, MSG.ActionDone, fnActionDone, STATE.Idle);
  341. // Ungrip
  342. Transition(STATE.Idle, MSG.Ungrip, fnUngrip, STATE.Ungripping);
  343. Transition(STATE.Ungripping, MSG.ActionDone, fnActionDone, STATE.Idle);
  344. // Aligner
  345. Transition(STATE.Idle, MSG.Lift, fnLift, STATE.Lifting);
  346. //Transition(STATE.Lifting, MSG.LiftActionDone, fnActionDone, STATE.Idle);
  347. Transition(STATE.Lifting, FSM_MSG.TIMER, fnLiftTimeout, STATE.Idle);
  348. Transition(STATE.Idle, MSG.Align, fnAlign, STATE.Aligning);
  349. Transition(STATE.Aligning, FSM_MSG.TIMER, fnAlignTimeout, STATE.Idle);
  350. Transition(STATE.Aligning, MSG.ActionDone, fnActionDone, STATE.Idle);
  351. //MapDummy
  352. Transition(STATE.Idle, MSG.MapDummy, MapDummy, STATE.Mapping);
  353. Transition(STATE.Mapping, FSM_MSG.TIMER, MapDummyTimeout, STATE.Idle);
  354. //Vacuum
  355. //Transition(STATE.Init, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
  356. //Transition(STATE.Idle, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
  357. //Transition(STATE.Error, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
  358. //Transition(STATE.Vacuuming, FSM_MSG.TIMER, VacuumActionTimeout, STATE.Idle);
  359. //Retry
  360. Transition(STATE.Error, MSG.Retry, NullFunc, STATE.Retrying);
  361. Transition(STATE.Retrying, FSM_MSG.TIMER, EfemRetry, STATE.Retrying);
  362. Transition(STATE.Retrying, MSG.Align, RetryAlign, STATE.Aligning);
  363. Transition(STATE.Retrying, MSG.Pick, RetryPick, STATE.Picking);
  364. Transition(STATE.Retrying, MSG.Place, RetryPlace, STATE.Placing);
  365. //ConfirmComplete
  366. Transition(STATE.Init, MSG.ConfirmComplete, ClearModuleAlarm, STATE.Init);
  367. Transition(STATE.Idle, MSG.ConfirmComplete, ClearModuleAlarm, STATE.Idle);
  368. Transition(STATE.Error, MSG.ConfirmComplete, NullFunc, STATE.ConfirmCompleting);
  369. Transition(STATE.ConfirmCompleting, FSM_MSG.TIMER, ConfirmComplete, STATE.ConfirmCompleting);
  370. Transition(STATE.ConfirmCompleting, MSG.Align, ConfirmAlign, STATE.Idle);
  371. Transition(STATE.ConfirmCompleting, MSG.Pick, ConfirmPickup, STATE.Idle);
  372. Transition(STATE.ConfirmCompleting, MSG.Place, ConfirmPlace, STATE.Idle);
  373. EnumLoop<STATE>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
  374. EnumLoop<MSG>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
  375. Running = true;
  376. }
  377. private bool fnCommReady(object[] param)
  378. {
  379. return true;
  380. }
  381. private bool fnCloseBuzzer(object[] param)
  382. {
  383. return _efem.CloseBuzzer();
  384. }
  385. private bool fnHomeAll(object[] param)
  386. {
  387. _isHomed = false;
  388. return _homeRoutine.Start(ModuleName.EFEM) == RState.Running;
  389. }
  390. private bool fnHomingTimeout(object[] param)
  391. {
  392. RState ret = _homeRoutine.Monitor();
  393. if (ret == RState.Failed || ret == RState.Timeout)
  394. {
  395. PostMsg(MSG.Error);
  396. return false;
  397. }
  398. bool result= ret == RState.End;
  399. if(result)
  400. {
  401. _isHomed= true;
  402. RecoverLPStatus();
  403. }
  404. return result;
  405. }
  406. private void RecoverLPStatus()
  407. {
  408. _lpms[0].PostMsg(LoadPortModule.MSG.EnterIdle);
  409. _lpms[1].PostMsg(LoadPortModule.MSG.EnterIdle);
  410. _lpms[2].PostMsg(LoadPortModule.MSG.EnterIdle);
  411. }
  412. private bool fnHomeRobot(object[] param)
  413. {
  414. if (_isHomed)
  415. {
  416. return _homeRoutine.Start(ModuleName.EfemRobot) == RState.Running;
  417. }
  418. else
  419. {
  420. return false;
  421. }
  422. }
  423. private bool fnHomingRobotTimeout(object[] param)
  424. {
  425. RState ret = _homeRoutine.Monitor();
  426. if (ret == RState.Failed || ret == RState.Timeout)
  427. {
  428. PostMsg(MSG.Error);
  429. return false;
  430. }
  431. bool result = ret == RState.End;
  432. if (result)
  433. {
  434. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Idle.ToString());
  435. }
  436. return result;
  437. }
  438. private bool fnHomeAligner(object[] param)
  439. {
  440. // module
  441. ModuleName unit = ModuleName.EFEM;
  442. if (param[0] is string s1)
  443. unit = ModuleNameString.ToEnum(s1);
  444. else if (param[0] is ModuleName mod)
  445. unit = mod;
  446. else
  447. throw new ArgumentException("Argument error");
  448. return _homeRoutine.Start(unit) == RState.Running;
  449. }
  450. private bool fnHomingAlignTimeout(object[] param)
  451. {
  452. RState ret = _homeRoutine.Monitor();
  453. if (ret == RState.Failed || ret == RState.Timeout)
  454. {
  455. PostMsg(MSG.Error);
  456. return false;
  457. }
  458. bool result = ret == RState.End;
  459. if (result)
  460. {
  461. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Idle.ToString());
  462. }
  463. return result;
  464. }
  465. private bool fnActionDone(object[] param)
  466. {
  467. return false;
  468. }
  469. public bool CheckToPostMessage(int msg, params object[] args)
  470. {
  471. if (!fsm.FindTransition(fsm.State, msg))
  472. {
  473. LOG.Write(eEvent.WARN_EFEM_COMMON_WARN, ModuleName.EFEM, $"{Name} is in {(STATE)fsm.State} state,can not do {(MSG)msg}");
  474. return false;
  475. }
  476. Running = true;
  477. fsm.PostMsg(msg, args);
  478. return true;
  479. }
  480. private bool fnMonitor(object[] param)
  481. {
  482. if (_isVacuume)
  483. {
  484. VacuumActionTimeout();
  485. _isVacuume = false;
  486. }
  487. // robot idle check
  488. _robotIdleTrigger.CLK = _efem.Status != RState.Running;
  489. if (_robotIdleTrigger.Q)
  490. {
  491. _robotWatch.Restart();
  492. LOG.WriteLog(eEvent.EV_EFEM_ROBOT, Module.ToString(), $"robot status changed to {_efem.Status}");
  493. }
  494. _autoMessageProcessor.Monitor();
  495. return true;
  496. }
  497. private bool fnOnline(object[] param)
  498. {
  499. bool bOnlineFlag = (bool)param[0];
  500. if (_efem is EfemBase efem)
  501. {
  502. efem.SetOnline(bOnlineFlag);
  503. }
  504. IsOnline = bOnlineFlag;
  505. return true;
  506. }
  507. private string GetFsmLastMessage()
  508. {
  509. int msg = fsm.LastMsg;
  510. if (msg >= (int)MSG.HomeAll && msg <= (int)MSG.Error)
  511. return ((MSG)msg).ToString();
  512. if (msg == (int)FSM_MSG.TIMER)
  513. return "Timer";
  514. return msg.ToString();
  515. }
  516. private bool fnError(object[] param)
  517. {
  518. _errorPreState = (STATE)fsm.State;
  519. string error = (param != null && param.Length != 0) ? param[0].ToString() : "";
  520. if (Singleton<RouteManager>.Instance.IsAutoRunning)
  521. {
  522. int msg = 0;
  523. if (_errorPreState == STATE.Picking)
  524. {
  525. msg = (int)MSG.Pick;
  526. }
  527. else if (_errorPreState == STATE.Aligning)
  528. {
  529. msg= (int)MSG.Align;
  530. }
  531. else if (_errorPreState == STATE.Placing)
  532. {
  533. msg = (int)MSG.Place;
  534. }
  535. else
  536. {
  537. error = $"{error}\r\n Plase Home Robot back to idle state";
  538. }
  539. AlarmList alarmList = new AlarmList(Module.ToString(), ((STATE)fsm.State).ToString(), msg,
  540. error, 0, (int)AlarmType.Error);
  541. AlarmListManager.Instance.AddAlarm(alarmList);
  542. }
  543. return true;
  544. }
  545. private bool fnToInit(object[] param)
  546. {
  547. return true;
  548. }
  549. private bool fnRecover(object[] param)
  550. {
  551. bool result=_efem.ClearError();
  552. if (result)
  553. {
  554. PostMsg(MSG.ToInit);
  555. }
  556. return result;
  557. }
  558. private bool fnAbortRobot(object[] param)
  559. {
  560. //_efem.ExecuteAction();
  561. return true;
  562. }
  563. private bool fnBackroundCommand(object[] param)
  564. {
  565. _autoMessageProcessor.SendAutoCommandMessage(param);
  566. return true;
  567. }
  568. private bool fnRobotPowerOn(object[] param)
  569. {
  570. return _efem.RobotPowerOn(ModuleName.EfemRobot, (bool)param[0]);
  571. }
  572. private bool fnSetLED(object[] param)
  573. {
  574. LightType light = (LightType)param[0];
  575. LightStatus st = (LightStatus)param[1];
  576. return _efem.SetLamp(light, st);
  577. }
  578. private bool fnTurnOffBuzzer(object[] param)
  579. {
  580. return false;
  581. }
  582. private bool FnStartPick(object[] param)
  583. {
  584. return _pickRoutine.Start(param) == RState.Running;
  585. }
  586. private bool FnErrorStartPick(object[] param)
  587. {
  588. if (!_isHomed)
  589. {
  590. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module.ToString(), "EFEM is not homed");
  591. return false;
  592. }
  593. _efem.Reset();
  594. return _pickRoutine.Start(param) == RState.Running;
  595. }
  596. /// <summary>
  597. /// Retry Pick
  598. /// </summary>
  599. /// <param name="param"></param>
  600. /// <returns></returns>
  601. private bool RetryPick(object[] param)
  602. {
  603. int stepIndex = (int)param[0];
  604. return _pickRoutine.Retry(stepIndex) == RState.Running;
  605. }
  606. private bool FnPickTimeout(object[] param)
  607. {
  608. RState ret = _pickRoutine.Monitor();
  609. if (ret == RState.Failed || ret == RState.Timeout)
  610. {
  611. PostMsg(MSG.Error,_pickRoutine.ErrorMsg);
  612. return false;
  613. }
  614. if (ret == RState.End)
  615. {
  616. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Picking.ToString());
  617. }
  618. return ret == RState.End;
  619. }
  620. private bool FnErrorPickTimeout(object[] param)
  621. {
  622. RState ret = _pickRoutine.Monitor();
  623. if (ret == RState.Failed || ret == RState.Timeout)
  624. {
  625. PostMsg(MSG.Error, _pickRoutine.ErrorMsg);
  626. return false;
  627. }
  628. return ret == RState.End;
  629. }
  630. /// <summary>
  631. /// 确认Pick是否完成
  632. /// </summary>
  633. /// <param name="param"></param>
  634. /// <returns></returns>
  635. private bool ConfirmPickup(object[] param)
  636. {
  637. int stepIdex = (int)param[0];
  638. bool result = _pickRoutine.CheckCompleteCondition(stepIdex);
  639. if (!result)
  640. {
  641. PostMsg(MSG.Error,_pickRoutine.ErrorMsg);
  642. }
  643. else
  644. {
  645. if (Singleton<RouteManager>.Instance.IsAutoRunning)
  646. {
  647. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Picking.ToString());
  648. }
  649. }
  650. return result;
  651. }
  652. private bool FnAbortPick(object[] param)
  653. {
  654. _pickRoutine.Abort();
  655. return true;
  656. }
  657. private bool FnErrorAbortPick(object[] param)
  658. {
  659. _pickRoutine.Abort();
  660. return true;
  661. }
  662. private bool FnStartPlace(object[] param)
  663. {
  664. return _placeRoutine.Start(param) == RState.Running;
  665. }
  666. private bool FnErrorStartPlace(object[] param)
  667. {
  668. if(!_isHomed)
  669. {
  670. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module.ToString(), "EFEM is not homed");
  671. return false;
  672. }
  673. _efem.Reset();
  674. return _placeRoutine.Start(param) == RState.Running;
  675. }
  676. /// <summary>
  677. /// Retry Place
  678. /// </summary>
  679. /// <param name="param"></param>
  680. /// <returns></returns>
  681. private bool RetryPlace(object[] param)
  682. {
  683. int stepIndex = (int)param[0];
  684. return _placeRoutine.Retry(stepIndex) == RState.Running;
  685. }
  686. private bool FnPlaceTimeout(object[] param)
  687. {
  688. RState ret = _placeRoutine.Monitor();
  689. if (ret == RState.Failed || ret == RState.Timeout)
  690. {
  691. PostMsg(MSG.Error,_placeRoutine.ErrorMsg);
  692. return false;
  693. }
  694. if (ret == RState.End)
  695. {
  696. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Placing.ToString());
  697. }
  698. return ret == RState.End;
  699. }
  700. private bool FnErrorPlaceTimeout(object[] param)
  701. {
  702. RState ret = _placeRoutine.Monitor();
  703. if (ret == RState.Failed || ret == RState.Timeout)
  704. {
  705. PostMsg(MSG.Error, _placeRoutine.ErrorMsg);
  706. return false;
  707. }
  708. return ret == RState.End;
  709. }
  710. /// <summary>
  711. /// 确认Place是否完成
  712. /// </summary>
  713. /// <param name="param"></param>
  714. /// <returns></returns>
  715. private bool ConfirmPlace(object[] param)
  716. {
  717. int stepIdex = (int)param[0];
  718. bool result = _placeRoutine.CheckCompleteCondition(stepIdex);
  719. if (!result)
  720. {
  721. PostMsg(MSG.Error, _placeRoutine.ErrorMsg);
  722. }
  723. else
  724. {
  725. if (Singleton<RouteManager>.Instance.IsAutoRunning)
  726. {
  727. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Picking.ToString());
  728. }
  729. }
  730. return result;
  731. }
  732. private bool FnAbortPlace(object[] param)
  733. {
  734. _placeRoutine.Abort();
  735. return true;
  736. }
  737. private bool FnErrorAbortPlace(object[] param)
  738. {
  739. _placeRoutine.Abort();
  740. return true;
  741. }
  742. private bool FnStartSwap(object[] param)
  743. {
  744. return _swapRoutine.Start(param) == RState.Running;
  745. }
  746. private bool FnSwapTimeout(object[] param)
  747. {
  748. RState ret = _swapRoutine.Monitor();
  749. if (ret == RState.Failed || ret == RState.Timeout)
  750. {
  751. PostMsg(MSG.Error);
  752. return false;
  753. }
  754. return ret == RState.End;
  755. }
  756. private bool FnAbortSwap(object[] param)
  757. {
  758. _swapRoutine.Abort();
  759. return true;
  760. }
  761. private bool fnGoto(object[] param)
  762. {
  763. // module
  764. ModuleName unit = ModuleName.EFEM;
  765. if (param[0] is string s1)
  766. unit = ModuleNameString.ToEnum(s1);
  767. else if (param[0] is ModuleName mod)
  768. unit = mod;
  769. else
  770. throw new ArgumentException("Argument error");
  771. _efem.Goto(unit, Hand.Blade1);
  772. return true;
  773. }
  774. private bool fnLift(object[] param)
  775. {
  776. // module
  777. ModuleName unit = ModuleName.EFEM;
  778. if (param[0] is string s1)
  779. unit = ModuleNameString.ToEnum(s1);
  780. else if (param[0] is ModuleName mod)
  781. unit = mod;
  782. else
  783. throw new ArgumentException("Argument error");
  784. bool isUp = true;
  785. if (param.Length > 1)
  786. {
  787. isUp = (bool) param[1];
  788. }
  789. if (isUp)
  790. {
  791. if (!_efem.SetPinUp(unit))
  792. return false;
  793. }
  794. else
  795. {
  796. if (!_efem.SetPinDown(unit))
  797. return false;
  798. }
  799. LiftMessage = isUp ? "Up" : "Down";
  800. return true;
  801. }
  802. private bool fnLiftTimeout(object[] param)
  803. {
  804. if (LiftMessage == "Up")
  805. {
  806. return _efem.LiftIsDown == false && _efem.LiftIsUp == true;
  807. }
  808. else if (LiftMessage == "Down")
  809. {
  810. return _efem.LiftIsDown == true && _efem.LiftIsUp == false;
  811. }
  812. return false;
  813. }
  814. private bool fnAlign(object[] param)
  815. {
  816. return _alignRoutine.Start(param) == RState.Running;
  817. }
  818. private bool fnAlignTimeout(object[] param)
  819. {
  820. RState ret = _alignRoutine.Monitor();
  821. if (ret == RState.Failed || ret == RState.Timeout)
  822. {
  823. PostMsg(MSG.Error,_alignRoutine.ErrorMsg);
  824. return false;
  825. }
  826. if (ret == RState.End)
  827. {
  828. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Aligning.ToString());
  829. }
  830. return ret == RState.End;
  831. }
  832. /// <summary>
  833. /// Retry Align
  834. /// </summary>
  835. /// <param name="param"></param>
  836. /// <returns></returns>
  837. private bool RetryAlign(object[] param)
  838. {
  839. int stepIndex = (int)param[0];
  840. return _alignRoutine.Retry(stepIndex) == RState.Running;
  841. }
  842. /// <summary>
  843. /// 确认Align是否完成
  844. /// </summary>
  845. /// <param name="param"></param>
  846. /// <returns></returns>
  847. private bool ConfirmAlign(object[] param)
  848. {
  849. int stepIdex = (int)param[0];
  850. bool result = _alignRoutine.CheckCompleteCondition(stepIdex);
  851. if (!result)
  852. {
  853. PostMsg(MSG.Error, _alignRoutine.ErrorMsg);
  854. }
  855. else
  856. {
  857. if (Singleton<RouteManager>.Instance.IsAutoRunning)
  858. {
  859. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), STATE.Aligning.ToString());
  860. }
  861. }
  862. return result;
  863. }
  864. private bool MapDummyTimeout(object[] param)
  865. {
  866. RState ret = _mapDummyRoutine.Monitor();
  867. if (ret == RState.Failed || ret == RState.Timeout)
  868. {
  869. PostMsg(MSG.Error);
  870. return false;
  871. }
  872. return ret == RState.End;
  873. }
  874. private bool VacuumActionTimeout()
  875. {
  876. RState ret = _vacuumRoutine.Monitor();
  877. if (ret == RState.Failed || ret == RState.Timeout)
  878. {
  879. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "Vacuum");
  880. return false;
  881. }
  882. return ret == RState.End;
  883. }
  884. private bool fnMap(object[] param)
  885. {
  886. // module
  887. ModuleName unit = ModuleName.EFEM;
  888. if (param[0] is string s1)
  889. unit = ModuleNameString.ToEnum(s1);
  890. else if (param[0] is ModuleName mod)
  891. unit = mod;
  892. else
  893. throw new ArgumentException("Argument error");
  894. if (!_efem.Map(unit))
  895. return false;
  896. return true;
  897. }
  898. private bool MapDummy(object[] param)
  899. {
  900. return _mapDummyRoutine.Start()==RState.Running;
  901. }
  902. private bool VacuumAction(object[] param)
  903. {
  904. ModuleName vacuumModule = (ModuleName)param[0];
  905. bool vacuum=(bool)param[1];
  906. bool result = _vacuumRoutine.Start(vacuumModule, vacuum) == RState.Running;
  907. if (result)
  908. {
  909. _isVacuume = true;
  910. }
  911. return result;
  912. }
  913. private bool fnGrip(object[] param)
  914. {
  915. Hand arm = (Hand)Enum.Parse(typeof(Hand), (string)param[0]);
  916. if (!_efem.Grip(arm, true))
  917. return false;
  918. return true;
  919. }
  920. public int SendEfemAutoCommand(params object[] args)
  921. {
  922. if (CheckToPostMessage((int)MSG.BackroundCmd, args))
  923. return (int)MSG.BackroundCmd;
  924. return (int)FSM_MSG.NONE;
  925. }
  926. private bool fnUngrip(object[] param)
  927. {
  928. Hand arm = (Hand)Enum.Parse(typeof(Hand), (string)param[0]);
  929. if (!_efem.Grip(arm, false))
  930. return false;
  931. return true;
  932. }
  933. #region EfemRetry
  934. /// <summary>
  935. /// Retry
  936. /// </summary>
  937. /// <param name="param"></param>
  938. /// <returns></returns>
  939. private bool EfemRetry(object[] param)
  940. {
  941. AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
  942. if (alarmList != null)
  943. {
  944. CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), alarmList.ModuleCmd,
  945. alarmList.ModuleStep);
  946. }
  947. return false;
  948. }
  949. #endregion
  950. #region ConfirmComplete
  951. /// <summary>
  952. /// 确认是否完成
  953. /// </summary>
  954. /// <param name="param"></param>
  955. /// <returns></returns>
  956. private bool ConfirmComplete(object[] param)
  957. {
  958. AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
  959. if (alarmList != null)
  960. {
  961. if (alarmList.ModuleState == STATE.Picking.ToString())
  962. {
  963. CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), (int)MSG.Pick, alarmList.ModuleStep);
  964. }
  965. else if (alarmList.ModuleState == STATE.Placing.ToString())
  966. {
  967. CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), (int)MSG.Place, alarmList.ModuleStep);
  968. }
  969. else if (alarmList.ModuleState == STATE.Aligning.ToString())
  970. {
  971. CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), (int)MSG.Align, alarmList.ModuleStep);
  972. }
  973. else
  974. {
  975. PostMsg(PUFSTATE.Error);
  976. }
  977. }
  978. return false;
  979. }
  980. /// <summary>
  981. /// 清除报警
  982. /// </summary>
  983. /// <param name="param"></param>
  984. /// <returns></returns>
  985. private bool ClearModuleAlarm(object[] param)
  986. {
  987. AlarmList alarmList = AlarmListManager.Instance.GetAlarmListByModule(Module.ToString());
  988. if (alarmList != null)
  989. {
  990. AlarmListManager.Instance.CheckModuleAlamAndRemove(Module.ToString(), "");
  991. }
  992. return true;
  993. }
  994. #endregion
  995. public int Invoke(string function, params object[] args)
  996. {
  997. switch (function)
  998. {
  999. case "HomeAll":
  1000. if (IsIdle)
  1001. {
  1002. return (int)FSM_MSG.NONE;
  1003. }
  1004. if (CheckToPostMessage((int)MSG.HomeAll))
  1005. {
  1006. return (int)MSG.HomeAll;
  1007. }
  1008. else
  1009. {
  1010. return (int)FSM_MSG.NONE;
  1011. }
  1012. case "Retry":
  1013. if (CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), (int)MSG.Retry, args))
  1014. {
  1015. return (int)MSG.Retry;
  1016. }
  1017. else
  1018. {
  1019. return (int)FSM_MSG.NONE;
  1020. }
  1021. case "ConfirmComplete":
  1022. if (CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_ROBOT, Module.ToString(), (int)MSG.ConfirmComplete, args))
  1023. {
  1024. return (int)MSG.ConfirmComplete;
  1025. }
  1026. else
  1027. {
  1028. return (int)FSM_MSG.NONE;
  1029. }
  1030. }
  1031. return (int)FSM_MSG.NONE;
  1032. }
  1033. public bool CheckAcked(int msg)
  1034. {
  1035. return fsm.CheckExecuted(msg);
  1036. }
  1037. internal void InvokeReset()
  1038. {
  1039. if (fsm.State == (int) STATE.Error)
  1040. {
  1041. PostMsg((int)MSG.Recover);
  1042. }
  1043. }
  1044. public int InvokeAlign(string module, int reserv, float time)
  1045. {
  1046. if (CheckToPostMessage((int)MSG.Align, module, reserv, time))
  1047. return (int)MSG.Align;
  1048. return (int)FSM_MSG.NONE;
  1049. }
  1050. public int InvokeLiftDown(string module)
  1051. {
  1052. if (CheckToPostMessage((int)MSG.Lift, module, false))
  1053. return (int)MSG.Lift;
  1054. return (int)FSM_MSG.NONE;
  1055. }
  1056. public int InvokePick(ModuleName source, int slot, Hand hand, WaferSize size)
  1057. {
  1058. if (CheckToPostMessage((int)MSG.Pick, source, slot, hand, size))
  1059. return (int)MSG.Pick;
  1060. return (int)FSM_MSG.NONE;
  1061. }
  1062. public int InvokeGoto(ModuleName source, int slot)
  1063. {
  1064. if (CheckToPostMessage((int)MSG.Goto, source, slot))
  1065. return (int)MSG.Goto;
  1066. return (int)FSM_MSG.NONE;
  1067. }
  1068. public int InvokePlace(ModuleName target, int slot, Hand hand, WaferSize size)
  1069. {
  1070. if (CheckToPostMessage((int)MSG.Place, target, slot, hand, size))
  1071. return (int)MSG.Place;
  1072. return (int)FSM_MSG.NONE;
  1073. }
  1074. public int InvokePickAndPlace(ModuleName targetModule, Hand pickHand, int pickSlot, Hand placeHand, int placeSlot, WaferSize size)
  1075. {
  1076. if (CheckToPostMessage((int)MSG.Swap, targetModule, pickSlot, pickHand, placeHand, placeSlot, size))
  1077. return (int)MSG.Swap;
  1078. return (int)FSM_MSG.NONE;
  1079. }
  1080. public int InvokeMap(string target )
  1081. {
  1082. if (CheckToPostMessage((int)MSG.Map, target ))
  1083. return (int)MSG.Map;
  1084. return (int)FSM_MSG.NONE;
  1085. }
  1086. public int InvokeFlip(Hand hand)
  1087. {
  1088. if (CheckToPostMessage((int)MSG.Flip, hand))
  1089. return (int)MSG.Flip;
  1090. return (int)FSM_MSG.NONE;
  1091. }
  1092. public bool IsPrepareTransferReady(ModuleName module, EnumTransferType type, int slot)
  1093. {
  1094. //if (type == EnumTransferType.Pick)
  1095. //{
  1096. // //需要补充:判断LP 放好了,而且已经map过。
  1097. // return _efem[module].HasCassette && _efem[module].IsMapped;
  1098. //}
  1099. //else if (type == EnumTransferType.Place)
  1100. //{
  1101. // //需要补充:判断LP 放好了,而且已经map过。
  1102. // return _efem[module].HasCassette && _efem[module].IsMapped;
  1103. //}
  1104. return false;
  1105. }
  1106. internal bool CheckReadyRunNewJob(ModuleName module)
  1107. {
  1108. //???
  1109. return true;
  1110. }
  1111. internal bool CheckReadyTransfer(ModuleName module)
  1112. {
  1113. //return _efem[module].HasCassette && _efem[module].IsMapped;
  1114. return true;
  1115. }
  1116. internal bool CheckPlaced(ModuleName module)
  1117. {
  1118. //return _efem[module].HasCassette;
  1119. return true;
  1120. }
  1121. internal void NoteJobStart(ModuleName module)
  1122. {
  1123. //_efem[module].NoteJobStart();
  1124. }
  1125. internal void NoteJobComplete(ModuleName module)
  1126. {
  1127. //_efem[module].NoteJobComplete();
  1128. }
  1129. }
  1130. }