alarm.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. """
  3. alarm
  4. ~~~~~
  5. This module contains the ATFC alarm logic.
  6. """
  7. from abc import ABC, abstractmethod
  8. class Alarm(ABC):
  9. """The base Alarm"""
  10. def __init__(self, params):
  11. self._params = params
  12. def get(self, property_name):
  13. return self._params.get(property_name)
  14. def set_alarm(self, category):
  15. self._params.update({'alarm_type': category})
  16. @abstractmethod
  17. def procedure(self):
  18. raise NotImplementedError
  19. class FanCoilUnitAlarm(Alarm):
  20. def __init__(self, params):
  21. super().__init__(params)
  22. def procedure(self):
  23. if self.get('water_valve_switch') == 1 and 0 not in self.get('water_valve_history_status'):
  24. if len(set(self.get('tap_history_status'))) == 1:
  25. air_temp_diff = self.get('return_air_temp') - abs(self.get('supply_air_temp'))
  26. water_temp_diff = self.get('water_out_temp') - abs(self.get('water_in_temp'))
  27. if air_temp_diff > 13 and water_temp_diff < 1.5:
  28. self.set_alarm(1)
  29. return