def consumer_set(self, sample): """ Called from a channel wishing to write this property's data. If there is a device set callback defined, it is called. If the callback is called it is the callback's responsiblity to set the data in the channel (by calling producer_set()). If the device wishes to reject the value of the set, it must raise an exception. If no callback is defined, the value is simply set on the channel as long as it passes type checking. """ if not self.perms_mask & DPROP_PERM_SET: raise DevicePropertyPermError, "set permission denied" sample = ChannelSource._type_remap_and_check(self, self.type, sample) self.__rlock.acquire() try: if self.device_set_cb is not None: # Exceptions are propagated upward: self.device_set_cb(sample) else: self.__sample = sample finally: self.__rlock.release()
def consumer_set(self, sample): """ Called from a channel wishing to write this property's data. If there is a device set callback defined, it is called. If the callback is called it is the callback's responsiblity to set the data in the channel (by calling producer_set()). If the device wishes to reject the value of the set, it must raise an exception. If no callback is defined, the value is simply set on the channel as long as it passes type checking. Return: Returns True if the set was performed by the channel_source rather than the driver and the Channel needs to generate an event. """ if not self.perms_mask & DPROP_PERM_SET: raise DevicePropertyPermError, "set permission denied" sample = ChannelSource._type_remap_and_check(self, self.type, sample) retval = False self.__rlock.acquire() try: if self.device_set_cb is not None: # Exceptions are propagated upward: self.device_set_cb(sample) else: self.__sample = sample retval = True finally: self.__rlock.release() return retval
def producer_set(self, sample): """ Update the current sample object. This function should only be called by a DeviceProperties object. """ sample = ChannelSource._type_remap_and_check(self, self.type, sample) self.__rlock.acquire() try: if sample.timestamp == 0 and self.options & DPROP_OPT_AUTOTIMESTAMP: sample.timestamp = time.time() self.__sample = copy(sample) finally: self.__rlock.release()
def producer_set(self, sample): """ Update the current sample object. This function should only be called by a DeviceProperties object. """ sample = ChannelSource._type_remap_and_check(self, self.type, sample) self.__rlock.acquire() try: if sample.timestamp == 0 and self.options & DPROP_OPT_AUTOTIMESTAMP: sample.timestamp = digitime.time() self.__sample = copy(sample) finally: self.__rlock.release()