def producer_set(self, sample):
     """\
     Update the current sample object.
     
     This function should only be called by a logging object.
     """
     self.type = ChannelSource._type_remap(self, type(sample.value))
     self.__sample = sample
 def producer_set(self, sample):
     """\
     Update the current sample object.
     
     This function should only be called by a logging object.
     """
     self.type = ChannelSource._type_remap(self, type(sample.value))
     self.__sample = sample
    def __init__(self,
                 name,
                 type,
                 initial=Sample(timestamp=0, value=0),
                 perms_mask=DPROP_PERM_NONE,
                 options=DPROP_OPT_NONE,
                 set_cb=lambda s: None,
                 refresh_cb=lambda: None):
        """
        Create a DevicePropertyItem.

        Keyword arguments:
        * **name:** the name of the device property
        * **type:** a type constructor to create the item from a string
        * **initial:** the initial Sample object used to populate the channel
        * **permissions:** a mask of permissions (constants DPROP_PERM_*)
        * **options:** a mask of options (constants DPROP_OPT_*)
        * **set_cb:** function called with sample argument for a set request
        * **refresh_cb:** function called when this property should be updated

        """

        if not isinstance(name, str):
            raise ValueError, "Channel name must be a string"
        if name.find('.') >= 0:
            raise ValueError("Channel name may not contain a dot (%s)" % name)
        if not callable(type):
            raise ValueError, "type must be callable"
        if not isinstance(initial, Sample):
            raise ValueError, "initial value must be Sample object instance"
        if not isinstance(initial.value, type):
            raise ValueError, \
                "(%s): cannot create, sample type/property type mis-match ('%s' != '%s')" % \
                    (name, repr(BUILTIN_TYPE(initial.value)), repr(type))
        if not isinstance(perms_mask, int) or perms_mask >= DPROP_PERM_MAX:
            raise ValueError, "invalid permissions mask"
        if not isinstance(options, int) or options >= DPROP_OPT_MAX:
            raise ValueError, "invalid options mask"
        if set_cb is not None and not callable(set_cb):
            raise ValueError, "set_cb must be callable"
        if not callable(refresh_cb):
            raise ValueError, "refresh_cb must be callable"

        # attributes of this property:
        self.name = name
        self.type = ChannelSource._type_remap(self, type)
        self.perms_mask = perms_mask
        self.options = options
        self.device_set_cb = set_cb
        self.device_refresh_cb = refresh_cb
        self.__rlock = threading.RLock()

        # the current sample for this channel:
        self.__sample = initial
    def __init__(self, initial=Sample(timestamp=0, value=0)):
        """\
        Create a ChannelSourceLogger; it implements the ChannelSource
        interface.
        """

        # channel meta-information
        self.type = ChannelSource._type_remap(self, type(initial.value))
        self.perms_mask = PERM_GET
        self.options = OPT_NONE

    	# the current sample for this channel:
    	self.__sample = initial
    def __init__(self, initial=Sample(timestamp=0, value=0)):
        """\
        Create a ChannelSourceLogger; it implements the ChannelSource
        interface.
        """

        # channel meta-information
        self.type = ChannelSource._type_remap(self, type(initial.value))
        self.perms_mask = PERM_GET
        self.options = OPT_NONE

        # the current sample for this channel:
        self.__sample = initial
    def __init__(self, name, type, initial=Sample(timestamp=0, value=0),
                    perms_mask=DPROP_PERM_NONE,
                    options=DPROP_OPT_NONE,
                    set_cb=lambda s: None, refresh_cb=lambda: None):
        """
        Create a DevicePropertyItem.

        Keyword arguments:
        * **name:** the name of the device property
        * **type:** a type constructor to create the item from a string
        * **initial:** the initial Sample object used to populate the channel
        * **permissions:** a mask of permissions (constants DPROP_PERM_*)
        * **options:** a mask of options (constants DPROP_OPT_*)
        * **set_cb:** function called with sample argument for a set request
        * **refresh_cb:** function called when this property should be updated

        """

        if not isinstance(name, str):
            raise ValueError, "Channel name must be a string"
        if name.find('.') >= 0:
            raise ValueError("Channel name may not contain a dot (%s)" % name)
        if not callable(type):
            raise ValueError, "type must be callable"
        if not isinstance(initial, Sample):
            raise ValueError, "initial value must be Sample object instance"
        if not isinstance(initial.value, type):
            raise ValueError, \
                "(%s): cannot create, sample type/property type mis-match ('%s' != '%s')" % \
                    (name, repr(BUILTIN_TYPE(initial.value)), repr(type))
        if not isinstance(perms_mask, int) or perms_mask >= DPROP_PERM_MAX:
            raise ValueError, "invalid permissions mask"
        if not isinstance(options, int) or options >= DPROP_OPT_MAX:
            raise ValueError, "invalid options mask"
        if set_cb is not None and not callable(set_cb):
            raise ValueError, "set_cb must be callable"
        if not callable(refresh_cb):
            raise ValueError, "refresh_cb must be callable"

        # attributes of this property:
        self.name = name
        self.type = ChannelSource._type_remap(self, type)
        self.perms_mask = perms_mask
        self.options = options
        self.device_set_cb = set_cb
        self.device_refresh_cb = refresh_cb
        self.__rlock = threading.RLock()

        # the current sample for this channel:
        self.__sample = initial