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)")
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
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))
def checkData(self, data): if not 0x00000000 <= data <= 0xffffffff: raise DPTXlatorValueError("data %s not in (0x00000000, 0xffffffff)" % hex(data))
def checkValue(self, value): for index in range(14): 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))
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))
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)))