# -*- coding: utf-8 -*- """ alarm ~~~~~ This module contains the ATFC alarm logic. """ from abc import ABC, abstractmethod class Alarm(ABC): """The base Alarm""" def __init__(self, params): self._params = params def get(self, property_name): return self._params.get(property_name) def set_alarm(self, category): self._params.update({'alarm_type': category}) @abstractmethod def procedure(self): raise NotImplementedError class FanCoilUnitAlarm(Alarm): def __init__(self, params): super().__init__(params) def procedure(self): if self.get('water_valve_switch') == 1 and 0 not in self.get('water_valve_history_status'): if len(set(self.get('tap_history_status'))) == 1: air_temp_diff = self.get('return_air_temp') - abs(self.get('supply_air_temp')) water_temp_diff = self.get('water_out_temp') - abs(self.get('water_in_temp')) if air_temp_diff > 13 and water_temp_diff < 1.5: self.set_alarm(1) return