|
@@ -0,0 +1,49 @@
|
|
|
+from typing import List, Optional
|
|
|
+
|
|
|
+from httpx import AsyncClient
|
|
|
+from loguru import logger
|
|
|
+
|
|
|
+from app.schemas.equipment import VAVBox
|
|
|
+from app.services.platform import DataPlatformService, InfoCode
|
|
|
+
|
|
|
+
|
|
|
+class ACATAHThermalModeController:
|
|
|
+ """
|
|
|
+ Decide whether to use cooling or heating mode according to space condition controlled by VAV Box.
|
|
|
+ Writen by WuXu
|
|
|
+ """
|
|
|
+
|
|
|
+ def __init__(self, vav_boxes_list: List[VAVBox]):
|
|
|
+ super(ACATAHThermalModeController, self).__init__()
|
|
|
+ self.vav_boxes_list = vav_boxes_list
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def count_box_weight(realtime: float, target: float) -> float:
|
|
|
+ diff = abs(realtime - target)
|
|
|
+ if diff > 3:
|
|
|
+ weight = 4
|
|
|
+ elif diff > 2:
|
|
|
+ weight = 3
|
|
|
+ elif diff > 1:
|
|
|
+ weight = 2
|
|
|
+ elif diff > 0:
|
|
|
+ weight = 1
|
|
|
+ else:
|
|
|
+ weight = 0
|
|
|
+
|
|
|
+ return weight * (realtime - target)
|
|
|
+
|
|
|
+ def build(self) -> str:
|
|
|
+ weight = 0.0
|
|
|
+ for box in self.vav_boxes_list:
|
|
|
+ weight += self.count_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
|
|
|
+
|
|
|
+ if weight > 0:
|
|
|
+ mode = 'cooling'
|
|
|
+ elif weight < 0:
|
|
|
+ mode = 'heating'
|
|
|
+ else:
|
|
|
+ mode = 'hold'
|
|
|
+
|
|
|
+ return mode
|
|
|
+
|