water_valve_opening.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from typing import List, Optional
  2. from httpx import AsyncClient
  3. from loguru import logger
  4. from app.schemas.equipment import VAVBox
  5. from app.services.platform import DataPlatformService, InfoCode
  6. class ACATAHThermalModeController:
  7. """
  8. Decide whether to use cooling or heating mode according to space condition controlled by VAV Box.
  9. Writen by WuXu
  10. """
  11. def __init__(self, vav_boxes_list: List[VAVBox]):
  12. super(ACATAHThermalModeController, self).__init__()
  13. self.vav_boxes_list = vav_boxes_list
  14. @staticmethod
  15. def count_box_weight(realtime: float, target: float) -> float:
  16. diff = abs(realtime - target)
  17. if diff > 3:
  18. weight = 4
  19. elif diff > 2:
  20. weight = 3
  21. elif diff > 1:
  22. weight = 2
  23. elif diff > 0:
  24. weight = 1
  25. else:
  26. weight = 0
  27. return weight * (realtime - target)
  28. def build(self) -> str:
  29. weight = 0.0
  30. for box in self.vav_boxes_list:
  31. weight += self.count_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
  32. if weight > 0:
  33. mode = 'cooling'
  34. elif weight < 0:
  35. mode = 'heating'
  36. else:
  37. mode = 'hold'
  38. return mode