本文整理汇总了Python中devices.xbee.xbee_devices.xbee_base.XBeeBase.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python XBeeBase.__init__方法的具体用法?Python XBeeBase.__init__怎么用?Python XBeeBase.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devices.xbee.xbee_devices.xbee_base.XBeeBase
的用法示例。
在下文中一共展示了XBeeBase.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services, set_in=None, prop_in=None):
"""\
Initialize an XBee Wall Router instance.
Parameters:
* name - The name of the XBee Wall Router instance.
* core - The Core services instance.
* set_in - settings from a derived class
* prop_in - properties from a derived class
"""
# DeviceBase will create:
# self._name, self._core, self._tracer,
# XBeeBase will create:
# self._xbee_manager, self._extended_address
## XBeeBase manages these settings:
# xbee_device_manager: the name of an XBeeDeviceManager instance.
# extended_address: the extended address of the XBee device you
# would like to monitor.
#
## This driver maintains
# sample_rate_ms: the sample rate in msec of the XBee Wall Router.
# offset: a raw offset to add/subtract from resulting temperature
# degf: T/F if degress Fahrenheit is desired instead of Celsius
settings_list = [
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=self.DEF_SAMPLE_MS,
verify_function=lambda x: x > 0 and x < 0xffff),
Setting(
name='offset', type=float, required=False,
default_value=self.DEF_OFFSET),
Setting(
name='degf', type=bool, required=False,
default_value=self.DEF_DEGF),
]
# Add our settings_list entries into the settings passed to us.
set_in = self.merge_settings(set_in, settings_list)
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="light", type=float,
initial=Sample(timestamp=0, unit="not init", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="temperature", type=float,
initial=Sample(timestamp=0, unit="not init", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
]
# Add our property_list entries into the properties passed to us.
prop_in = self.merge_properties(prop_in, property_list)
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, name, core_services, set_in, prop_in)
self._tracer.calls("XBeeXBR.__init__()")
示例2: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services, property_list):
self.__name = name
self.__core = core_services
self.__property_list = property_list
## Local State Variables:
self.__xbee_manager = None
self.sensor = None
# Settings
#
# xbee_device_manager: must be set to the name of an XBeeDeviceManager
# instance.
# extended_address: the extended address of the XBee Watchport Sensor
# device you would like to monitor.
# sleep: True/False setting which determines if we should put the
# device to sleep between samples.
# sample_rate_ms: the sample rate of the XBee adapter.
# enable_low_battery: Force an adapter to enable support for
# battery-monitor pin.
# It should be only enabled if adapter is using
# internal batteries. Optional, Off by default.
settings_list = [
Setting(
name='sleep', type=bool, required=False,
default_value=False),
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=60000,
verify_function=lambda x: x >= 0 and x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(
name='poll_clean_minutes', type=int, required=False,
default_value=0,
verify_function=self.__verify_clean_minutes),
# This setting is provided for advanced users, it is not required:
Setting(
name='awake_time_ms', type=int, required=False,
default_value=5000,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='enable_low_battery', type=Boolean, required=False,
default_value=Boolean("Off", STYLE_ONOFF)),
]
## Channel Properties Definition:
__property_list_internal = [
]
property_list.extend(__property_list_internal)
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例3: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
"""\
Initialize an XBee Wall Router instance.
Parameters:
* name - The name of the XBee Wall Router instance.
* core_services - The Core services instance.
"""
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
from core.tracing import get_tracer
self.__tracer = get_tracer(name)
# Settings:
#
# xbee_device_manager: must be set to the name of an XBeeDeviceManager
# instance.
# extended_address: is the extended address of the XBee device you
# would like to monitor.
# sample_rate_ms: is the sample rate of the XBee Wall Router.
settings_list = [
Setting(
name = 'xbee_device_manager', type = str, required = False,
default_value = ''),
Setting(
name = 'extended_address', type = str, required = False,
default_value = ''),
Setting(
name = 'sample_rate_ms', type = int, required = False,
default_value = 1000,
verify_function = lambda x: x > 0 and x < 0xffff),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name = "light", type = float,
initial = Sample(timestamp = 0, unit = "brightness", value = 0.0),
perms_mask = DPROP_PERM_GET, options = DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name = "temperature", type = float,
initial = Sample(timestamp = 0, unit = "C", value = 0.0),
perms_mask = DPROP_PERM_GET, options = DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例4: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
self.include_unit = "F"
self.count = 0
self.upCount = 11
## Local State Variables:
self.__xbee_manager = None
## Settings Table Definition:
settings_list = [
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=60000,
verify_function=lambda x: x > 0 and x < 0xffff),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="last_com", type=str,
initial=Sample(timestamp=1, unit="", value=""),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
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="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="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="light", type=float,
initial=Sample(timestamp=0, unit="brightness", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="temperature", type=float,
initial=Sample(timestamp=0, unit="F", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例5: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
self.offset = 520.0
self.__power_on_time = 0
## Settings Table Definition:
settings_list = [
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=1000,
verify_function=lambda x: x > 0 and x < 0xffff),
Setting(
name='default_state', type=str, required=False,
default_value="on",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='idle_off_seconds', type=int, required=False,
default_value=0, verify_function=lambda x: x >= 0),
Setting(name="power_on_source", type=str, required=False),
Setting(name="pf_adjustment", type=float, required=False,
default_value=1.0,
verify_function=lambda i:0 < i and i <= 1.0),
Setting(name="device_profile", type=str, required=False),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="light", type=float,
initial=Sample(timestamp=0, unit="brightness", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="temperature", type=float,
initial=Sample(timestamp=0, unit="C", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="current", type=float,
initial=Sample(timestamp=0, unit="A", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="power_on", 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=self.prop_set_power_control),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例6: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services, set_in=None, prop_in=None):
# DeviceBase will create:
# self._name, self._core, self._tracer,
# XBeeBase will create:
# self._xbee_manager, self._extended_address
## Local State Variables:
## Settings Table Definition:
settings_list = [
Setting(
name='baudrate', type=int, required=False,
default_value=self.DEF_BAUDRATE,
verify_function=self.__verify_baudrate),
Setting(
name='parity', type=str, required=False,
default_value=self.DEF_PARITY,
verify_function=self.__verify_parity),
# NOTE: SB/Stop-bits is not available in all XBEE
Setting(
name='stopbits', type=int, required=False,
default_value=self.DEF_STOPBITS,
verify_function=self.__verify_stopbits),
Setting(
name='hardwareflowcontrol', type=str, required=False,
default_value=self.DEF_HWFLOW,
verify_function=self.__verify_hwflow),
# These setting is for legacy compatibility & ignored.
# Having it here is not appropriate given this driver is commonly
# used with third party XBee products.
Setting(
name='enable_low_battery', type=Boolean, required=False,
default_value=False),
]
# Add our settings_list entries into the settings passed to us.
set_in = self.merge_settings(set_in, settings_list)
## Channel Properties Definition:
# property_list = []
# Add our property_list entries into the properties passed to us.
# prop_in = self.merge_properties(prop_in, property_list)
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, name, core_services, set_in, prop_in)
self._tracer.calls("XBeeSerial.__init__()")
示例7: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
## Settings Table Definition:
settings_list = [
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=10000,
verify_function=lambda x: x > 0 and x < 0xffff),
Setting(
name='idle_off_seconds', type=int, required=False,
default_value=0, verify_function=lambda x: x >= 0),
Setting(name='input_source', type=str, required=False, default_value=None),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="adder_reg1", type=float,
initial=Sample(timestamp=0, value=0.0),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda x: self.prop_set_adder("adder_reg1", x)),
ChannelSourceDeviceProperty(name="power_on", 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=self.prop_set_power_control1),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例8: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
self.__xbee_manager = None
from core.tracing import get_tracer
self.__tracer = get_tracer(name)
# Settings:
#
# xbee_device_manager: must be set to the name of an XBeeDeviceManager
# instance.
# extended_address: is the extended address of the XBee device you
# would like to monitor.
# sample_rate_ms: is the sample rate of the XBee device.
settings_list = [
Setting(
name='xbee_device_manager', type=str, required=False,
default_value=''),
Setting(
name='extended_address', type=str, required=False,
default_value=''),
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=2000,
verify_function=lambda x: x > 0 and x < 0xffff),
Setting(
name='channel_settings', type=str, required=False,
default_value="name,unit"),
]
## Channel Properties Definition:
property_list = []
## Initialize the DeviceBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例9: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
## Settings Table Definition:
settings_list = [
Setting(
name='sleep', type=bool, required=False,
default_value=True),
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=400,
verify_function=lambda x: x >= 0 and x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(
name='awake_time_ms', type=int, required=False,
default_value=5000,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='sample_predelay', type=int, required=False,
default_value=125,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='default_state1', type=str, required=False,
default_value="same",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='default_state2', type=str, required=False,
default_value="off",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='default_state3', type=str, required=False,
default_value="off",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='idle_off_seconds', type=int, required=False,
default_value=0, verify_function=lambda x: x >= 0),
Setting(name='power_on_source1', type=str, required=False),
Setting(name='power_on_source2', type=str, required=False),
Setting(name='power_on_source3', type=str, required=False),
Setting(name='device_profile', type=str, required=False),
Setting(name='input_source', type=str, required=False, default_value=None),
]
## Channel Properties Definition:
property_list = [
# gettable properties
# ChannelSourceDeviceProperty(name="input", type=tuple,
# initial=Sample(timestamp=0, value=(0,None)),
# perms_mask=DPROP_PERM_SET | DPROP_PERM_GET,
# set_cb=self.prop_set_power_control1),
ChannelSourceDeviceProperty(name="activate", 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=self.unlock),
ChannelSourceDeviceProperty(name="aa", type=str,
initial=Sample(timestamp=0, value="lock"),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET), options=DPROP_OPT_AUTOTIMESTAMP),
# settable properties
# ChannelSourceDeviceProperty(name="counter_reset", type=int,
# perms_mask=DPROP_PERM_SET,
# set_cb=self.prop_set_counter_reset),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例10: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
self.trace = True
settings_list = [
Setting(
name='sleep', type=Boolean, required=False,
default_value=Boolean(False)),
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=0,
verify_function=lambda x: x >= 0 and x <= 60000),
Setting(
name='sleep_time_ms', type=int, required=False,
default_value=60000,
verify_function=lambda x: x >= 0 and \
x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(
name='power', type=Boolean, required=True,
default_value=Boolean("On", STYLE_ONOFF)),
Setting(
name='channel1_dir', type=str, required=True),
Setting(
name='channel1_source', type=str, required=False,
default_value=''),
Setting(
name='channel2_dir', type=str, required=True),
Setting(
name='channel2_source', type=str, required=False,
default_value=''),
Setting(
name='channel3_dir', type=str, required=True),
Setting(
name='channel3_source', type=str, required=False,
default_value=''),
Setting(
name='channel4_dir', type=str, required=True),
Setting(
name='channel4_source', type=str, required=False,
default_value=''),
# This setting is provided for advanced users, it is not required:
Setting(
name='awake_time_ms', type=int, required=False,
default_value=5000,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='sample_predelay', type=int, required=False,
default_value=1000,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='enable_low_battery', type=Boolean, required=False,
default_value=Boolean("Off", STYLE_ONOFF)),
]
## Channel Properties Definition:
# This device hardware can monitor the state of its output
# pins. Therefore, there are always four input channels.
# The other properties and channels will be populated when we
# know the directions of our IO ports.
property_list = [
ChannelSourceDeviceProperty(
name='channel1_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='1'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel2_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='1'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel3_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='s1'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel4_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='s2'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例11: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
self.__tracer = get_tracer(name)
## Local State Variables:
self.__xbee_manager = None
self.offset = 520.0
self.__power_on_time = 0
# Settings
#
# xbee_device_manager: must be set to the name of an
# XBeeDeviceManager instance.
# extended_address: the extended address of the XBee device you
# would like to monitor.
# sample_rate_ms: the sample rate of the XBee SmartPlug.
# default_state: "On"/"Off"/"Same", if "On" the plug will default to
# being switched on.
# idle_off_seconds: Number of seconds to go by before forcing
# power off.
# If not set the value defauts to 0, which means
# the device never idles out.
# power_on_source: optional setting; string name of a Boolean
# "device.channel" to be used as the state. For
# example, if set to the name of a channel which
# changes value from False to True, the SmartPlug
# would change from being off to on.
# pf_adjustment: optional setting; floating point value between
# 0 and 1, that is used to adjust the current
# output given a known power factor.
# defaults to 1 (i.e no adjustment)
# Note: The unit cannot determine the pf,
# it is strictly a user supplied value.
# device_profile: optional setting; string value corresponding
# to a preset pf_adjustment value.
# These values are by not intended to be precise;
# they are only estimates.
# For a list of valid device_profile settings see the
# check_profiles() function in the driver source.
settings_list = [
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=self.DEF_SAMPLE_MS,
verify_function=lambda x: x > 0 and x < 0xffff),
Setting(
name='default_state', type=str, required=False,
default_value=self.DEF_STATE,
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='idle_off_seconds', type=int, required=False,
default_value=self.DEF_IDLE_OFF,
verify_function=lambda x: x >= 0),
Setting(name="power_on_source", type=str, required=False),
Setting(name="pf_adjustment", type=float, required=False,
default_value=self.DEF_PF,
verify_function=lambda i:0 < i and i <= 1.0),
Setting(name="device_profile", type=str, required=False),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="light", type=float,
initial=Sample(timestamp=0, unit="brightness", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="temperature", type=float,
initial=Sample(timestamp=0, unit="C", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="current", type=float,
initial=Sample(timestamp=0, unit="A", value=0.0),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="power_on", type=str,
initial=Sample(timestamp=0,
value=str(Boolean(True, style=STYLE_ONOFF))),
perms_mask=(DPROP_PERM_GET | DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=self.prop_set_power_control),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例12: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
## Settings Table Definition:
settings_list = [
Setting(
name='sleep', type=bool, required=False,
default_value=True),
Setting(
name='sample_rate_ms', type=int, required=True,
default_value=60000,
verify_function=lambda x: x >= 0 and x <= CYCLIC_SLEEP_EXT_MAX_MS),
# These settings are provided for advanced users, they
# are not required:
Setting(
name='default_state', type=str, required=False,
default_value="off",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(name="power_on_source", type=str, required=False),
Setting(
name='trace', type=Boolean, required=False,
default_value=Boolean("On", STYLE_ONOFF)),
Setting(
name='awake_time_ms', type=int, required=False,
default_value=1000,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='sample_predelay', type=int, required=False,
default_value=125,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='humidity_present', type=bool, required=False,
default_value=False),
Setting(
name='count_init', type=int, required=False, default_value=0,
verify_function=lambda x: x >= 0),
Setting(
name='update_rate', type=float, required=False, default_value=1.0,
verify_function=lambda x: x > 0.0),
Setting(
name='temp', type=float, required=False, default_value=1.0),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="aa", type=str,
initial=Sample(timestamp=0, value="temp_motion"),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET), options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="motion", type=float,
initial=Sample(timestamp=0, value=0.0, unit="F"),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="temperature", type=float,
initial=Sample(timestamp=0, value=0.0, unit="F"),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="low_battery", type=Boolean,
initial=Sample(timestamp=0, value=Boolean(False, style=STYLE_ONOFF)),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="motion_event", type=Boolean,
initial=Sample(timestamp=0, value=Boolean(False, style=STYLE_ONOFF)),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="power_on", 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=self.prop_set_power_control),
]
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例13: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
self.__event_timer = None
## Local State Variables:
self.__xbee_manager = None
self.update_timer = None
## Settings Table Definition:
settings_list = [
Setting(
name='sleep', type=bool, required=False,
default_value=True),
Setting(
name='sample_rate_sec', type=int, required=False,
default_value=30,
verify_function=lambda x: x >= 10 and x < 0xffff),
Setting(
name='sample_rate_ms', type=int, required=False,
default_value=5000,
verify_function=lambda x: x >= 0 and x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(
name='awake_time_ms', type=int, required=False,
default_value=50,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='sample_predelay', type=int, required=False,
default_value=50,
verify_function=lambda x: x >= 0 and x <= 0xffff),
Setting(
name='default_state1', type=str, required=False,
default_value="same",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='default_state2', type=str, required=False,
default_value="off",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='default_state3', type=str, required=False,
default_value="off",
parser=lambda s: s.lower(),
verify_function=lambda s: s in initial_states),
Setting(
name='idle_off_seconds', type=int, required=False,
default_value=0, verify_function=lambda x: x >= 0),
Setting(name='input_source', type=str, required=False, default_value=None),
]
## Channel Properties Definition:
property_list = [
# gettable properties
# ChannelSourceDeviceProperty(name="input", type=tuple,
# initial=Sample(timestamp=0, value=(0,None)),
# perms_mask=DPROP_PERM_SET | DPROP_PERM_GET,
# set_cb=self.prop_set_power_control1),
ChannelSourceDeviceProperty(name="open_close", 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=self.open),
ChannelSourceDeviceProperty(name="auto", 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=self.auto),
ChannelSourceDeviceProperty(name="aa", type=str,
initial=Sample(timestamp=0, value="vent"),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET), options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="zone_temperature", type=str,
initial=Sample(timestamp=0, value=""),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda x: self.prop_set_adder("zone_temperature", x)),
ChannelSourceDeviceProperty(name="driving_thermostat", type=str,
initial=Sample(timestamp=0, value="thermostat.on_for_ac_off_for_heat_status"),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda x: self.prop_set_adder("driving_thermostat", x)),
ChannelSourceDeviceProperty(name="battery", type=int,
initial=Sample(timestamp=0, unit="V", value=0),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="driving_temp", type=float,
initial=Sample(timestamp=0, value=0.0),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda x: self.prop_set_adder("desired_temp", x)),
ChannelSourceDeviceProperty(name="desired_temp", type=float,
initial=Sample(timestamp=0, value=0.0),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda x: self.prop_set_adder("desired_temp", x)),
ChannelSourceDeviceProperty(name="thermostat_mode", type=str,
initial=Sample(timestamp=0, unit="N/A", value="Off"),
perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
def __init__(self, name, core_services, set_in=None, prop_in=None):
"""\
Initialize an XBee Wall Router instance.
Parameters:
* name - The name of the XBee Wall Router instance.
* core - The Core services instance.
* set_in - settings from a derived class
* prop_in - properties from a derived class
"""
# DeviceBase will create:
# self._name, self._core, self._tracer,
# XBeeBase will create:
# self._xbee_manager, self._extended_address
## Settings Table Definition:
settings_list = [
Setting(
name='sleep_ms', type=int, required=False,
default_value=self.DEF_SLEEP_MS,
verify_function=lambda x: x >= 0 and \
x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(name="led1_source", type=str, required=False),
Setting(name="led2_source", type=str, required=False),
Setting(name="led3_source", type=str, required=False),
# This setting is provided for advanced users:
Setting(
name='awake_time_ms', type=int, required=False,
default_value=self.DEF_AWAKE_MS,
verify_function=lambda x: x >= 0 and x <= 0xffff),
]
# Add our settings_list entries into the settings passed to us.
set_in = self.merge_settings(set_in, settings_list)
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="sw1", type=bool,
initial=Sample(timestamp=0, value=False),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="sw2", type=bool,
initial=Sample(timestamp=0, value=False),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="sw3", type=bool,
initial=Sample(timestamp=0, value=False),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="sw4", type=bool,
initial=Sample(timestamp=0, value=False),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
# gettable and settable properties
ChannelSourceDeviceProperty(name="led1", 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 sample: self.prop_set_led("led1", sample)),
ChannelSourceDeviceProperty(name="led2", 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 sample: self.prop_set_led("led2", sample)),
ChannelSourceDeviceProperty(name="led3", 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 sample: self.prop_set_led("led3", sample)),
]
# Add our property_list entries into the properties passed to us.
prop_in = self.merge_properties(prop_in, property_list)
## Initialize the XBeeBase interface:
XBeeBase.__init__(self, name, core_services, set_in, prop_in)
self._tracer.calls("XBeeXBIB.__init__()")
示例15: __init__
# 需要导入模块: from devices.xbee.xbee_devices.xbee_base import XBeeBase [as 别名]
# 或者: from devices.xbee.xbee_devices.xbee_base.XBeeBase import __init__ [as 别名]
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
# xbee_device_manager: must be set to the name of an XBeeDeviceManager
# instance.
# sample_rate_ms: the sample rate of the XBee adapter.
# channel1_dir: Operating I/O mode for pin 1 of the adapter.
# Must be a string value comprised of one of the following:
# "In" - pin is configured to be an input.
# "Out" - pin is configured to be an output.
# channel2_dir: Operating I/O mode for pin 2 of the adapter.
# See channel2_dir for valid setting information.
# channel3_dir: Operating I/O mode for pin 3 of the adapter.
# See channel3_dir for valid setting information.
# channel4_dir: Operating I/O mode for pin 4 of the adapter.
# See channel4_dir for valid setting information.
# channel1_source: If channel1_dir is configed as an output, this
# option setting may be specified to a
# "device.channel" channel name. The Boolean value
# of this channel will specify to logic state for
# pin 1 on the adapter.
# channel2_source: Configures output value source channel for pin 2
# of the adapter.
# See channel1_source setting information.
# channel3_source: Configures output value source channel for pin 3
# of the adapter.
# See channel1_source setting information.
# channel4_source: Configures output value source channel for pin 4
# of the adapter.
# See channel1_source setting information.
settings_list = [
Setting(
name='extended_address', type=str, required=False,
default_value=''),
Setting(
name='sample_rate_ms', type=int, required=True,
default_value=60000,
verify_function=lambda x: x >= 0 and x <= CYCLIC_SLEEP_EXT_MAX_MS),
Setting(
name='channel1_dir', type=str, required=True),
Setting(
name='channel1_source', type=str, required=False,
default_value=''),
Setting(
name='channel2_dir', type=str, required=True),
Setting(
name='channel2_source', type=str, required=False,
default_value=''),
Setting(
name='channel3_dir', type=str, required=True),
Setting(
name='channel3_source', type=str, required=False,
default_value=''),
Setting(
name='channel4_dir', type=str, required=True),
Setting(
name='channel4_source', type=str, required=False,
default_value=''),
]
## Channel Properties Definition:
property_list = [
ChannelSourceDeviceProperty(
name='channel1_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='bool'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel2_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='bool'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel3_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='bool'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(
name='channel4_input', type=bool,
initial=Sample(timestamp=0, value=False, unit='bool'),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
]
self.DIO_CONTROL_LINES = [ "d0", "d1", "d2", "d3" ]
self.INPUT_CHANNEL_TO_PIN = [ 0, 1, 2, 3 ]
self.DIO_MODE_INPUT = 3
self.DIO_MODE_OUTPUT_HIGH = 3
self.DIO_MODE_OUTPUT_LOW = 4
## Initialize the XBeeBase interface:
#.........这里部分代码省略.........