supply_air_temperature_set.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from typing import List, Optional
  2. from httpx import AsyncClient
  3. from loguru import logger
  4. from app.controllers.equipment.ahu.water_valve_opening import count_vav_box_weight
  5. from app.models.domain.devices import ThermalMode
  6. from app.schemas.equipment import VAVBox
  7. class ACATAHSupplyAirTemperatureController:
  8. """
  9. Supply air temperature setting logic version 2 by WuXu.
  10. """
  11. def __init__(self, vav_boxes_list: List[VAVBox], current: float, return_air: float, thermal_mode: ThermalMode):
  12. super(ACATAHSupplyAirTemperatureController, self).__init__()
  13. self.vav_boxes_list = vav_boxes_list
  14. self.current = current
  15. self.return_air = return_air
  16. self.thermal_mode = thermal_mode
  17. def calculate_by_cold_vav(self, cold_ratio: float) -> float:
  18. if self.thermal_mode == ThermalMode.cooling:
  19. if cold_ratio < 0.3:
  20. new = self.current - 1.0
  21. elif cold_ratio < 0.45:
  22. new = self.current - 0.5
  23. elif cold_ratio <= 0.55:
  24. new = self.current
  25. elif cold_ratio <= 0.7:
  26. new = self.current + 1.0
  27. elif cold_ratio <= 1.0:
  28. new = self.return_air
  29. else:
  30. new = self.current
  31. elif self.thermal_mode == ThermalMode.heating:
  32. if cold_ratio < 0.3:
  33. new = self.return_air
  34. elif cold_ratio < 0.45:
  35. new = self.current - 1
  36. elif cold_ratio <= 0.55:
  37. new = self.current
  38. elif cold_ratio <= 0.7:
  39. new = self.current + 0.5
  40. elif cold_ratio <= 1.0:
  41. new = self.current + 1
  42. else:
  43. new = self.current
  44. else:
  45. new = self.current
  46. return new
  47. def get_cold_ratio(self):
  48. cold, total = 0, 0
  49. for box in self.vav_boxes_list:
  50. temp = count_vav_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
  51. cold += temp if temp < 0 else 0
  52. total += abs(temp)
  53. return abs(cold / total)