当前位置: 首页>>代码示例>>Python>>正文


Python XBeeConfigBlockDDO.apply_only_to_modules方法代码示例

本文整理汇总了Python中devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO.apply_only_to_modules方法的典型用法代码示例。如果您正苦于以下问题:Python XBeeConfigBlockDDO.apply_only_to_modules方法的具体用法?Python XBeeConfigBlockDDO.apply_only_to_modules怎么用?Python XBeeConfigBlockDDO.apply_only_to_modules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO的用法示例。


在下文中一共展示了XBeeConfigBlockDDO.apply_only_to_modules方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    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
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:57,代码来源:dhw.py

示例2: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    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")

        # Retrieve the flag which tells us if we should sleep:

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        xbdm_rx_event_spec = XBeeDeviceManagerRxEventSpec()
        xbdm_rx_event_spec.cb_set(self.sample_indication)
        xbdm_rx_event_spec.match_spec_set(
            (extended_address, 0xe8, 0xc105, 0x92),
            (True, True, True, True))
        self.__xbee_manager.xbee_device_event_spec_add(self,
                                xbdm_rx_event_spec)

        # 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)

        # Get the gateway's extended address:
        gw_xbee_sh, gw_xbee_sl = gw_extended_address_tuple()

        # Set the destination for I/O samples to be the gateway:
        xbee_ddo_cfg.add_parameter('DH', gw_xbee_sh)
        xbee_ddo_cfg.add_parameter('DL', gw_xbee_sl)

        # Configure pins DI1 .. DI3 for analog input:
        for io_pin in [ 'D1', 'D2', 'D3' ]:
            xbee_ddo_cfg.add_parameter(io_pin, 2)

        # Configure battery-monitor pin DIO11/P1 for digital input:
        xbee_ddo_cfg.add_parameter('P1', 3)
        # Enable change detection on DIO11:
        #
        # 0x   8    0    0
        #   1000 0000 0000 (b)
        #   DDDD DDDD DDDD
        #   IIII IIII IIII
        #   OOOO OOOO OOOO
        #   1198 7654 3210
        #   10
        #
        xbee_ddo_cfg.add_parameter('IC', 0x800)

        if SettingsBase.get_setting(self, "humidity_present"):
            # Get gateway module_id, universal to all nodes on the network:
            gw_dd = self.__xbee_manager.xbee_device_ddo_get_param(
                        None, 'DD', use_cache=True)
            module_id, product_id = parse_dd(gw_dd)
            # Re-program DD value to set sensor type to /L/T/H:
            device_dd = format_dd(module_id, PROD_DIGI_XB_SENSOR_LTH)
            xbee_ddo_cfg.add_parameter('DD', device_dd)

        # Configure the IO Sample Rate:
        # Clip sample_rate_ms to the max value of IR:
        sample_rate_ms = SettingsBase.get_setting(self, "sample_rate_ms")
        sample_rate_ms = min(sample_rate_ms, 0xffff)
        xbee_ddo_cfg.add_parameter('IR', sample_rate_ms)

        # 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, MOD_XB_S2C_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)
        else:
#.........这里部分代码省略.........
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:103,代码来源:digi_temp.py

示例3: initialize_xbee_serial

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    def initialize_xbee_serial(self, xbee_ddo_cfg=None):
        """\
        Creates a DDO command sequence of the user selected serial settings.

        .. Note::
            * This routine does everything EXCEPT calling for final configuration
            * It will add its own ddo config block
            * The caller can add another after the return

        For example::
            XBeeSerial.initialize_xbee_serial(self)
            my_ddo_cfg = XBeeConfigBlockDDO(self._extended_address)
            my_ddo_cfg.add_parameter('IR', 60000)
            self._xbee_manager.xbee_device_config_block_add(self, my_ddo_cfg)
            self._xbee_manager.xbee_device_configure(self)

        Returns True if successful, False on failure.
        """
        
        extended_address = SettingsBase.get_setting(self, "extended_address")

        self._tracer.calls("XBeeSerial.initialize_xbee_serial()")

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:

        self._xbee_manager.register_serial_listener(self,
                        self._extended_address, self.__read_callback)

        # callback for cb_set(self.__running_indication) is in xbee_base()

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

        # Set up the baud rate for the device.
        try:
            baud = SettingsBase.get_setting(self, "baudrate")
        except:
            baud = self.DEF_BAUDRATE
        baud = self.__derive_baudrate(baud)
        xbee_ddo_cfg.add_parameter('BD', baud)

        # Set up the parity for the device.
        try:
            parity = SettingsBase.get_setting(self, "parity")
        except:
            parity = self.DEF_PARITY
        parity = self.__derive_parity(parity)
        xbee_ddo_cfg.add_parameter('NB', parity)

        if self._xbee_manager.is_zigbee():
            # Set up the stop bits for the device.
            try:
                stopbits = SettingsBase.get_setting(self, "stopbits")
            except:
                stopbits = self.DEF_STOPBITS
            stopbits = self.__derive_stopbits(stopbits)
            # The SB command is new.
            # It may or may not be supported on the XBee Serial Device/Adapter.
            # If its not supported, then we know the device
            # is simply at 1 stop bit, and we can ignore the failure.
            xbee_ddo_cfg.add_parameter('SB', stopbits,
                                       failure_callback=self.__ignore_if_fail)
        # else skip it for 802.15.4 or DigiMesh

        # Set up the hardware flow control mode for the device.
        
        try:
            hwflow = SettingsBase.get_setting(self, "hardwareflowcontrol")
        except:
            hwflow = self.DEF_HWFLOW
        d6, d7 = self.__derive_hardwareflowcontrol(hwflow)
        xbee_ddo_cfg.add_parameter('D6', d6)
        #xbee_ddo_cfg.add_parameter('D7', d7)
        xbee_ddo_cfg.add_parameter('D7', 7)
        self._xbee_manager.xbee_device_config_block_add(self, xbee_ddo_cfg)
        
        
        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_ZB1,
                                                     MOD_XB_S2C_ZB1,))
            xbee_ddo_wh_block.add_parameter('WH', sample_predelay)
            self._xbee_manager.xbee_device_config_block_add(self,
                                    xbee_ddo_wh_block)


        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:
#.........这里部分代码省略.........
开发者ID:Lewiswight,项目名称:MistAway-Gateway,代码行数:103,代码来源:xbee_serialMCOGEN.py

示例4: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    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 for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        xbdm_rx_event_spec = XBeeDeviceManagerRxEventSpec()
        xbdm_rx_event_spec.cb_set(self.sample_indication)
        xbdm_rx_event_spec.match_spec_set(
            (extended_address, 0xe8, 0xc105, 0x92),
            (True, True, True, True))
        self.__xbee_manager.xbee_device_event_spec_add(self,
                                xbdm_rx_event_spec)

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

        # Get the gateway's extended address:
        gw_xbee_sh, gw_xbee_sl = gw_extended_address_tuple()

        # Set the destination for I/O samples to be the gateway:
        xbee_ddo_cfg.add_parameter('DH', gw_xbee_sh)
        xbee_ddo_cfg.add_parameter('DL', gw_xbee_sl)

        # Configure pins DI1 & DI2 & DI0 for analog input:

        
        xbee_ddo_cfg.add_parameter('D0', 1) 
        

        for io_pin in ['D3', 'D4', 'D6', 'D7' ]:
            xbee_ddo_cfg.add_parameter(io_pin, 4)

    
        
        # Configure the IO Sample Rate:
        sample_rate = SettingsBase.get_setting(self, "sample_rate_ms")
        xbee_ddo_cfg.add_parameter('IR', sample_rate)
        
        # Handle subscribing the devices output to a named channel,
        # if configured to do so:
 #       power_on_source1 = SettingsBase.get_setting(self, 'power_on_source1')
  #      if power_on_source1 is not None:
   #         cm = self.__core.get_service("channel_manager")
    #        cp = cm.channel_publisher_get()
     #       self.property_set("adder_reg2", Sample(0, float(power_on_source1)))
      #      cp.subscribe(power_on_source1, self.update_power_state1)
            
        
            
 #       power_on_source2 = SettingsBase.get_setting(self, 'power_on_source2')
 #       if power_on_source2 is not None:
 #W           cm = self.__core.get_service("channel_manager")
  #          cp = cm.channel_publisher_get()
  #          cp.subscribe(power_on_source2, self.update_power_state2)
            
 #       power_on_source3 = SettingsBase.get_setting(self, 'power_on_source3')
 #       if power_on_source3 is not None:
 #           cm = self.__core.get_service("channel_manager")
 #           cp = cm.channel_publisher_get()
 #           cp.subscribe(power_on_source3, self.update_power_state3)
            


        

        # 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)
#.........这里部分代码省略.........
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:103,代码来源:gate.py

示例5: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]

#.........这里部分代码省略.........
                    )

                # If set, subscribe to the channel that drives our output logic:
                source = SettingsBase.get_setting(self, 'channel%d_source' 
                                                  % (io_pin+1))
                print
                print "here is the place that really matters when it comes to the source"
                print source 
                
                if len(source):
                    cp.subscribe(source, 
                                 lambda chan, io=io_pin: self.update(chan, io) )

                # Set initial value of output to low:
                # TODO: add a default output condition here:
                xbee_ddo_cfg.add_parameter(CONTROL_LINES[io_pin][OUT], 4)

        # if adapter is using internal batteries, then configure battery-monitor
        # pin and add low_battery channel
        if SettingsBase.get_setting(self, "enable_low_battery"):
            # configure battery-monitor pin DIO11/P1 for digital input
            xbee_ddo_cfg.add_parameter('P1', 3)
            # add low_battery channel
            print ("XBeeDIO(%s): adapter is using internal batteries adding " \
                + "low_battery channel") % self.__name
            self.add_property(
                ChannelSourceDeviceProperty(name="low_battery", type=bool,
                    initial=Sample(timestamp=0, value=False),
                    perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP))
        else:
            print "XBeeDIO(%s): adapter is not using internal batteries." \
                % self.__name

        # Enable I/O line monitoring on pins DIO0 .. DIO3 &
        # enable change detection on DIO11:
        #
        # 0x   8    0    0
        #   1000 0000 0000 (b)
        #   DDDD DDDD DDDD
        #   IIII IIII IIII
        #   OOOO OOOO OOOO
        #   1198 7654 3210
        #   10
        #
        #ic |= 0x800
        #xbee_ddo_cfg.add_parameter('IC', ic)

        # disable the triggered low-battery alarm since a hardware bug
        # causes it to be unrealiable
        #ic |= 0x800
        xbee_ddo_cfg.add_parameter('IC', ic)

        # Assert input pull-ups
        xbee_ddo_cfg.add_parameter('PR', 0x1fff)

        # this defaults to 0
        xbee_ddo_cfg.add_parameter('IR', SettingsBase.get_setting(self, 'sample_rate_ms'))

        # Enable/disable power output on terminal 6:
        power = SettingsBase.get_setting(self, "power")
        if power:
            xbee_ddo_cfg.add_parameter('p3', 5)
        else:
            xbee_ddo_cfg.add_parameter('p3', 4)

        # 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)
        # The original sample rate is used as the sleep rate:
        sleep_time_ms = SettingsBase.get_setting(self, "sleep_time_ms")
        xbee_sleep_cfg = XBeeConfigBlockSleep(self.__extended_address)
        if will_sleep:
            xbee_sleep_cfg.sleep_cycle_set(awake_time_ms, sleep_time_ms)
        else:
            xbee_sleep_cfg.sleep_mode_set(SM_DISABLED)
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)

        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(self.__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)

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

        
        
        
        
        
        return True 
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:104,代码来源:xbee_dio.py

示例6: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    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")

        # Retrieve the flag which tells us if we should sleep:

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        xbdm_rx_event_spec = XBeeDeviceManagerRxEventSpec()
        xbdm_rx_event_spec.cb_set(self.sample_indication)
        xbdm_rx_event_spec.match_spec_set(
            (extended_address, 0xe8, 0xc105, 0x92),
            (True, True, True, True))
        self.__xbee_manager.xbee_device_event_spec_add(self,
                                xbdm_rx_event_spec)

        # 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)

        # Get the gateway's extended address:
        gw_xbee_sh, gw_xbee_sl = gw_extended_address_tuple()

        # Set the destination for I/O samples to be the gateway:
        xbee_ddo_cfg.add_parameter('DH', gw_xbee_sh)
        xbee_ddo_cfg.add_parameter('DL', gw_xbee_sl)

        # Configure pins DI1 .. DI3 for analog input:
        for io_pin in [ 'D1', 'D2', 'D3' ]:
            xbee_ddo_cfg.add_parameter(io_pin, 2)

        # Configure battery-monitor pin DIO11/P1 for digital input:
        xbee_ddo_cfg.add_parameter('D2', 3)
        # Enable change detection on DIO11:
        #
        # 0x   8    0    0
        #   1000 0000 0000 (b)
        #   DDDD DDDD DDDD
        #   IIII IIII IIII
        #   OOOO OOOO OOOO
        #   1198 7654 3210
        #   10
        #
        xbee_ddo_cfg.add_parameter('IC', 0x800)

        
            
        

        # Configure the IO Sample Rate:
        # Clip sample_rate_ms to the max value of IR:
        sample_rate_ms = SettingsBase.get_setting(self, "sample_rate_ms")
        sample_rate_ms = min(sample_rate_ms, 0xffff)
        xbee_ddo_cfg.add_parameter('IR', sample_rate_ms)

        # 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)

        # Handle subscribing the devices output to a named channel,
#.........这里部分代码省略.........
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:103,代码来源:temp_motion.py

示例7: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]
    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 for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        xbdm_rx_event_spec = XBeeDeviceManagerRxEventSpec()
        xbdm_rx_event_spec.cb_set(self._sample_indication)
        xbdm_rx_event_spec.match_spec_set(
            (extended_address, 0xe8, 0xc105, 0x92),
            (True, True, True, True))
        self.__xbee_manager.xbee_device_event_spec_add(self,
                                xbdm_rx_event_spec)

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

        # Get the gateway's extended address:
        gw_xbee_sh, gw_xbee_sl = gw_extended_address_tuple()

        # Set the destination for I/O samples to be the gateway:
        xbee_ddo_cfg.add_parameter('DH', gw_xbee_sh)
        xbee_ddo_cfg.add_parameter('DL', gw_xbee_sl)
        
        #""" IF YOUR XBEE DEVICE DON'N SLEEP AND YOU SEND DATA FROM XBEE DEVICE TO ConnectPort X manually then uncoment the start of that line.
        # Configure the IO Sample Rate:
        # Clip sample_rate_ms to the max value of IR:
        sample_rate_ms = SettingsBase.get_setting(self, "sample_rate_ms")
        sample_rate_ms = min(sample_rate_ms, 0xffff)
        xbee_ddo_cfg.add_parameter('IR', sample_rate_ms)

        # 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, MOD_XB_S2C_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)
        else:
            xbee_sleep_cfg.sleep_mode_set(SM_DISABLED)
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_sleep_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
开发者ID:nikolaijivkov,项目名称:MS_HV_Presentation__iDigi_Dia,代码行数:78,代码来源:demo_driver.py

示例8: start

# 需要导入模块: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo import XBeeConfigBlockDDO [as 别名]
# 或者: from devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO import apply_only_to_modules [as 别名]

#.........这里部分代码省略.........
                xbee_ddo_cfg.add_parameter(
                    AIO_CONTROL_LINES[io_pin][AIO_LINE_B], 5)
                xbee_ddo_cfg.add_parameter(
                    AIO_CONTROL_LINES[io_pin+1][AIO_LINE_A], 4)
            # else: for OFF, do nothing

            # TODO: in the future when we support changing the settings
            #       for this adapter on the fly we would need to do:
            #if previous_mode == Differential and new_mode != Differential:
            #    xbee_ddo_cfg.add_paramseter(
            #        (AIO_CONTROL_LINES[io_pin+1][AIO_LINE_A], 5))
            #    # TODO: Set setting for io_pin+1 to TenV Mode

        # if adapter is using internal batteries, then configure battery-monitor
        # pin and add low_battery channel
        if SettingsBase.get_setting(self, "enable_low_battery"):
            # configure battery-monitor pin DIO11/P1 for digital input
            xbee_ddo_cfg.add_parameter('P1', 3)
            # add low_battery channel
            self.__tracer.info("adapter is using internal batteries... " +
                               "adding low battery channel")
            self.add_property(
                ChannelSourceDeviceProperty(name="low_battery", type=bool,
                    initial=Sample(timestamp=0, value=False),
                    perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP))
        else:
            self.__tracer.info("adapter is not using internal batteries.")
        
        
        # disable the triggered low-battery alarm since it causes problems
        # we see the value every time new values are sent anyway
        
        ic = 0
        xbee_ddo_cfg.add_parameter('IC', ic)
        
        # Assert input pull-ups
        xbee_ddo_cfg.add_parameter('PR', 0x1fff)

        # Is the unit meant to sleep or not?
        will_sleep = SettingsBase.get_setting(self, "sleep")

        # Configure the IO Sample Rate.
        #
        # This gets a little trickier in cases where the unit is NOT
        # in sleep mode, yet the sampling rate is over a minute.
        #
        # (The max value for IR is 64K and is in milliseconds.
        # This ends up being a tad over a minute.
        #
        # So if we are NOT in sleep mode, and our sample rate
        # is over 1 minute, 5 seconds (64K), we will set IR to 0,
        # and set up Dia (in the make_request call), to call us back
        # when our poll rate is about to trigger.

        sample_rate_ms = SettingsBase.get_setting(self, "sample_rate_ms")

        if will_sleep or (not will_sleep and sample_rate_ms <= 0xffff):
            # Clip sample_rate_ms to the max value of IR:
            sample_rate_ms = min(sample_rate_ms, 0xffff)
            xbee_ddo_cfg.add_parameter('IR', sample_rate_ms)
        else:
            xbee_ddo_cfg.add_parameter('IR', 0)

        # Enable/disable power output on terminal 6:
        power = SettingsBase.get_setting(self, "power")
        if power:
            xbee_ddo_cfg.add_parameter('p3', 5)
        else:
            xbee_ddo_cfg.add_parameter('p3', 4)
            
        # 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)
        # 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)
        else:
            xbee_sleep_cfg.sleep_mode_set(SM_DISABLED)
        self.__xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)

        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, MOD_XB_S2C_ZB,))
            xbee_ddo_wh_block.add_parameter('WH', sample_predelay)
            self.__xbee_manager.xbee_device_config_block_add(self,
                                    xbee_ddo_wh_block)

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

        return True
开发者ID:nikolaijivkov,项目名称:Cndep_Rest_Service__iDigi_Dia,代码行数:104,代码来源:xbee_aio.py


注:本文中的devices.xbee.xbee_config_blocks.xbee_config_block_ddo.XBeeConfigBlockDDO.apply_only_to_modules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。