浏览代码

add partial logic of thermal diagnosis

highing666 3 年之前
父节点
当前提交
77c5d91b6d
共有 3 个文件被更改,包括 56 次插入8 次删除
  1. 54 7
      app/controllers/diagnosis/thermal_comfort.py
  2. 1 0
      app/models/domain/diagnosis.py
  3. 1 1
      app/schemas/diagnosis.py

+ 54 - 7
app/controllers/diagnosis/thermal_comfort.py

@@ -5,6 +5,7 @@ import numpy as np
 from loguru import logger
 
 from app.schemas.diagnosis import FaultCategory
+from app.schemas.equipment import FCU, VAVBox, VRF
 
 
 class DiagnotorBase(ABC):
@@ -12,27 +13,73 @@ 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
+    def controller_check(
+            self,
+            setting_value: float,
+            feedback_value: float,
+            is_categorical: bool = False,
+            tolerance_pct: float = 0.0
+    ) -> None:
+        if is_categorical:
+            if setting_value != feedback_value:
+                self._result.controller_err = True
+        else:
+            if not setting_value * (1 - tolerance_pct) <= feedback_value <= setting_value * (1 + tolerance_pct):
+                self._result.controller_err = True
 
 
 class ThermalComfortDiagnotor(DiagnotorBase):
 
-    pass
+    def __init__(self):
+        super(ThermalComfortDiagnotor, self).__init__()
 
 
 class FCUDiagnotor(DiagnotorBase):
 
-    def __init__(self):
+    def __init__(self, fcu: FCU):
         super(FCUDiagnotor, self).__init__()
+        self._fcu = fcu
+
+    def low_in_heating(self) -> None:
+        if self._fcu.air_valve_speed == 'off':
+            if self._fcu.speed_limit == 'off':
+                self._result.over_constrained = True
+            else:
+                self._result.control_logic_err = True
+        else:
+            if self._fcu.air_valve_speed == self._fcu.recommended_speed:
+                self.controller_check(self._fcu.air_valve_speed_set, self._fcu.air_valve_speed)
+                if not self._result.controller_err:
+                    if self._fcu.air_valve_speed_set == 'high':
+                        pass
+                    else:
+                        self._result.control_logic_err = True
+
+            else:
+                if self._fcu.speed_limit == self._fcu.air_valve_speed:
+                    self._result.over_constrained = True
+                else:
+                    self._result.obj_info_err = True
+
+    def low_in_cooling(self) -> None:
+        pass
+
+    def high_in_heating(self) -> None:
+        pass
+
+    def high_in_cooling(self) -> None:
+        pass
 
 
 class VAVDiagnotor(DiagnotorBase):
 
-    pass
+    def __init__(self, vav: VAVBox):
+        super(VAVDiagnotor, self).__init__()
+        self._vav = vav
 
 
 class VRFDiagnotor(DiagnotorBase):
 
-    pass
+    def __init__(self, vrf: VRF):
+        super(VRFDiagnotor, self).__init__()
+        self._vrf = vrf

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

@@ -10,6 +10,7 @@ class ThermalComfortDiagnosisRequest(BaseModel):
     realtimeTemp: float
     targetTemp: float
     season: Season
+    duration_minutes: float
     fcu: Optional[List[FCU]]
     vav: Optional[List[VAVBox]]
     ahu: Optional[AHU]

+ 1 - 1
app/schemas/diagnosis.py

@@ -8,7 +8,6 @@ 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
@@ -17,3 +16,4 @@ class FaultCategory(BaseModel):
     sensor_err: Optional[bool] = False
     unreasonable_space_weight: Optional[bool] = False
     unreasonable_vav_flow_limit: Optional[bool] = False
+    obj_info_err: Optional[bool] = False