Browse Source

log cold ratio and thermal comfort diagnosis

highing666 3 years ago
parent
commit
bbecc682b6

+ 11 - 0
app/api/routers/diagnosis.py

@@ -0,0 +1,11 @@
+from fastapi import APIRouter
+from loguru import logger
+
+from app.models.domain.diagnosis import ThermalComfortDiagnosisRequest, ThermalComfortDiagnosisResponse
+
+router = APIRouter()
+
+
+@router.post('/space/thermal-comfort', response_model=ThermalComfortDiagnosisResponse)
+async def get_thermal_comfort_diagnosis_result(params: ThermalComfortDiagnosisRequest):
+    pass

+ 0 - 0
app/controllers/diagnosis/__init__.py


+ 38 - 0
app/controllers/diagnosis/thermal_comfort.py

@@ -0,0 +1,38 @@
+from abc import ABC, abstractmethod
+from typing import Optional
+
+import numpy as np
+from loguru import logger
+
+from app.schemas.diagnosis import FaultCategory
+
+
+class DiagnotorBase(ABC):
+
+    def __init__(self):
+        self._result = FaultCategory()
+
+    def target_check(self, target: float) -> None:
+        if np.isnan(target):
+            self._result.no_target = True
+
+
+class ThermalComfortDiagnotor(DiagnotorBase):
+
+    pass
+
+
+class FCUDiagnotor(DiagnotorBase):
+
+    def __init__(self):
+        super(FCUDiagnotor, self).__init__()
+
+
+class VAVDiagnotor(DiagnotorBase):
+
+    pass
+
+
+class VRFDiagnotor(DiagnotorBase):
+
+    pass

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

@@ -89,6 +89,8 @@ class ACATAHSupplyAirTemperatureController:
         except ZeroDivisionError:
             cold_ratio = np.NAN
 
+        logger.debug(f'cold ratio: {cold_ratio}')
+
         return cold_ratio
 
     def build(self) -> float:
@@ -217,4 +219,6 @@ async def get_next_supply_air_temperature_set(project_id: str, device_id: str) -
     except KeyError and IndexError:
         new = await get_default(project_id)
 
+    logger.debug(f'next supply air temperature set: {device_id} - {new}')
+
     return new

+ 19 - 0
app/models/domain/diagnosis.py

@@ -0,0 +1,19 @@
+from typing import List, Optional
+
+from pydantic import BaseModel
+
+from app.schemas.equipment import AHU, FCU, VAVBox
+from app.services.transfer import Season
+
+
+class ThermalComfortDiagnosisRequest(BaseModel):
+    realtimeTemp: float
+    targetTemp: float
+    season: Season
+    fcu: Optional[List[FCU]]
+    vav: Optional[List[VAVBox]]
+    ahu: Optional[AHU]
+
+
+class ThermalComfortDiagnosisResponse(BaseModel):
+    pass

+ 19 - 0
app/schemas/diagnosis.py

@@ -0,0 +1,19 @@
+from enum import Enum
+from typing import Optional
+
+from pydantic import BaseModel
+
+
+class FaultCategory(BaseModel):
+    no_problems_found: Optional[bool] = False
+    control_logic_err: Optional[bool] = False
+    over_constrained: Optional[bool] = False
+    no_target: Optional[bool] = False
+    insufficient_heating: Optional[bool] = False
+    insufficient_cooling: Optional[bool] = False
+    excessive_heating: Optional[bool] = False
+    excessive_cooling: Optional[bool] = False
+    controller_err: Optional[bool] = False
+    sensor_err: Optional[bool] = False
+    unreasonable_space_weight: Optional[bool] = False
+    unreasonable_vav_flow_limit: Optional[bool] = False