瀏覽代碼

add some files about devices

chenhaiyang 4 年之前
父節點
當前提交
7bb6059bae

+ 22 - 0
app/api/routers/devices.py

@@ -0,0 +1,22 @@
+from fastapi import APIRouter, Query
+
+from app.models.domain.devices import ACATAHThermalModeSetResponse, ACATAHSupplyAirTemperatureSetResponse
+
+
+router = APIRouter()
+
+
+@router.get('/instructions/acatah/thermal-mode-set', response_model=ACATAHThermalModeSetResponse)
+async def get_acatah_thermal_mode_set(
+        project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
+        device_id: str = Query(..., max_length=50, regex='^Eq', alias='equipId')
+):
+    pass
+
+
+@router.get('/instructions/acatah/supply-air-temperature-set', response_model=ACATAHSupplyAirTemperatureSetResponse)
+async def get_acatah_supply_air_temperature_set(
+        project_id: str = Query(..., max_length=50, regex='^Pj', alias='projectId'),
+        device_id: str = Query(..., max_length=50, regex='^Eq', alias='equipId')
+):
+    pass

+ 13 - 0
app/controllers/equipment/ahu/supply_air_temperature_set.py

@@ -0,0 +1,13 @@
+from typing import Optional
+
+from httpx import AsyncClient
+from loguru import logger
+
+
+class ACATAHSupplyAirTemperatureController:
+    """
+    Supply air temperature setting logic version 2 by WuXu.
+    """
+
+    def __init__(self):
+        super(ACATAHSupplyAirTemperatureController, self).__init__()

+ 49 - 0
app/controllers/equipment/ahu/water_valve_opening.py

@@ -0,0 +1,49 @@
+from typing import List, Optional
+
+from httpx import AsyncClient
+from loguru import logger
+
+from app.schemas.equipment import VAVBox
+from app.services.platform import DataPlatformService, InfoCode
+
+
+class ACATAHThermalModeController:
+    """
+    Decide whether to use cooling or heating mode according to space condition controlled by VAV Box.
+    Writen by WuXu
+    """
+
+    def __init__(self, vav_boxes_list: List[VAVBox]):
+        super(ACATAHThermalModeController, self).__init__()
+        self.vav_boxes_list = vav_boxes_list
+
+    @staticmethod
+    def count_box_weight(realtime: float, target: float) -> float:
+        diff = abs(realtime - target)
+        if diff > 3:
+            weight = 4
+        elif diff > 2:
+            weight = 3
+        elif diff > 1:
+            weight = 2
+        elif diff > 0:
+            weight = 1
+        else:
+            weight = 0
+
+        return weight * (realtime - target)
+
+    def build(self) -> str:
+        weight = 0.0
+        for box in self.vav_boxes_list:
+            weight += self.count_box_weight(box.virtual_realtime_temperature, box.virtual_target_temperature)
+
+        if weight > 0:
+            mode = 'cooling'
+        elif weight < 0:
+            mode = 'heating'
+        else:
+            mode = 'hold'
+
+        return mode
+

+ 23 - 0
app/models/domain/devices.py

@@ -0,0 +1,23 @@
+from enum import Enum
+from typing import Optional
+
+from pydantic import BaseModel
+
+
+class ThermalMode(str, Enum):
+    cooling = 'cooling'
+    heating = 'heating'
+    hold = 'hold'
+
+
+class DevicesInstructionsBaseResponse(BaseModel):
+    projectId: str
+    equipId: str
+
+
+class ACATAHThermalModeSetResponse(DevicesInstructionsBaseResponse):
+    thermal_mode_set: ThermalMode
+
+
+class ACATAHSupplyAirTemperatureSetResponse(DevicesInstructionsBaseResponse):
+    supply_air_temperature_set: float