48 lines
754 B
Python
48 lines
754 B
Python
import abc
|
|
from utils.value import AttributeChange
|
|
from contextlib import contextmanager
|
|
|
|
|
|
class AHeater(AttributeChange):
|
|
def __init__(self):
|
|
AttributeChange.__init__(self)
|
|
self.is_active = False
|
|
|
|
@abc.abstractmethod
|
|
def get_power_min(self):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_power_max(self):
|
|
pass
|
|
|
|
@contextmanager
|
|
def open(self):
|
|
try:
|
|
self.activate(True)
|
|
yield None
|
|
finally:
|
|
self.activate(False)
|
|
|
|
return None
|
|
|
|
@abc.abstractmethod
|
|
def activate(self, enable):
|
|
self.is_active = enable
|
|
|
|
@abc.abstractmethod
|
|
def is_activated(self):
|
|
return self.is_active
|
|
|
|
@abc.abstractmethod
|
|
def process(self):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def set_power(self, power):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_power(self):
|
|
return None
|