PlatingCellEntity.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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. /// <summary>
  92. /// 当前是否在跑dummy recipe
  93. /// </summary>
  94. private bool _isCurrentRunDummyRecipe;
  95. #endregion
  96. #region 属性
  97. /// <summary>
  98. /// 模块名称
  99. /// </summary>
  100. public ModuleName Module { get; private set; }
  101. /// <summary>
  102. /// 是否Init
  103. /// </summary>
  104. public bool IsInit
  105. {
  106. get { return fsm.State == (int)PlatingCellState.Init; }
  107. }
  108. /// <summary>
  109. /// 是否Idle
  110. /// </summary>
  111. public bool IsIdle
  112. {
  113. get
  114. {
  115. return fsm.State == (int)PlatingCellState.Idle;
  116. }
  117. }
  118. /// <summary>
  119. /// 是否错误
  120. /// </summary>
  121. public bool IsError
  122. {
  123. get { return fsm.State == (int)PlatingCellState.Error; }
  124. }
  125. /// <summary>
  126. /// 正在忙碌
  127. /// </summary>
  128. public bool IsBusy
  129. {
  130. get { return fsm.State == (int)PlatingCellState.Initializing ; }
  131. }
  132. /// <summary>
  133. /// 正在Run recipe
  134. /// </summary>
  135. public bool IsInRecipe
  136. {
  137. get { return fsm.State == (int)PlatingCellState.RunReciping; }
  138. }
  139. /// <summary>
  140. /// 已完成的RunRecipeCycle次数
  141. /// </summary>
  142. public int AchievedCycle { get { return _achievedCycle; } }
  143. /// <summary>
  144. /// 化学液
  145. /// </summary>
  146. public string Chemistry
  147. {
  148. get { return _currentRecipe != null ? _currentRecipe.Chemistry : ""; }
  149. }
  150. /// <summary>
  151. /// 当前正在run 的recipe
  152. /// </summary>
  153. public DepRecipe CurrentRecipe
  154. {
  155. get { return _currentRecipe; }
  156. }
  157. /// <summary>
  158. /// 是否禁用
  159. /// </summary>
  160. public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
  161. /// <summary>
  162. /// 自动模式
  163. /// </summary>
  164. public bool IsAuto { get { return _persistentValue != null && _persistentValue.OperatingMode == AUTO; } }
  165. /// <summary>
  166. /// 自动模式
  167. /// </summary>
  168. public bool IsManual { get { return _persistentValue != null && _persistentValue.OperatingMode == MANUAL; } }
  169. /// <summary>
  170. /// 是否为工程模式
  171. /// </summary>
  172. public bool IsEngineering { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == ENGINEERING; } }
  173. /// <summary>
  174. /// 是否为产品模式
  175. /// </summary>
  176. public bool IsProduction { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == PRODUCTION; } }
  177. /// <summary>
  178. /// 当前状态机状态
  179. /// </summary>
  180. public int State { get { return fsm.State; } }
  181. /// <summary>
  182. /// 是否初始化完成
  183. /// </summary>
  184. public bool IsInitialized { get { return fsm.State >= (int)PlatingCellState.Initialized; } }
  185. /// <summary>
  186. /// Reservoir项
  187. /// </summary>
  188. private ReservoirItem _reservoirItem;
  189. /// <summary>
  190. /// Wafer信息
  191. /// </summary>
  192. public WaferInfo WaferInfo { get { return WaferManager.Instance.GetWafer(Module,0); } }
  193. /// <summary>
  194. /// 当前Metal设置的WaferSize
  195. /// </summary>
  196. public int MetalWaferSize { get { return _persistentValue.PlatingCellWaferSize; } }
  197. /// <summary>
  198. /// 当前工步
  199. /// </summary>
  200. public string CurrentStepState { get { return _currentStepState; } }
  201. /// <summary>
  202. /// 是否正在跑dummy recipe
  203. /// </summary>
  204. public bool IsCurrentRunDummyRecipe
  205. {
  206. get
  207. {
  208. return _isCurrentRunDummyRecipe;
  209. }
  210. }
  211. #endregion
  212. /// <summary>
  213. /// 构造函数
  214. /// </summary>
  215. /// <param name="module"></param>
  216. public PlatingCellEntity(ModuleName module)
  217. {
  218. this.Module = module;
  219. InitialFsm();
  220. }
  221. /// <summary>
  222. /// 初始化
  223. /// </summary>
  224. /// <returns></returns>
  225. protected override bool Init()
  226. {
  227. WaferManager.Instance.SubscribeLocation(Module, 1);
  228. InitializeRoutine();
  229. InitializeDATA();
  230. InitializeOperation();
  231. InitializeParameter();
  232. return true;
  233. }
  234. /// <summary>
  235. /// 初始化参数
  236. /// </summary>
  237. private void InitializeParameter()
  238. {
  239. _persistentValue = PlatingCellPersistentManager.Instance.GetPlatingCellPersistentValue(Module.ToString());
  240. if (_persistentValue == null)
  241. {
  242. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), "Persistent Value Object is not exist");
  243. }
  244. }
  245. /// <summary>
  246. /// 初始化Routine
  247. /// </summary>
  248. private void InitializeRoutine()
  249. {
  250. _initializeRoutine = new PlatingCellInitializeRoutine(Module.ToString());
  251. _platingCellCRRoutine = new PlatingCellCCRRoutine(Module.ToString());
  252. _runRecipeRoutine=new PlatingCellRunRecipeRoutine(Module.ToString());
  253. _dummyRinseRunRecipeRoutine=new DummyRinseRunRecipeRoutine(Module.ToString());
  254. _unloadRoutine=new PlatingCellUnloadRoutine(Module.ToString());
  255. }
  256. /// <summary>
  257. /// 初始化DATA
  258. /// </summary>
  259. private void InitializeDATA()
  260. {
  261. DATA.Subscribe($"{Module}.FsmState", () => ((PlatingCellState)fsm.State).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  262. DATA.Subscribe($"{Module}.CurrentRecipe", () => _currentRecipe != null ? _currentRecipe.Ppid : "", SubscriptionAttribute.FLAG.IgnoreSaveDB);
  263. DATA.Subscribe($"{Module}.TotalTime", () => _recipeTime, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  264. DATA.Subscribe($"{Module}.TimeRemain", () => _recipeTime != 0 && _runRecipeRoutine != null ? (_recipeTime - Math.Round((double)_runRecipeRoutine.ElapsedMilliseconds / 1000, 0)) : 0, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  265. DATA.Subscribe($"{Module}.Chemistry", () => Chemistry, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  266. DATA.Subscribe($"{Module}.AchievedCycle", () => AchievedCycle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  267. DATA.Subscribe($"{Module}.IsInit", () => IsInit, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  268. DATA.Subscribe($"{Module}.IsIdle", () => IsIdle, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  269. DATA.Subscribe($"{Module}.IsError", () => IsError, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  270. DATA.Subscribe($"{Module}.IsBusy", () => IsBusy, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  271. DATA.Subscribe($"{Module}.IsDisable", () => IsDisable, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  272. }
  273. /// <summary>
  274. /// 初始化Operation
  275. /// </summary>
  276. private void InitializeOperation()
  277. {
  278. OP.Subscribe($"{Module}.InitializeAll", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.Initialize); });
  279. OP.Subscribe($"{Module}.ManualCCRStart", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.CCR); });
  280. OP.Subscribe($"{Module}.ManualCCRStop", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.CCRAbort); });
  281. OP.Subscribe($"{Module}.CycleManualProcessRecipe", (cmd, args) =>
  282. {
  283. bool isDummyLoad = (bool)args[1];
  284. object recipe = null;
  285. if (!isDummyLoad)
  286. {
  287. recipe = RecipeFileManager.Instance.LoadGenericityRecipe<DepRecipe>(args[0].ToString());
  288. if (recipe == null)
  289. {
  290. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), $"{args[0]} recipe is null");
  291. return false;
  292. }
  293. }
  294. else
  295. {
  296. recipe = RecipeFileManager.Instance.LoadGenericityRecipe<DqdrRecipe>(args[0].ToString());
  297. if (recipe == null)
  298. {
  299. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module.ToString(), $"{args[0]} recipe is null");
  300. return false;
  301. }
  302. }
  303. object[] objects = new object[args.Length];
  304. objects[0] = recipe;
  305. for (int i = 1; i < args.Length; i++)
  306. {
  307. objects[i] = args[i];
  308. }
  309. return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PREWET, Module.ToString(), (int)PlatingCellMsg.RunRecipe, objects);
  310. });
  311. OP.Subscribe($"{Module}.Abort", (cmd, args) => { return CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_RESERVOIR, Module.ToString(), (int)PlatingCellMsg.Abort); });
  312. }
  313. /// 初始化状态机
  314. /// </summary>
  315. private void InitialFsm()
  316. {
  317. fsm = new StateMachine<PlatingCellEntity>(Module.ToString(), (int)PlatingCellState.Init, 100);
  318. fsm.EnableRepeatedMsg(true);
  319. AnyStateTransition(PlatingCellMsg.Error, NullFunc, PlatingCellState.Error);
  320. //Initialized
  321. Transition(PlatingCellState.Error, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  322. Transition(PlatingCellState.Init, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  323. Transition(PlatingCellState.Idle, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  324. Transition(PlatingCellState.Abort, PlatingCellMsg.Initialize, InitializeAll, PlatingCellState.Initializing);
  325. Transition(PlatingCellState.Initializing, FSM_MSG.TIMER, InitializeAllMonitor, PlatingCellState.Idle);
  326. //CCR
  327. Transition(PlatingCellState.Idle, PlatingCellMsg.CCR, ManualCCRStart, PlatingCellState.CCRing);
  328. Transition(PlatingCellState.CCRing, FSM_MSG.TIMER, CCRMonitor, PlatingCellState.Idle);
  329. Transition(PlatingCellState.CCRing, PlatingCellMsg.CCRAbort, CCRAbort, PlatingCellState.Init);
  330. //Cycle Manual Process
  331. Transition(PlatingCellState.Idle, PlatingCellMsg.RunRecipe, CycleManualProcess, PlatingCellState.RunReciping);
  332. Transition(PlatingCellState.RunReciping, FSM_MSG.TIMER, CycleManualMonitor, PlatingCellState.Idle);
  333. Transition(PlatingCellState.RunReciping, PlatingCellMsg.Abort, RunRecipeAbort, PlatingCellState.Idle);
  334. Transition(PlatingCellState.RunReciping, PlatingCellMsg.Abort, AbortRecipe, PlatingCellState.Abort);
  335. //Unload
  336. Transition(PlatingCellState.Idle, PlatingCellMsg.Unload, Unload, PlatingCellState.Unloading);
  337. Transition(PlatingCellState.Unloading, FSM_MSG.TIMER, UnloadMonitor, PlatingCellState.Idle);
  338. Transition(PlatingCellState.Unloading, PlatingCellMsg.Abort, UnloadAbort, PlatingCellState.Idle);
  339. //直接进入Idle
  340. Transition(PlatingCellState.Initialized, FSM_MSG.TIMER, NullFunc, PlatingCellState.Idle);
  341. //Enter Init
  342. Transition(PlatingCellState.Idle, PlatingCellMsg.Init, NullFunc, PlatingCellState.Init);
  343. EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
  344. EnumLoop<PlatingCellState>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
  345. }
  346. /// <summary>
  347. /// Abort Recipe
  348. /// </summary>
  349. /// <param name="param"></param>
  350. /// <returns></returns>
  351. public bool AbortRecipe(object[] param)
  352. {
  353. //后续还要增加lottrack相关
  354. if (!_isCurrentRunDummyRecipe)
  355. {
  356. _runRecipeRoutine.Abort();
  357. }
  358. else
  359. {
  360. _dummyRinseRunRecipeRoutine.Abort();
  361. }
  362. return true;
  363. }
  364. /// <summary>
  365. /// 手动CCR
  366. /// </summary>
  367. /// <returns></returns>
  368. private bool ManualCCRStart(object[] param)
  369. {
  370. bool result = _platingCellCRRoutine.Start() == RState.Running;
  371. return result;
  372. }
  373. /// <summary>
  374. /// CCR 监控
  375. /// </summary>
  376. /// <param name="param"></param>
  377. /// <returns></returns>
  378. private bool CCRMonitor(object[] param)
  379. {
  380. RState rsstate = RState.Running;
  381. rsstate = _platingCellCRRoutine.Monitor();
  382. if (rsstate == RState.End)
  383. {
  384. return true;
  385. }
  386. else if (rsstate == RState.Failed || rsstate == RState.Timeout)
  387. {
  388. PostMsg(PlatingCellMsg.Error);
  389. return false;
  390. }
  391. return false;
  392. }
  393. /// <summary>
  394. /// CCR abort
  395. /// </summary>
  396. /// <param name="param"></param>
  397. /// <returns></returns>
  398. private bool CCRAbort(object[] param)
  399. {
  400. if(_platingCellCRRoutine.Monitor() == RState.Running)
  401. {
  402. _platingCellCRRoutine.Abort();
  403. }
  404. return true;
  405. }
  406. /// <summary>
  407. /// 初始化
  408. /// </summary>
  409. /// <returns></returns>
  410. private bool InitializeAll(object[] param)
  411. {
  412. if (_persistentValue == null)
  413. {
  414. LOG.WriteLog(eEvent.ERR_RESERVOIR, Module.ToString(), "persistent is null");
  415. return false;
  416. }
  417. if (fsm.State == (int)PlatingCellState.Initializing)
  418. {
  419. LOG.WriteLog(eEvent.WARN_PLATINGCELL, Module.ToString(), "state is Initializing,cannot do initialize");
  420. return false;
  421. }
  422. if (!CheckReservoirInitialized())
  423. {
  424. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Reservoir is not initialized");
  425. return false;
  426. }
  427. if (!MetalUsageMointor(Module.ToString()))
  428. {
  429. return false;
  430. }
  431. if ("Auto".Equals(_persistentValue.OperatingMode))
  432. {
  433. if (!CheckReservoirIsAuto())
  434. {
  435. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Reservoir is not in Auto OperationMode");
  436. return false;
  437. }
  438. }
  439. string AnotherModule = ModuleMatcherManager.Instance.GetMatcherByModule(Module.ToString());
  440. PlatingCellEntity anotherEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(AnotherModule);
  441. {
  442. if(anotherEntity != null && anotherEntity.IsBusy)
  443. {
  444. LOG.WriteLog(eEvent.ERR_METAL, Module.ToString(), "Another Platingcell is busy, can not initialized");
  445. return false;
  446. }
  447. }
  448. bool result = _initializeRoutine.Start(_persistentValue) == RState.Running;
  449. return result;
  450. }
  451. /// <summary>
  452. /// 检验Reservoir是否Auto
  453. /// </summary>
  454. /// <returns></returns>
  455. private bool CheckReservoirIsAuto()
  456. {
  457. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module.ToString());
  458. ReservoirsPersistentValue reservoirsPersistentValue = ReservoirsPersistentManager.Instance.GetReservoirsPersistentValue(reservoir);
  459. if ("Auto".Equals(reservoirsPersistentValue.OperatingMode))
  460. {
  461. return true;
  462. }
  463. return false;
  464. }
  465. /// <summary>
  466. /// 检验Reservoir是否Initialized
  467. /// </summary>
  468. /// <returns></returns>
  469. private bool CheckReservoirInitialized()
  470. {
  471. string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module.ToString());
  472. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(reservoir);
  473. if (reservoirEntity != null)
  474. {
  475. return reservoirEntity.IsInitialized;
  476. }
  477. return false;
  478. }
  479. /// <summary>
  480. /// 监控 PM Counter Metal用量
  481. /// </summary>
  482. private bool MetalUsageMointor(string Module)
  483. {
  484. return true;
  485. }
  486. /// <summary>
  487. /// Initialize 监控
  488. /// </summary>
  489. /// <param name="param"></param>
  490. /// <returns></returns>
  491. private bool InitializeAllMonitor(object[] param)
  492. {
  493. RState rsstate = RState.Running;
  494. rsstate = _initializeRoutine.Monitor();
  495. if (rsstate == RState.End)
  496. {
  497. return true;
  498. }
  499. else if (rsstate == RState.Failed || rsstate == RState.Timeout)
  500. {
  501. PostMsg(PlatingCellMsg.Error);
  502. return false;
  503. }
  504. return false;
  505. }
  506. /// <summary>
  507. /// EnterInit
  508. /// </summary>
  509. public void EnterInit()
  510. {
  511. if ((PlatingCellState)fsm.State != PlatingCellState.Idle) return;
  512. else
  513. {
  514. CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.Init);
  515. }
  516. }
  517. #region cycle manual process
  518. /// <summary>
  519. /// process
  520. /// </summary>
  521. /// <param name="param"></param>
  522. /// <returns></returns>
  523. private bool CycleManualProcess(object[] param)
  524. {
  525. bool _isDummyLoad = (bool)param[1];
  526. if (!_isDummyLoad)
  527. {
  528. _isCurrentRunDummyRecipe = false;
  529. bool result = _runRecipeRoutine.Start(param) == RState.Running;
  530. _currentStepState = "";
  531. DepRecipe recipe = param[0] as DepRecipe;
  532. _cycle = (int)param[2];
  533. if (result)
  534. {
  535. _recipeTime = recipe.CalculateRecipeTotalTime() * _cycle;
  536. _currentRecipe = recipe;
  537. }
  538. return result;
  539. }
  540. else
  541. {
  542. _isCurrentRunDummyRecipe = true;
  543. bool result = _dummyRinseRunRecipeRoutine.Start(param) == RState.Running;
  544. _currentStepState = "";
  545. DqdrRecipe recipe = param[0] as DqdrRecipe;
  546. _cycle = (int)param[2];
  547. if (result)
  548. {
  549. _recipeTime = recipe.CalculateRecipeTotalTime() * _cycle;
  550. //run dummy recipe不需要纪律当前recipe
  551. }
  552. return result;
  553. }
  554. }
  555. /// <summary>
  556. /// 监控
  557. /// </summary>
  558. /// <param name="param"></param>
  559. /// <returns></returns>
  560. private bool CycleManualMonitor(object[] param)
  561. {
  562. if (!_isCurrentRunDummyRecipe)
  563. {
  564. RState state = _runRecipeRoutine.Monitor();
  565. _currentStepState = _runRecipeRoutine.CurrentStep;
  566. _achievedCycle = _runRecipeRoutine.GetCurrentCycle();
  567. //LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module.ToString(), _currentStepState);
  568. if (state == RState.Failed || state == RState.Timeout)
  569. {
  570. PostMsg(PlatingCellMsg.Error);
  571. _currentStepState = "";
  572. _currentRecipe = null;
  573. return false;
  574. }
  575. bool result = state == RState.End;
  576. if (result)
  577. {
  578. _currentStepState = "";
  579. _currentRecipe = null;
  580. }
  581. return result;
  582. }
  583. else
  584. {
  585. RState state = _dummyRinseRunRecipeRoutine.Monitor();
  586. _currentStepState = _dummyRinseRunRecipeRoutine.CurrentStep;
  587. _achievedCycle = _dummyRinseRunRecipeRoutine.GetCurrentCycle();
  588. //LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module.ToString(), _currentStepState);
  589. if (state == RState.Failed || state == RState.Timeout)
  590. {
  591. PostMsg(PlatingCellMsg.Error);
  592. _currentStepState = "";
  593. _currentRecipe = null;
  594. return false;
  595. }
  596. bool result = state == RState.End;
  597. if (result)
  598. {
  599. _currentStepState = "";
  600. _currentRecipe = null;
  601. }
  602. return result;
  603. }
  604. }
  605. /// <summary>
  606. /// 中止
  607. /// </summary>
  608. /// <param name="param"></param>
  609. /// <returns></returns>
  610. private bool RunRecipeAbort(object[] param)
  611. {
  612. _runRecipeRoutine.Abort();
  613. _currentStepState = "";
  614. return true;
  615. }
  616. #endregion
  617. #region unload
  618. /// <summary>
  619. /// unload
  620. /// </summary>
  621. /// <param name="param"></param>
  622. /// <returns></returns>
  623. private bool Unload(object[] param)
  624. {
  625. return _unloadRoutine.Start(param) == RState.Running;
  626. }
  627. /// <summary>
  628. /// 监控
  629. /// </summary>
  630. /// <param name="param"></param>
  631. /// <returns></returns>
  632. private bool UnloadMonitor(object[] param)
  633. {
  634. RState state = _unloadRoutine.Monitor();
  635. if (state == RState.Failed || state == RState.Timeout)
  636. {
  637. PostMsg(PlatingCellMsg.Error);
  638. return false;
  639. }
  640. return state == RState.End;
  641. }
  642. /// <summary>
  643. /// 中止
  644. /// </summary>
  645. /// <param name="param"></param>
  646. /// <returns></returns>
  647. private bool UnloadAbort(object[] param)
  648. {
  649. _unloadRoutine.Abort();
  650. return true;
  651. }
  652. #endregion
  653. public bool Check(int msg, out string reason, params object[] args)
  654. {
  655. reason = "";
  656. return true;
  657. }
  658. public bool CheckAcked(int msg)
  659. {
  660. throw new NotImplementedException();
  661. }
  662. public int Invoke(string function, params object[] args)
  663. {
  664. switch (function)
  665. {
  666. case "HomeAll":
  667. if (IsIdle)
  668. {
  669. return (int)FSM_MSG.NONE;
  670. }
  671. if (CheckToPostMessage<PlatingCellState, PlatingCellMsg>(eEvent.ERR_PLATINGCELL, Module.ToString(), (int)PlatingCellMsg.Initialize))
  672. {
  673. return (int)PlatingCellMsg.Initialize;
  674. }
  675. else
  676. {
  677. return (int)FSM_MSG.NONE;
  678. }
  679. }
  680. return (int)FSM_MSG.NONE;
  681. }
  682. }
  683. public enum PlatingCellMsg
  684. {
  685. NONE,
  686. Error,
  687. ResumeError,
  688. Initialize,
  689. Manual,
  690. Auto,
  691. CloseFlowValve,
  692. OpenFlowValve,
  693. RunRecipe,
  694. Abort,
  695. Init,
  696. CCR,
  697. CCRAbort,
  698. Unload
  699. }
  700. }