本文整理汇总了Python中janitoo.component.JNTComponent.start方法的典型用法代码示例。如果您正苦于以下问题:Python JNTComponent.start方法的具体用法?Python JNTComponent.start怎么用?Python JNTComponent.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类janitoo.component.JNTComponent
的用法示例。
在下文中一共展示了JNTComponent.start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the bus
"""
JNTComponent.start(self, mqttc)
self._bus.i2c_acquire()
try:
self.sensor = BMP085.BMP085(mode=self.values["mode"].data, address=self.values["addr"].data, i2c=self._bus._ada_i2c)
except Exception:
logger.exception("[%s] - Can't start component", self.__class__.__name__)
finally:
self._bus.i2c_release()
示例2: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component.
"""
logger.warning("[%s] - Start component : %s ", self.__class__.__name__, self.values['rrd_file'].data)
JNTComponent.start(self, mqttc)
value_source = self.values['source']
config = {}
for i in range(0, value_source.get_max_index()+1):
config[i] = value_source.get_config(value_source.node_uuid, i)
self._bus.store.timer_add_config(self.values['rrd_file'].data, self.values['rrd_step'].data, config)
return True
示例3: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the bus
"""
JNTComponent.start(self, mqttc)
self._bus.i2c_acquire()
try:
self.sensor = MAX9744(address=self.values["addr"].data, i2c=self._bus.get_adafruit_i2c(), busnum=self._bus.get_busnum())
except Exception:
logger.exception("[%s] - Can't start component", self.__class__.__name__)
finally:
self._bus.i2c_release()
示例4: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the bus
"""
JNTComponent.start(self, mqttc)
self._bus.i2c_acquire()
try:
self.clock = SDL_DS1307(address=self.values["addr"].data, busnum=self._bus.get_busnum())
except Exception:
logger.exception("[%s] - Can't start component", self.__class__.__name__)
finally:
self._bus.i2c_release()
示例5: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component.
"""
JNTComponent.start(self, mqttc)
configs = len(self.values["add"].get_index_configs())
for config in range(configs):
try:
pass
except:
logger.exception("Exception when starting NXP Reader component")
return True
示例6: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component
"""
JNTComponent.start(self, mqttc)
self._bus.spi_acquire()
try:
device = self.values["device"].data
dc_pin = self._bus.get_spi_device_pin(device)
spi = self._bus.get_spi_device(device, max_speed_hz=1000000)
self.setup_pn532(dc_pin, spi, self._ada_gpio)
except Exception:
logger.exception("[%s] - Can't start component", self.__class__.__name__)
finally:
self._bus.spi_release()
示例7: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component.
"""
JNTComponent.start(self, mqttc)
configs = len(self.values["addr"].get_index_configs())
if configs == 0:
self.devices = [(0, self.values["addr"].data, 0)]
else:
self.devices = []
for config in range(configs):
self.devices += (config, self.values["addr"].instances[config]['data'])
self.on_check()
return True
示例8: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component.
"""
self.state = 'BOOT'
JNTComponent.start(self, mqttc)
hadd = self.values['remote_hadd'].data
logger.debug("[%s] - Found remote HADD %s for node %s", self.__class__.__name__, hadd, self.node.uuid)
if hadd is None:
logger.debug("[%s] - No remote HADD. Exit ...", self.__class__.__name__)
return False
self.remote_hadd = hadd_split(hadd)
if self.remote_hadd[0] is None or self.remote_hadd[1] is None:
logger.warning("[%s] - Bad remote HADD %s", self.__class__.__name__, hadd)
return False
try:
self.mqttc_heartbeat = MQTTClient(options=self.options.data)
self.mqttc_heartbeat.connect()
self.mqttc_heartbeat.subscribe(topic=TOPIC_HEARTBEAT_NODE%(hadd), callback=self.on_heartbeat)
self.mqttc_heartbeat.start()
except Exception:
logger.exception("[%s] - start", self.__class__.__name__)
values_read = self.get_read_values()
values_write = self.get_write_values()
logger.debug("[%s] - found %s values_read", self.__class__.__name__, len(values_read))
logger.debug("[%s] - found %s values_write", self.__class__.__name__, len(values_write))
topics = []
for value in values_read:
if value[0] == 'user':
topic=TOPIC_VALUES_USER
else:
topic=TOPIC_VALUES_BASIC
topic = topic%(hadd+'/'+value[1])
topics.append((topic, 0))
logger.debug("[%s] - subscribe to %s", self.__class__.__name__, topic)
if len(topics)>0:
try:
self.mqttc_values = MQTTClient(options=self.options.data)
self.mqttc_values.connect()
self.mqttc_values.subscribe(topics=topics, callback=self.on_remote_value)
self.mqttc_values.start()
except Exception:
logger.exception("[%s] - start", self.__class__.__name__)
#~ print max_index
#~ for index in range(max_index):
#~ print index
return True
示例9: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component.
"""
JNTComponent.start(self, mqttc)
return True
示例10: start
# 需要导入模块: from janitoo.component import JNTComponent [as 别名]
# 或者: from janitoo.component.JNTComponent import start [as 别名]
def start(self, mqttc):
"""Start the component. Can be used to start a thread to acquire data.
"""
self._bus.nodeman.add_daily_job(self.current_rotate)
return JNTComponent.start(self, mqttc)