예제 #1
0
    def start(self):
        """Start the device driver.  Returns bool."""

        self.logger.info("========== Starting up ==========")

        self.apply_settings()

        # Fetch the XBee Manager name from the Settings Manager:
        xbee_manager_name = SettingsBase.get_setting(self,
                                                     "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)

        # Register ourselves with the XBee Device Manager instance:
        self.__xbee_manager.xbee_device_register(self)

        # Get the extended address of the device:
        extended_address = SettingsBase.get_setting(self, "extended_address")

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(extended_address)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devide, and also set
        # the default baud rate, parity, stop bits and flow control.
        XBeeSerial.initialize_xbee_serial(self, xbee_ddo_cfg)

        # Register this configuration block with the XBee Device Manager:
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Indicate that we have no more configuration to add:
        self.__xbee_manager.xbee_device_configure(self)

        threading.Thread.start(self)
        return True
    def start(self):

        # Fetch the XBee Manager name from the Settings Manager:
        xbee_manager_name = SettingsBase.get_setting(self, "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)

        # Register ourselves with the XBee Device Manager instance:
        self.__xbee_manager.xbee_device_register(self)

        # Get the extended address of the device:
        extended_address = SettingsBase.get_setting(self, "extended_address")

        #register a callback for when the config is done
        xb_rdy_state_spec = XBeeDeviceManagerRunningEventSpec()
        xb_rdy_state_spec.cb_set(self._config_done_cb)
        self.__xbee_manager.xbee_device_event_spec_add(self, xb_rdy_state_spec)
        
        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(extended_address)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        XBeeSerial.initialize_xbee_serial(self, xbee_ddo_cfg)

        # Register this configuration block with the XBee Device Manager:
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Indicate that we have no more configuration to add:
        self.__xbee_manager.xbee_device_configure(self)

        return True
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__request_events = []
        self.__request_retry_events = []
        self._loopback_data = ""
        self._loopback_attempts = 0
        self._loopback_passes = 0
        self._loopback_fails = 0
        self._loopback_total_bytes_sent = 0
        self._loopback_total_bytes_received = 0

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='loop_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 0),
            Setting(
                name='packet_size', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x <= 10),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="attempts", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_sent", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_received", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="passes", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="fails", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeLoopBack.__init__()")
예제 #4
0
    def start(self):

        # Fetch the XBee Manager name from the Settings Manager:
        xbee_manager_name = SettingsBase.get_setting(self, "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)

        # Register ourselves with the XBee Device Manager instance:
        self.__xbee_manager.xbee_device_register(self)

        # Get the extended address of the device:
        extended_address = SettingsBase.get_setting(self, "extended_address")

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(extended_address)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        XBeeSerial.initialize_xbee_serial(self, xbee_ddo_cfg)

        # Register this configuration block with the XBee Device Manager:
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)
        
        # Setup the sleep parameters on this device:
        will_sleep = SettingsBase.get_setting(self, "sleep")
        sample_predelay = SettingsBase.get_setting(self, "sample_predelay")
        awake_time_ms = (SettingsBase.get_setting(self, "awake_time_ms") +
                         sample_predelay)
        
        if will_sleep:
            # Sample time pre-delay, allow the circuitry to power up and
            # settle before we allow the XBee to send us a sample:            
            xbee_ddo_wh_block = XBeeConfigBlockDDO(extended_address)
            xbee_ddo_wh_block.apply_only_to_modules((MOD_XB_ZB,))
            xbee_ddo_wh_block.add_parameter('WH', sample_predelay)
            self.__xbee_manager.xbee_device_config_block_add(self,
                                    xbee_ddo_wh_block)

        # The original sample rate is used as the sleep rate:
        sleep_rate_ms = SettingsBase.get_setting(self, "sample_rate_ms")
        xbee_sleep_cfg = XBeeConfigBlockSleep(extended_address)
        if will_sleep:
            xbee_sleep_cfg.sleep_cycle_set(awake_time_ms, sleep_rate_ms, enable_pin_wake=True)
        else:
            xbee_sleep_cfg.sleep_mode_set(SM_DISABLED)
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)



        # Indicate that we have no more configuration to add:
        self.__xbee_manager.xbee_device_configure(self)

        
        return True
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        ## Local State Variables:
        self.__xbee_manager = None
        self.__response_buffer = ""
        self.__request_events = []
        self.__request_retry_events = []

        from core.tracing import get_Tracer
        self.__tracer = get_tracer(name)

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='poll_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 0),
            Setting(
                name='bus_id', type=int, required=False,
                default_value=0,
                verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength", type=int,
                initial=Sample(timestamp=0, value=0, unit="%"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="target_detected", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="error_flag", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="range", type=int,
                initial=Sample(timestamp=0, value=0, unit="in"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="temperature", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="C"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        XBeeSerial.__init__(self, self.__name, self.__core,
                                settings_list, property_list)
    def start(self):
        """Start the device driver.  Returns bool."""

        # Fetch the XBee Manager name from the Settings Manager:
        xbee_manager_name = SettingsBase.get_setting(self, "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)

        # Register ourselves with the XBee Device Manager instance:
        self.__xbee_manager.xbee_device_register(self)

        # Get the extended address of the device:
        extended_address = SettingsBase.get_setting(self, "extended_address")

        # Create a callback specification that calls back this driver when
        # our device has left the configuring state and has transitioned
        # to the running state:
        xbdm_running_event_spec = XBeeDeviceManagerRunningEventSpec()
        xbdm_running_event_spec.cb_set(self.running_indication)
        self.__xbee_manager.xbee_device_event_spec_add(self,
                                                       xbdm_running_event_spec)

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(extended_address)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        XBeeSerial.initialize_xbee_serial(self, xbee_ddo_cfg)

        # TODO - these RS-485 issues should be abstracted to XBeeSerial

        # Assert that the AT node is enabled for RS-485 HIGH:
        xbee_ddo_cfg.add_parameter('D7', 7)

        # Enable +12v outpout terminal on RS-485 adapter pin 6:
        xbee_ddo_cfg.add_parameter('D2', 5)

        # Packetization timeout to 6 characters (standard M300 msg len):
        xbee_ddo_cfg.add_parameter('RO', 6)

        # Register configuration blocks with the XBee Device Manager:
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Indicate that we have no more configuration to add:
        self.__xbee_manager.xbee_device_configure(self)

        return True
예제 #7
0
    def start(self):
        """Start the device driver.  Returns bool."""

        self._tracer.calls("MassaM300.start()")

        # create our M300 object
        bus_id = SettingsBase.get_setting(self, "bus_id")
        self.__sensor = MassaM300_Sensor(bus_id)
        # if bus_id isn't 0, treat as multi-drop
        self.__sensor.set_mode_multidrop(bus_id != 0)

        # init self._xbee_manager and self._extended_address
        # register ourself with our Xbee manager
        # create the self.running_indication callback
        # XBeeBase.pre_start(self)
        self.pre_start()

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(self._extended_address)

        # Enable +12v output terminal on RS-485 adapter pin 6:
        xbee_ddo_cfg.add_parameter('D2', 5)

        # Register configuration blocks with the XBee Device Manager:
        self._xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        return XBeeSerial.start(self)
    def probe():
        """\
            Collect important information about the driver.

            .. Note::

                * This method is a static method.  As such, all data returned
                  must be accessible from the class without having a instance
                  of the device created.

            Returns a dictionary that must contain the following 2 keys:
                    1) address_table:
                       A list of XBee address tuples with the first part of the
                       address removed that this device might send data to.
                       For example: [ 0xe8, 0xc105, 0x95 ]
                    2) supported_products:
                       A list of product values that this driver supports.
                       Generally, this will consist of Product Types that
                       can be found in 'devices/xbee/common/prodid.py'
        """
        probe_data = XBeeSerial.probe()

        for address in MassaM300.ADDRESS_TABLE:
            probe_data['address_table'].append(address)

        # We don't care what devices our base class might support.
        # We do not want to support all of those devuces, so we will
        # wipe those out, and instead JUST use ours instead.
        probe_data['supported_products'] = []

        for product in MassaM300.SUPPORTED_PRODUCTS:
            probe_data['supported_products'].append(product)

        return probe_data
예제 #9
0
    def start(self):
        """Start the device driver.  Returns bool."""

        self._tracer.calls("MassaM300.start()")

        # create our M300 object
        bus_id = SettingsBase.get_setting(self, "bus_id")
        self.__sensor = MassaM300_Sensor(bus_id)
        # if bus_id isn't 0, treat as multi-drop
        self.__sensor.set_mode_multidrop(bus_id != 0)

        # init self._xbee_manager and self._extended_address
        # register ourself with our Xbee manager
        # create the self.running_indication callback
        # XBeeBase.pre_start(self)
        self.pre_start()

        # Create a DDO configuration block for this device:
        xbee_ddo_cfg = XBeeConfigBlockDDO(self._extended_address)

        # Enable +12v output terminal on RS-485 adapter pin 6:
        xbee_ddo_cfg.add_parameter('D2', 5)

        # Register configuration blocks with the XBee Device Manager:
        self._xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)

        # Call the XBeeSerial function to add the initial set up of our device.
        # This will set up the destination address of the devidce, and also set
        # the default baud rate, parity, stop bits and flow control.
        return XBeeSerial.start(self)
예제 #10
0
    def probe():
        """\
            Collect important information about the driver.

            .. Note::

                * This method is a static method.  As such, all data returned
                  must be accessible from the class without having a instance
                  of the device created.

            Returns a dictionary that must contain the following 2 keys:
                    1) address_table:
                       A list of XBee address tuples with the first part of the
                       address removed that this device might send data to.
                       For example: [ 0xe8, 0xc105, 0x95 ]
                    2) supported_products:
                       A list of product values that this driver supports.
                       Generally, this will consist of Product Types that
                       can be found in 'devices/xbee/common/prodid.py'
        """
        probe_data = XBeeSerial.probe()

        for address in MassaM300.ADDRESS_TABLE:
            probe_data['address_table'].append(address)

        # We don't care what devices our base class might support.
        # We do not want to support all of those devuces, so we will
        # wipe those out, and instead JUST use ours instead.
        probe_data['supported_products'] = []

        for product in MassaM300.SUPPORTED_PRODUCTS:
            probe_data['supported_products'].append(product)

        return probe_data
    def start(self):

        # save the Async Scheduler for our character timeout
        self.__sched = self._core.get_service("scheduler")

        # you could add other ddo settings here

        return XBeeSerial.start(self)
예제 #12
0
    def start(self):

        # save the Async Scheduler for our character timeout
        self.__sched = self._core.get_service("scheduler")

        # you could add other ddo settings here

        return XBeeSerial.start(self)
예제 #13
0
    def stop(self):
        """Stop the device driver.  Returns bool."""

        # cancel any out-standing events
        try:
            self._xbee_manager.xbee_device_schedule_cancel(self.__request_event)
        except:
            pass
        self.__request_event = None

        return XBeeSerial.stop(self)
예제 #14
0
    def stop(self):
        """Stop the device driver.  Returns bool."""

        # cancel any out-standing events
        try:
            self._xbee_manager.xbee_device_schedule_cancel(
                self.__request_event)
        except:
            pass
        self.__request_event = None

        return XBeeSerial.stop(self)
예제 #15
0
    def start(self):

        xbee_manager_name = SettingsBase.get_setting(self, "xbee_device_manager")
        dm = self.__core.get_service("device_driver_manager")
        self.__xbee_manager = dm.instance_get(xbee_manager_name)
        
        test = XBeeSerial.start(self)
        
        self._config_done_cb()
        
        self.update()
        
        
        return test
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        from core.tracing import get_tracer

        self.__tracer = get_tracer(name)

        ## Local State Variables:
        self.__xbee_manager = None

        ## Settings Table Definition:
        settings_list = []

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(
                name="read",
                type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET,
                options=DPROP_OPT_AUTOTIMESTAMP,
            ),
            ChannelSourceDeviceProperty(
                name="write",
                type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET | DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write,
            ),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core, settings_list, property_list)
예제 #17
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        # local variables used for packing of multiple rcv packets
        self.rcv_buffer = ''
        self.__chr_timer = None

        # create a resource semaphore for receiving and timeout
        self.__rcv_lock = threading.Lock()

        # local variables used for append/strip EOLN
        self.__eoln_save = None
        self._eoln = None

        ## Settings Table Definition:
        settings_list = [
            # if True, then data is converted from hexadecimal to binary
            # if False, then data is assumed ASCII (or raw)
            Setting(
                name='hexadecimal', type=bool, required=False,
                default_value=self.DEF_HEXDEC),

            # add/strip an end-of-line sequence
            # set to None to disable
            # else likely set to '\r', '\n', or '\r\n'
            # other escapes need to be of the form '\xXX', which XX is
            # exactly 2 hexadecimal bytes. Example: '\x0D' is '\r'
            Setting(
                name='eoln', type=str, required=False,
                default_value=self.DEF_EOLN),

            # character timeout to 'pack' data into a single receive
            Setting(
                name='char_timeout', type=float, required=False,
                default_value=self.DEF_CHARTOUT,
                verify_function=lambda x: x == 0.0 or x >= 0.25),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeSerialTerminal.__init__()")
예제 #18
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None
        self.local = 0
        self.hour_timer = 0
        self.source2 = None 
        self.source1 = None
        self.ud_once = 0
        self.sched = 0
        self.w_retry = 0
        self.timer_c = 0
        self.main_addr = "mainMistaway_" + gw_extended_address()
        self.last_temp = 0
        


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=300,
                verify_function=lambda x: x >= 10 and x < 0xffff),
        ]

        ## Channel Properties Definition
       
        
        
        
        property_list = [
                         
            ChannelSourceDeviceProperty(name="SS", type=str,
                initial=Sample(timestamp=0, unit="", value="System is Idle"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="ST", type=str,
                initial=Sample(timestamp=0, unit="R,W,I", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="med", type=str,
                initial=Sample(timestamp=0, unit="med", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="w_t", type=str,
                initial=Sample(timestamp=0, unit="degF", value="60"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="w_h", type=str,
                initial=Sample(timestamp=0, unit="percent", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
          
            
            ChannelSourceDeviceProperty(name="sch", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("sch", x)),
            
            ChannelSourceDeviceProperty(name="err", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("err", x)),
            
            ChannelSourceDeviceProperty(name="hour", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hour("hour", x)),
            
            
            
            ChannelSourceDeviceProperty(name="heat_4", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_5", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_7", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
                   
            ChannelSourceDeviceProperty(name="heat_6", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            
            
           
            
            
            # setable channesls
            
            
            
            ChannelSourceDeviceProperty(name="f_count", type=int,
                initial=Sample(timestamp=0, unit="failed", value=0),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.send_failed("f_count", x)),
            
            ChannelSourceDeviceProperty(name="hd1_on1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_on1", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_off1", x)),
            
            ChannelSourceDeviceProperty(name="ot_on1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on1", x)),
            
            ChannelSourceDeviceProperty(name="mode1", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("mode1", x)),
                      
            ChannelSourceDeviceProperty(name="dev_h1", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h1", x)),
            
            ChannelSourceDeviceProperty(name="dev_l1", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l1", x)),         
                   
            ChannelSourceDeviceProperty(name="splt1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="65"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("splt1", x)),
            
            ChannelSourceDeviceProperty(name="hd1_on2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_on2", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_off2", x)),
            
            ChannelSourceDeviceProperty(name="ot_on2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on2", x)),
            
            ChannelSourceDeviceProperty(name="mode2", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("mode2", x)),
                      
            ChannelSourceDeviceProperty(name="dev_h2", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h2", x)),
            
            ChannelSourceDeviceProperty(name="dev_l2", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l2", x)),         
                   
            ChannelSourceDeviceProperty(name="splt2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="65"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("splt2", x)),
            
            
            ChannelSourceDeviceProperty(name="ot_on", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on", x)),
            
            
            ChannelSourceDeviceProperty(name="dev_h", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h", x)),
            
            ChannelSourceDeviceProperty(name="dev_l", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l", x)),         
                   
            
            ChannelSourceDeviceProperty(name="zip", type=str,
                initial=Sample(timestamp=0, unit="zip", value="10001"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("zip", x)),
            
            
            
            
            # gettable properties
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_send),
            ChannelSourceDeviceProperty(name="current_temp", type=int,
                initial=Sample(timestamp=0, unit="degF", value=0),
                perms_mask=(DPROP_PERM_GET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="spt", type=int,
                initial=Sample(timestamp=0, unit="fF", value=75),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_sp(x.value)),
            ChannelSourceDeviceProperty(name="spht", type=int,
                initial=Sample(timestamp=0, unit="fF", value=80),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_sph(x.value)),
            ChannelSourceDeviceProperty(name="splt", type=int,
                initial=Sample(timestamp=0, unit="fF", value=65),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_spc(x.value)),
            ChannelSourceDeviceProperty(name="mode", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="Off"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mode(x.value)),
            ChannelSourceDeviceProperty(name="fan", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_fan(x.value)),
            ChannelSourceDeviceProperty(name="ac_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),                
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="ac_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_3", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="set_current_temp", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_temp(x.value)),
            
            ChannelSourceDeviceProperty(name="outside_temp", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_outside(x.value)),
            
            ChannelSourceDeviceProperty(name="lock", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_lock(x.value)),
            
            ChannelSourceDeviceProperty(name="hd1_off", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hd1_off(x.value)),
            
            ChannelSourceDeviceProperty(name="hd1_on", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hd1_on(x.value)),
            
            ChannelSourceDeviceProperty(name="mrt", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mrt(x.value)),
            
            ChannelSourceDeviceProperty(name="mot", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mot(x.value)),
            
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
예제 #19
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__response_buffer = ""
        self.__request_event = None
        self.__mode = self.MODE_IDLE
        self.__req_cnt = 0
        self.__rsp_cnt = 0
        self.__sensor = None

        ## Over-ride our parent's settings
        self.DEF_BAUDRATE = 19200
        self.DEF_PARITY = 'none'
        self.DEF_STOPBITS = 1
        self.DEF_HWFLOW = '485'

        ## Settings Table Definition:
        settings_list = [
            Setting(name='poll_rate_sec',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x >= 1),
            Setting(name='bus_id',
                    type=int,
                    required=False,
                    default_value=1,
                    verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength",
                                        type=int,
                                        initial=Sample(timestamp=0,
                                                       value=0,
                                                       unit="%"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="target_detected",
                                        type=Boolean,
                                        initial=Sample(timestamp=0,
                                                       value=Boolean(
                                                           False,
                                                           style=STYLE_YESNO)),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="error_flag",
                                        type=Boolean,
                                        initial=Sample(timestamp=0,
                                                       value=Boolean(
                                                           False,
                                                           style=STYLE_YESNO)),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="range",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="in"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="temperature",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="C"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="availability",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="prc"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services, settings_list,
                            property_list)

        self._tracer.calls("MassaM300.__init__()")
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=300),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="signal", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="mist_cycle", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="pm", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="status", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="F", value=" "),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
            ChannelSourceDeviceProperty(name="r", type=str,
                initial=Sample(timestamp=0, unit="F", value="not_set"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.new_update("r", x)),
            ChannelSourceDeviceProperty(name="cartridge_remaining_volume", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
           #     set_cb=lambda x: self.set_sph("cartridge_remaining_volume", x)),
            ChannelSourceDeviceProperty(name="cartridge_full_volume", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
        #        set_cb=lambda x: self.set_sph("cartridge_full_volume", x)),
            ChannelSourceDeviceProperty(name="crc", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
        #        set_cb=lambda x: self.set_sph("crc", x)),
                
            
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
예제 #21
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.string = ""
        self.signals = 0
        self.include_unit = "F"
        self.sleeping = 0

        ## Local State Variables:
        self.__xbee_manager = None

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='sleep', type=bool, required=False,
                default_value=False),
            Setting(
                name='sample_rate_ms', type=int, required=False,
                default_value=5000),
            # These settings are provided for advanced users, they
            # are not required:
            Setting(
                name='awake_time_ms', type=int, required=False,
                default_value=700,
                verify_function=lambda x: x >= 0 and x <= 0xffff),
            Setting(
                name='sample_predelay', type=int, required=False,
                default_value=0,
                verify_function=lambda x: x >= 0 and x <= 0xffff)

        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
             ChannelSourceDeviceProperty(name="excl", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.exclude("excl", x)),
             ChannelSourceDeviceProperty(name="signal", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
             ChannelSourceDeviceProperty(name="volts", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
             ChannelSourceDeviceProperty(name="get_signal", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
               set_cb=lambda x: self.set_sig_update()),
             ChannelSourceDeviceProperty(name="incl", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.include("incl", x)),
            ChannelSourceDeviceProperty(name="temperature", type=str,
                initial=Sample(timestamp=0, value="0.0", unit="fF"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="low_battery", type=bool,
                initial=Sample(timestamp=0, value=False),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
예제 #22
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.radio_requests_from_presentation_queue = Queue.Queue(8)
        self.radio_message_from_waveport_queue = Queue.Queue(1024)

        self.init_module_logger()

        ## Settings Table Definition:
        settings_list = [
            Setting(name='log_level',
                    type=str,
                    required=False,
                    default_value='DEBUG',
                    verify_function=self.check_debug_level_setting),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="response",
                                        type=str,
                                        initial=Sample(timestamp=0,
                                                       value="stres"),
                                        perms_mask=DPROP_PERM_GET
                                        | DPROP_PERM_SET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),

            # settable properties
            ChannelSourceDeviceProperty(name="request",
                                        type=str,
                                        initial=Sample(timestamp=0,
                                                       value="streq"),
                                        perms_mask=DPROP_PERM_GET
                                        | DPROP_PERM_SET,
                                        options=DPROP_OPT_AUTOTIMESTAMP,
                                        set_cb=self.request_channel_cb),
        ]

        ## Local State Variables:
        self.__xbee_manager = None

        ## Initialize the XBeeSerial interface:
        self.logger.debug("Initialize XBeeSerial")
        XBeeSerial.__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)

        # Arm watchdogs
        if (on_digi_board()):
            self.mainloop_made_one_loop = digiwdog.Watchdog(
                MAIN_LOOP_STILL_LOOPING_WATCHOG_DELAY,
                "AO Presentation main loop no more looping. Force reset")
            self.mainloop_made_a_pause = digiwdog.Watchdog(
                MAIN_LOOP_IS_NOT_INSTANTANEOUS_WATCHDOG_DELAY,
                "AO Presentation main loop no more looping. Force reset")
        else:
            self.mainloop_made_one_loop = None
            self.mainloop_made_a_pause = None
예제 #23
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None
        self.string = ""


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=30,
                verify_function=lambda x: x >= 10 and x < 0xffff),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
			            
			
            ChannelSourceDeviceProperty(name="hd1_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd1_on", x)),
            
            ChannelSourceDeviceProperty(name="cd1_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd1_on", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd1_off", x)),
            
            ChannelSourceDeviceProperty(name="cd1_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd1_off", x)),
                  
            ChannelSourceDeviceProperty(name="hd2_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd2_on", x)), 
            
            ChannelSourceDeviceProperty(name="hd2_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd2_off", x)),
            
            ChannelSourceDeviceProperty(name="hd3_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd3_on", x)),
            
            ChannelSourceDeviceProperty(name="hd3_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd3_off", x)),
            
            ChannelSourceDeviceProperty(name="cd2_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd2_on", x)),
                  
            
            ChannelSourceDeviceProperty(name="cd2_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd2_off", x)),
            
            ChannelSourceDeviceProperty(name="tm", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("tm", x)),
            
            ChannelSourceDeviceProperty(name="mont", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mont", x)),
            
            ChannelSourceDeviceProperty(name="mofft", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mofft", x)),
            
            ChannelSourceDeviceProperty(name="cs", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("cs", x)),
			
            ChannelSourceDeviceProperty(name="ht1on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht1on", x)),
			
            ChannelSourceDeviceProperty(name="ht2on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht2on", x)),
			
            ChannelSourceDeviceProperty(name="ht3on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht3on", x)),
			      
			ChannelSourceDeviceProperty(name="ht1off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht1off", x)),
            
            ChannelSourceDeviceProperty(name="ht2off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht2off", x)),
            
            ChannelSourceDeviceProperty(name="ht3off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht3off", x)),
            
            ChannelSourceDeviceProperty(name="ct1on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct1on", x)),
            
            ChannelSourceDeviceProperty(name="ct2on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct2on", x)),
            
            
            ChannelSourceDeviceProperty(name="ct1off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct1off", x)),
            
            ChannelSourceDeviceProperty(name="ct2off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct2off", x)),
            
            ChannelSourceDeviceProperty(name="t", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("t", x)),
            
            ChannelSourceDeviceProperty(name="d", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("d", x)),
            
            
            
            
            
            
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_send),
            
            ChannelSourceDeviceProperty(name="current_temp", type=float,
                initial=Sample(timestamp=0, unit="F", value=0.0),
                perms_mask=(DPROP_PERM_GET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            ChannelSourceDeviceProperty(name="splt", type=str,
                  initial=Sample(timestamp=0, unit="", value="65"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("splt", x)),
            
            
            ChannelSourceDeviceProperty(name="mode", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mode", x)),
            
            
            ChannelSourceDeviceProperty(name="cot", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("cot", x)),
            
            
            ChannelSourceDeviceProperty(name="hp", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("hp", x)),
            
            ChannelSourceDeviceProperty(name="tfoh", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("tfoh", x)),
            
            ChannelSourceDeviceProperty(name="essh", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("essh", x)),
            
            ChannelSourceDeviceProperty(name="eahp", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("eahp", x)),
            
            ChannelSourceDeviceProperty(name="essc", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("essc", x)),
            
            ChannelSourceDeviceProperty(name="tsm", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("tsm", x)),
            
            
            ChannelSourceDeviceProperty(name="fan", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("fan", x)),
            
            ChannelSourceDeviceProperty(name="ac_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),                
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="ac_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_3", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            
            
            
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        # local variables used for packing of multiple rcv packets
        self.rcv_buffer = ''
        self.__chr_timer = None

        # create a resource semaphore for receiving and timeout
        self.__rcv_lock = threading.Lock()

        # local variables used for append/strip EOLN
        self.__eoln_save = None
        self._eoln = None

        ## Settings Table Definition:
        settings_list = [
            # if True, then data is converted from hexadecimal to binary
            # if False, then data is assumed ASCII (or raw)
            Setting(
                name='hexadecimal', type=bool, required=False,
                default_value=self.DEF_HEXDEC),

            # add/strip an end-of-line sequence
            # set to None to disable
            # else likely set to '\r', '\n', or '\r\n'
            # other escapes need to be of the form '\xXX', which XX is
            # exactly 2 hexadecimal bytes. Example: '\x0D' is '\r'
            Setting(
                name='eoln', type=str, required=False,
                default_value=self.DEF_EOLN),

            # character timeout to 'pack' data into a single receive
            Setting(
                name='char_timeout', type=float, required=False,
                default_value=self.DEF_CHARTOUT,
                verify_function=lambda x: x == 0.0 or x >= 0.25),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeSerialTerminal.__init__()")
예제 #25
0
    def __init__(self, name, core_services):

            ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__response_buffer = ""
        self.__request_event = None
        self.__mode = self.MODE_IDLE
        self.__req_cnt = 0
        self.__rsp_cnt = 0
        self.__sensor = None

        ## Over-ride our parent's settings
        self.DEF_BAUDRATE = 19200
        self.DEF_PARITY = 'none'
        self.DEF_STOPBITS = 1
        self.DEF_HWFLOW = '485'

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='poll_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 1),
            Setting(
                name='bus_id', type=int, required=False,
                default_value=1,
                verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength", type=int,
                initial=Sample(timestamp=0, value=0, unit="%"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="target_detected", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="error_flag", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="range", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="in"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="temperature", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="C"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="availability", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="prc"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("MassaM300.__init__()")
    def start(self):

        # Seed random number generator.
        random.seed()

        return XBeeSerial.start(self)
예제 #27
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__request_events = []
        self.__request_retry_events = []
        self._loopback_data = ""
        self._loopback_attempts = 0
        self._loopback_passes = 0
        self._loopback_fails = 0
        self._loopback_total_bytes_sent = 0
        self._loopback_total_bytes_received = 0

        ## Settings Table Definition:
        settings_list = [
            Setting(name='loop_rate_sec',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x >= 0),
            Setting(name='packet_size',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x <= 10),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="attempts",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_sent",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_received",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="passes",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="fails",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services, settings_list,
                            property_list)

        self._tracer.calls("XBeeLoopBack.__init__()")
예제 #28
0
    def start(self):

        # Seed random number generator.
        random.seed()

        return XBeeSerial.start(self)