|
@@ -0,0 +1,62 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+
|
|
|
+from loguru import logger
|
|
|
+
|
|
|
+
|
|
|
+from app.controllers.equipment.controller import EquipmentController
|
|
|
+from app.models.domain.devices import ACATVIModeRequest
|
|
|
+from app.schemas.season import Season
|
|
|
+
|
|
|
+
|
|
|
+class VRFModeController(EquipmentController):
|
|
|
+ def __init__(self, season: Season, space_temperature: list):
|
|
|
+ super().__init__()
|
|
|
+ self._season = season
|
|
|
+ self._space_temperature = space_temperature
|
|
|
+ self._new_mode = "hold"
|
|
|
+
|
|
|
+ def run(self) -> None:
|
|
|
+ if self._season == Season.cooling:
|
|
|
+ cold_space_count, hot_space_count = 0, 0
|
|
|
+ for item in self._space_temperature:
|
|
|
+ if item < 22.0:
|
|
|
+ cold_space_count += 1
|
|
|
+ if item > 26.0:
|
|
|
+ hot_space_count += 1
|
|
|
+ if (
|
|
|
+ cold_space_count / len(self._space_temperature) > 0.6
|
|
|
+ and hot_space_count < 1
|
|
|
+ ):
|
|
|
+ new_mode = "ventilation"
|
|
|
+ else:
|
|
|
+ new_mode = "cooling"
|
|
|
+ elif self._season == Season.transition:
|
|
|
+ new_mode = "ventilation"
|
|
|
+ else:
|
|
|
+ cold_space_count, hot_space_count = 0, 0
|
|
|
+ for item in self._space_temperature:
|
|
|
+ if item < 22.0:
|
|
|
+ cold_space_count += 1
|
|
|
+ if item > 25.0:
|
|
|
+ hot_space_count += 1
|
|
|
+ if (
|
|
|
+ hot_space_count / len(self._space_temperature) > 0.6
|
|
|
+ and cold_space_count < 1
|
|
|
+ ):
|
|
|
+ new_mode = "ventilation"
|
|
|
+ else:
|
|
|
+ new_mode = "heating"
|
|
|
+
|
|
|
+ self._new_mode = new_mode
|
|
|
+
|
|
|
+ def get_results(self) -> str:
|
|
|
+ return self._new_mode
|
|
|
+
|
|
|
+
|
|
|
+@logger.catch()
|
|
|
+async def build_acatvi_mode(params: ACATVIModeRequest) -> str:
|
|
|
+ controller = VRFModeController(params.season, params.space_temperature_list)
|
|
|
+ controller.run()
|
|
|
+ new_mode = controller.get_results()
|
|
|
+
|
|
|
+ return new_mode
|