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


Python XBeeBase.pre_start方法代码示例

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


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

示例1: start

# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import pre_start [as 别名]
    def start(self):

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

        # init self._xbee_manager and self._extended_address
        # then register ourself with our Xbee manager
        XBeeBase.pre_start(self)

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        self._xbee_manager.register_sample_listener(self, self._extended_address,
                                                     self.sample_indication)

        # Configure node sleep behavior:
        sleep_ms = SettingsBase.get_setting(self, "sleep_ms")
        awake_time_ms = SettingsBase.get_setting(self, "awake_time_ms")
        # The original sample rate is used as the sleep rate:

        xbee_sleep_cfg = self._xbee_manager.get_sleep_block(
            self._extended_address,
            sleep=sleep_ms > 0,
            sleep_rate_ms=sleep_ms,
            awake_time_ms=awake_time_ms)

        self._xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)

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

        # Configure pins DIO0 .. DIO3 for digital input:
        for io_pin in ['D0', 'D1', 'D2', 'D3']:
            xbee_ddo_cfg.add_parameter(io_pin, 3)

        # Turn off LEDs:
        for led in LED_IO_MAP:
            xbee_ddo_cfg.add_parameter(LED_IO_MAP[led], 0)

        # Assert that all pin pull-ups are enabled:
        xbee_ddo_cfg.add_parameter('PR', 0x1fff)

        # Enable I/O line monitoring on pins DIO0 .. DIO3:
        xbee_ddo_cfg.add_parameter('IC', 0xf)

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

        # Handle channels subscribed to output their data to our led
        # properties:
        cm = self._core.get_service("channel_manager")
        cp = cm.channel_publisher_get()
        for i in range(1, 4):
            setting_name = "led%d_source" % i
            channel_name = SettingsBase.get_setting(self, setting_name)
            if channel_name is not None:
                cp.subscribe(channel_name,
                    (lambda prop: lambda cn: self.update_property(prop, cn))(
                        "led%d" % i))

        # we've no more to config, indicate we're ready to configure.
        return XBeeBase.start(self)
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:62,代码来源:xbee_xbib.py

示例2: start

# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import pre_start [as 别名]
    def start(self):
        """Start the device driver.  Returns bool."""

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

        # 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.initialize_xbee_serial()

        # we've no more to config, indicate we're ready to configure.
        return XBeeBase.start(self)
开发者ID:Lewiswight,项目名称:4CT_Project-Gateway-master,代码行数:16,代码来源:xbee_serial.py

示例3: start

# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import pre_start [as 别名]
    def start(self):

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

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

        # Create a callback specification for our device address, endpoint
        # Digi XBee profile and sample cluster id:
        self._xbee_manager.register_sample_listener(self, self._extended_address,
                                                     self._sample_indication)

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

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

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

        # Configure the IO Sample Rate:
        sample_rate = SettingsBase.get_setting(self, "sample_rate_ms")

        # DigiMesh requires at least 'Sleep Compatibility'
        # this call will also set IR to sample_rate
        xbee_sleep_cfg = self._xbee_manager.get_sleep_block(
            self._extended_address,
            sleep=False, sleep_rate_ms=sample_rate, awake_time_ms=0)

        self._xbee_manager.xbee_device_config_block_add(self, xbee_sleep_cfg)

        # we've no more to config, indicate we're ready to configure.
        return XBeeBase.start(self)
开发者ID:Lewiswight,项目名称:4CT-GW--master,代码行数:39,代码来源:xbee_xbr.py


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