|
@@ -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
|