import abc
from utils.value import AttributeChange
from contextlib import contextmanager


class APlant(AttributeChange):
	def __init__(self):
		AttributeChange.__init__(self)

	@contextmanager
	def open(self):
		try:
			self.activate(True)
			yield None
		finally:
			self.activate(False)

		return None

	@abc.abstractmethod
	def activate(self, enable):
		return None

	@abc.abstractmethod
	def is_activated(self):
		return None

	@abc.abstractmethod
	def process(self):
		pass

	@abc.abstractmethod
	def set_power(self, power):
		pass

	@abc.abstractmethod
	def get_power(self):
		return None

	@abc.abstractmethod
	def get_temperature(self):
		return None
