IoPump.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.RT.DataCenter;
  5. using Aitex.Core.RT.Device;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.IOCore;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.OperationCenter;
  10. using Aitex.Core.RT.SCCore;
  11. using Aitex.Core.RT.Tolerance;
  12. using Aitex.Core.Util;
  13. using MECF.Framework.Common.Device.Bases;
  14. namespace VirgoRT.Devices
  15. {
  16. public class IoPump : PumpBase
  17. {
  18. [Subscription(AITPumpProperty.EnableDryPump)]
  19. public bool IsDryPumpEnabled
  20. {
  21. get
  22. {
  23. return _scEnableDryPump == null || _scEnableDryPump.BoolValue;
  24. }
  25. }
  26. [Subscription(AITPumpProperty.EnableWaterFlow)]
  27. public bool EnableWaterFlow
  28. {
  29. get
  30. {
  31. return _scEnableWaterFlow != null && _scEnableWaterFlow.BoolValue;
  32. }
  33. }
  34. [Subscription(AITPumpProperty.WaterFlowWarning)]
  35. public bool WaterFlowWarning
  36. {
  37. get
  38. {
  39. return _checkWaterFlowWarning.Result;
  40. }
  41. }
  42. //[Subscription(AITPumpProperty.WaterFlowAlarm)]
  43. public bool WaterFlowAlarm
  44. {
  45. get
  46. {
  47. return _diWaterFlowAlarm.Value;
  48. }
  49. }
  50. [Subscription(AITPumpProperty.WaterFlowAlarmSetPoint)]
  51. public bool WaterFlowAlarmSetPoint
  52. {
  53. get
  54. {
  55. return _doWaterFlowAlarm != null && _doWaterFlowAlarm.Value;
  56. }
  57. set
  58. {
  59. if (_doWaterFlowAlarm != null)
  60. {
  61. string reason;
  62. if (!_doWaterFlowAlarm.SetValue(value, out reason))
  63. {
  64. LOG.Write(reason);
  65. }
  66. }
  67. }
  68. }
  69. [Subscription(AITPumpProperty.WaterFlowWarningTime)]
  70. public float WaterFlowWarningTime
  71. {
  72. get
  73. {
  74. return _scWaterFlowOutOfToleranceWarningTime == null ? 0 : (float)_scWaterFlowOutOfToleranceWarningTime.Value;
  75. }
  76. }
  77. [Subscription(AITPumpProperty.WaterFlowAlarmTime)]
  78. public float WaterFlowAlarmTime
  79. {
  80. get
  81. {
  82. return _scWaterFlowOutOfToleranceAlarmTime == null ? 0 : (float)_scWaterFlowOutOfToleranceAlarmTime.Value;
  83. }
  84. }
  85. [Subscription(AITPumpProperty.WaterFlowValue)]
  86. public double WaterFlowValue
  87. {
  88. get
  89. {
  90. return _aiWaterFlow == null ? 0 : _aiWaterFlow.Value;
  91. }
  92. }
  93. [Subscription(AITPumpProperty.WaterFlowMinValue)]
  94. public double WaterFlowMinValue
  95. {
  96. get
  97. {
  98. return _scWaterFlowMinValue == null ? 0 : (float)_scWaterFlowMinValue.Value;
  99. }
  100. }
  101. [Subscription(AITPumpProperty.WaterFlowMaxValue)]
  102. public double WaterFlowMaxValue
  103. {
  104. get
  105. {
  106. return _scWaterFlowMaxValue == null ? 0 : (float)_scWaterFlowMaxValue.Value;
  107. }
  108. }
  109. [Subscription(AITPumpProperty.EnableN2Pressure)]
  110. public bool EnableN2Pressure
  111. {
  112. get
  113. {
  114. if (_scEnableN2Pressure == null || _scN2PressureMinValue == null || _scN2PressureMaxValue == null ||
  115. _scN2PressureOutOfToleranceWarningTime == null || _scN2PressureOutOfToleranceAlarmTime == null)
  116. return false;
  117. return _scEnableN2Pressure != null && _scEnableN2Pressure.BoolValue;
  118. }
  119. }
  120. [Subscription(AITPumpProperty.N2PressureWarning)]
  121. public bool N2PressureWarning
  122. {
  123. get
  124. {
  125. return _checkN2PressureWarning.Result;
  126. }
  127. }
  128. [Subscription(AITPumpProperty.N2PressureValue)]
  129. public float N2PressureValue
  130. {
  131. get
  132. {
  133. return _aiN2Pressure == null ? 0 : _aiN2Pressure.Value;
  134. }
  135. }
  136. [Subscription(AITPumpProperty.N2PressureWarningTime)]
  137. public float N2PressureWarningTime
  138. {
  139. get
  140. {
  141. return _scN2PressureOutOfToleranceWarningTime == null ? 0 : (float)_scN2PressureOutOfToleranceWarningTime.Value;
  142. }
  143. }
  144. [Subscription(AITPumpProperty.N2PressureAlarmTime)]
  145. public float N2PressureAlarmTime
  146. {
  147. get
  148. {
  149. return _scN2PressureOutOfToleranceAlarmTime == null ? 0 : (float)_scN2PressureOutOfToleranceAlarmTime.Value;
  150. }
  151. }
  152. [Subscription(AITPumpProperty.N2PressureMinValue)]
  153. public float N2PressureMinValue
  154. {
  155. get
  156. {
  157. return _scN2PressureMinValue == null ? 0 : (float)_scN2PressureMinValue.Value;
  158. }
  159. }
  160. [Subscription(AITPumpProperty.N2PressureMaxValue)]
  161. public float N2PressureMaxValue
  162. {
  163. get
  164. {
  165. return _scN2PressureMaxValue == null ? 0 : (float)_scN2PressureMaxValue.Value;
  166. }
  167. }
  168. //[Subscription(AITPumpProperty.N2PressureAlarm)]
  169. public bool N2PressureAlarm
  170. {
  171. get
  172. {
  173. return _diN2Alarm.Value;
  174. }
  175. }
  176. [Subscription(AITPumpProperty.N2PressureAlarmSetPoint)]
  177. public bool N2PressureAlarmSetPoint
  178. {
  179. get
  180. {
  181. return _doN2PressureAlarm != null && _doN2PressureAlarm.Value;
  182. }
  183. set
  184. {
  185. if (_doN2PressureAlarm != null)
  186. {
  187. string reason;
  188. if (!_doN2PressureAlarm.SetValue(value, out reason))
  189. {
  190. LOG.Write(reason);
  191. }
  192. }
  193. }
  194. }
  195. public int LocalRemoteMode
  196. {
  197. get
  198. {
  199. return _doLocalRemote.Value ? 1 : 0;
  200. }
  201. }
  202. public bool HasError
  203. {
  204. get
  205. {
  206. return IsPumpTempAlarm || IsPumpOverloadAlarm || IsError || N2PressureAlarm || WaterFlowAlarm || _trigExhaustPressureAlarm.M;
  207. }
  208. }
  209. public bool HasWarning
  210. {
  211. get
  212. {
  213. return IsPumpN2FlowWarning || IsPumpTempWarning || IsWaterFlowWarning || IsWarning;
  214. }
  215. }
  216. [Subscription(AITPumpProperty.IsRunning)]
  217. public override bool IsRunning
  218. {
  219. get
  220. {
  221. if (_diRunning != null)
  222. return _diRunning.Value;
  223. if (_diPowerOn != null)
  224. return _diPowerOn.Value;
  225. return true; //默认常开
  226. }
  227. }
  228. public bool IsWarning
  229. {
  230. get
  231. {
  232. return _diWarning != null && _diWarning.Value;
  233. }
  234. }
  235. public bool IsPumpTempWarning
  236. {
  237. get
  238. {
  239. return _diPumpTempWaring != null && _diPumpTempWaring.Value;
  240. }
  241. }
  242. public bool IsPumpN2FlowWarning
  243. {
  244. get
  245. {
  246. return _diPumpN2FlowWarning != null && _diPumpN2FlowWarning.Value;
  247. }
  248. }
  249. public override bool IsError
  250. {
  251. get
  252. {
  253. return _diError != null && _diError.Value;
  254. }
  255. }
  256. public bool IsWaterFlowWarning
  257. {
  258. get
  259. {
  260. return _diWaterFlowWarning != null && _diWaterFlowWarning.Value;
  261. }
  262. }
  263. public bool IsPumpTempAlarm
  264. {
  265. get
  266. {
  267. return _diPumpTempAlarm != null && _diPumpTempAlarm.Value;
  268. }
  269. }
  270. public bool IsPumpOverloadAlarm
  271. {
  272. get
  273. {
  274. return _diOverloadAlarm != null && _diOverloadAlarm.Value;
  275. }
  276. }
  277. public double H2OSensorMassWarningThreshold
  278. {
  279. get
  280. {
  281. return _aiH2OSensorMassWarningThreshold == null ? 0 : _aiH2OSensorMassWarningThreshold.Value;
  282. }
  283. set
  284. {
  285. if (_scH2OSensorMassWarningThreshold == null)
  286. return;
  287. double result = value;
  288. result = Math.Max(int.Parse(_scH2OSensorMassWarningThreshold.Min), result);
  289. result = Math.Min(int.Parse(_scH2OSensorMassWarningThreshold.Max), result);
  290. _scH2OSensorMassWarningThreshold.DoubleValue = result;
  291. //_aoH2OSensorMassWarningThreshold.Value = (float)value;
  292. }
  293. }
  294. public double H2OSensorMassWarningTime
  295. {
  296. get
  297. {
  298. return _aiH2OSensorMassWarningTime == null ? 0 : _aiH2OSensorMassWarningTime.Value;
  299. }
  300. set
  301. {
  302. if (_scH2OSensorMassWarningTime == null)
  303. return;
  304. double result = value;
  305. result = Math.Max(int.Parse(_scH2OSensorMassWarningTime.Min), result);
  306. result = Math.Min(int.Parse(_scH2OSensorMassWarningTime.Max), result);
  307. _scH2OSensorMassWarningTime.DoubleValue = result;
  308. //_aoH2OSensorMassWarningTime.Value = (float) value;
  309. }
  310. }
  311. public double N2PurgeFlow
  312. {
  313. get
  314. {
  315. return _aiN2PurgeFlow == null ? 0 : _aiN2PurgeFlow.Value;
  316. }
  317. }
  318. public double N2PurgeFlowWarningThreshold
  319. {
  320. get
  321. {
  322. return _aiN2PurgeFlowWarningThreshold == null ? 0 : _aiN2PurgeFlowWarningThreshold.Value;
  323. }
  324. set
  325. {
  326. if (_scN2PurgeFlowWarning == null)
  327. return;
  328. double result = value;
  329. result = Math.Max(int.Parse(_scN2PurgeFlowWarning.Min), result);
  330. result = Math.Min(int.Parse(_scN2PurgeFlowWarning.Max), result);
  331. _scN2PurgeFlowWarning.DoubleValue = result;
  332. //_aoN2PurgeFlowWarning.Value = (float) value;
  333. }
  334. }
  335. public double N2PurgeFlowWarningTime
  336. {
  337. get
  338. {
  339. return _aiN2PurgeFlowWarningTime == null ? 0 : _aiN2PurgeFlowWarningTime.Value;
  340. }
  341. set
  342. {
  343. if (_scN2PurgeFlowWarningTime == null)
  344. return;
  345. double result = value;
  346. result = Math.Max(int.Parse(_scN2PurgeFlowWarningTime.Min), result);
  347. result = Math.Min(int.Parse(_scN2PurgeFlowWarningTime.Max), result);
  348. _scN2PurgeFlowWarningTime.DoubleValue = result;
  349. //_aoN2PurgeFlowWarningTime.Value = (float) value;
  350. }
  351. }
  352. public double ExhaustPressure
  353. {
  354. get
  355. {
  356. return _aiExhaustPressure == null ? 0 : _aiExhaustPressure.Value;
  357. }
  358. }
  359. public double ExhaustPressurePreWarningThreshold
  360. {
  361. get
  362. {
  363. return _aiExhaustPressurePreWarningThreshold == null ? 0 : _aiExhaustPressurePreWarningThreshold.Value;
  364. }
  365. set
  366. {
  367. if (_scExhaustPressurePreWarningThreshold == null)
  368. return;
  369. double result = value;
  370. result = Math.Max(int.Parse(_scExhaustPressurePreWarningThreshold.Min), result);
  371. result = Math.Min(int.Parse(_scExhaustPressurePreWarningThreshold.Max), result);
  372. _scExhaustPressurePreWarningThreshold.DoubleValue = result;
  373. //_aoExhaustPressurePreWarningThreshold.Value = (float) value;
  374. }
  375. }
  376. public double ExhaustPressurePreWarningTime
  377. {
  378. get
  379. {
  380. return _aiExhaustPressurePreWarningTime == null ? 0 : _aiExhaustPressurePreWarningTime.Value;
  381. }
  382. set
  383. {
  384. if (_scExhaustPressurePreWarningTime == null)
  385. return;
  386. double result = value;
  387. result = Math.Max(int.Parse(_scExhaustPressurePreWarningTime.Min), result);
  388. result = Math.Min(int.Parse(_scExhaustPressurePreWarningTime.Max), result);
  389. _scExhaustPressurePreWarningTime.DoubleValue = result;
  390. //_aoExhaustPressurePreWarningTime.Value = (float) value;
  391. }
  392. }
  393. public bool IsStartButtonPushed
  394. {
  395. get
  396. {
  397. return _diStart != null && _diStart.Value;
  398. }
  399. }
  400. public bool IsStopButtonPushed
  401. {
  402. get
  403. {
  404. return _diStop != null && _diStop.Value;
  405. }
  406. }
  407. private readonly DIAccessor _diRunning = null;
  408. private readonly DIAccessor _diPumpTempWaring = null;
  409. private readonly DIAccessor _diPumpN2FlowWarning = null;
  410. private readonly DIAccessor _diPumpTempAlarm = null;
  411. private readonly DIAccessor _diWaterFlowWarning = null;
  412. private readonly DIAccessor _diOverloadAlarm;
  413. private readonly DIAccessor _diPowerOn;
  414. private readonly DIAccessor _diStart;
  415. private readonly DIAccessor _diStop;
  416. private readonly DIAccessor _diError;
  417. private readonly DIAccessor _diWarning;
  418. private readonly DIAccessor _diWaterFlowAlarm;
  419. private readonly DIAccessor _diN2Warning;
  420. private readonly DIAccessor _diN2Alarm;
  421. private readonly DIAccessor _diExhaustPressureWarning;
  422. private readonly DIAccessor _diExhaustPressureAlarm;
  423. private readonly DIAccessor _diLogicWaterFlowAlarm;
  424. private readonly DIAccessor _diLogicN2PressureAlarm;
  425. private readonly DOAccessor _doStart;
  426. private readonly DOAccessor _doStop;
  427. private readonly DOAccessor _doLocalRemote;
  428. private readonly DOAccessor _doWarningReset;
  429. private readonly DOAccessor _doWaterFlowAlarm;
  430. private readonly DOAccessor _doN2PressureAlarm;
  431. private readonly AOAccessor _aoH2OSensorMassWarningThreshold;
  432. private readonly AOAccessor _aoH2OSensorMassWarningTime;
  433. private readonly AOAccessor _aoN2PurgeFlowWarning;
  434. private readonly AOAccessor _aoN2PurgeFlowWarningTime;
  435. private readonly AOAccessor _aoExhaustPressurePreWarningThreshold;
  436. private readonly AOAccessor _aoExhaustPressurePreWarningTime;
  437. private readonly AOAccessor _aoWaterFlowAlarmMinValue;
  438. private readonly AOAccessor _aoWaterFlowAlarmMaxValue;
  439. private readonly AOAccessor _aoN2PressureAlarmMinValue;
  440. private readonly AOAccessor _aoN2PressureAlarmMaxValue;
  441. private readonly AIAccessor _aiWaterFlow;
  442. private readonly AIAccessor _aiN2Pressure;
  443. private readonly AIAccessor _aiH2OSensorMassWarningThreshold;
  444. private readonly AIAccessor _aiH2OSensorMassWarningTime;
  445. private readonly AIAccessor _aiN2PurgeFlow;
  446. private readonly AIAccessor _aiN2PurgeFlowWarningThreshold;
  447. private readonly AIAccessor _aiN2PurgeFlowWarningTime;
  448. private readonly AIAccessor _aiExhaustPressure;
  449. private readonly AIAccessor _aiExhaustPressurePreWarningThreshold;
  450. private readonly AIAccessor _aiExhaustPressurePreWarningTime;
  451. private readonly SCConfigItem _scH2OSensorMassWarningThreshold;
  452. private readonly SCConfigItem _scH2OSensorMassWarningTime;
  453. private readonly SCConfigItem _scN2PurgeFlowWarning;
  454. private readonly SCConfigItem _scN2PurgeFlowWarningTime;
  455. private readonly SCConfigItem _scExhaustPressurePreWarningThreshold;
  456. private readonly SCConfigItem _scExhaustPressurePreWarningTime;
  457. private readonly SCConfigItem _scEnableWaterFlow;
  458. private readonly SCConfigItem _scWaterFlowMinValue;
  459. private readonly SCConfigItem _scWaterFlowMaxValue;
  460. private readonly SCConfigItem _scWaterFlowOutOfToleranceWarningTime;
  461. private readonly SCConfigItem _scWaterFlowOutOfToleranceAlarmTime;
  462. private readonly SCConfigItem _scEnableN2Pressure;
  463. private readonly SCConfigItem _scN2PressureMinValue;
  464. private readonly SCConfigItem _scN2PressureMaxValue;
  465. private readonly SCConfigItem _scN2PressureOutOfToleranceWarningTime;
  466. private readonly SCConfigItem _scN2PressureOutOfToleranceAlarmTime;
  467. private readonly SCConfigItem _scEnableDryPump;
  468. private readonly R_TRIG _trigWarning = new R_TRIG();
  469. private readonly R_TRIG _trigError = new R_TRIG();
  470. private readonly R_TRIG _trigWaterFlowSensorWarning = new R_TRIG();
  471. private readonly R_TRIG _trigWaterFlowSensorAlarm = new R_TRIG();
  472. private readonly R_TRIG _trigN2Warning = new R_TRIG();
  473. private readonly R_TRIG _trigN2Alarm = new R_TRIG();
  474. private readonly R_TRIG _trigExhaustPressureWarning = new R_TRIG();
  475. private readonly R_TRIG _trigExhaustPressureAlarm = new R_TRIG();
  476. private readonly ToleranceChecker _checkN2PressureWarning = new ToleranceChecker();
  477. private readonly ToleranceChecker _checkN2PressureAlarm = new ToleranceChecker();
  478. private readonly ToleranceChecker _checkWaterFlowWarning = new ToleranceChecker();
  479. private readonly ToleranceChecker _checkWaterFlowAlarm = new ToleranceChecker();
  480. private readonly DeviceTimer _timer = new DeviceTimer();
  481. public IoPump(string module, XmlElement node, string ioModule = "")
  482. {
  483. base.Module = module;
  484. base.Name = node.GetAttribute("id");
  485. base.Display = node.GetAttribute("display");
  486. base.DeviceID = node.GetAttribute("schematicId");
  487. _diError = ParseDiNode("diAlarm", node, ioModule);
  488. _diRunning = ParseDiNode("diRunning", node, ioModule);
  489. _diWarning = ParseDiNode("diWarning", node, ioModule);
  490. _diOverloadAlarm = ParseDiNode("diOverloadAlarm", node, ioModule);
  491. _diPowerOn = ParseDiNode("diPowerOn", node, ioModule);
  492. _diStart = ParseDiNode("diStart", node, ioModule);
  493. _diStop = ParseDiNode("diStop", node, ioModule);
  494. _diPumpTempWaring = ParseDiNode("diPumpTempWaring", node, ioModule);
  495. _diPumpTempAlarm = ParseDiNode("diPumpTempAlarm", node, ioModule);
  496. _diWaterFlowWarning = ParseDiNode("diWaterFlowWarning", node, ioModule);
  497. _diWaterFlowAlarm = ParseDiNode("diWaterFlowAlarm", node, ioModule);
  498. _diN2Warning = ParseDiNode("diN2Warning", node, ioModule);
  499. _diN2Alarm = ParseDiNode("diN2Alarm", node, ioModule);
  500. _diExhaustPressureWarning = ParseDiNode("diExhaustPressureWarning", node, ioModule);
  501. _diExhaustPressureAlarm = ParseDiNode("diExhaustPressureAlarm", node, ioModule);
  502. _diLogicWaterFlowAlarm = ParseDiNode("diLogicWaterFlowAlarm", node, ioModule);
  503. _diLogicN2PressureAlarm = ParseDiNode("diLogicN2PressureAlarm", node, ioModule);
  504. _doStart = ParseDoNode("doStart", node, ioModule);
  505. _doStop = ParseDoNode("doStop", node, ioModule);
  506. _doLocalRemote = ParseDoNode("doLocalRemote", node, ioModule);
  507. _doWarningReset = ParseDoNode("doReset", node, ioModule);
  508. _doN2PressureAlarm = ParseDoNode("doN2PressureAlarm", node, ioModule);
  509. _doWaterFlowAlarm = ParseDoNode("doWaterFlowAlarm", node, ioModule);
  510. _aoH2OSensorMassWarningThreshold = ParseAoNode("aoH2OSensorMassWarningThreshold", node, ioModule);
  511. _aoH2OSensorMassWarningTime = ParseAoNode("aoH2OSensorMassWarningTime", node, ioModule);
  512. _aoN2PurgeFlowWarning = ParseAoNode("aoN2PurgeFlowWarning", node, ioModule);
  513. _aoN2PurgeFlowWarningTime = ParseAoNode("aoN2PurgeFlowWarningTime", node, ioModule);
  514. _aoExhaustPressurePreWarningThreshold = ParseAoNode("aoExhaustPressurePreWarningThreshold", node, ioModule);
  515. _aoExhaustPressurePreWarningTime = ParseAoNode("aoExhaustPressurePreWarningTime", node, ioModule);
  516. _aoWaterFlowAlarmMinValue = ParseAoNode("aoWaterFlowAlarmMinValue", node, ioModule);
  517. _aoWaterFlowAlarmMaxValue = ParseAoNode("aoWaterFlowAlarmMaxValue", node, ioModule);
  518. _aoN2PressureAlarmMinValue = ParseAoNode("aoN2PressureAlarmMinValue", node, ioModule);
  519. _aoN2PressureAlarmMaxValue = ParseAoNode("aoN2PressureAlarmMaxValue", node, ioModule);
  520. _aiWaterFlow = ParseAiNode("aiWaterFlow", node, ioModule);
  521. _aiN2Pressure = ParseAiNode("aiN2Pressure", node, ioModule);
  522. _aiH2OSensorMassWarningThreshold = ParseAiNode("aiH2OSensorMassWarningThreshold", node, ioModule);
  523. _aiH2OSensorMassWarningTime = ParseAiNode("aiH2OSensorMassWarningTime", node, ioModule);
  524. _aiN2PurgeFlow = ParseAiNode("aiN2PurgeFlow", node, ioModule);
  525. _aiN2PurgeFlowWarningThreshold = ParseAiNode("aiN2PurgeFlowWarningThreshold", node, ioModule);
  526. _aiN2PurgeFlowWarningTime = ParseAiNode("aiN2PurgeFlowWarningTime", node, ioModule);
  527. _aiExhaustPressure = ParseAiNode("aiExhaustPressure", node, ioModule);
  528. _aiExhaustPressurePreWarningThreshold = ParseAiNode("aiExhaustPressurePreWarningThreshold", node, ioModule);
  529. _aiExhaustPressurePreWarningTime = ParseAiNode("aiExhaustPressurePreWarningTime", node, ioModule);
  530. _scH2OSensorMassWarningThreshold = ParseScNode("scH2OSensorMassWarningThreshold", node);
  531. _scH2OSensorMassWarningTime = ParseScNode("scH2OSensorMassWarningTime", node);
  532. _scN2PurgeFlowWarning = ParseScNode("scN2PurgeFlowWarning", node);
  533. _scN2PurgeFlowWarningTime = ParseScNode("scN2PurgeFlowWarningTime", node);
  534. _scExhaustPressurePreWarningThreshold = ParseScNode("scExhaustPressurePreWarningThreshold", node);
  535. _scExhaustPressurePreWarningTime = ParseScNode("scExhaustPressurePreWarningTime", node);
  536. _scEnableDryPump = ParseScNode("scEnableDryPump", node);
  537. _scEnableWaterFlow = ParseScNode("scEnableWaterFlow", node);
  538. _scWaterFlowMinValue = ParseScNode("scWaterFlowMinValue", node);
  539. _scWaterFlowMaxValue = ParseScNode("scWaterFlowMaxValue", node);
  540. _scWaterFlowOutOfToleranceWarningTime = ParseScNode("scWaterFlowOutOfToleranceWarningTime", node);
  541. _scWaterFlowOutOfToleranceAlarmTime = ParseScNode("scWaterFlowOutOfToleranceAlarmTime", node);
  542. _scEnableN2Pressure = ParseScNode("scEnableN2Pressure", node);
  543. _scN2PressureMinValue = ParseScNode("scN2PressureMinValue", node);
  544. _scN2PressureMaxValue = ParseScNode("scN2PressureMaxValue", node);
  545. _scN2PressureOutOfToleranceWarningTime = ParseScNode("scN2PressureOutOfToleranceWarningTime", node);
  546. _scN2PressureOutOfToleranceAlarmTime = ParseScNode("scN2PressureOutOfToleranceAlarmTime", node);
  547. }
  548. private void SetConfigValue()
  549. {
  550. if (_aoWaterFlowAlarmMinValue != null && _scWaterFlowMinValue != null)
  551. _aoWaterFlowAlarmMinValue.Value = (short)_scWaterFlowMinValue.Value;
  552. if (_aoWaterFlowAlarmMaxValue != null && _scWaterFlowMaxValue != null)
  553. _aoWaterFlowAlarmMaxValue.Value = (short)_scWaterFlowMaxValue.Value;
  554. if (_aoN2PressureAlarmMinValue != null && _scN2PressureMinValue != null)
  555. _aoN2PressureAlarmMinValue.Value = (short)_scN2PressureMinValue.Value;
  556. if (_aoN2PressureAlarmMaxValue != null && _scN2PressureMaxValue != null)
  557. _aoN2PressureAlarmMaxValue.Value = (short)_scN2PressureMaxValue.Value;
  558. }
  559. public override bool Initialize()
  560. {
  561. SetConfigValue();
  562. DATA.Subscribe($"{Module}.{Name}.DeviceData", () =>
  563. {
  564. AITPumpData data = new AITPumpData()
  565. {
  566. DeviceName = Name,
  567. DeviceModule = Module,
  568. DeviceSchematicId = DeviceID,
  569. DisplayName = Display,
  570. IsError = HasError,
  571. IsWarning = HasWarning,
  572. IsOn = IsRunning,
  573. WaterFlow = WaterFlowValue,
  574. IsDryPumpEnable = IsDryPumpEnabled,
  575. IsN2PressureEnable = true,
  576. IsWaterFlowEnable = true,
  577. WaterFlowWarning = WaterFlowWarning,
  578. WaterFlowAlarm = WaterFlowAlarm,
  579. N2PressureAlarm = N2PressureAlarm,
  580. N2PressureWarning = N2PressureWarning,
  581. };
  582. return data;
  583. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  584. OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOn}", (cmd, args) =>
  585. {
  586. if (IsError)
  587. {
  588. EV.PostWarningLog(Module, "Pump is in error state, reset before turn ON");
  589. return false;
  590. }
  591. if (IsRunning)
  592. {
  593. EV.PostWarningLog(Module, "Pump is running");
  594. return false;
  595. }
  596. Start(true);
  597. return true;
  598. });
  599. OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOff}", (cmd, args) =>
  600. {
  601. if (IsError)
  602. {
  603. EV.PostWarningLog(Module, "Pump is in error state, reset before turn OFF");
  604. return false;
  605. }
  606. if (!IsRunning)
  607. {
  608. EV.PostWarningLog(Module, "Pump is not running");
  609. return false;
  610. }
  611. Start(false);
  612. return true;
  613. });
  614. DEVICE.Register($"{Module}.{Name}.{AITPumpOperation.SetOnOff}", (out string reason, int time, object[] param) =>
  615. {
  616. bool isOn = Convert.ToBoolean((string)param[0]);
  617. if (IsError)
  618. {
  619. reason = string.Format("Pump is in error state, reset before turn {0}", isOn ? "ON" : "OFF");
  620. return false;
  621. }
  622. reason = string.Empty;
  623. this.Start(isOn);
  624. return true;
  625. });
  626. return true;
  627. }
  628. public override void Terminate()
  629. {
  630. }
  631. public void Start(bool on)
  632. {
  633. if (on)
  634. {
  635. if (_doStart != null)
  636. {
  637. _doStart.Value = true;
  638. _doStop.Value = false;
  639. }
  640. }
  641. else
  642. {
  643. if (_doStop != null)
  644. {
  645. _doStart.Value = false;
  646. _doStop.Value = true;
  647. }
  648. }
  649. _timer.Start(2000);
  650. }
  651. private void ResetSwitch()
  652. {
  653. if (null != _doStart) _doStart.Value = false;
  654. if (null != _doStop) _doStop.Value = false;
  655. }
  656. private void MonitorN2Pressure()
  657. {
  658. if (!IsDryPumpEnabled)
  659. return;
  660. if (!EnableN2Pressure)
  661. return;
  662. //_checkN2PressureWarning.Monitor(N2PressureValue, N2PressureMinValue, N2PressureMaxValue, N2PressureWarningTime);
  663. //if (_checkN2PressureWarning.Trig)
  664. //{
  665. // EV.PostMessage(Module, EventEnum.DefaultWarning, string.Format("{0} N2 pressure out of tolerance [{1}, {2}] for {3} seconds", Display, N2PressureMinValue, N2PressureMaxValue, N2PressureWarningTime));
  666. //}
  667. //_checkN2PressureAlarm.Monitor(N2PressureValue, N2PressureMinValue, N2PressureMaxValue, N2PressureAlarmTime);
  668. //if (_checkN2PressureAlarm.Trig)
  669. //{
  670. // EV.PostMessage(Module, EventEnum.DefaultAlarm, string.Format("{0} N2 pressure out of tolerance [{1}, {2}] for {3} seconds", Display, N2PressureMinValue, N2PressureMaxValue, N2PressureAlarmTime));
  671. //}
  672. if (_diLogicN2PressureAlarm != null)
  673. _diLogicN2PressureAlarm.RawData = N2PressureAlarm;
  674. N2PressureAlarmSetPoint = N2PressureAlarm;
  675. }
  676. private void MonitorWaterFlow()
  677. {
  678. if (!IsDryPumpEnabled)
  679. return;
  680. if (!EnableWaterFlow)
  681. return;
  682. _checkWaterFlowWarning.Monitor(WaterFlowValue, WaterFlowMinValue, WaterFlowMaxValue, WaterFlowWarningTime);
  683. if (_checkWaterFlowWarning.Trig)
  684. {
  685. EV.PostMessage(Module, EventEnum.DefaultWarning, string.Format("{0} Cooling Water Flow Out Of Tolerance [{1}, {2}] for {3} seconds", Display, WaterFlowMinValue, WaterFlowMaxValue, WaterFlowWarningTime));
  686. }
  687. _checkWaterFlowAlarm.Monitor(WaterFlowValue, WaterFlowMinValue, WaterFlowMaxValue, WaterFlowAlarmTime);
  688. if (_checkWaterFlowAlarm.Trig)
  689. {
  690. EV.PostMessage(Module, EventEnum.DefaultAlarm, string.Format("{0} Cooling Water Flow Out Of Tolerance [{1}, {2}] for {3} seconds", Display, WaterFlowMinValue, WaterFlowMaxValue, WaterFlowAlarmTime));
  691. }
  692. if (_diLogicWaterFlowAlarm != null)
  693. _diLogicWaterFlowAlarm.RawData = WaterFlowAlarm;
  694. WaterFlowAlarmSetPoint = WaterFlowAlarm;
  695. }
  696. public override void Monitor()
  697. {
  698. try
  699. {
  700. SetConfigValue();
  701. //if (_timer.IsTimeout())
  702. //{
  703. // //this.ResetSwitch();
  704. // _timer.Stop();
  705. //}
  706. //MonitorN2Pressure();
  707. //MonitorWaterFlow();
  708. if (_scH2OSensorMassWarningThreshold != null && _aoH2OSensorMassWarningThreshold != null)
  709. _aoH2OSensorMassWarningThreshold.Value = (short)_scH2OSensorMassWarningThreshold.Value;
  710. if (_scH2OSensorMassWarningTime != null && _aoH2OSensorMassWarningTime != null)
  711. _aoH2OSensorMassWarningTime.Value = (short)_scH2OSensorMassWarningTime.Value;
  712. if (_scN2PurgeFlowWarning != null && _aoN2PurgeFlowWarning != null)
  713. _aoN2PurgeFlowWarning.Value = (short)_scN2PurgeFlowWarning.Value;
  714. if (_scN2PurgeFlowWarningTime != null && _aoN2PurgeFlowWarningTime != null)
  715. _aoN2PurgeFlowWarningTime.Value = (short)_scN2PurgeFlowWarningTime.Value;
  716. if (_scExhaustPressurePreWarningThreshold != null && _aoExhaustPressurePreWarningThreshold != null)
  717. _aoExhaustPressurePreWarningThreshold.Value = (short)_scExhaustPressurePreWarningThreshold.Value;
  718. if (_scExhaustPressurePreWarningTime != null && _aoExhaustPressurePreWarningTime != null)
  719. _aoExhaustPressurePreWarningTime.Value = (short)_scExhaustPressurePreWarningTime.Value;
  720. _trigWarning.CLK = IsWarning;
  721. if (_trigWarning.Q)
  722. {
  723. EV.PostMessage(Module, EventEnum.DefaultWarning, "Dry Pump Warning");
  724. }
  725. _trigError.CLK = IsError;
  726. if (_trigError.Q)
  727. {
  728. EV.PostMessage(Module, EventEnum.DefaultAlarm, "Dry Pump Error");
  729. }
  730. _trigWaterFlowSensorWarning.CLK = _diWaterFlowWarning != null && _diWaterFlowWarning.Value;
  731. if (_trigWaterFlowSensorWarning.Q)
  732. {
  733. EV.PostMessage(Module, EventEnum.DefaultWarning, "Dry Pump water flow warning");
  734. }
  735. _trigWaterFlowSensorAlarm.CLK = _diWaterFlowAlarm != null && _diWaterFlowAlarm.Value;
  736. if (_trigWaterFlowSensorAlarm.Q)
  737. {
  738. EV.PostMessage(Module, EventEnum.DefaultAlarm, "Dry Pump water flow alarm");
  739. }
  740. _trigN2Warning.CLK = _diN2Warning != null && _diN2Warning.Value;
  741. if (_trigN2Warning.Q)
  742. {
  743. EV.PostMessage(Module, EventEnum.DefaultWarning, "Dry Pump N2 flow warning");
  744. }
  745. _trigN2Alarm.CLK = _diN2Alarm != null && _diN2Alarm.Value;
  746. if (_trigN2Alarm.Q)
  747. {
  748. EV.PostMessage(Module, EventEnum.DefaultAlarm, "Dry Pump N2 flow alarm");
  749. }
  750. _trigExhaustPressureWarning.CLK = _diExhaustPressureWarning != null && _diExhaustPressureWarning.Value;
  751. if (_trigExhaustPressureWarning.Q)
  752. {
  753. EV.PostMessage(Module, EventEnum.DefaultWarning, "Dry Pump exhaust pressure warning");
  754. }
  755. _trigExhaustPressureAlarm.CLK = _diExhaustPressureAlarm != null && _diExhaustPressureAlarm.Value;
  756. if (_trigExhaustPressureAlarm.Q)
  757. {
  758. EV.PostMessage(Module, EventEnum.DefaultAlarm, "Dry Pump exhaust pressure alarm");
  759. }
  760. }
  761. catch (Exception ex)
  762. {
  763. LOG.Write(ex);
  764. }
  765. }
  766. public override void Reset()
  767. {
  768. if ((IsWarning || IsError) && _doWarningReset != null)
  769. _doWarningReset.Value = true;
  770. _trigWarning.RST = true;
  771. _trigError.RST = true;
  772. _trigWaterFlowSensorWarning.RST = true;
  773. _trigWaterFlowSensorAlarm.RST = true;
  774. _trigN2Warning.RST = true;
  775. _trigN2Alarm.RST = true;
  776. _trigExhaustPressureWarning.RST = true;
  777. _trigExhaustPressureAlarm.RST = true;
  778. _checkN2PressureAlarm.RST = true;
  779. _checkN2PressureWarning.RST = true;
  780. _checkWaterFlowAlarm.RST = true;
  781. _checkWaterFlowWarning.RST = true;
  782. }
  783. public override void SetPumpOnOff(bool isOn)
  784. {
  785. Start(isOn);
  786. }
  787. }
  788. }