PlatingCellEntity.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Fsm;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.RecipeCenter;
  8. using Aitex.Core.RT.Routine;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.Util;
  11. using Aitex.Core.Utilities;
  12. using CyberX12_RT.Modules.VpwCell;
  13. using MECF.Framework.Common.Equipment;
  14. using MECF.Framework.Common.Persistent.Reservoirs;
  15. using MECF.Framework.Common.ProcessCell;
  16. using MECF.Framework.Common.RecipeCenter;
  17. using MECF.Framework.Common.Routine;
  18. using MECF.Framework.Common.SubstrateTrackings;
  19. using MECF.Framework.Common.ToolLayout;
  20. using MECF.Framework.RT.Core.Equipments;
  21. using PunkHPX8_Core;
  22. using PunkHPX8_RT.Devices.PlatingCell;
  23. using PunkHPX8_RT.Devices.PowerSupplier;
  24. using PunkHPX8_RT.Devices.Reservoir;
  25. using PunkHPX8_RT.Devices.Temperature;
  26. using PunkHPX8_RT.Modules.Reservoir;
  27. using PunkHPX8_RT.Modules.VpwCell;
  28. using PunkHPX8_RT.Modules.VpwMain;
  29. using System;
  30. using System.Collections.Generic;
  31. using System.Linq;
  32. using System.Text;
  33. using System.Threading.Tasks;
  34. namespace PunkHPX8_RT.Modules.PlatingCell
  35. {
  36. public class PlatingCellEntity : Entity, IEntity, IModuleEntity
  37. {
  38. #region 常量
  39. private const string STRATUS = "Stratus";
  40. private const string AUTO = "Auto";
  41. private const string MANUAL = "Manual";
  42. private const string DISABLED = "Disabled";
  43. private const string ENGINEERING = "Engineering";
  44. private const string PRODUCTION = "Production";
  45. #endregion
  46. #region 内部变量
  47. /// <summary>
  48. /// 持久化数值
  49. /// </summary>
  50. private PlatingCellPersistentValue _persistentValue;
  51. /// <summary>
  52. /// 当前recipe
  53. /// </summary>
  54. private DepRecipe _currentRecipe;
  55. /// <summary>
  56. /// recipe时间
  57. /// </summary>
  58. private int _recipeTime;
  59. /// <summary>
  60. /// 循环次数
  61. /// </summary>
  62. private int _cycle = 0;
  63. /// <summary>
  64. /// 已经完成的Cycle次数
  65. /// </summary>
  66. private int _achievedCycle = 0;
  67. /// <summary>
  68. /// c&m Initialize routine
  69. /// </summary>
  70. private PlatingCellInitializeRoutine _initializeRoutine;
  71. /// <summary>
  72. /// CCR routine
  73. /// </summary>
  74. private PlatingCellCCRRoutine _platingCellCRRoutine;
  75. /// <summary>
  76. /// Run recipe routine
  77. /// </summary>
  78. private PlatingCellRunRecipeRoutine _runRecipeRoutine;
  79. /// <summary>
  80. /// dummy risne Run recipe routine
  81. /// </summary>
  82. private DummyRinseRunRecipeRoutine _dummyRinseRunRecipeRoutine;
  83. /// <summary>
  84. /// Unload Routine
  85. /// </summary>
  86. private PlatingCellUnloadRoutine _unloadRoutine;
  87. /// <summary>
  88. /// 工艺当前执行小步骤
  89. /// </summary>
  90. private string _currentStepState = "Init";
  91. #endregion
  92. #region 属性
  93. /// <summary>
  94. /// 模块名称
  95. /// </summary>
  96. public ModuleName Module { get; private set; }
  97. /// <summary>
  98. /// 是否Init
  99. /// </summary>
  100. public bool IsInit
  101. {
  102. get { return fsm.State == (int)PlatingCellState.Init; }
  103. }
  104. /// <summary>
  105. /// 是否Idle
  106. /// </summary>
  107. public bool IsIdle
  108. {
  109. get
  110. {
  111. return fsm.State == (int)PlatingCellState.Idle;
  112. }
  113. }
  114. /// <summary>
  115. /// 是否错误
  116. /// </summary>
  117. public bool IsError
  118. {
  119. get { return fsm.State == (int)PlatingCellState.Error; }
  120. }
  121. /// <summary>
  122. /// 正在忙碌
  123. /// </summary>
  124. public bool IsBusy
  125. {
  126. get { return fsm.State == (int)PlatingCellState.Initializing ; }
  127. }
  128. /// <summary>
  129. /// 正在Run recipe
  130. /// </summary>
  131. public bool IsInRecipe
  132. {
  133. get { return fsm.State == (int)PlatingCellState.RunReciping; }
  134. }
  135. /// <summary>
  136. /// 已完成的RunRecipeCycle次数
  137. /// </summary>
  138. public int AchievedCycle { get { return _achievedCycle; } }
  139. /// <summary>
  140. /// 化学液
  141. /// </summary>
  142. public string Chemistry
  143. {
  144. get { return _currentRecipe != null ? _currentRecipe.Chemistry : ""; }
  145. }
  146. /// <summary>
  147. /// 当前正在run 的recipe
  148. /// </summary>
  149. public DepRecipe CurrentRecipe
  150. {
  151. get { return _currentRecipe; }
  152. }
  153. /// <summary>
  154. /// 是否禁用
  155. /// </summary>
  156. public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
  157. /// <summary>
  158. /// 自动模式
  159. /// </summary>
  160. public bool IsAuto { get { return _persistentValue != null && _persistentValue.OperatingMode == AUTO; } }
  161. /// <summary>
  162. /// 自动模式
  163. /// </summary>
  164. public bool IsManual { get { return _persistentValue != null && _persistentValue.OperatingMode == MANUAL; } }
  165. /// <summary>
  166. /// 是否为工程模式
  167. /// </summary>
  168. public bool IsEngineering { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == ENGINEERING; } }
  169. /// <summary>
  170. /// 是否为产品模式
  171. /// </summary>
  172. public bool IsProduction { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == PRODUCTION; } }
  173. /// <summary>
  174. /// 当前状态机状态
  175. /// </summary>
  176. public int State { get { return fsm.State; } }
  177. /// <summary>
  178. /// 是否初始化完成
  179. /// </summary>
  180. public bool IsInitialized { get { return fsm.State >= (int)PlatingCellState.Initialized; } }
  181. /// <summary>
  182. /// Reservoir项
  183. /// </summary>
  184. private ReservoirItem _reservoirItem;
  185. /// <summary>
  186. /// Wafer信息
  187. /// </summary>
  188. public WaferInfo WaferInfo { get { return WaferManager.Instance.GetWafer(Module,0); } }
  189. /// <summary>
  190. /// 当前Metal设置的WaferSize
  191. /// </summary>
  192. public int MetalWaferSize { get { return _persistentValue.PlatingCellWaferSize; } }
  193. /// <summary>
  194. /// 当前工步
  195. /// </summary>
  196. public string CurrentStepState { get { return _currentStepState; } }
  197. #endregion
  198. /// <summary>
  199. /// 构造函数
  200. /// </summary>
  201. /// <param name="module"></param>
  202. public PlatingCellEntity(ModuleName module)
  203. {
  204. this.Module = module;
  205. InitialFsm();
  206. }
  207. /// <summary>
  208. /// 初始化
  209. /// </summary>
  210. /// <returns></returns>
  211. protected override bool Init()
  212. {
  213. WaferManager.Instance.SubscribeLocation(Module, 1);
  214. InitializeRoutine();
  215. InitializeDATA();
  216. InitializeOperation();
  217. InitializeParameter();
  218. return true;
  219. }
  220. /// <summary>
  221. /// 初始化参数
  222. /// </summary>
  223. private void InitializeParameter()
  224. {
  225. _persistentValue = PlatingCellPersistentManager.Instance.GetPlatingCellPersistentValue(Module.ToString());
  226. if (_persistentValue == null)
  227. {
  228. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), "Persistent Value Object is not exist");
  229. }
  230. }
  231. /// <summary>
  232. /// 初始化Routine
  233. /// </summary>
  234. private void InitializeRoutine()
  235. {
  236. _initializeRoutine = new PlatingCellInitializeRoutine(Module.ToString());
  237. _platingCellCRRoutine = new PlatingCellCCRRoutine(Module.ToString());
  238. _runRecipeRoutine=new PlatingCellRunRecipeRoutine(Module.ToString());
  239. _dummyRinseRunRecipeRoutine=new DummyRinseRunRecipeRoutine(Module.ToString());
  240. _unloadRoutine=new PlatingCellUnloadRoutine(Module.ToString());
  241. }
  242. /// <summary>
  243. /// 初始化DATA
  244. /// </summary>
  245. private void InitializeDATA()
  246. {
  247. DATA.Subscribe($"{Module}.FsmState", () => ((PlatingCellState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  248. DATA.Subscribe($"{Module}.CurrentRecipe", () => _currentRecipe != null ? _currentRecipe.Ppid : "", SubscriptionAttribute.FLAG.IgnoreSaveDB);
  249. DATA.Subscribe($"{Module}.TotalTime", () => _recipeTime, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  250. DATA.Subscribe($"{Module}.TimeRemain", () => _recipeTime != 0 && _runRecipeRoutine != null ? (_recipeTime - Math.Round((double)_runRecipeRoutine.ElapsedMilliseconds / 1000, 0)) : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  251. DATA.Subscribe($"{Module}.Chemistry", () => Chemistry, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  252. DATA.Subscribe($"{Module}.AchievedCycle", () => AchievedCycle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  253. DATA.Subscribe($"{Module}.IsInit", () => IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  254. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  255. DATA.Subscribe($"{Module}.IsError", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  256. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  257. DATA.Subscribe($"{Module}.IsDisable", () => IsDisable, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  258. }
  259. /// <summary>
  260. /// 初始化Operation
  261. /// </summary>
  262. private void InitializeOperation()
  263. {
  264. OP.Subscribe($"{Module}.InitializeAll", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.Initialize); });
  265. OP.Subscribe($"{Module}.ManualCCRStart", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.CCR); });
  266. OP.Subscribe($"{Module}.ManualCCRStop", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.CCRAbort); });
  267. OP.Subscribe($"{Module}.CycleManualProcessRecipe", (cmd, args) =>
  268. {
  269. bool isDummyLoad = (bool)args[1];
  270. object recipe = null;
  271. if (!isDummyLoad)
  272. {
  273. recipe = RecipeFileManager.Instance.LoadGenericityRecipe<DepRecipe>(args[0].ToString());
  274. if (recipe == null)
  275. {
  276. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), $"{args[0]} recipe is null");
  277. return false;
  278. }
  279. }
  280. else
  281. {
  282. recipe = RecipeFileManager.Instance.LoadGenericityRecipe<DqdrRecipe>(args[0].ToString());
  283. if (recipe == null)
  284. {
  285. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), $"{args[0]} recipe is null");
  286. return false;
  287. }
  288. }
  289. object[] objects = new object[args.Length];
  290. objects[0] = recipe;
  291. for (int i = 1; i < args.Length; i++)
  292. {
  293. objects[i] = args[i];
  294. }
  295. return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PlatingCellMsg.RunRecipe, objects);
  296. });
  297. }
  298. /// 初始化状态机
  299. /// </summary>
  300. private void InitialFsm()
  301. {
  302. fsm = new StateMachine<PlatingCellEntity>(Module.ToString(), (int)PlatingCellState.Init, 100);
  303. fsm.EnableRepeatedMsg(true);
  304. AnyStateTransition(PlatingCellMsg.Error, NullFunc, PlatingCellState.Error);
  305. //Initialized
  306. Transition(PlatingCellState.Error, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  307. Transition(PlatingCellState.Init, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  308. Transition(PlatingCellState.Idle, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  309. Transition(PlatingCellState.Initializing, FSM_MSG.TIMER, InitializeAllMonitor, PlatingCellState.Idle);
  310. //CCR
  311. Transition(PlatingCellState.Idle, PlatingCellMsg.CCR, ManualCCRStart, PlatingCellState.CCRing);
  312. Transition(PlatingCellState.CCRing, FSM_MSG.TIMER, CCRMonitor, PlatingCellState.Idle);
  313. Transition(PlatingCellState.CCRing, PlatingCellMsg.CCRAbort, CCRAbort, PlatingCellState.Init);
  314. //Cycle Manual Process
  315. Transition(PlatingCellState.Idle, PlatingCellMsg.RunRecipe, CycleManualProcess, PlatingCellState.RunReciping);
  316. Transition(PlatingCellState.RunReciping, FSM_MSG.TIMER, CycleManualMonitor, PlatingCellState.Idle);
  317. Transition(PlatingCellState.RunReciping, PlatingCellMsg.Abort, RunRecipeAbort, PlatingCellState.Idle);
  318. //Unload
  319. Transition(PlatingCellState.Idle, PlatingCellMsg.Unload, Unload, PlatingCellState.Unloading);
  320. Transition(PlatingCellState.Unloading, FSM_MSG.TIMER, UnloadMonitor, PlatingCellState.Idle);
  321. Transition(PlatingCellState.Unloading, PlatingCellMsg.Abort, UnloadAbort, PlatingCellState.Idle);
  322. //直接进入Idle
  323. Transition(PlatingCellState.Initialized, FSM_MSG.TIMER, NullFunc, PlatingCellState.Idle);
  324. //Enter Init
  325. Transition(PlatingCellState.Idle, PlatingCellMsg.Init, NullFunc, PlatingCellState.Init);
  326. EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
  327. EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
  328. }
  329. /// <summary>
  330. /// 手动CCR
  331. /// </summary>
  332. /// <returns></returns>
  333. private bool ManualCCRStart(object[] param)
  334. {
  335. bool result = _platingCellCRRoutine.Start() == RState.Running;
  336. return result;
  337. }
  338. /// <summary>
  339. /// CCR 监控
  340. /// </summary>
  341. /// <param name="param"></param>
  342. /// <returns></returns>
  343. private bool CCRMonitor(object[] param)
  344. {
  345. RState rsstate = RState.Running;
  346. rsstate = _platingCellCRRoutine.Monitor();
  347. if (rsstate == RState.End)
  348. {
  349. return true;
  350. }
  351. else if (rsstate == RState.Failed || rsstate == RState.Timeout)
  352. {
  353. PostMsg(PlatingCellMsg.Error);
  354. return false;
  355. }
  356. return false;
  357. }
  358. /// <summary>
  359. /// CCR abort
  360. /// </summary>
  361. /// <param name="param"></param>
  362. /// <returns></returns>
  363. private bool CCRAbort(object[] param)
  364. {
  365. if(_platingCellCRRoutine.Monitor() == RState.Running)
  366. {
  367. _platingCellCRRoutine.Abort();
  368. }
  369. return true;
  370. }
  371. /// <summary>
  372. /// 初始化
  373. /// </summary>
  374. /// <returns></returns>
  375. private bool InitializeAll(object[] param)
  376. {
  377. if (_persistentValue == null)
  378. {
  379. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "persistent is null");
  380. return false;
  381. }
  382. if (fsm.State == (int)PlatingCellState.Initializing)
  383. {
  384. LOG.WriteLog(eEvent.WARN_PLATINGCELL, Module.ToString(), "state is Initializing,cannot do initialize");
  385. return false;
  386. }
  387. if (!CheckReservoirInitialized())
  388. {
  389. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Reservoir is not initialized");
  390. return false;
  391. }
  392. if (!MetalUsageMointor(Module.ToString()))
  393. {
  394. return false;
  395. }
  396. if ("Auto".Equals(_persistentValue.OperatingMode))
  397. {
  398. if (!CheckReservoirIsAuto())
  399. {
  400. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Reservoir is not in Auto OperationMode");
  401. return false;
  402. }
  403. }
  404. string AnotherModule = ModuleMatcherManager.Instance.GetMatcherByModule(Module.ToString());
  405. PlatingCellEntity anotherEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(AnotherModule);
  406. {
  407. if(anotherEntity != null && anotherEntity.IsBusy)
  408. {
  409. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Another Platingcell is busy, can not initialized");
  410. return false;
  411. }
  412. }
  413. bool result = _initializeRoutine.Start(_persistentValue) == RState.Running;
  414. return result;
  415. }
  416. /// <summary>
  417. /// 检验Reservoir是否Auto
  418. /// </summary>
  419. /// <returns></returns>
  420. private bool CheckReservoirIsAuto()
  421. {
  422. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module.ToString());
  423. ReservoirsPersistentValue reservoirsPersistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(reservoir);
  424. if ("Auto".Equals(reservoirsPersistentValue.OperatingMode))
  425. {
  426. return true;
  427. }
  428. return false;
  429. }
  430. /// <summary>
  431. /// 检验Reservoir是否Initialized
  432. /// </summary>
  433. /// <returns></returns>
  434. private bool CheckReservoirInitialized()
  435. {
  436. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module.ToString());
  437. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(reservoir);
  438. if (reservoirEntity != null)
  439. {
  440. return reservoirEntity.IsInitialized;
  441. }
  442. return false;
  443. }
  444. /// <summary>
  445. /// 监控 PM Counter Metal用量
  446. /// </summary>
  447. private bool MetalUsageMointor(string Module)
  448. {
  449. return true;
  450. }
  451. /// <summary>
  452. /// Initialize 监控
  453. /// </summary>
  454. /// <param name="param"></param>
  455. /// <returns></returns>
  456. private bool InitializeAllMonitor(object[] param)
  457. {
  458. RState rsstate = RState.Running;
  459. rsstate = _initializeRoutine.Monitor();
  460. if (rsstate == RState.End)
  461. {
  462. return true;
  463. }
  464. else if (rsstate == RState.Failed || rsstate == RState.Timeout)
  465. {
  466. PostMsg(PlatingCellMsg.Error);
  467. return false;
  468. }
  469. return false;
  470. }
  471. /// <summary>
  472. /// EnterInit
  473. /// </summary>
  474. public void EnterInit()
  475. {
  476. if ((PlatingCellState)fsm.State != PlatingCellState.Idle) return;
  477. else
  478. {
  479. CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.Init);
  480. }
  481. }
  482. #region cycle manual process
  483. /// <summary>
  484. /// process
  485. /// </summary>
  486. /// <param name="param"></param>
  487. /// <returns></returns>
  488. private bool CycleManualProcess(object[] param)
  489. {
  490. bool _isDummyLoad = (bool)param[1];
  491. if (!_isDummyLoad)
  492. {
  493. bool result = _runRecipeRoutine.Start(param) == RState.Running;
  494. _currentStepState = "";
  495. DepRecipe recipe = param[0] as DepRecipe;
  496. _cycle = (int)param[2];
  497. if (result)
  498. {
  499. _recipeTime = recipe.CalculateRecipeTotalTime() * _cycle;
  500. _currentRecipe = recipe;
  501. }
  502. return result;
  503. }
  504. else
  505. {
  506. bool result = _dummyRinseRunRecipeRoutine.Start(param) == RState.Running;
  507. _currentStepState = "";
  508. DqdrRecipe recipe = param[0] as DqdrRecipe;
  509. _cycle = (int)param[2];
  510. if (result)
  511. {
  512. _recipeTime = recipe.CalculateRecipeTotalTime() * _cycle;
  513. //run dummy recipe不需要纪律当前recipe
  514. }
  515. return result;
  516. }
  517. }
  518. /// <summary>
  519. /// 监控
  520. /// </summary>
  521. /// <param name="param"></param>
  522. /// <returns></returns>
  523. private bool CycleManualMonitor(object[] param)
  524. {
  525. RState state = _runRecipeRoutine.Monitor();
  526. _currentStepState = _runRecipeRoutine.CurrentStep;
  527. _achievedCycle = _runRecipeRoutine.GetCurrentCycle();
  528. //LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module.ToString(), _currentStepState);
  529. if (state == RState.Failed || state == RState.Timeout)
  530. {
  531. PostMsg(PlatingCellMsg.Error);
  532. _currentStepState = "";
  533. _currentRecipe = null;
  534. return false;
  535. }
  536. bool result = state == RState.End;
  537. if (result)
  538. {
  539. _currentStepState = "";
  540. _currentRecipe = null;
  541. }
  542. return result;
  543. }
  544. /// <summary>
  545. /// 中止
  546. /// </summary>
  547. /// <param name="param"></param>
  548. /// <returns></returns>
  549. private bool RunRecipeAbort(object[] param)
  550. {
  551. _runRecipeRoutine.Abort();
  552. _currentStepState = "";
  553. return true;
  554. }
  555. #endregion
  556. #region unload
  557. /// <summary>
  558. /// unload
  559. /// </summary>
  560. /// <param name="param"></param>
  561. /// <returns></returns>
  562. private bool Unload(object[] param)
  563. {
  564. return _unloadRoutine.Start(param) == RState.Running;
  565. }
  566. /// <summary>
  567. /// 监控
  568. /// </summary>
  569. /// <param name="param"></param>
  570. /// <returns></returns>
  571. private bool UnloadMonitor(object[] param)
  572. {
  573. RState state = _unloadRoutine.Monitor();
  574. if (state == RState.Failed || state == RState.Timeout)
  575. {
  576. PostMsg(PlatingCellMsg.Error);
  577. return false;
  578. }
  579. return state == RState.End;
  580. }
  581. /// <summary>
  582. /// 中止
  583. /// </summary>
  584. /// <param name="param"></param>
  585. /// <returns></returns>
  586. private bool UnloadAbort(object[] param)
  587. {
  588. _unloadRoutine.Abort();
  589. return true;
  590. }
  591. #endregion
  592. public bool Check(int msg, out string reason, params object[] args)
  593. {
  594. reason = "";
  595. return true;
  596. }
  597. public bool CheckAcked(int msg)
  598. {
  599. throw new NotImplementedException();
  600. }
  601. public int Invoke(string function, params object[] args)
  602. {
  603. switch (function)
  604. {
  605. case "HomeAll":
  606. if (IsIdle)
  607. {
  608. return (int)FSM_MSG.NONE;
  609. }
  610. if (CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.Initialize))
  611. {
  612. return (int)PlatingCellMsg.Initialize;
  613. }
  614. else
  615. {
  616. return (int)FSM_MSG.NONE;
  617. }
  618. }
  619. return (int)FSM_MSG.NONE;
  620. }
  621. }
  622. public enum PlatingCellMsg
  623. {
  624. NONE,
  625. Error,
  626. ResumeError,
  627. Initialize,
  628. Manual,
  629. Auto,
  630. CloseFlowValve,
  631. OpenFlowValve,
  632. RunRecipe,
  633. Abort,
  634. Init,
  635. CCR,
  636. CCRAbort,
  637. Unload
  638. }
  639. }