本文整理汇总了Python中devices.device_base.DeviceBase.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceBase.__init__方法的具体用法?Python DeviceBase.__init__怎么用?Python DeviceBase.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devices.device_base.DeviceBase
的用法示例。
在下文中一共展示了DeviceBase.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Settings Table Definition:
settings_list = [
Setting(
name='sample_rate_ms', type=float, required=False,
default_value=1000.0,
verify_function=lambda x: x >= 0.0),
Setting(
name='channel_settings', type=str, required=False,
default_value="name,unit"),
]
## Channel Properties Definition:
property_list = []
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core, settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例2: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services, settings, properties):
# DeviceBase will create:
# self._name, self._core, self._tracer,
self._xbee_manager = None
self._extended_address = None
## Settings Table Definition:
settings_list = [
Setting(
name='xbee_device_manager', type=str, required=True),
Setting(
name='extended_address', type=str, required=True),
]
# Add our settings_list entries into the settings passed to us.
settings = self.merge_settings(settings, settings_list)
## Channel Properties Definition:
property_list = [
]
# Add our property_list entries into the properties passed to us.
properties = self.merge_properties(properties, property_list)
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, name, core_services, settings, properties)
self._tracer.calls("XBeeBase.__init__()")
示例3: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
# Create protected dictionaries and lists
self.name_to_signal = lockDict()
self.name_to_type = lockDict()
self.signal_to_name = lockDict()
self.signal_to_units_range = lockDict()
self.reads_reqd = lockList()
self.signals_reqd = lockList()
self.units_reqd = lockList()
self.names_reqd = lockList()
self.info_timeout_scale = 1
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
from core.tracing import get_tracer
self.__tracer = get_tracer("XBeeGPIOClient")
## Settings Table Definition:
settings_list = [
Setting( name='xbee_device_manager', type=str, required=True),
Setting( name='extended_address', type=str, required=True),
Setting( name='poll_rate', type=float, required=False),
]
## Channel Properties Definition is in start() below:
property_list = []
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例4: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Settings Table Definition:
settings_list = [
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),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="counter", type=int,
initial=Sample(timestamp=0, value=0),
perms_mask=DPROP_PERM_GET|DPROP_PERM_REFRESH,
options=DPROP_OPT_AUTOTIMESTAMP,
refresh_cb = self.refresh_counter),
ChannelSourceDeviceProperty(name="adder_total", type=float,
initial=Sample(timestamp=0, value=0.0),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
# settable properties
ChannelSourceDeviceProperty(name="counter_reset", type=int,
perms_mask=DPROP_PERM_SET,
set_cb=self.prop_set_counter_reset),
ChannelSourceDeviceProperty(name="global_reset", type=int,
perms_mask=DPROP_PERM_SET,
set_cb=self.prop_set_global_reset),
# gettable & settable 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="adder_reg2", 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_reg2", x)),
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例5: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__state = STATE_PUMP_OUT_LEFT
## Settings Table Definition:
settings_list = [
Setting(name=LEFT_VOLUME_CHANNEL, type=str, required=True),
Setting(name=RIGHT_VOLUME_CHANNEL, type=str, required=True),
Setting(
name='transition_threshold', type=float, required=False,
default_value=5.0,
verify_function=lambda x: x > 0),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="left_pump_on",
type=Boolean,
initial=Sample(0, Boolean(False, STYLE_ONOFF)),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="right_pump_on",
type=Boolean,
initial=Sample(0, Boolean(False, STYLE_ONOFF)),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例6: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase 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)
settings_list = [
Setting(
name='extended_address', type=str, required=False,
default_value=''),
Setting(
name='sample_rate_ms', type=int, required=False),
Setting(
name='channel_settings', type=str, required=False,
default_value="name,unit"),
Setting(
name='encryption', type=bool, required=False,
default_value=False)
]
## Channel Properties Definition:
property_list = []
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core, settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例7: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services, settings, properties):
self.__name = name
self.__core = core_services
## Local State Variables:
self.__xbee_manager = None
## Settings Table Definition:
settings_list = [
Setting(name="xbee_device_manager", type=str, required=True),
Setting(name="extended_address", type=str, required=True),
]
# Add our settings_list entries to the settings passed to us.
#
# NOTE: If the settings passed to us contain a setting that
# is of the same name as one of ours, we will use the
# passed in setting, and throw ours away.
for our_setting in settings_list:
for setting in settings:
if our_setting.name == setting.name:
break
else:
settings.append(our_setting)
## Channel Properties Definition:
property_list = []
# Add our property_list entries to the properties passed to us.
properties.extend(property_list)
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core, settings, properties)
示例8: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Settings Table Definition:
settings_list = [
Setting(
name='update_rate', type=float, required=False, default_value=60.0,
verify_function=lambda x: x > 0.0),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="rtt", type=float,
initial=Sample(timestamp=0, value=0.0, unit="dBm"),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="evdo", type=float,
initial=Sample(timestamp=0, value=0.0, unit="dBm"),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP)
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例9: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
# DeviceBase will create:
# self._name, self._core, self._tracer,
# Settings
#
# xbee_device_manager: must be set to the name of an XBeeDeviceManager
# instance.
settings_list = [
Setting(
name='xbee_device_manager', type=str, required=True),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name="button", type=str,
initial=Sample(timestamp=0, value=''),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="cb_trigger", type=bool,
initial=Sample(timestamp=0, value=False),
perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, name, core_services,
settings_list, property_list)
示例10: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Settings Table Definition:
settings_list = [
Setting(
name='EnglishToSpanish', type=bool, required=False,
default_value=True)]
#Declare the Input and Output channels
property_list = [
ChannelSourceDeviceProperty(name="InputString", type=str,
initial=Sample(time.time(), ""),
perms_mask=DPROP_PERM_GET | DPROP_PERM_SET,
options=DPROP_OPT_AUTOTIMESTAMP,
set_cb=lambda sample: self.translate(sample=sample)),
ChannelSourceDeviceProperty(name="OutputString", type=str,
initial=Sample(time.time(), ""),
perms_mask=DPROP_PERM_GET,
options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialze the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例11: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services, extra_settings=[],
create_remote=True, create_local=True):
self.__name = name
self.__core = core_services
self.__create_remote = create_remote
self.__create_local = create_local
## Local State Variables:
self.__xbee_manager = None
from core.tracing import get_tracer
self.__tracer = get_tracer(name)
## Settings Table Definition:
settings_list = [
Setting( name='xbee_device_manager', type=str, required=True),
Setting( name='extended_address', type=str, required=True),
Setting( name='endpoint', type=int, required=True),
Setting( name='profile', type=int, required=True),
Setting( name='cluster', type=int, required=True),
Setting( name='local', type=str, required=False),
Setting( name='remote', type=str, required=False),
]
for s in extra_settings:
settings_list.append(Setting(name=s['name'], type=s['type'],
required=s['required']))
## Channel Properties Definition is in start() below:
property_list = []
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
示例12: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase 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)
self.main_addr = "mainMistaway_" + gw_extended_address()
## Local State Variables:
self.__xbee_manager = None
self.__settings_ctx = \
core_services.get_service("settings_base").get_context()
self.__purgatory = []
self.__callbacks = []
## Settings Table Definition:
settings_list = [
Setting(
name='xbee_device_manager', type=str, required=True),
# Contains the device driver settings for every device
# that is intended to be auto enumerated.
# The 'name: tag' is used as part of the new device name
Setting(name='devices', type=dict, required=True,
default_value=[]),
Setting(
name='discover_rate', type=int, required=False,
default_value=600,
verify_function=lambda x: x >= 1 and x <= 86400),
# Shortens the discovered device names, when NI is not used,
# to only include the last two octets of the XBee MAC Address.
# User must confirm uniqueness of these 2 octets.
# Example: 'aio_[00:13:a2:00:40:52:e0:fc]!'
# becomes just 'aio_E0_FC'
Setting(name='short_names', type=bool, required=False,
default_value=False),
]
## Channel Properties Definition:
property_list = [
]
self.__add_device_queue = Queue.Queue()
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例13: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
self.targets = {}
from core.tracing import get_tracer
self.__tracer = get_tracer(name)
## Settings Table Definition:
settings_list = [
Setting(name=PROP_PRINTF, type=str, required=False, default_value=PROP_MINUTE),
Setting( # how often to check for work
name=PROP_TICK_RATE, type=int, required=False,
default_value=DEFAULT_TICK_RATE,
verify_function=lambda x: x > 0.0),
]
## Channel Properties Definition:
property_list = [
# gettable properties
ChannelSourceDeviceProperty(name=PROP_15SEC, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
ChannelSourceDeviceProperty(name=PROP_MINUTE, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
ChannelSourceDeviceProperty(name=PROP_15MIN, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
ChannelSourceDeviceProperty(name=PROP_HOUR, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
ChannelSourceDeviceProperty(name=PROP_SIXHR, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
ChannelSourceDeviceProperty(name=PROP_DAY, type=tuple,
initial=Sample(timestamp=0, value=(0,None)),
perms_mask=DPROP_PERM_GET),
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Thread initialization:
self.__stopevent = threading.Event()
threading.Thread.__init__(self, name=name)
threading.Thread.setDaemon(self, True)
示例14: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Local State Variables:
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:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Initialize the serial interface:
Serial.__init__(self, 0, 19200, timeout = 0)
示例15: __init__
# 需要导入模块: from devices.device_base import DeviceBase [as 别名]
# 或者: from devices.device_base.DeviceBase import __init__ [as 别名]
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
print "SystemStatus: initializing class"
## Settings Table Definition:
settings_list = [
Setting(name='update_rate', type=float, required=False, default_value=300.0),
Setting(name='no_mobile', type=bool, required=False, default_value=False),
Setting(name='no_zigbee', type=bool, required=False, default_value=False),
]
## Channel Properties Definition:
property_list = [
# gettable & settable properties
ChannelSourceDeviceProperty(name="free_memory", type=int,
initial=Sample(timestamp=0, unit="bytes", value=0),
perms_mask=(DPROP_PERM_GET),options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="cpu_utilization", type=int,
initial=Sample(timestamp=0, unit="%", value=0),
perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP),
#ChannelSourceDeviceProperty(name="mobile_status", type=str,
# initial=Sample(timestamp=0, value="N/A"),
# perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP),
#ChannelSourceDeviceProperty(name="mobile_rssi", type=int,
# initial=Sample(timestamp=0, value=0),
# perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP),
ChannelSourceDeviceProperty(name="idigi_status", type=str,
initial=Sample(timestamp=0, value="N/A"),
perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP),
]
## Initialize the DeviceBase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
print "Setting no_mobile:",SettingsBase.get_setting(self, "no_mobile")
if not SettingsBase.get_setting(self,"no_mobile"):
print "adding mobile properties"
self.add_property(ChannelSourceDeviceProperty(name="mobile_rssi", type=int,
initial=Sample(timestamp=0, value=0),
perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP))
self.add_property(ChannelSourceDeviceProperty(name="mobile_status", type=str,
initial=Sample(timestamp=0, value="N/A"),
perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP))
self.apply_settings()
print "Setting no_zigbee:",SettingsBase.get_setting(self, "no_zigbee")
if not SettingsBase.get_setting(self,"no_zigbee"):
print "adding zigbee properties"
self.add_property(ChannelSourceDeviceProperty(name="zigbee_coord_rssi", type=int,
initial=Sample(timestamp=0, value=0),
perms_mask=(DPROP_PERM_GET), options=DPROP_OPT_AUTOTIMESTAMP))
self.apply_settings()