water_temp_setpoint_new.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. import os
  2. import pandas as pd
  3. # from logs_conf.logger import *
  4. from logs.logger import *
  5. from data_initialize_standard.constant import *
  6. class SetPointStrategyOff(object):
  7. """智控模式关闭状态下的水温设定值"""
  8. def __init__(self, dict_chiller_inner, data_temp_humi):
  9. # self.dict_code = dict_code
  10. self.dict_chiller_inner = dict_chiller_inner
  11. self.data_temp_humi = data_temp_humi
  12. def chiller_off(self):
  13. """冷机关机状态下,分制冷和制热模式,回水和进水控制四种情况,将初始设定值赋值"""
  14. if self.dict_chiller_inner['runMode'] == 0:
  15. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  16. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSetInitial']
  17. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  18. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSetInitial']
  19. else:
  20. water_temp_set_new = ''
  21. logger.critical('============冷机控制选择输入错误============')
  22. elif self.dict_chiller_inner['runMode'] == 1:
  23. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  24. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSetInitial']
  25. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  26. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSetInitial']
  27. else:
  28. water_temp_set_new = ''
  29. logger.critical('============冷机控制选择输入错误============')
  30. else:
  31. water_temp_set_new = ''
  32. logger.critical('============冷机运行模式输入错误============')
  33. return water_temp_set_new
  34. def chiller_on(self):
  35. """冷机开机状态下,分制冷和制热模式,回水和进水控制四种情况,通过对比当前设定值和初始设定值再赋值"""
  36. if self.dict_chiller_inner['runMode'] == 0:
  37. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  38. if self.dict_chiller_inner['chillerWaterTempSet'] < self.dict_chiller_inner['chillerWaterTempSetInitial']:
  39. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSet']
  40. else:
  41. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSetInitial']
  42. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  43. if self.dict_chiller_inner['chillerWaterTempInSet'] < self.dict_chiller_inner['chillerWaterTempInSetInitial']:
  44. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSet']
  45. else:
  46. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSetInitial']
  47. else:
  48. water_temp_set_new = ''
  49. logger.critical('============冷机控制选择输入错误============')
  50. elif self.dict_chiller_inner['runMode'] == 1:
  51. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  52. if self.dict_chiller_inner['heatingWaterTempSet'] > self.dict_chiller_inner['heatingWaterTempSetInitial']:
  53. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSet']
  54. else:
  55. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSetInitial']
  56. else:
  57. if self.dict_chiller_inner['heatingWaterTempInSet'] > self.dict_chiller_inner['heatingWaterTempInSetInitial']:
  58. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSet']
  59. else:
  60. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSetInitial']
  61. else:
  62. water_temp_set_new = ''
  63. logger.critical('============冷机运行模式输入错误============')
  64. return water_temp_set_new
  65. def self_control_strategy_off(self):
  66. """判断冷机当前运行状态,进而赋值,主要是对于运行冷机有个恢复初始值的过程"""
  67. if self.dict_chiller_inner['runStatus'][-1] == 0:
  68. water_temp_set_new = self.chiller_off()
  69. elif self.dict_chiller_inner['runStatus'][-1] == 1:
  70. water_temp_set_new = self.chiller_on()
  71. else:
  72. water_temp_set_new = ''
  73. logger.critical('============冷机运行状态输入错误============')
  74. return water_temp_set_new
  75. class SetPointStrategyOnChillerOff(SetPointStrategyOff):
  76. """冷机停机下水温设定值策略"""
  77. def __init__(self, dict_chiller_inner, data_temp_humi):
  78. super(SetPointStrategyOnChillerOff, self).__init__(dict_chiller_inner, data_temp_humi)
  79. def judge_off_time(self):
  80. """冷机已关机时长"""
  81. off_time_latest = pd.to_datetime(self.dict_chiller_inner['chillerOffTimeLatest'])
  82. date_time_now = pd.to_datetime(self.dict_chiller_inner['triggerTime'])
  83. chiller_off_time = (date_time_now - off_time_latest).total_seconds()
  84. if abs(chiller_off_time) < 5:
  85. chiller_off_time = 0 # 终端设备时间和服务器设备时间之间小偏差修正
  86. chiller_off_time = chiller_off_time / 3600.0
  87. return chiller_off_time
  88. def chiller_off_short_time(self):
  89. """设定值赋值为最近一次关机时的设定值"""
  90. if self.dict_chiller_inner['runMode'] == 0:
  91. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  92. water_temp_set_new = self.dict_chiller_inner['offSetTempLatestCooling']
  93. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  94. water_temp_set_new = self.dict_chiller_inner['offSetTempInLatestCooling']
  95. else:
  96. water_temp_set_new = ''
  97. logger.critical('============冷机控制选择输入错误============')
  98. elif self.dict_chiller_inner['runMode'] == 1:
  99. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  100. water_temp_set_new = self.dict_chiller_inner['offSetTempLatestHeating']
  101. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  102. water_temp_set_new = self.dict_chiller_inner['offSetTempInLatestHeating']
  103. else:
  104. water_temp_set_new = ''
  105. logger.critical('============冷机控制选择输入错误============')
  106. else:
  107. water_temp_set_new = ''
  108. logger.critical('============冷机运行状态输入错误============')
  109. return water_temp_set_new
  110. def water_temp_set_confirm(self):
  111. """关机时长大于16小时,则设定值为初始设定值;关机时长在16小时以内,则设定值为最近一次关机设定值"""
  112. chiller_off_time = self.judge_off_time()
  113. if chiller_off_time > 16:
  114. water_temp_set_new = self.chiller_off()
  115. elif 16 >= chiller_off_time >= 0:
  116. water_temp_set_new = self.chiller_off_short_time()
  117. else:
  118. water_temp_set_new = ''
  119. logger.critical('============冷机停机时间输入错误============')
  120. return water_temp_set_new
  121. class JudgeTempControlMode(object):
  122. def __init__(self, dict_chiller_inner):
  123. self.dict_chiller_inner = dict_chiller_inner
  124. def is_single_control_strategy(self):
  125. """判断所有冷机的冷水控制方式是否唯一,全部为供水或全部为回水
  126. 0表示全部供水或全部回水,1表示供水和回水共存"""
  127. para_accs = pd.DataFrame(self.dict_chiller_inner['allChillerControlSelect'], columns=['para_accs'])
  128. para_accs = para_accs.drop_duplicates()
  129. if len(para_accs) > 1: # 0为全部供水或全部回水,1为供水和回水共存
  130. judge_sin_mul = 1 # 供水和回水共存的情况暂不考虑
  131. elif len(para_accs) == 1:
  132. judge_sin_mul = 0
  133. else:
  134. judge_sin_mul = ''
  135. logger.critical('============所有冷机制冷控制选择输入错误============')
  136. return judge_sin_mul
  137. class JudgeSynchronizeAsynchronous(object):
  138. """判断冷机的设定值为同步还是异步"""
  139. def __init__(self, dict_chiller_inner):
  140. self.dict_chiller_inner = dict_chiller_inner
  141. def parameter_middle(self):
  142. """获取所有开机冷机的出水或回水温度设定值的反馈值"""
  143. if self.dict_chiller_inner['runMode'] == 0:
  144. """全部为供水或全部为回水,则返回对应模式下水温的设定值反馈值"""
  145. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  146. para_middle = pd.DataFrame(self.dict_chiller_inner['allChillerWaterTempSetOn'], columns=['para_middle'])
  147. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  148. para_middle = pd.DataFrame(self.dict_chiller_inner['allChillerWaterTempInSetOn'], columns=['para_middle'])
  149. else:
  150. para_middle = ''
  151. logger.critical('============冷机控制选择输入错误============')
  152. elif self.dict_chiller_inner['runMode'] == 1:
  153. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  154. para_middle = pd.DataFrame(self.dict_chiller_inner['allHeatingWaterTempSetOn'], columns=['para_middle'])
  155. else:
  156. para_middle = pd.DataFrame(self.dict_chiller_inner['allHeatingWaterTempInSetOn'], columns=['para_middle'])
  157. else:
  158. para_middle = ''
  159. logger.critical('============冷机运行模式输入错误============')
  160. para_middle = para_middle.drop_duplicates()
  161. list_para_middle = para_middle['para_middle'].tolist()
  162. return list_para_middle
  163. def is_synchronize(self, para_middle):
  164. # if self.judge_sin_mul == 0:
  165. """全部为供水控制或全部为回水控制的判断,设定值一致为同步,设定值不一致为异步"""
  166. if len(para_middle) > 1:
  167. judge_synchronize = 1 # 1为异步,0为同步
  168. elif len(para_middle) == 1:
  169. judge_synchronize = 0
  170. else:
  171. judge_synchronize = ''
  172. logger.critical('============所有开机冷机冷冻水温度设定值输入错误============')
  173. # else: # 供水和回水共存的场景暂不考虑
  174. # judge_synchronize = ''
  175. # logger.critical('============所有冷机制冷控制选择输入错误或控制方式不唯一============')
  176. return judge_synchronize
  177. def judge_synchronize_asynchronous(self):
  178. para_middle = self.parameter_middle()
  179. results = self.is_synchronize(para_middle) # 若供水和回水控制共存,则输出为空值,否则1代表异步,0代表同步
  180. return results
  181. # ①异步,制冷设定温度最高,且末端温度不超标,或制热设定温度最低,且末端温度不超标
  182. # ②异步,制冷设定温度不是最高,且末端温度超标,或制热设定温度不是最低,且末端温度超标
  183. # ③异步,制冷设定温度最高,且末端温度超标,或制热设定温度最低,且末端温度超标
  184. # ④异步,制冷设定温度不是最高,且末端温度不超标,或制热设定温度不是最低,且末端温度不超标
  185. # ⑤同步,末端温度不超标
  186. # ⑥同步,末端温度超标
  187. class SetPointStrategyOnChillerOnAsynchronous(SetPointStrategyOff):
  188. def __init__(self, dict_chiller_inner, data_temp_humi, excess_result):
  189. super(SetPointStrategyOnChillerOnAsynchronous, self).__init__(dict_chiller_inner, data_temp_humi)
  190. self.is_out_range = excess_result['isOutRange']
  191. self.excess_result = excess_result
  192. def set_temp_bad_in_range(self):
  193. """
  194. 异步,制冷设定温度不是最高,且末端温度不超标,或制热设定温度不是最低,且末端温度不超标
  195. ## 全部为供水控制或全部为回水温度控制:制冷水温上调至 max(所有运行冷机) , 制热水温下调至min(所有运行冷机),最大步受限于停机补偿值##
  196. :return:
  197. """
  198. # 制冷模式,不超标下的异步,水温上调至最大设定值,但最大步长通过停机补偿值限制
  199. if self.dict_chiller_inner['runMode'] == 0:
  200. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  201. water_temp_set_highest = self.dict_chiller_inner['chillerWaterTempOut'][-1] + \
  202. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']
  203. if water_temp_set_highest > max(self.dict_chiller_inner['allChillerWaterTempSetOn']):
  204. water_temp_set_new = max(self.dict_chiller_inner['allChillerWaterTempSetOn'])
  205. else:
  206. water_temp_set_new = water_temp_set_highest
  207. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  208. water_temp_set_highest = self.dict_chiller_inner['chillerWaterTempIn'][-1] + \
  209. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']
  210. if water_temp_set_highest > max(self.dict_chiller_inner['allChillerWaterTempInSetOn']):
  211. water_temp_set_new = max(self.dict_chiller_inner['allChillerWaterTempInSetOn'])
  212. else:
  213. water_temp_set_new = water_temp_set_highest
  214. else:
  215. water_temp_set_new = ''
  216. logger.critical('============冷机控制选择输入错误============')
  217. elif self.dict_chiller_inner['runMode'] == 1:
  218. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  219. water_temp_set_lowest = self.dict_chiller_inner['heatingWaterTempOut'] - \
  220. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']
  221. if water_temp_set_lowest > min(self.dict_chiller_inner['allHeatingWaterTempSetOn']):
  222. water_temp_set_new = water_temp_set_lowest
  223. else:
  224. water_temp_set_new = min(self.dict_chiller_inner['allHeatingWaterTempSetOn'])
  225. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  226. water_temp_set_lowest = self.dict_chiller_inner['heatingWaterTempIn'] - \
  227. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']
  228. if water_temp_set_lowest > min(self.dict_chiller_inner['allHeatingWaterTempInSetOn']):
  229. water_temp_set_new = water_temp_set_lowest
  230. else:
  231. water_temp_set_new = min(self.dict_chiller_inner['allHeatingWaterTempInSetOn'])
  232. else:
  233. water_temp_set_new = ''
  234. logger.critical('============冷机控制选择输入错误============')
  235. else:
  236. water_temp_set_new = ''
  237. logger.critical('============冷机运行模式输入错误============')
  238. return water_temp_set_new
  239. # ----------------以下内容为重构----------------------
  240. def set_point_asynchronous(self): # ****************************************************** #
  241. """
  242. 分两类:全部为供水温度控制(含制热模式)、全部为回水温度控制(含制热模式), 暂不支持供水和回水温度共存
  243. 1、全部为供水控制
  244. (1)满足以下条件,设定值保持不变
  245. ①异步,(制冷设定温度最高 or 制热设定温度最低) and 末端温度不超标
  246. ②异步,(制冷设定温度不是最高 or 制热设定温度不是最低) and 末端温度超标
  247. (2)满足以下条件,制冷设定值下调,至 min(所有运行主机的设定值);制热设定值上调
  248. 异步,制冷设定温度最高,且末端温度超标,或制热设定温度最低,且末端温度超标
  249. (3)满足以下条件,制冷设定值上调,至 max(所有运行主机的设定值),制热设定值下调,最大调控步长受限停机补偿值
  250. 异步,制冷设定温度不是最高,且末端温度不超标,或制热设定温度不是最低,且末端温度不超标
  251. 2、全部为回水温度控制
  252. 调整逻辑和 全部为回水温度控制一致,只是水温设定值是进水设定值
  253. :return:
  254. """
  255. if self.dict_chiller_inner['runMode'] == 0:
  256. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  257. if (self.dict_chiller_inner['chillerWaterTempSet'] == max(self.dict_chiller_inner['allChillerWaterTempSetOn'])
  258. and self.is_out_range == 0) or \
  259. (self.dict_chiller_inner['chillerWaterTempSet'] < max(self.dict_chiller_inner['allChillerWaterTempSetOn'])
  260. and self.is_out_range != 0):
  261. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSet']
  262. elif self.dict_chiller_inner['chillerWaterTempSet'] == max(self.dict_chiller_inner['allChillerWaterTempSetOn']) \
  263. and self.is_out_range != 0:
  264. water_temp_set_new = min(self.dict_chiller_inner['allChillerWaterTempSetOn'])
  265. elif self.dict_chiller_inner['chillerWaterTempSet'] < max(self.dict_chiller_inner['allChillerWaterTempSetOn']) \
  266. and self.is_out_range == 0:
  267. water_temp_set_new = self.set_temp_bad_in_range()
  268. else:
  269. water_temp_set_new = ''
  270. logger.critical('============异步状态输入参数错误============')
  271. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  272. if (self.dict_chiller_inner['chillerWaterTempInSet'] == max(self.dict_chiller_inner['allChillerWaterTempInSetOn'])
  273. and self.is_out_range == 0) or \
  274. (self.dict_chiller_inner['chillerWaterTempInSet'] < max(self.dict_chiller_inner['allChillerWaterTempInSetOn'])
  275. and self.is_out_range != 0):
  276. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSet']
  277. elif self.dict_chiller_inner['chillerWaterTempInSet'] == max(self.dict_chiller_inner['allChillerWaterTempInSetOn']) \
  278. and self.is_out_range != 0:
  279. water_temp_set_new = min(self.dict_chiller_inner['allChillerWaterTempInSetOn'])
  280. elif self.dict_chiller_inner['chillerWaterTempInSet'] < max(self.dict_chiller_inner['allChillerWaterTempInSetOn']) \
  281. and self.is_out_range == 0:
  282. water_temp_set_new = self.set_temp_bad_in_range()
  283. else:
  284. water_temp_set_new = ''
  285. logger.critical('============异步状态输入参数错误============')
  286. else:
  287. water_temp_set_new = ''
  288. logger.critical('============冷机控制选择输入错误============')
  289. elif self.dict_chiller_inner['runMode'] == 1:
  290. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  291. if (self.dict_chiller_inner['heatingWaterTempSet'] == min(self.dict_chiller_inner['allHeatingWaterTempSetOn'])
  292. and self.is_out_range == 0) or \
  293. (self.dict_chiller_inner['heatingWaterTempSet'] > min(self.dict_chiller_inner['allHeatingWaterTempSetOn'])
  294. and self.is_out_range != 0):
  295. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSet']
  296. elif self.dict_chiller_inner['heatingWaterTempSet'] == min(self.dict_chiller_inner['allHeatingWaterTempSetOn'])\
  297. and self.is_out_range != 0:
  298. water_temp_set_new = max(self.dict_chiller_inner['allHeatingWaterTempSetOn'])
  299. elif self.dict_chiller_inner['heatingWaterTempSet'] > min(self.dict_chiller_inner['allHeatingWaterTempSetOn']) \
  300. and self.is_out_range == 0:
  301. water_temp_set_new = self.set_temp_bad_in_range()
  302. else:
  303. water_temp_set_new = ''
  304. logger.critical('============异步状态输入参数错误============')
  305. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  306. if (self.dict_chiller_inner['heatingWaterTempInSet'] == min(self.dict_chiller_inner['allHeatingWaterTempInSetOn'])
  307. and self.is_out_range == 0) or \
  308. (self.dict_chiller_inner['heatingWaterTempInSet'] > min(self.dict_chiller_inner['allHeatingWaterTempInSetOn'])
  309. and self.is_out_range != 0):
  310. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSet']
  311. elif self.dict_chiller_inner['heatingWaterTempInSet'] == min(self.dict_chiller_inner['allHeatingWaterTempInSetOn'])\
  312. and self.is_out_range != 0:
  313. water_temp_set_new = max(self.dict_chiller_inner['allHeatingWaterTempInSetOn'])
  314. elif self.dict_chiller_inner['heatingWaterTempInSet'] > min(self.dict_chiller_inner['allHeatingWaterTempInSetOn']) \
  315. and self.is_out_range == 0:
  316. water_temp_set_new = self.set_temp_bad_in_range()
  317. else:
  318. water_temp_set_new = ''
  319. logger.critical('============异步状态输入参数错误============')
  320. else:
  321. water_temp_set_new = ''
  322. logger.critical('============冷机控制选择输入错误============')
  323. else:
  324. water_temp_set_new = ''
  325. logger.critical('============冷机运行模式输入错误============')
  326. # water_temp_set_new = self.water_temp_limit_verify(water_temp_set_new)
  327. return water_temp_set_new
  328. # 同步状态下,温度超标
  329. # 同步状态下,温度不超标
  330. class SetPointStrategyOnChillerOnSynchronous(SetPointStrategyOnChillerOnAsynchronous):
  331. def __init__(self, dict_chiller_inner, data_temp_humi, excess_result):
  332. super(SetPointStrategyOnChillerOnSynchronous, self).__init__(
  333. dict_chiller_inner, data_temp_humi, excess_result)
  334. # self.data_upper_correct = data_upper_correct
  335. def temp_humi_in_range(self, control_bisis):
  336. # 根据控制依据判断水温调节,温度、湿度、温度和湿度
  337. if control_bisis == 0 and self.data_temp_humi['deltaTemp'].min():
  338. delta_water_temp = self.data_temp_humi['deltaTemp'].min() * Coefficient['inTemp']
  339. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaTemp'].min(), 1)
  340. elif control_bisis == 1 and self.data_temp_humi['deltaHumi'].min():
  341. delta_water_temp = self.data_temp_humi['deltaHumi'].min() * Coefficient['inHumi']
  342. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaHumi'].min(), 1)
  343. elif control_bisis == 2 and (self.data_temp_humi['deltaTemp'].min() or self.data_temp_humi['deltaHumi'].min()):
  344. delta_water_temp = min(self.data_temp_humi['deltaTemp'].min() * Coefficient['inTemp'],
  345. self.data_temp_humi['deltaHumi'].min() * Coefficient['inHumi'])
  346. if self.data_temp_humi['deltaTemp'].min() * Coefficient['inTemp'] <= \
  347. self.data_temp_humi['deltaHumi'].min() * Coefficient['inHumi']:
  348. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaTemp'].min(), 1)
  349. else:
  350. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaHumi'].min(), 1)
  351. self.excess_result['minName'] = self.data_temp_humi.loc[self.data_temp_humi['deltaHumi'].idxmin(), 'ahuName']
  352. else:
  353. delta_water_temp = 0
  354. if self.dict_chiller_inner['runMode'] == 0:
  355. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  356. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSet'] + delta_water_temp
  357. if water_temp_set_new - self.dict_chiller_inner['chillerWaterTempOut'][-1] > \
  358. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']:
  359. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempOut'][-1] + \
  360. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']
  361. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  362. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSet'] + delta_water_temp
  363. if water_temp_set_new - self.dict_chiller_inner['chillerWaterTempIn'][-1] > \
  364. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']:
  365. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempIn'][-1] + \
  366. 0.75 * self.dict_chiller_inner['coolingShutdownOffset']
  367. else:
  368. water_temp_set_new = ''
  369. logger.critical('============冷机控制选择输入错误============')
  370. elif self.dict_chiller_inner['runMode'] == 1:
  371. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  372. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSet'] - delta_water_temp
  373. if self.dict_chiller_inner['heatingWaterTempOut'][-1] - water_temp_set_new > \
  374. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']:
  375. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempOut'][-1] - \
  376. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']
  377. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  378. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSet'] - delta_water_temp
  379. if self.dict_chiller_inner['heatingWaterTempIn'][-1] - water_temp_set_new > \
  380. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']:
  381. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempIn'][-1] - \
  382. 0.75 * self.dict_chiller_inner['heatingShutdownOffset']
  383. else:
  384. water_temp_set_new = ''
  385. logger.critical('============冷机控制选择输入错误============')
  386. else:
  387. water_temp_set_new = ''
  388. logger.critical('============冷机运行模式输入错误============')
  389. return water_temp_set_new
  390. def temp_humi_out_range(self):
  391. # 1表示温度超标, 2表示露点超标, 3表示湿度超标
  392. if self.is_out_range == 1 and self.data_temp_humi['deltaTemp'].min():
  393. delta_water_temp = self.data_temp_humi['deltaTemp'].min() * Coefficient['outTemp']
  394. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaTemp'].min(), 1)
  395. elif self.is_out_range == 2 and self.data_temp_humi['deltaDewPoint'].min():
  396. delta_water_temp = self.data_temp_humi['deltaDewPoint'].min() * Coefficient['outDewPoint']
  397. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaDewPoint'].min(), 1)
  398. elif self.is_out_range == 3 and self.data_temp_humi['deltaHumi'].min():
  399. delta_water_temp = self.data_temp_humi['deltaHumi'].min() * Coefficient['outHumi']
  400. self.excess_result['minDelta'] = round(self.data_temp_humi['deltaHumi'].min(), 1)
  401. else:
  402. delta_water_temp = 0
  403. if self.dict_chiller_inner['runMode'] == 0:
  404. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  405. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempSet'] + delta_water_temp
  406. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  407. water_temp_set_new = self.dict_chiller_inner['chillerWaterTempInSet'] + delta_water_temp
  408. else:
  409. water_temp_set_new = ''
  410. logger.critical('============冷机控制选择输入错误============')
  411. elif self.dict_chiller_inner['runMode'] == 1:
  412. if self.dict_chiller_inner['waterTempControlMode'] == 0:
  413. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempSet'] - delta_water_temp
  414. elif self.dict_chiller_inner['waterTempControlMode'] == 1:
  415. water_temp_set_new = self.dict_chiller_inner['heatingWaterTempInSet'] - delta_water_temp
  416. else:
  417. water_temp_set_new = ''
  418. logger.critical('============冷机控制选择输入错误============')
  419. else:
  420. water_temp_set_new = ''
  421. logger.critical('============冷机运行模式输入错误============')
  422. return water_temp_set_new
  423. def set_point_synchronous(self, control_bisis):
  424. if self.is_out_range == 0:
  425. water_temp_set_new = self.temp_humi_in_range(control_bisis)
  426. elif self.is_out_range != 0:
  427. water_temp_set_new = self.temp_humi_out_range()
  428. else:
  429. water_temp_set_new = ''
  430. logger.critical('============温湿度超标输入错误============')
  431. # water_temp_set_new = self.water_temp_limit_verify(water_temp_set_new)
  432. return water_temp_set_new, self.excess_result
  433. # if __name__ == '__main__':
  434. # data_temp_humi = pd.DataFrame({
  435. # "tempHumiMeterId": ["3000638", "3000694"],
  436. # "terminalName": ["监测点A", "监测点B"],
  437. # "coolingTempUpper": [25.0, 26.0],
  438. # "coolingHumiUpper": [60.0, 65.0],
  439. # "heatingTempDown": [18.0, 17.5],
  440. # "tempReal": [24.5, 25.3],
  441. # "humiReal": [50, 50],
  442. # "deltaTemp": [-1, 1],
  443. # 'deltaDewPoint': [1, 1],
  444. # "deltaHumi": [1, 1],
  445. # })
  446. #
  447. # ################################# 确认这些参数是实时值还是列表
  448. # dict_chiller_inner = {'runMode': 0, 'chillerWaterTempSet': 10, 'chillerWaterTempSetUpper': 15,
  449. # 'chillerWaterTempOut': 9.8, 'chillerWaterTempIn': 9.8, 'coolingWaterTempSetUpper': 45,
  450. # 'heatingWaterTempInSet': 40, 'heatingWaterTempSet': 43, 'chillerWaterTempInSet': 12,
  451. # 'waterTempControlMode': 0, 'coolingShutdownOffset': 2, 'heatingShutdownOffset': 2,
  452. # 'allHeatingWaterTempSetOn': [7, 7], 'allHeatingWaterTempInSetOn': [12, 12],
  453. # 'allChillerWaterTempSetOn': [9, 10], 'allChillerWaterTempInSetOn': [40, 40],
  454. # 'runStatus': [1, 1, 1, 1]}
  455. # excess_result_ = {'isOutRange': 0, 'minDelta': '', 'minName': ''}
  456. # parameter = (dict_chiller_inner, data_temp_humi)
  457. # judge_syn_asy = 1
  458. # basis = 0
  459. # if judge_syn_asy == 1:
  460. # spsocoa = SetPointStrategyOnChillerOnAsynchronous(*parameter, excess_result_) # 异步算法
  461. # water_temp_set = spsocoa.set_point_asynchronous() # 异步算法
  462. # else:
  463. # spsocos = SetPointStrategyOnChillerOnSynchronous(*parameter, excess_result_) # 同步算法
  464. # water_temp_set = spsocos.set_point_synchronous(basis) # 同步算法
  465. # print(water_temp_set)