water_valve_opening.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. def count_vav_box_weight(realtime: float, target: float) -> float:
  7. diff = abs(realtime - target)
  8. if diff > 3:
  9. weight = 4
  10. elif diff > 2:
  11. weight = 3
  12. elif diff > 1:
  13. weight = 2
  14. elif diff > 0:
  15. weight = 1
  16. else:
  17. weight = 0
  18. return weight * (realtime - target)
  19. class ACATAHThermalModeController:
  20. """
  21. Decide whether to use cooling or heating mode according to space condition controlled by VAV Box.
  22. Writen by WuXu
  23. """
  24. def __init__(self, vav_boxes_list: List[VAVBox]):
  25. super(ACATAHThermalModeController, self).__init__()
  26. self.vav_boxes_list = vav_boxes_list
  27. def build(self) -> str:
  28. weight = 0.0
  29. for box in self.vav_boxes_list:
  30. weight += count_vav_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
  31. if weight > 0:
  32. mode = 'cooling'
  33. elif weight < 0:
  34. mode = 'heating'
  35. else:
  36. mode = 'hold'
  37. return mode