# Path: backend/components/base_component.py
# class BaseComponent(object):
#     """Base component for all system components It stores id type name and trivial string representation"""
#     column_headers_and_types = [['id', 'integer primary key'],
#                                 ['type', 'integer'],
#                                 ['name', 'text'], ]
#     COL_ID, COL_TYPE, COL_NAME = 0, 1, 2  # numery kolumn
# 
#     def __init__(self, *args):
#         self.id, self.type, self.name = args
# 
#         #if not isinstance(self.id, int):
#         #   raise TypeError("Id must be int")
# 
#         if not (isinstance(self.type, int) or isinstance(self.type, Enum)):
#             raise TypeError("Type must be int or enum")
# 
#         if not isinstance(self.name, str):
#             raise TypeError("name must be str")
# 
#         #if self.id < 0:
#         #    raise ValueError("Component id must be positive number")
# 
#     def __str__(self, ):
#         """Representation of object"""
#         return "".join(["ID: ", str(self.id), "\ttype: ", self.type.name, "\tname: ", self.name])
# 
#     def __repr__(self,):
#         return "".join(["ID: ", str(self.id), " type: ", self.type.name])
# 
# Path: backend/components/element.py
# class OutputElement(Element):
#  
#     types = {Et.led, Et.heater, Et.ventilator, Et.blind}
# 
#     defualt_priority = 15
#     items = {}
# 
#     def __init__(self, *args):
#         super().__init__(*args)
#         OutputElement.items[self.id] = self
#         self.desired_value = 0
#         self.setter_priority = OutputElement.defualt_priority  # Default priority can be overriden by everybody
# 
#     def set_desired_value(self, value, priority, set_flag=False):
# 
#         if priority <= self.setter_priority:
#             self.desired_value = value
# 
#             if set_flag:
#                 self.setter_priority = priority
#             else: 
#                 self.setter_priority = self.defualt_priority
# 
#             return True
# 
#         else:
#             return False
# 
#     def __str__(self, ):
#         return "".join([super().__str__(), "\tdesired_value: ", str(self.desired_value)])
# 
#     @staticmethod
#     def str():
#         string = "\n"
#         for element in OutputElement.items.values():
#             el_str = str(element) 
#             string += el_str + "\n"
# 
#         return string
# 
# Path: backend/misc/sys_types.py
# class Regt(AutoNumber):
#     temp = ()
#     hum = ()


from backend.components.base_component import BaseComponent
from backend.components.element import OutputElement
from backend.misc.sys_types import Regt


class RegulationConfigError(Exception):
    def __init__(self, msg):
        self.msg = msg


class Regulation(BaseComponent):
    """Rehulation algoritms for controlling outputs based on inputs values"""
    
    table_name = "regulation"


# Path: backend/components/base_component.py
# class BaseComponent(object):
#     """Base component for all system components It stores id type name and trivial string representation"""
#     column_headers_and_types = [['id', 'integer primary key'],
#                                 ['type', 'integer'],
#                                 ['name', 'text'], ]
#     COL_ID, COL_TYPE, COL_NAME = 0, 1, 2  # numery kolumn
# 
#     def __init__(self, *args):
#         self.id, self.type, self.name = args
# 
#         #if not isinstance(self.id, int):
#         #   raise TypeError("Id must be int")
# 
#         if not (isinstance(self.type, int) or isinstance(self.type, Enum)):
#             raise TypeError("Type must be int or enum")
# 
#         if not isinstance(self.name, str):
#             raise TypeError("name must be str")
# 
#         #if self.id < 0:
#         #    raise ValueError("Component id must be positive number")
# 
#     def __str__(self, ):
#         """Representation of object"""
#         return "".join(["ID: ", str(self.id), "\ttype: ", self.type.name, "\tname: ", self.name])
# 
#     def __repr__(self,):
#         return "".join(["ID: ", str(self.id), " type: ", self.type.name])
# 
# Path: backend/components/element.py
# class OutputElement(Element):
#  
#     types = {Et.led, Et.heater, Et.ventilator, Et.blind}
# 
#     defualt_priority = 15
#     items = {}
# 
#     def __init__(self, *args):
#         super().__init__(*args)
#         OutputElement.items[self.id] = self
#         self.desired_value = 0
#         self.setter_priority = OutputElement.defualt_priority  # Default priority can be overriden by everybody
# 
#     def set_desired_value(self, value, priority, set_flag=False):
# 
#         if priority <= self.setter_priority:
#             self.desired_value = value
# 
#             if set_flag:
#                 self.setter_priority = priority
#             else: 
#                 self.setter_priority = self.defualt_priority
# 
#             return True
# 
#         else:
#             return False
# 
#     def __str__(self, ):
#         return "".join([super().__str__(), "\tdesired_value: ", str(self.desired_value)])
# 
#     @staticmethod
#     def str():
#         string = "\n"
#         for element in OutputElement.items.values():
#             el_str = str(element) 
#             string += el_str + "\n"
# 
#         return string
# 
# Path: backend/misc/sys_types.py
# class Regt(AutoNumber):
#     temp = ()
#     hum = ()


# Path: backend/components/regulation.py
from backend.components.base_component import BaseComponent
from backend.components.element import OutputElement
from backend.misc.sys_types import Regt



class RegulationConfigError(Exception):
    def __init__(self, msg):
        self.msg = msg


class Regulation(BaseComponent):
    """Rehulation algoritms for controlling outputs based on inputs values"""
    
    table_name = "regulation"


    column_headers_and_types = BaseComponent.column_headers_and_types + [['feed_el_id', 'integer'],