SETMEntity.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Fsm;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using Aitex.Sorter.Common;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Diagnostics;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using Venus_Core;
  19. using Venus_RT.Devices;
  20. using Venus_RT.Devices.PreAligner;
  21. using Venus_RT.Devices.VCE;
  22. using Venus_RT.Modules.PMs;
  23. using static Mono.Security.X509.X520;
  24. namespace Venus_RT.Modules.TM.VenusEntity
  25. {
  26. public class SETMEntity : Entity, IModuleEntity
  27. {
  28. public enum STATE
  29. {
  30. Unknown,
  31. Init,
  32. Initializing,
  33. InitializingRB,
  34. Idle,
  35. Error,
  36. Pumping,
  37. Venting,
  38. Purging,
  39. Leakchecking,
  40. Picking,
  41. Placing,
  42. Swaping,
  43. PMPicking,
  44. PMPlacing,
  45. PMSwaping,
  46. Aligning,
  47. Mapping,
  48. Extending,
  49. Retracting,
  50. Swapping,
  51. Gotoing,
  52. ControllingPressure,
  53. }
  54. public enum MSG
  55. {
  56. Home,
  57. RobotHome,
  58. Online,
  59. Offline,
  60. Pump,
  61. Vent,
  62. Purge,
  63. CyclePurge,
  64. LeakCheck,
  65. Pick,
  66. Place,
  67. Swap,
  68. DoublePick,
  69. DoublePlace,
  70. DoubleSwap,
  71. PMPick,
  72. PMPlace,
  73. PMSwap,
  74. Extend,
  75. Retract,
  76. TMCycle,
  77. ControlPressure,
  78. Error,
  79. Abort,
  80. AbortControlPressure,
  81. Align,
  82. CreateJob,
  83. StartJob,
  84. Goto,
  85. }
  86. #region 公开变量
  87. public bool IsIdle
  88. {
  89. get { return fsm.State == (int)STATE.Idle; }
  90. }
  91. public bool IsError
  92. {
  93. get { return fsm.State == (int)STATE.Error; }
  94. }
  95. public bool IsInit
  96. {
  97. get { return fsm.State == (int)STATE.Unknown || fsm.State == (int)STATE.Init; }
  98. }
  99. public bool IsBusy
  100. {
  101. get { return !IsInit && !IsError && !IsIdle; }
  102. }
  103. public bool VCEIsATM => _tm.IsVCEATM;
  104. public bool TMIsATM => _tm.IsTMATM;
  105. public bool TMIsVAC => _tm.IsTMVAC;
  106. public bool VCEIsVAC => _tm.IsVCEVAC;
  107. public bool IsPMASlitDoorClosed => _tm.PMASlitDoorClosed;
  108. public bool IsPMBSlitDoorClosed => _tm.PMBSlitDoorClosed;
  109. public bool IsPMCSlitDoorClosed => _tm.PMCSlitDoorClosed;
  110. public bool IsVCESlitDoorClosed => _tm.VCESlitDoorClosed;
  111. public bool IsPMASlitDoorOpen => _tm.PMASlitDoorOpen;
  112. public bool IsPMBSlitDoorOpen => _tm.PMBSlitDoorOpen;
  113. public bool IsPMCSlitDoorOpen => _tm.PMCSlitDoorOpen;
  114. public bool IsVCESlitDoorOpen => _tm.VCESlitDoorOpen;
  115. public double VCEPressure => _tm.VCEPressure;
  116. public RState RobotStatus
  117. {
  118. get
  119. {
  120. if (_robot.Status != RState.Running)
  121. {
  122. if (_robotWatch.ElapsedMilliseconds < 100)
  123. return RState.Running;
  124. else
  125. return _robot.Status;
  126. }
  127. else
  128. return RState.Running;
  129. }
  130. }
  131. private bool _IsOnline;
  132. public bool IsOnline => _IsOnline;
  133. //public bool IsTMVac => _tm.IsTMVac;
  134. //public bool IsTMATM => _tm.IsTMATM;
  135. #endregion
  136. #region 私有变量
  137. private readonly HongHuTM _tm;
  138. private readonly ITransferRobot _robot;
  139. private readonly IPreAlign _vpa;
  140. private readonly SEMFHomeRoutine _homeRoutine;
  141. private readonly SEMFPickRoutine _pickRoutine;
  142. private readonly SEMFPlaceRoutine _placeRoutine;
  143. private readonly SEMFVentRoutine _ventRoutine;
  144. private readonly SEMFPumpRoutine _pumpRoutine;
  145. private readonly SEMFPMPickRoutine _pickpmRoutine;
  146. private readonly SEMFPMPlaceRoutine _placepmRoutine;
  147. private readonly SEMFSwapRoutine _swaproutine;
  148. private readonly SEMFPMSwapRoutine _pmswaproutine;
  149. private readonly SEMFPMRetractRoutine _pmRetractRoutine;
  150. private readonly SEMFPMExtendRoutine _pmExtendRoutine;
  151. //private readonly
  152. //private bool startControlPressureFlag = true;
  153. //private bool stopControlPressureFlag = false;
  154. private Stopwatch _robotWatch = new Stopwatch();
  155. //private R_TRIG _robotIdleTrigger = new R_TRIG();
  156. //private int _controlPressureCheckPoint = 100;
  157. //private int _controlPressureSetPoint = 90;
  158. //private int _controlFlowSetPoint = 90;
  159. #endregion
  160. public SETMEntity()
  161. {
  162. _tm = DEVICE.GetDevice<HongHuTM>("SETM");
  163. if(ModuleHelper.IsInstalled(ModuleName.TMRobot))
  164. _robot = new HongHuVR();
  165. _vpa = new HongHuVPA(ModuleName.VPA);
  166. _robotWatch = new Stopwatch();
  167. _homeRoutine = new SEMFHomeRoutine(_tm,_robot, _vpa);
  168. _pickRoutine = new SEMFPickRoutine(_tm,_robot, _vpa);
  169. _placeRoutine = new SEMFPlaceRoutine(_tm, _robot, _vpa);
  170. _pumpRoutine = new SEMFPumpRoutine(_tm, ModuleName.SETM);
  171. _ventRoutine = new SEMFVentRoutine(_tm, ModuleName.SETM);
  172. _pickpmRoutine = new SEMFPMPickRoutine(_tm, _robot);
  173. _placepmRoutine = new SEMFPMPlaceRoutine(_tm, _robot);
  174. _swaproutine = new SEMFSwapRoutine(_tm, _robot);
  175. _pmswaproutine = new SEMFPMSwapRoutine(_tm, _robot);
  176. _pmExtendRoutine = new SEMFPMExtendRoutine(_tm, _robot, _vpa);
  177. _pmRetractRoutine = new SEMFPMRetractRoutine(_tm, _robot, _vpa);
  178. InitFsmMap();
  179. }
  180. protected override bool Init()
  181. {
  182. DATA.Subscribe($"SETM.FsmState", () => ((STATE)fsm.State).ToString());
  183. DATA.Subscribe("SETM.RobotMoveAction", () => _robot.TMRobotMoveInfo, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  184. DATA.Subscribe("SETM.RobotMoveAction.ArmTarget", () => _robot.TMRobotMoveInfo.ArmTarget.ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  185. DATA.Subscribe("SETM.RobotMoveAction.BladeTarget", () => _robot.TMRobotMoveInfo.BladeTarget, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  186. DATA.Subscribe("SETM.RobotMoveAction.RobotAction", () => _robot.TMRobotMoveInfo.Action.ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  187. DATA.Subscribe("SETM.IsOnline", () => IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  188. DATA.Subscribe("SETM.IsOffline", () => !IsOnline, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  189. OP.Subscribe("SETM.Goto", (cmd, args) => RobotGoto(args));
  190. OP.Subscribe("SETM.Home", (cmd, args) => { PostMsg(MSG.Home); return true; });
  191. OP.Subscribe("SETM.Abort", (cmd, args) => { PostMsg(MSG.Abort); return true; });
  192. OP.Subscribe("SETM.Pick", (cmd, args) => { PostMsg(MSG.Pick, args); return true; });
  193. OP.Subscribe("SETM.Place", (cmd, args) => { PostMsg(MSG.Place, args); return true; });
  194. OP.Subscribe("SETM.Extend", (cmd, args) => { PostMsg(MSG.Extend, args); return true; });
  195. OP.Subscribe("SETM.Retract", (cmd, args) => { PostMsg(MSG.Retract, args); return true; });
  196. OP.Subscribe("SETM.PMPick", (cmd, args) => { PostMsg(MSG.PMPick, args); return true; });
  197. OP.Subscribe("SETM.PMPlace", (cmd, args) => { PostMsg(MSG.PMPlace, args); return true; });
  198. OP.Subscribe("SETM.PumpDown", (cmd, args) => { PostMsg(MSG.Pump); return true; });
  199. OP.Subscribe("SETM.Vent", (cmd, args) => { PostMsg(MSG.Vent); return true; });
  200. OP.Subscribe("SETM.SetOnline", (cmd, args) =>
  201. {
  202. if (IsIdle)
  203. _IsOnline = true;
  204. else
  205. LOG.Write(eEvent.WARN_TM,ModuleName.TM,"cannot Set Online as TM is not idle");
  206. return true;
  207. });
  208. OP.Subscribe("SETM.SetOffline", (cmd, args) =>
  209. {
  210. _IsOnline = false;
  211. return true;
  212. });
  213. return true;
  214. }
  215. private void InitFsmMap()
  216. {
  217. fsm = new StateMachine<SETMEntity>("SETM", (int)STATE.Init, 50);
  218. AnyStateTransition(MSG.Error, fnError, STATE.Error);
  219. AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
  220. AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
  221. AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
  222. //Home
  223. Transition(STATE.Initializing, FSM_MSG.TIMER, fnHomeTimeout, STATE.Idle);
  224. Transition(STATE.Initializing, MSG.Abort, fnAbortHome, STATE.Init);
  225. //Pick
  226. Transition(STATE.Idle, MSG.Pick, fnStartPick, STATE.Picking);
  227. Transition(STATE.Picking, FSM_MSG.TIMER, fnPickTimeout, STATE.Idle);
  228. Transition(STATE.Picking, MSG.Abort, fnAbortPick, STATE.Idle);
  229. //Place
  230. Transition(STATE.Idle, MSG.Place, fnStartPlace, STATE.Placing);
  231. Transition(STATE.Placing, FSM_MSG.TIMER, fnPlaceTimeout, STATE.Idle);
  232. Transition(STATE.Placing, MSG.Abort, fnAbortPlace, STATE.Idle);
  233. //Pump
  234. Transition(STATE.Idle, MSG.Pump, fnStartPump, STATE.Pumping);
  235. Transition(STATE.Pumping, FSM_MSG.TIMER, fnPumpTimeout, STATE.Idle);
  236. Transition(STATE.Pumping, MSG.Abort, fnAbortPump, STATE.Idle);
  237. //Vent
  238. Transition(STATE.Idle, MSG.Vent, fnStartVent, STATE.Venting);
  239. Transition(STATE.Venting, FSM_MSG.TIMER, fnVentTimeout, STATE.Idle);
  240. Transition(STATE.Venting, MSG.Abort, fnAbortVent, STATE.Idle);
  241. //PMPick
  242. Transition(STATE.Idle, MSG.PMPick, fnStartPMPick, STATE.PMPicking);
  243. Transition(STATE.PMPicking, FSM_MSG.TIMER, fnPMPickTimeout, STATE.Idle);
  244. Transition(STATE.PMPicking, MSG.Abort, fnAbortPMPick, STATE.Idle);
  245. //PMPlace
  246. Transition(STATE.Idle, MSG.PMPlace, fnStartPMPlace, STATE.PMPlacing);
  247. Transition(STATE.PMPlacing, FSM_MSG.TIMER, fnPMPlaceTimeout, STATE.Idle);
  248. Transition(STATE.PMPlacing, MSG.Abort, fnAbortPMPlace, STATE.Idle);
  249. //PA align
  250. Transition(STATE.Idle, MSG.Align, fnStartAlign, STATE.Aligning);
  251. Transition(STATE.Aligning, FSM_MSG.TIMER, fnAlignTimeout, STATE.Idle);
  252. Transition(STATE.Aligning, MSG.Abort, fnAbortAlign, STATE.Idle);
  253. //Swap
  254. Transition(STATE.Idle, MSG.Swap, fnStartSwap, STATE.Swapping);
  255. Transition(STATE.Swapping, FSM_MSG.TIMER, fnSwapTimeout, STATE.Idle);
  256. Transition(STATE.Swapping, MSG.Abort, fnAbortSwap, STATE.Idle);
  257. //PM Swap
  258. Transition(STATE.Idle, MSG.PMSwap, fnStartPMSwap, STATE.PMSwaping);
  259. Transition(STATE.PMSwaping, FSM_MSG.TIMER, fnPMSwapTimeout, STATE.Idle);
  260. Transition(STATE.PMSwaping, MSG.Abort, fnAbortPMSwap, STATE.Idle);
  261. //Extend
  262. Transition(STATE.Idle, MSG.Extend, FnStartExtend, STATE.Extending);
  263. Transition(STATE.Extending, FSM_MSG.TIMER, FnExtend, STATE.Idle);
  264. Transition(STATE.Extending, MSG.Abort, FnAbortExtend, STATE.Idle);
  265. //Retract
  266. Transition(STATE.Idle, MSG.Retract, FnStartRetract, STATE.Retracting);
  267. Transition(STATE.Retracting, FSM_MSG.TIMER, FnRetract, STATE.Idle);
  268. Transition(STATE.Retracting, MSG.Abort, FnAbortRetract, STATE.Idle);
  269. //Control Pressure
  270. AnyStateTransition(FSM_MSG.TIMER, ControlPressureTimer_Elapsed, FSM_STATE.SAME);
  271. Running = true;
  272. }
  273. private bool RobotGoto(object[] param)
  274. {
  275. return _robot.Goto((ModuleName)param[0], (int)param[1], (Hand)param[2]);
  276. }
  277. private bool FnStartExtend(object[] param)
  278. {
  279. return _pmExtendRoutine.Start(param) == RState.Running;
  280. }
  281. private bool FnExtend(object[] param)
  282. {
  283. RState ret = _pmExtendRoutine.Monitor();
  284. if (ret == RState.Failed || ret == RState.Timeout)
  285. {
  286. PostMsg(MSG.Error);
  287. return false;
  288. }
  289. return ret == RState.End;
  290. }
  291. private bool FnAbortExtend(object[] param)
  292. {
  293. _pmExtendRoutine.Abort();
  294. return true;
  295. }
  296. private bool FnStartRetract(object[] param)
  297. {
  298. return _pmRetractRoutine.Start(param) == RState.Running;
  299. }
  300. private bool FnRetract(object[] param)
  301. {
  302. RState ret = _pmRetractRoutine.Monitor();
  303. if (ret == RState.Failed || ret == RState.Timeout)
  304. {
  305. PostMsg(MSG.Error);
  306. return false;
  307. }
  308. return ret == RState.End;
  309. }
  310. private bool FnAbortRetract(object[] param)
  311. {
  312. _pmRetractRoutine.Abort();
  313. return true;
  314. }
  315. private bool fnAbortPMSwap(object[] param)
  316. {
  317. _pmswaproutine.Abort();
  318. return true;
  319. }
  320. private bool fnPMSwapTimeout(object[] param)
  321. {
  322. RState ret = _pmswaproutine.Monitor();
  323. if (ret == RState.Failed || ret == RState.Timeout)
  324. {
  325. PostMsg(MSG.Error);
  326. return false;
  327. }
  328. return ret == RState.End;
  329. }
  330. private bool fnStartPMSwap(object[] param)
  331. {
  332. return _pmswaproutine.Start(param) == RState.Running;
  333. }
  334. private bool fnAbortSwap(object[] param)
  335. {
  336. _swaproutine.Abort();
  337. return true;
  338. }
  339. private bool fnSwapTimeout(object[] param)
  340. {
  341. RState ret = _swaproutine.Monitor();
  342. if (ret == RState.Failed || ret == RState.Timeout)
  343. {
  344. PostMsg(MSG.Error);
  345. return false;
  346. }
  347. return ret == RState.End;
  348. }
  349. private bool fnStartSwap(object[] param)
  350. {
  351. return _swaproutine.Start(param) == RState.Running;
  352. }
  353. private bool fnStartAlign(object[] param)
  354. {
  355. if (float.TryParse(param[0].ToString(), out float angle))
  356. {
  357. return _vpa.Align();
  358. }
  359. else
  360. {
  361. LOG.Write(eEvent.ERR_TM,ModuleName.VPA,$"wrong angle, value is {param[0]}.");
  362. return false;
  363. }
  364. }
  365. private bool fnAlignTimeout(object[] param)
  366. {
  367. if (_vpa.Status == RState.End)
  368. {
  369. return true;
  370. }
  371. else if (_vpa.Status != RState.Running)
  372. {
  373. LOG.Write(eEvent.ERR_TM, ModuleName.VPA, $"PreAligner align failed: {_vpa.Status}");
  374. return true;
  375. }
  376. return false;
  377. }
  378. private bool fnAbortAlign(object[] param)
  379. {
  380. return true;
  381. }
  382. private bool fnAbortPMPlace(object[] param)
  383. {
  384. _placepmRoutine.Abort();
  385. return true;
  386. }
  387. private bool fnPMPlaceTimeout(object[] param)
  388. {
  389. RState ret = _placepmRoutine.Monitor();
  390. if (ret == RState.Failed || ret == RState.Timeout)
  391. {
  392. PostMsg(MSG.Error);
  393. return false;
  394. }
  395. return ret == RState.End;
  396. }
  397. private bool fnStartPMPlace(object[] param)
  398. {
  399. return _placepmRoutine.Start(param) == RState.Running;
  400. }
  401. private bool fnAbortPMPick(object[] param)
  402. {
  403. _pickpmRoutine.Abort();
  404. return true;
  405. }
  406. private bool fnPMPickTimeout(object[] param)
  407. {
  408. RState ret = _pickpmRoutine.Monitor();
  409. if (ret == RState.Failed || ret == RState.Timeout)
  410. {
  411. PostMsg(MSG.Error);
  412. return false;
  413. }
  414. return ret == RState.End;
  415. }
  416. private bool fnStartPMPick(object[] param)
  417. {
  418. return _pickpmRoutine.Start(param) == RState.Running;
  419. }
  420. private bool fnAbortVent(object[] param)
  421. {
  422. _ventRoutine.Abort();
  423. return true;
  424. }
  425. private bool fnVentTimeout(object[] param)
  426. {
  427. RState ret = _ventRoutine.Monitor();
  428. if (ret == RState.Failed || ret == RState.Timeout)
  429. {
  430. _ventRoutine.Abort();
  431. PostMsg(MSG.Error);
  432. return false;
  433. }
  434. return ret == RState.End;
  435. }
  436. private bool fnStartVent(object[] param)
  437. {
  438. return _ventRoutine.Start(param) == RState.Running;
  439. }
  440. private bool fnAbortPump(object[] param)
  441. {
  442. _pumpRoutine.Abort();
  443. return true;
  444. }
  445. private bool fnPumpTimeout(object[] param)
  446. {
  447. RState ret = _pumpRoutine.Monitor();
  448. if (ret == RState.Failed || ret == RState.Timeout)
  449. {
  450. _pumpRoutine.Abort();
  451. PostMsg(MSG.Error);
  452. return false;
  453. }
  454. return ret == RState.End;
  455. }
  456. private bool fnStartPump(object[] param)
  457. {
  458. return _pumpRoutine.Start(param) == RState.Running;
  459. }
  460. private bool fnAbortPlace(object[] param)
  461. {
  462. return true;
  463. }
  464. private bool fnPlaceTimeout(object[] param)
  465. {
  466. RState ret = _placeRoutine.Monitor();
  467. if (ret == RState.Failed || ret == RState.Timeout)
  468. {
  469. PostMsg(MSG.Error);
  470. return false;
  471. }
  472. return ret == RState.End;
  473. }
  474. private bool fnStartPlace(object[] param)
  475. {
  476. return _placeRoutine.Start(param) == RState.Running;
  477. }
  478. private bool fnAbortPick(object[] param)
  479. {
  480. _pickRoutine.Abort();
  481. return true;
  482. }
  483. private bool fnStartPick(object[] param)
  484. {
  485. return _pickRoutine.Start(param) == RState.Running;
  486. }
  487. private bool fnPickTimeout(object[] param)
  488. {
  489. RState ret = _pickRoutine.Monitor();
  490. if (ret == RState.Failed || ret == RState.Timeout)
  491. {
  492. PostMsg(MSG.Error);
  493. return false;
  494. }
  495. return ret == RState.End;
  496. }
  497. private bool fnAbortHome(object[] param)
  498. {
  499. _homeRoutine.Abort();
  500. return true;
  501. }
  502. private bool fnHome(object[] param)
  503. {
  504. if (fsm.State == (int)STATE.Init && param.Length > 0)//带参home
  505. {
  506. return false;
  507. }
  508. else
  509. return _homeRoutine.Start(param) == RState.Running;
  510. }
  511. private bool fnHomeTimeout(object[] param)
  512. {
  513. RState ret = _homeRoutine.Monitor();
  514. if (ret == RState.Failed || ret == RState.Timeout)
  515. {
  516. PostMsg(MSG.Error);
  517. return false;
  518. }
  519. return ret == RState.End;
  520. }
  521. private bool fnOffline(object[] param)
  522. {
  523. //IsOnline = false;
  524. //return true;
  525. throw new NotImplementedException();
  526. }
  527. private bool fnOnline(object[] param)
  528. {
  529. //IsOnline = true;
  530. //return true;
  531. throw new NotImplementedException();
  532. }
  533. private bool fnError(object[] param)
  534. {
  535. return true;
  536. }
  537. private bool ControlPressureTimer_Elapsed(object[] param)
  538. {
  539. if (RouteManager.IsATMMode)
  540. return true;
  541. if (IsOnline && _tm.PumpingState == HongHuTM.PumpState.Idle)
  542. {
  543. if (SC.GetValue<bool>($"SETM.PressureControl.ControlWriteMode"))
  544. {
  545. SC.SetItemValue("SETM.PressureControl.ControlWriteMode",false);
  546. }
  547. }
  548. else
  549. {
  550. if (!SC.GetValue<bool>($"SETM.PressureControl.ControlWriteMode"))
  551. {
  552. SC.SetItemValue("SETM.PressureControl.ControlWriteMode", true);
  553. }
  554. }
  555. return true;
  556. }
  557. public bool Check(int msg, out string reason, params object[] args)
  558. {
  559. reason = "";
  560. return true;
  561. }
  562. public bool CheckAcked(int msg)
  563. {
  564. return fsm.CheckExecuted(msg);
  565. }
  566. public bool CheckToPostMessage(int msg, params object[] args)
  567. {
  568. if (!fsm.FindTransition(fsm.State, msg))
  569. {
  570. LOG.Write(eEvent.WARN_FSM_WARN, ModuleName.TM, $"TM is in {(STATE)fsm.State} state,can not do {(MSG)msg}");
  571. return false;
  572. }
  573. Running = true;
  574. fsm.PostMsg(msg, args);
  575. return true;
  576. }
  577. public int Invoke(string function, params object[] args)
  578. {
  579. switch (function)
  580. {
  581. case "Home":
  582. CheckToPostMessage((int)MSG.Home);
  583. return (int)MSG.Home;
  584. }
  585. return (int)FSM_MSG.NONE;
  586. }
  587. }
  588. }