|
@@ -1,13 +1,63 @@
|
|
|
-from typing import Optional
|
|
|
+from typing import List, Optional
|
|
|
|
|
|
from httpx import AsyncClient
|
|
|
from loguru import logger
|
|
|
|
|
|
+from app.controllers.equipment.ahu.water_valve_opening import count_vav_box_weight
|
|
|
+from app.models.domain.devices import ThermalMode
|
|
|
+from app.schemas.equipment import VAVBox
|
|
|
+
|
|
|
|
|
|
class ACATAHSupplyAirTemperatureController:
|
|
|
"""
|
|
|
Supply air temperature setting logic version 2 by WuXu.
|
|
|
"""
|
|
|
|
|
|
- def __init__(self):
|
|
|
+ def __init__(self, vav_boxes_list: List[VAVBox], current: float, return_air: float, thermal_mode: ThermalMode):
|
|
|
super(ACATAHSupplyAirTemperatureController, self).__init__()
|
|
|
+ self.vav_boxes_list = vav_boxes_list
|
|
|
+ self.current = current
|
|
|
+ self.return_air = return_air
|
|
|
+ self.thermal_mode = thermal_mode
|
|
|
+
|
|
|
+ def calculate_by_cold_vav(self, cold_ratio: float) -> float:
|
|
|
+ if self.thermal_mode == ThermalMode.cooling:
|
|
|
+ if cold_ratio < 0.3:
|
|
|
+ new = self.current - 1.0
|
|
|
+ elif cold_ratio < 0.45:
|
|
|
+ new = self.current - 0.5
|
|
|
+ elif cold_ratio <= 0.55:
|
|
|
+ new = self.current
|
|
|
+ elif cold_ratio <= 0.7:
|
|
|
+ new = self.current + 1.0
|
|
|
+ elif cold_ratio <= 1.0:
|
|
|
+ new = self.return_air
|
|
|
+ else:
|
|
|
+ new = self.current
|
|
|
+ elif self.thermal_mode == ThermalMode.heating:
|
|
|
+ if cold_ratio < 0.3:
|
|
|
+ new = self.return_air
|
|
|
+ elif cold_ratio < 0.45:
|
|
|
+ new = self.current - 1
|
|
|
+ elif cold_ratio <= 0.55:
|
|
|
+ new = self.current
|
|
|
+ elif cold_ratio <= 0.7:
|
|
|
+ new = self.current + 0.5
|
|
|
+ elif cold_ratio <= 1.0:
|
|
|
+ new = self.current + 1
|
|
|
+ else:
|
|
|
+ new = self.current
|
|
|
+ else:
|
|
|
+ new = self.current
|
|
|
+
|
|
|
+ return new
|
|
|
+
|
|
|
+ def get_cold_ratio(self):
|
|
|
+ cold, total = 0, 0
|
|
|
+ for box in self.vav_boxes_list:
|
|
|
+ temp = count_vav_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
|
|
|
+ cold += temp if temp < 0 else 0
|
|
|
+ total += abs(temp)
|
|
|
+
|
|
|
+ return abs(cold / total)
|
|
|
+
|