vav.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. from app.controllers.equipment.controller import EquipmentController
  4. from app.models.equipment import VAVBox, FCU
  5. class VAVController(EquipmentController):
  6. def __init__(self, equipment: VAVBox):
  7. super(VAVController, self).__init__()
  8. self._equipment = equipment
  9. async def get_strategy(self):
  10. strategy = 'Plan A'
  11. for space in self._equipment.spaces:
  12. for eq in space.equipment:
  13. if isinstance(eq, FCU):
  14. strategy = 'Plan B'
  15. break
  16. return strategy
  17. async def get_temperature_target(self) -> float:
  18. total_targets = []
  19. total_buffer = []
  20. strategy = self.get_strategy()
  21. for space in self._equipment.spaces:
  22. if strategy == 'Plan A':
  23. total_targets.append(space.temperature_target)
  24. elif strategy == 'Plan B':
  25. for eq in space.equipment:
  26. if isinstance(eq, FCU):
  27. buffer = (4 - eq.air_valve_speed) / 4
  28. total_buffer.append(buffer)
  29. break
  30. total = total_buffer + total_targets
  31. result = np.array(total).sum() / len(total_targets)
  32. self._equipment.setting_temperature = result
  33. return result
  34. def run(self):
  35. pass