def summary(self): ''' Returns a summary of the counters current status :returns: A byte with each bit representing each counter ''' count, result = 0x01, 0x00 for i in itervalues(self.__data): if i != 0x00: result |= count count <<= 1 return result
def __init__(self, values): ''' Initializes the datastore Using the input values we create the default datastore value and the starting address :param values: Either a list or a dictionary of values ''' if isinstance(values, dict): self.values = values elif hasattr(values, '__iter__'): self.values = dict(enumerate(values)) else: raise ParameterException( "Values for datastore must be a list or dictionary") self.default_value = get_next(itervalues(self.values)).__class__() self.address = get_next(iterkeys(self.values))
def reset(self): ''' Resets all the datastores to their default values ''' for datastore in itervalues(self.store): datastore.reset()
def __iter__(self): ''' Iterater over the device counters :returns: An iterator of the device counters ''' return izip(self.__names, itervalues(self.__data))
def summary(self): ''' Return a summary of the main items :returns: An dictionary of the main items ''' return dict(zip(self.__names, itervalues(self.__data)))
def summary(self): ''' Returns a summary of the modbus plus statistics :returns: 54 16-bit words representing the status ''' return itervalues(self.__data)