Exemplo n.º 1
0
 def checkData(self, data):
     if data not in (0x00, 0x01):
         try:
             raise DPTXlatorValueError("data %s not in (0x00, 0x01)" %
                                       hex(data))
         except TypeError:
             raise DPTXlatorValueError("data not in (0x00, 0x01)")
Exemplo n.º 2
0
    def __init__(self, dptId, dptXlatorClass, desc=""):
        """ Creates a new Datapoint Type main type to DPT mapper

        @param dptId: Datapoint Type ID
                      This id must be the generic form ("1.xxx")
        @type dptId: str or L{DPTID}

        @param dptXlatorClass: Datapoint Type class
        @type dptXlatorClass: class

        @param desc: description of the Datapoint Type main type mapper
        @type desc: str

        @raise DPTXlatorValueError:
        """
        super(DPTMainTypeMapper, self).__init__()

        if not issubclass(dptXlatorClass, DPTXlatorBase):
            raise DPTXlatorValueError(
                "dptXlatorClass %s not a sub-class of DPT" %
                repr(dptXlatorClass))
        if not isinstance(dptId, DPTID):
            dptId = DPTID(dptId)
        self._dptId = dptId
        self._dptXlatorClass = dptXlatorClass
        self._desc = desc
Exemplo n.º 3
0
 def checkValue(self, value):
     for index in range(4):
         if not self._dpt.limits[0][index] <= value[
                 index] <= self._dpt.limits[1][index]:
             raise DPTXlatorValueError("value not in range %s" %
                                       repr(self._dpt.limits))
Exemplo n.º 4
0
 def checkData(self, data):
     if not 0x000000 <= data <= 0xffffff:
         raise DPTXlatorValueError("data %s not in (0x000000, 0xffffff)" %
                                   hex(data))
Exemplo n.º 5
0
 def checkValue(self, value):
     if self.dpt is self.DPT_Generic:
         if not self._dpt.limits[0] <= value <= self._dpt.limits[1]:
             raise DPTXlatorValueError("value not in range %s" % repr(self._dpt.limits))
     elif value not in self._dpt.limits:
         raise DPTXlatorValueError("value not in %r" % repr(self._dpt.limits))
Exemplo n.º 6
0
 def checkValue(self, value):
     if value not in self._dpt.limits and value not in self.DPT_Generic.limits:
         raise DPTXlatorValueError("value %s not in %s" %
                                   (value, str(self._dpt.limits)))
Exemplo n.º 7
0
 def checkValue(self, value):
     if not self._dpt.limits[0] <= value <= self._dpt.limits[1]:
         raise DPTXlatorValueError("Value not in range %s" %
                                   repr(self._dpt.limits))