IoPump.cs 35 KB

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