TemperatureController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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 CyberX8_RT.Devices.Facilities;
  9. using CyberX8_RT.Devices.Reservoir;
  10. using CyberX8_RT.Modules;
  11. using CyberX8_RT.Modules.Reservoir;
  12. using MECF.Framework.Common.CommonData.TemperatureControl;
  13. using MECF.Framework.Common.Device.TemperatureController;
  14. using MECF.Framework.Common.Persistent.Temperature;
  15. using MECF.Framework.Common.ToolLayout;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Reflection;
  20. using System.Text;
  21. using System.Threading.Tasks;
  22. namespace CyberX8_RT.Devices.Temperature
  23. {
  24. public class TemperatureController : BaseDevice, IDevice
  25. {
  26. #region 常量
  27. private const string STRATUS = "Stratus";
  28. private const string TARGET_TEMPERATURE = "TargetTemperature";
  29. private const string RESERVIOR_TEMPERATURE = "ReserviorTemperature";
  30. private const string HEAT_EXCHANGER_TEMPERATURE = "HeatExchangerTemperature";
  31. private const string ALARM = "Alarm";
  32. private const string OFFSET = "Offset";
  33. private const string CONTROL_OPERATION_MODEL="ControlOperationModel";
  34. private const string PB_RANGE = "PBRange";
  35. private const string ARW_RANGE = "ARWRange";
  36. private const string I_CONSTANT = "IConstant";
  37. private const string D_CONSTANT = "DConstant";
  38. private const string HEATING_POWER_UPPER_LIMIT = "HeatingPowerUpperLimit";
  39. private const string COOLING_POWER_UPPER_LIMIT="CoolingPowerUpperLimit";
  40. private const string OUT_PUT_RATIO="OutputRatio";
  41. private const string TEMPERATURE_DATA = "TemperatureData";
  42. private const string IS_CONNECTED = "IsConnected";
  43. private const int ENABLE = 5;
  44. private const int DISABLE = 0;
  45. private const string PERSISTENT_VALUE = "PersistentValue";
  46. #endregion
  47. #region 内部变量
  48. private byte _address;
  49. private TemperatureControllerData _temperatureData = new TemperatureControllerData();
  50. private PeriodicJob _periodicJob = null;
  51. private bool _startMonitorData = false;
  52. private bool _readAlarm = false;
  53. private double _temeratureDeltaLimit = SC.GetValue<double>("System.TemeratureDelatLimit");
  54. private bool _isApplying = false; //用于判断是否在apply中
  55. private bool _isAlarmErrorLoged = false; //用于判断是否打印过alarm触发
  56. private bool _isAlarmWarningLoged = false; //用于判断是否打印过alarm warning触发
  57. private bool _isTCConnect = false;
  58. /// <summary>
  59. /// TC 持久性数值对象
  60. /// </summary>
  61. private TCPersistentValue _tCPersistentValue;
  62. private Dictionary<int,string> _errorMessage = new Dictionary<int, string>
  63. { { 3, " HighTempCutoff Property" },
  64. { 2, " LowTempCutoff Property" },
  65. { 1, " Fan Property" },
  66. { 0, " OutputFailure Property" },
  67. { 7, " TempLimitWarn Property" },
  68. { 6, " RemoteOff Property" },
  69. { 5, " Thermostat Property" },
  70. { 4, " PowerFailure Property" },
  71. { 11, " ExtSensorFailure Property" },
  72. { 10, " IntSensorFailure Property" },
  73. { 9, " AutoTuning Property" },
  74. { 8, " Leak Property" }};
  75. #endregion
  76. #region 属性
  77. /// <summary>
  78. /// 连接状态
  79. /// </summary>
  80. public bool IsConnected { get { return TemperatureConfigManager.Instance.GetDeviceConnect(Module); } }
  81. /// <summary>
  82. /// 数据
  83. /// </summary>
  84. public TemperatureControllerData TemperatureData
  85. {
  86. get { return _temperatureData; }
  87. }
  88. #endregion
  89. /// <summary>
  90. /// 构造函数
  91. /// </summary>;
  92. /// <param name="moduleName"></param>
  93. public TemperatureController(string moduleName) : base(moduleName, moduleName, moduleName, moduleName)
  94. {
  95. SubscribeValueAction();
  96. InitializeData();
  97. InitializeOperation();
  98. _periodicJob = new PeriodicJob(5000, OnTimer, $"{moduleName}_reader");
  99. _temperatureData.Name = $"{moduleName}";
  100. _isAlarmErrorLoged = false;
  101. _isAlarmWarningLoged = false;
  102. }
  103. /// <summary>
  104. /// 初始化
  105. /// </summary>
  106. /// <returns></returns>
  107. public bool Initialize()
  108. {
  109. TemperatureConfigManager.Instance.InitialDevice(Module);
  110. _periodicJob.Start();
  111. return true;
  112. }
  113. /// <summary>
  114. /// 初始化操作
  115. /// </summary>
  116. private void InitializeOperation()
  117. {
  118. OP.Subscribe($"{Module}.Apply", SetTargetTemperatureOperation);
  119. OP.Subscribe($"{Module}.Enable", EnableOperation);
  120. OP.Subscribe($"{Module}.Disable", DisableOperation);
  121. }
  122. /// <summary>
  123. /// 监控TC电源
  124. /// </summary>
  125. /// <returns></returns>
  126. private bool CheckTCIsConnect()
  127. {
  128. return TemperatureConfigManager.Instance.GetDevicePowerConnect(Module);
  129. }
  130. /// <summary>
  131. /// 应用
  132. /// </summary>
  133. /// <param name="cmd"></param>
  134. /// <param name="param"></param>
  135. /// <returns></returns>
  136. public bool SetTargetTemperatureOperation(string cmd,object[] param)
  137. {
  138. _isApplying = true; //表示正在调温
  139. _temperatureData.HeatExchangerSeries = new List<double>();
  140. _temperatureData.ReserviorSeries = new List<double>();
  141. if (param.Length == 3 && double.TryParse(param[0].ToString(), out double targetTemperature) && double.TryParse(param[1].ToString(), out double targetTemperatureLowLimit) && double.TryParse(param[2].ToString(), out double targetTemperatureHighLimit))
  142. {
  143. TemperatureConfigManager.Instance.SetTargetTemperature(Module, _address, targetTemperature);
  144. if (TemperatureData.ControlOperationModel == ENABLE)
  145. {
  146. _startMonitorData = true;
  147. }
  148. //将前端输入的数据存入持久化文件
  149. TCPersistentManager.Instance.UpdateTemperatureValue(Module, targetTemperature, targetTemperatureLowLimit, targetTemperatureHighLimit);
  150. return true;
  151. }
  152. if (param.Length == 1 && double.TryParse(param[0].ToString(), out double targetTemperature1))
  153. {
  154. TemperatureConfigManager.Instance.SetTargetTemperature(Module, _address, targetTemperature1);
  155. if (TemperatureData.ControlOperationModel == ENABLE)
  156. {
  157. _startMonitorData = true;
  158. }
  159. //将前端输入的数据存入持久化文件
  160. TCPersistentManager.Instance.UpdateTemperatureValue(Module, targetTemperature1, 0, 0); // 0 0是上下限
  161. return true;
  162. }
  163. else
  164. {
  165. LOG.WriteLog(eEvent.INFO_TEMPERATURE, Module, $"{param[0]} is invalid");
  166. return false;
  167. }
  168. }
  169. /// <summary>
  170. /// 启用
  171. /// </summary>
  172. /// <param name="cmd"></param>
  173. /// <param name="param"></param>
  174. /// <returns></returns>
  175. public bool EnableOperation(string cmd, object[] param)
  176. {
  177. if (!JudgeReservoirCondition())
  178. {
  179. return false;
  180. }
  181. if (!CheckTCIsConnect())
  182. {
  183. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"TC is not connect");
  184. return false ;
  185. }
  186. //校验TC状态
  187. if (TemperatureData.Alarm != null && TemperatureData.Alarm.Contains("1"))
  188. {
  189. string errorItemString = TemperatureData.Alarm.Substring(0, 11) + TemperatureData.Alarm.Substring(13, 1) + TemperatureData.Alarm.Substring(15);
  190. if (errorItemString.Contains("1"))
  191. {
  192. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"TC is in error state");
  193. return false;
  194. }
  195. }
  196. TemperatureData.ControlOperationModel = ENABLE;
  197. bool result= TemperatureConfigManager.Instance.EnableControl(Module, _address,ENABLE);
  198. if (result)
  199. {
  200. LOG.WriteLog(eEvent.INFO_TEMPERATURE, Module, "control operation set enable");
  201. _startMonitorData = true;
  202. }
  203. return result;
  204. }
  205. /// <summary>
  206. /// 禁用
  207. /// </summary>
  208. /// <param name="cmd"></param>
  209. /// <param name="param"></param>
  210. /// <returns></returns>
  211. public bool DisableOperation(string cmd, object[] param)
  212. {
  213. _isApplying = false;
  214. TemperatureData.ControlOperationModel = DISABLE;
  215. bool result= TemperatureConfigManager.Instance.DisableController(Module, _address,DISABLE);
  216. if(result)
  217. {
  218. if (result)
  219. {
  220. ReservoirPostError();
  221. LOG.WriteLog(eEvent.INFO_TEMPERATURE, Module, "control operation set disable");
  222. }
  223. _startMonitorData = false;
  224. if(TemperatureData.ReserviorSeries != null && TemperatureData.HeatExchangerSeries != null)
  225. {
  226. _temperatureData.HeatExchangerSeries.Clear();
  227. _temperatureData.ReserviorSeries.Clear();
  228. }
  229. }
  230. return result;
  231. }
  232. /// <summary>
  233. /// Reservoir通知进入错误状态
  234. /// </summary>
  235. private void ReservoirPostError()
  236. {
  237. string reservoir = ReservoirItemManager.Instance.GetReservoirByTC(Module);
  238. IModuleEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(reservoir);
  239. if (reservoirEntity != null)
  240. {
  241. if (!reservoirEntity.IsError && !reservoirEntity.IsDisable)
  242. {
  243. reservoirEntity.PostMsg(ReservoirMsg.Error);
  244. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"TC is abnormal,notify Reservoir {reservoir} enter error");
  245. }
  246. }
  247. }
  248. /// <summary>
  249. /// 访问数据变更
  250. /// </summary>
  251. private void SubscribeValueAction()
  252. {
  253. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, TARGET_TEMPERATURE, UpdateVariableValue);
  254. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, RESERVIOR_TEMPERATURE, UpdateVariableValue);
  255. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, HEAT_EXCHANGER_TEMPERATURE, UpdateVariableValue);
  256. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, ALARM, UpdateVariableValue);
  257. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, OFFSET, UpdateVariableValue);
  258. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, CONTROL_OPERATION_MODEL, UpdateVariableValue);
  259. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, PB_RANGE, UpdateVariableValue);
  260. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, ARW_RANGE, UpdateVariableValue);
  261. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, I_CONSTANT, UpdateVariableValue);
  262. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, D_CONSTANT, UpdateVariableValue);
  263. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, OUT_PUT_RATIO, UpdateVariableValue);
  264. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, HEATING_POWER_UPPER_LIMIT, UpdateVariableValue);
  265. TemperatureConfigManager.Instance.SubscribeModuleVariable(Module, COOLING_POWER_UPPER_LIMIT, UpdateVariableValue);
  266. }
  267. /// <summary>
  268. /// 初始化数据
  269. /// </summary>
  270. private void InitializeData()
  271. {
  272. _address= TemperatureConfigManager.Instance.GetAddress(Module);
  273. _tCPersistentValue = TCPersistentManager.Instance.GetTCPersistentValue(Module);
  274. DATA.Subscribe($"{Module}.{TEMPERATURE_DATA}", () => _temperatureData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  275. DATA.Subscribe($"{Module}.{IS_CONNECTED}", () => _isTCConnect, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  276. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _tCPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  277. DATA.Subscribe($"{Module}.TargetTemperature", () => _temperatureData.TargetTemperature, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  278. DATA.Subscribe($"{Module}.Status", () => _temperatureData.Status, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  279. DATA.Subscribe($"{Module}.Alarm", () => _temperatureData.Alarm, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  280. DATA.Subscribe($"{Module}.ReserviorTemperature", () => _temperatureData.ReserviorTemperature, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  281. DATA.Subscribe($"{Module}.HeatExchangerTemperature", () => _temperatureData.HeatExchangerTemperature, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  282. }
  283. /// <summary>
  284. /// 更新变量数值
  285. /// </summary>
  286. /// <param name="variable"></param>
  287. /// <param name="value"></param>
  288. private void UpdateVariableValue(string variable, object value)
  289. {
  290. if(!TemperatureData.IsInitialized)
  291. {
  292. TemperatureData.IsInitialized = true;
  293. TemperatureConfigManager.Instance.ReadControlOperationModel(Module, _address);
  294. TemperatureConfigManager.Instance.ReadTargetTemperature(Module, _address);
  295. }
  296. PropertyInfo property = TemperatureData.GetType().GetProperty(variable);
  297. if (property != null)
  298. {
  299. property.SetValue(TemperatureData, value);
  300. }
  301. //判断temperatureReached AtTemperatureRange
  302. double atTemperatureRange = SC.GetValue<double>("System.AtTemperatureRange");
  303. atTemperatureRange = atTemperatureRange == 0 ? 0.1 : atTemperatureRange;
  304. if (Math.Abs(TemperatureData.ReserviorTemperature - TemperatureData.TargetTemperature) < atTemperatureRange)
  305. {
  306. TemperatureData.TemperatureReached = true;
  307. //_startMonitorData = false;
  308. }
  309. else
  310. {
  311. TemperatureData.TemperatureReached = false;
  312. }
  313. //判断deltaexceed
  314. if (Math.Abs(TemperatureData.ReserviorTemperature - TemperatureData.ReserviorTemperature) > _temeratureDeltaLimit)
  315. {
  316. TemperatureData.DeltaExceed = true;
  317. }
  318. else
  319. {
  320. TemperatureData.DeltaExceed = false;
  321. }
  322. if (_startMonitorData && TemperatureData.ReserviorSeries!=null && TemperatureData.HeatExchangerSeries!=null)
  323. {
  324. if (TemperatureData.ReserviorSeries.Count == 20)
  325. {
  326. TemperatureData.ReserviorSeries.RemoveAt(0);
  327. for (int i = 1; i < TemperatureData.ReserviorSeries.Count; i++)
  328. {
  329. TemperatureData.ReserviorSeries[i - 1] = TemperatureData.ReserviorSeries[i];
  330. }
  331. TemperatureData.ReserviorSeries.Add(TemperatureData.ReserviorTemperature);
  332. }
  333. else
  334. {
  335. TemperatureData.ReserviorSeries.Add(TemperatureData.ReserviorTemperature);
  336. }
  337. if (TemperatureData.HeatExchangerSeries.Count == 20)
  338. {
  339. TemperatureData.HeatExchangerSeries.RemoveAt(0);
  340. for (int i = 1; i < TemperatureData.HeatExchangerSeries.Count; i++)
  341. {
  342. TemperatureData.HeatExchangerSeries[i - 1] = TemperatureData.HeatExchangerSeries[i];
  343. }
  344. TemperatureData.HeatExchangerSeries.Add(TemperatureData.HeatExchangerTemperature);
  345. }
  346. else
  347. {
  348. TemperatureData.HeatExchangerSeries.Add(TemperatureData.HeatExchangerTemperature);
  349. }
  350. }
  351. }
  352. /// <summary>
  353. /// 定时器
  354. /// </summary>
  355. /// <returns></returns>
  356. private bool OnTimer()
  357. {
  358. _isTCConnect = CheckTCIsConnect();
  359. if (!_isTCConnect)
  360. {
  361. string reservoir = ReservoirItemManager.Instance.GetReservoirByTC(Module);
  362. if (!string.IsNullOrEmpty(reservoir))
  363. {
  364. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(reservoir);
  365. if(reservoirEntity != null && !reservoirEntity.IsError)
  366. {
  367. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} is disconnect,releate reservoir into error");
  368. reservoirEntity.PostMsg(ReservoirMsg.Error);
  369. }
  370. }
  371. }
  372. TemperatureConfigManager.Instance.ReadReserviorExtendSensorTemperature(Module, _address);
  373. TemperatureConfigManager.Instance.ReadHeatExchangerInternelSensorTemperature(Module, _address);
  374. if (_readAlarm)
  375. {
  376. TemperatureConfigManager.Instance.ReadAlarmStatus(Module, _address);
  377. _readAlarm= false;
  378. }
  379. else
  380. {
  381. _readAlarm = true;
  382. }
  383. double rampStepSize = SC.GetValue<double>("System.RampStepSize");
  384. rampStepSize = rampStepSize == 0 ? 0.11 : rampStepSize;
  385. if (TemperatureData.TargetTemperature - TemperatureData.ReserviorTemperature > rampStepSize + 0.1 && _isApplying == true)
  386. {
  387. TemperatureData.Status = "RampingUp";
  388. }
  389. else if(TemperatureData.TargetTemperature - TemperatureData.ReserviorTemperature < -rampStepSize - 0.1 && _isApplying == true)
  390. {
  391. TemperatureData.Status = "RampingDown";
  392. }
  393. else if (TemperatureData.TargetTemperature - TemperatureData.ReserviorTemperature <= rampStepSize + 0.1 && TemperatureData.TargetTemperature - TemperatureData.ReserviorTemperature >= - rampStepSize - 0.1 && _isApplying == true)
  394. {
  395. TemperatureData.Status = "Maintaining";
  396. }
  397. else if(TemperatureData.Alarm!=null&&TemperatureData.Alarm.Contains("1"))
  398. {
  399. string errorItemString = TemperatureData.Alarm.Substring(0, 11) + TemperatureData.Alarm.Substring(13, 1) + TemperatureData.Alarm.Substring(15);
  400. if (TemperatureData.Alarm.Substring(12,1) == "1" || TemperatureData.Alarm.Substring(14, 1)== "1")
  401. {
  402. TemperatureData.Status = "Warning";
  403. if (!_isAlarmWarningLoged)
  404. {
  405. LOG.WriteLog(eEvent.WARN_TEMPERATURE, Module, $"{Module} Warning is activate");
  406. _isAlarmWarningLoged = true;
  407. }
  408. }
  409. if(errorItemString.Contains("1"))
  410. {
  411. if (!_isAlarmErrorLoged)
  412. {
  413. string errormessage = "";
  414. string[] strAry = TemperatureData.Alarm.ToString().Split('-');
  415. if (strAry.Length > 0)
  416. {
  417. for (int i = 0; i < strAry.Length; i++)
  418. {
  419. if (strAry[i] == "1")
  420. {
  421. errormessage += _errorMessage[i];
  422. }
  423. }
  424. }
  425. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} {errormessage} is activate");
  426. ReservoirPostError();//将对应的reservoir切成error
  427. _isAlarmErrorLoged = true;
  428. }
  429. }
  430. }
  431. else
  432. {
  433. TemperatureData.Status = "Normal";
  434. _isAlarmErrorLoged = false; //用于控制触发alarm要不要打印error日志
  435. _isAlarmWarningLoged = false; //用于控制触发alarm要不要打印error日志
  436. }
  437. if (TemperatureData.ControlOperationModel != 0)
  438. {
  439. if (!JudgeReservoirCondition())
  440. {
  441. DisableOperation("", null);
  442. }
  443. }
  444. if (TemperatureData.Alarm!=null && TemperatureData.Alarm.Contains("1") && _isApplying == true)
  445. {
  446. string errorItemString = TemperatureData.Alarm.Substring(0, 11) + TemperatureData.Alarm.Substring(13, 1) + TemperatureData.Alarm.Substring(15);
  447. if (errorItemString.Contains("1"))
  448. {
  449. DisableOperation("", null);
  450. string errormessage = "";
  451. string[] strAry = errorItemString.ToString().Split('-');
  452. if (strAry.Length > 0)
  453. {
  454. for (int i = 0; i < strAry.Length; i++)
  455. {
  456. if (strAry[i] == "1")
  457. {
  458. errormessage += _errorMessage[i];
  459. }
  460. }
  461. }
  462. ReservoirPostError();//将对应的reservoir切成error
  463. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} {errormessage} is activate");
  464. _isApplying = false;
  465. }
  466. }
  467. return true;
  468. }
  469. /// <summary>
  470. /// 检验Reservoir条件
  471. /// </summary>
  472. private bool JudgeReservoirCondition()
  473. {
  474. SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  475. if (systemFacilities == null)
  476. {
  477. return false;
  478. }
  479. //冷却水没开
  480. if (!systemFacilities.HouseChilledWaterEnable)
  481. {
  482. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, "Facilities HouseChilledWaterEnable is off");
  483. return false;
  484. }
  485. var houseChilledResult = systemFacilities.CheckHouseChilledWaterResult();
  486. if (!houseChilledResult.result)
  487. {
  488. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, houseChilledResult.reason);
  489. return false;
  490. }
  491. string reservoir = ReservoirItemManager.Instance.GetReservoirByTC(Module);
  492. if (string.IsNullOrEmpty(reservoir))
  493. {
  494. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} reservoir is empty");
  495. return false;
  496. }
  497. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(reservoir);
  498. if (reservoirItem.SubType == STRATUS)
  499. {
  500. StandardHotReservoirDevice reservoirDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(reservoir);
  501. if (reservoirDevice == null)
  502. {
  503. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} reservoir is null");
  504. return false;
  505. }
  506. bool result= reservoirDevice.ReservoirData.HedFlow > 0;
  507. if (!result)
  508. {
  509. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} reservoir HED flow is 0");
  510. }
  511. return result;
  512. }
  513. else
  514. {
  515. CompactMembranReservoirDevice reservoirDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(reservoir);
  516. if (reservoirDevice == null)
  517. {
  518. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} reservoir is null");
  519. return false;
  520. }
  521. bool result = reservoirDevice.ReservoirData.CAHedFlow > 0;
  522. if (!result)
  523. {
  524. LOG.WriteLog(eEvent.ERR_TEMPERATURE, Module, $"{Module} reservoir CA HED flow is 0");
  525. }
  526. return result;
  527. }
  528. }
  529. /// <summary>
  530. /// 设置Enable并设置温度
  531. /// </summary>
  532. /// <param name="targetTemperature"></param>
  533. /// <returns></returns>
  534. public bool SetEnableTargetTemperature(double targetTemperature)
  535. {
  536. TemperatureConfigManager.Instance.SetTargetTemperature(Module, _address, targetTemperature);
  537. if (_temperatureData.ControlOperationModel == DISABLE)
  538. {
  539. EnableOperation("", null);
  540. }
  541. return true;
  542. }
  543. /// <summary>
  544. /// 监控
  545. /// </summary>
  546. public void Monitor()
  547. {
  548. }
  549. public void Reset()
  550. {
  551. }
  552. public void Terminate()
  553. {
  554. }
  555. }
  556. }