def set_gpio(self, gpio, sample): self.setting_gpio = True #Update the channel and the module GPIO if sample.value == True: self.property_set(gpio, Sample(digitime.time(), True)) digihw.gpio_set_value(self.gpios_ind[gpio], 1) else: self.property_set(gpio, Sample(digitime.time(), False)) digihw.gpio_set_value(self.gpios_ind[gpio], 0) self.setting_gpio = False
def get_GPIOs(self): for gpio in self.input_gpios: val = digihw.gpio_get_value(gpio) #If the GPIO value has changed, update its channel if self.gpios["GPIO_" + str(gpio)] != val: self.gpios["GPIO_" + str(gpio)] = val if val == 0: self.property_set("GPIO_" + str(gpio), Sample(digitime.time(), False)) else: self.property_set("GPIO_" + str(gpio), Sample(digitime.time(), True))
def waveport_driver_request(self, req_pkt, timeout): ''' Once a packet is fully unpacked and processed this function will send the data into a device drivers request channel. Returns the response packet receiver before the timeout occurs Retruns None if no answer has been receiver ''' if (self.request_channel_to_wp0_dd): pass else: cm = self.__core.get_service("channel_manager") cd = cm.channel_database_get() for destination in self.destinations: if destination['value'] == 0: channel_name = destination['device_driver_name'] + '.request' self.request_channel_to_wp0_dd = cd.channel_get(channel_name) # send the message via DIA channel self.logger.debug('Req set:%s' % ''.join('%02X ' % ord(x) for x in req_pkt)) self.request_channel_to_wp0_dd.set(Sample(value=req_pkt)) # Wait for an answer, bounded by timeout response = self.receive_dd_message(timeout) if (response): self.logger.debug("Received a response to driver request") return (response) else: self.logger.critical("Timeout waiting for Request reply %f", timeout) return (None)
def process_xbeerawout_dd_message(self, dd_message): # send the frame directly to the dd default_return_value = '' if (not self.xbeerawout_channel): # channel has not yet been retrieved cm = self.__core.get_service("channel_manager") # XBeeRawOut channel xbeerawout_destination_description_list = SettingsBase.get_setting( self, 'xbeerawout_interface') xbeerawout_destination_description = xbeerawout_destination_description_list[ 0] xbeerawout_channel_name = xbeerawout_destination_description[ 'device_driver_name'] + '.' + CHANNEL_NAME_TO_XBEERAWOUT cd = cm.channel_database_get() if (cd.channel_exists(xbeerawout_channel_name)): self.xbeerawout_channel = cd.channel_get( xbeerawout_channel_name) else: self.logger.error('Could not retreive DIA channel named: %s' % xbeerawout_channel_name) return default_return_value try: self.xbeerawout_channel.set(Sample(timestamp=0, value=dd_message)) except Exception, msg: self.logger.error( 'Could not send xbeerawout message to channel: %s' % msg)
def do_channel_set(self, arg): try: args = parse_line(arg) except: self.write("invalid syntax.\r\n") return 0 channel_name = "" value = None unit = "" if len(args) < 2 or len(args) > 3: self.write("invalid argument(s) specified.\r\n") return 0 if len(args) > 1: channel_name = args[0] value = args[1] if len(args) > 2: unit = args[2] self.__tracer.info("have unit: %s", unit) if not self.__cdb.channel_exists(channel_name): self.write("unknown channel '%s'\r\n" % (channel_name)) return 0 channel = self.__cdb.channel_get(channel_name) sample = None try: sample = Sample(digitime.time(), channel.type()(value), unit) except Exception, e: self.write("unable to parse '%s': %s\r\n" % (value, str(e))) self.write("type expected: %s\r\n" % (channel.type())) return 0
def reply_pangoo_message(self, pangoo_message): self.logger.debug('Reply message to pangoo: %s' % pangoo_message) try: self.property_set("pangoo_response", Sample(timestamp=0, value=pangoo_message)) except Exception, msg: self.logger.error( 'Exception raised during reply sending. Exception was: %s' % (msg))
def __write_channel_database(self, chdb, channel_prefix=""): channel_list = filter(lambda c: c.startswith(channel_prefix), chdb.channel_list()) channels = {} for channel_name in channel_list: try: sample = chdb.channel_get(channel_name).get() except Exception, e: sample = Sample(value="(N/A)") channels[channel_name] = self._marshal_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 generic_radio_pkt(self, bin_pkt, route): """Put messages in receive channel of any non-waveport interface""" # send the message via DIA channel cm = self.__core.get_service("channel_manager") cd = cm.channel_database_get() for destination in self.destinations: if destination['value'] == route: channel_name = destination['device_driver_name'] + '.request' our_channel = cd.channel_get(channel_name) self.logger.debug('Req set:%s' % ''.join('%02X ' % ord(x) for x in bin_pkt)) our_channel.set(Sample(value=bin_pkt))
def run(self): while 1: if self.__stopevent.isSet(): self.__stopevent.clear() break try: device_stats = query_state("device_stats") for stat in [ 'uptime', 'cpu', 'freemem', 'usedmem', 'totalmem' ]: for item in device_stats: data = item.find(stat) if data != None: data = data.text break else: continue if stat == 'uptime': self.property_set( "uptime", Sample(0, int(float(data)), unit="sec")) elif stat == 'cpu': self.property_set("cpu_utilization", Sample(0, int(data), unit="%")) elif stat == 'freemem': self.property_set("free_memory", Sample(0, int(data), unit="bytes")) elif stat == 'usedmem': self.property_set("used_memory", Sample(0, int(data), unit="bytes")) elif stat == 'totalmem': self.property_set("total_memory", Sample(0, int(data), unit="bytes")) except Exception, e: self.__tracer.error("Unable to update stat: %s", str(e)) digitime.sleep(SettingsBase.get_setting(self, "update_rate"))
def set_channel(self, channel_name, value): try: cm = self.__core.get_service("channel_manager") cdb = cm.channel_database_get() channel = cdb.channel_get(channel_name) try: typing_value = channel.type()(value) except Exception: self.__tracer.debug(traceback.format_exc()) return channel.consumer_set(Sample(digitime.time(), typing_value)) except Exception: self.__tracer.debug(traceback.format_exc())
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 channel_set(self, channel_name, timestamp, value, unit="", autotimestamp=False): if autotimestamp: timestamp = digitime.time() channel = self.__cdb.channel_get(channel_name) try: sample = Sample(timestamp, channel.type()(value), unit) except Exception, e: raise Exception, "unable to coerce value '%s' to type '%s'" % \ (value, repr(channel.type()))
def __do_channel_set(self, attrs): """ Build a response for a channel set request. Keyword arguments: attrs -- dictionary of attributes, should have 'name' and 'value' Returns a channel_set XML element which includes the name, value, and units of the specified channel, along with a timestamp. If the 'name' attribute is missing, an empty '<channel_set>' element is returned, along with an ERR_MISSING_ATTRIBUTE error. If the specified channel doesn't seem to exist, only the name is included in the response element, along with an ERR_UNKNOWN_CHANNEL. If the sample value cannot be correctly parsed, a channel_set element is returned with the channel_name and an ERR_INVALID_SAMPLE_VALUE. If the channel set operation fails, a channel_set element is returned with the channel_name and an ERR_SET_FAILED. """ try: channel_name = attrs['name'] value = self.__unescape_entities(attrs['value']) except KeyError: return '<channel_set>' + RCIHandler.ERR_MISSING_ATTRIBUTE cdb = self._core.get_service("channel_manager").\ channel_database_get() if not cdb.channel_exists(channel_name): return ('<channel_set name="%s">' % channel_name + RCIHandler.ERR_UNKNOWN_CHANNEL) channel = cdb.channel_get(channel_name) sample = None try: sample = Sample(time.time(), channel.type()(str(value))) except Exception, e: self._tracer.error("unable to parse '%s': %s\r\n", value, str(e)) self._tracer.error("type expected: %s\r\n", channel.type()) return '<channel_set name="%s"/>' % channel_name \ + RCIHandler.ERR_INVALID_SAMPLE_VALUE
def set(request): """auto-generated from set.pyhtml""" import sys, string, cStringIO py_code = cStringIO.StringIO() py_code.write("<script>\n") import digitime from samples.sample import Sample from common.types.boolean import Boolean import channels.channel_source_device_property as dev_props try: e = request["args"]['own'] chan = request["cm"].channel_get(e[3:]) val_type = chan.type() value = request["args"]["val"] if isinstance(value, Boolean) and not value: value = "" chan.consumer_set(Sample(digitime.time(), val_type(value))) if chan.perm_mask() & dev_props.DPROP_PERM_GET and not ( chan.options_mask() & dev_props.DPROP_OPT_DONOTDUMPDATA): py_code.write(" $(\"") py_code.write(str(e)) py_code.write("\").value = \"") py_code.write(str(chan.get().value)) py_code.write("\";\n") py_code.write(" $(\"") py_code.write(str(e)) py_code.write(".debug\").innerHTML = \"\";\n") else: py_code.write(" $(\"") py_code.write(str(e)) py_code.write("\").value = \"\";\n") except Exception, detail: py_code.write(" $(\"") py_code.write(str(e)) py_code.write("\").value = \"\";\n") if request["args"].has_key( "val") and not request["args"]["val"].split() == "": py_code.write(" $(\"") py_code.write(str(e)) py_code.write(".debug\").innerHTML = \"") py_code.write(str(detail)) py_code.write("\";\n")
def process_ao_received_message(self, msg): """ This function is called after the message is received to actually act upon the data. It also performs some final verification that message is not corrupt. """ ao_command, ao_payload = msg if (not self.write_channel): # channel has not yet been retrieved cm = self.__core.get_service("channel_manager") cd = cm.channel_database_get() # test if a channel with that name exists if (cd.channel_exists(self.write_channel_name)): self.write_channel = cd.channel_get(self.write_channel_name) else: self.logger.error('Could not retreive DIA channel named: %s' % self.write_channel_name) return try: self.write_channel.set(Sample(timestamp=0, value=ao_payload)) except Exception, msg: self.logger.error('Could not send message to channel: %s' % ao_bin_to_hexstr(msg, True))
def __init__(self, name, core_services): """Performs startup initializations. It verifies and loads the settings list.""" self.__name = name self.__core = core_services self.destinations = [] self.request_channel_to_wp0_dd = None self.xbeerawout_channel = None self.waiting_for_reply = False self.gateway_v1_backward_compatibility = False self.radio_responses_queue = Queue.Queue(8) self.pangoo_request_queue = Queue.Queue(8) self.logger = init_module_logger(name) settings_list = [ Setting(name='destinations', type=list, required=False, default_value=[{ 'value': 0, 'device_driver_name': 'waveport' }]), Setting(name='xbeerawout_interface', type=list, required=False, default_value=[{ 'device_driver_name': 'rawxbeeout' }]), Setting(name='gateway_v1_backward_compatibility', type=bool, required=False, default_value=False), Setting(name='log_level', type=str, required=False, default_value='DEBUG', verify_function=check_debug_level_setting), ] ## Channel Properties Definition: property_list = [ # properties ChannelSourceDeviceProperty(name="pangoo_ascii_request", type=str, initial=Sample(timestamp=0, value=""), perms_mask=DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=self.pangoo_ascii_request_cb), ChannelSourceDeviceProperty(name="pangoo_bin_request", type=str, initial=Sample(timestamp=0, value=""), perms_mask=DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=self.pangoo_bin_request_cb), ChannelSourceDeviceProperty(name="pangoo_response", type=str, initial=Sample(timestamp=0, value=""), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ChannelSourceDeviceProperty(name='software_version', type=str, initial=Sample( timestamp=digitime.time(), value=VERSION_NUMBER), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ] ## Initialize the DeviceBase interface: DeviceBase.__init__(self, self.__name, self.__core, settings_list, property_list) # Arm watchdogs if (on_digi_board()): self.mainloop_made_one_loop = digiwdog.Watchdog( MAIN_LOOP_STILL_LOOPING_WATCHOG_DELAY, self.get_name() + " main loop no more looping. Force reset") self.mainloop_made_a_pause = digiwdog.Watchdog( MAIN_LOOP_IS_NOT_INSTANTANEOUS_WATCHDOG_DELAY, self.get_name() + " main is looping instantaneously. Force reset") else: self.mainloop_made_one_loop = None self.mainloop_made_a_pause = None ## Thread initialization: self.__stopevent = threading.Event() threading.Thread.__init__(self, name=name) threading.Thread.setDaemon(self, True)
def __init__(self, sample): self.errors = set() self.other = set() Sample.__init__(self, sample.timestamp, sample.value, sample.unit)
def get_table(self, args): def unescape(txt): words = txt.split('%') for i in range(1, len(words)): char = chr(int(words[i][:2], 16)) words[i] = char + words[i][2:].replace('+', ' ') return ''.join(words) refresh_all = False if args: argpairs = [s2 for s1 in args.split('&') for s2 in s1.split(';')] argslist = [tuple(kv.split('=')) for kv in argpairs] for kv in argslist: if len(kv) == 2: key, val = kv elif len(kv) == 1: key, = kv val = '' else: key, val = "", "kv: len==%d, should be 1 or 2" % len(kv) if key: channel = unescape(key) value = unescape(val) self.set_channel(channel, value) else: refresh_all = val == REFRESHALL data_table = {'settings': {}} try: data_table['settings']['polling'] =\ SettingsBase.get_setting(self, 'polling') except: data_table['settings']['polling'] = 0 cm = self.__core.get_service("channel_manager") cdb = cm.channel_database_get() channel_list = cdb.channel_list() channel_list.sort() old_device = '' devices = [] data_table['devices'] = devices for channel_name in channel_list: #sample = { 'channel_name': channel_name } device, name = channel_name.split('.', 1) if device != old_device: old_device = device devices.append({}) db, = devices[-1:] db['name'] = device db['channels'] = [] try: channel = cdb.channel_get(channel_name) perm = channel.perm_mask() options = channel.options_mask() if (perm & PERM_GET and not options & OPT_DONOTDUMPDATA): sample = channel.get() else: sample = Sample(0, 0) if refresh_all and (perm & PERM_REFRESH): self.refresh_channel(channel_name) if sample.timestamp > 0: timestr = self.iso_date(sample.timestamp) else: timestr = "None" db['channels'].append({ 'name': name, 'value': sample.value, 'time': timestr, 'perm': channel.perm_mask(), 'unit': sample.unit }) except Exception: self.__tracer.error("exception on channel_name '%s': %s", channel_name, traceback.format_exc()) return json(data_table.__repr__() + '\n')
def __init__(self, name, core_services): self.__name = name self.__core = core_services from core.tracing import get_tracer self.__tracer = get_tracer(name) ## Settings Table Definition: settings_list = [ Setting(name='update_rate', type=float, required=False, default_value=1.0, verify_function=lambda x: x > 0.0) ] property_list = [ ChannelSourceDeviceProperty(name="uptime", type=int, initial=Sample(timestamp=0, value=-1, unit="sec"), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ChannelSourceDeviceProperty(name="cpu_utilization", type=int, initial=Sample(timestamp=0, value=0, unit="%"), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ChannelSourceDeviceProperty(name="free_memory", type=int, initial=Sample(timestamp=0, value=-1, unit="bytes"), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ChannelSourceDeviceProperty(name="used_memory", type=int, initial=Sample(timestamp=0, value=-1, unit="bytes"), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ChannelSourceDeviceProperty(name="total_memory", type=int, initial=Sample(timestamp=0, value=-1, unit="bytes"), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP), ] ## Initialize the DeviceBase interface: DeviceBase.__init__(self, self.__name, self.__core, settings_list, property_list) ## Thread initialization: self.__stopevent = threading.Event() threading.Thread.__init__(self, name=name) threading.Thread.setDaemon(self, True)
def __command_set_channel_data(self, data): """\ Given a channel name, sets the specified data value on the channel. Returns the current information about the channel. """ channel_name = "" for i in data: if i == '\0': break channel_name += i else: self.__tracer.warning("Ill-formed Set Channel Command." \ " Channel name not sent correctly.") return None data = data[len(channel_name) + 1:] self.__tracer.info("Set Channel name: %s", channel_name) value_type = struct.unpack("!c", data[0])[0] data = data[1:] self.__tracer.info("Set value type: %s", value_type) if value_type == '?': value = struct.unpack("!B", data[0:1])[0] value = bool(value) data = data[1:] elif value_type == 'i': value = struct.unpack("!i", data[0:4])[0] data = data[4:] elif value_type == 'f': value = struct.unpack("!f", data[0:4])[0] data = data[4:] elif value_type == 's': value = "" for i in data: if i == '\0': break value += i else: self.__tracer.warning("Ill-formed Set Channel Command." \ " String value type not sent correctly.") return None data = data[len(value) + 1:] else: self.__tracer.warning("Ill-formed Set Channel Command." \ " Unknown value type.") return None self.__tracer.info("Set Value: %s", value) cm = self.__core.get_service("channel_manager") cdb = cm.channel_database_get() channel = cdb.channel_get(channel_name) sample = None try: sample = Sample(digitime.time(), channel.type()(value), "") except Exception, e: self.__tracer.error("Set Channel Command." \ " Unable to create sample.") return None
def run(self): """This is the main loop of the thread in this driver. This function will never exit. It manages the sending of keep alive packets and will occasionally check for data coming from the server. """ self.logger.info("Run, init") self.init_hardware_board_system_config() # Get settings to initialize local class variables keep_alive_interval = SettingsBase.get_setting(self, 'keep_alive_interval') keep_alive_interval_timer_total_blinks = keep_alive_interval * 60 * ( 1.0 / BLINK_TIME_BASE_SLEEP) ao_server_connexion_timer_total_blinks = WAIT_TIME_BETWEEN_SUCCESSIVE_FAILD_SERVER_CONNECT * ( 1.0 / BLINK_TIME_BASE_SLEEP) self.open_tcp_connection() #subscribe to the response channels cm = self.__core.get_service("channel_manager") cp = cm.channel_publisher_get() self.logger.info("Setting up channels") self.logger.info("Subscribing to channel: %s" % self.read_channel_name) cp.subscribe(self.read_channel_name, self.receive_response_cb) # Creating the "software_version" channel # Since this module is not declared as a "DeviceDriver", it should not have "publication channels" # Make a workaround by adding specifically the "software_version" channel (which is commonly done in the "__init__" function self.logger.info("Setting up the \"software_version\" channel") channel_db = cm.channel_database_get() channel_name = "%s.%s" % (self.__name, 'software_version') prop = ChannelSourceDeviceProperty(name='software_version', type=str, initial=Sample( timestamp=digitime.time(), value=VERSION_NUMBER), perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP) channel_db.channel_add(channel_name, prop) #=============================================================== # # Loop body # conn_cnt = 0 blink_cnt = 0 mainloop_made_a_pause_strike_cnt = 0 take_a_delay_in_next_loop_iteration = False while (True): if (take_a_delay_in_next_loop_iteration): # take a rest time.sleep(BLINK_TIME_BASE_SLEEP) mainloop_made_a_pause_strike_cnt += 1 # WARNING: infinite active loop risk here # To prevent this, we use a watchdog to check that to insure that this code # is executed some times if (self.mainloop_made_a_pause): self.mainloop_made_a_pause.stroke() # Notify the watchdog that we are still looping if (self.mainloop_made_one_loop): self.mainloop_made_one_loop.stroke() blink_cnt += 1 if (blink_cnt > 50): blink_cnt = 0 self.logger.debug('Blink (Nb pauses: %d)' % mainloop_made_a_pause_strike_cnt) mainloop_made_a_pause_strike_cnt = 0 if (self.server_conn_handle): # Connected to AO server: we can process datas # WARNING: this may introduce an infinite loop # The loop ends only if no more data are available for processing # # The watchdog is of this loop so that if this loop lasts to much time, # the watchdog resets everything # poll for work data_has_been_processed = self.aos_poll() if (data_has_been_processed): # aos_poll does not consume all available data # so, loop immediately as long as data are available take_a_delay_in_next_loop_iteration = False else: # aos_poll processed no data, which means that no data is currently available. # so, in the next loop iteration, we tell to take a rest take_a_delay_in_next_loop_iteration = True if (keep_alive_interval > 0): self.keep_alive_timer += 1 if (self.keep_alive_timer >= keep_alive_interval_timer_total_blinks): self.send_keep_alive() else: # Not connected to AO server: try first to connect to it take_a_delay_in_next_loop_iteration = True conn_cnt += 1 if (conn_cnt > ao_server_connexion_timer_total_blinks): self.logger.info('Retry to open TCP connection') conn_cnt = 0 #open our server connection self.open_tcp_connection()
def __init__(self, name, core_services): self.__name = name self.__core = core_services self.setting_gpio = False from core.tracing import get_tracer self.__tracer = get_tracer(name) ## Settings Table Definition: settings_list = [ Setting(name='input_gpios', type=list, required=True), Setting(name='output_gpios', type=list, required=True), Setting(name='update_rate', type=float, required=False, default_value=0.1, verify_function=lambda x: x > 0.0) ] ## Declare the GPIOs channels property_list = [ ChannelSourceDeviceProperty( name="GPIO_0", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_0", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_1", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_1", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_2", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_2", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_3", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_3", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_4", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_4", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_5", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_5", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_6", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_6", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_7", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_7", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_8", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_8", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_9", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_9", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_10", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_10", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_11", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_11", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_12", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_12", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_13", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_13", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_14", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_14", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_15", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_15", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_16", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_16", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_17", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_17", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_18", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_18", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_19", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_19", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_20", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_20", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_21", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_21", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_22", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_22", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_23", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_23", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_24", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_24", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_25", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_25", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_26", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_26", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_27", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_27", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_28", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_28", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_29", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_29", sample=sample)), ChannelSourceDeviceProperty( name="GPIO_30", type=bool, initial=Sample(0, False), perms_mask=DPROP_PERM_GET | DPROP_PERM_SET, options=DPROP_OPT_AUTOTIMESTAMP, set_cb=lambda sample: self.set_gpio(gpio="GPIO_30", sample=sample)) ] ## Initialize the DeviceBase interface: DeviceBase.__init__(self, self.__name, self.__core, settings_list, property_list) ## Thread initialization: self.__stopevent = threading.Event() threading.Thread.__init__(self, name=name) threading.Thread.setDaemon(self, True)