Skip to content
Snippets Groups Projects
Commit f2888477 authored by jkerdreu's avatar jkerdreu
Browse files

Added default config file building

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1952 b32b6428-25c9-4566-ad07-03861ab6144f
parent c419b0a5
No related branches found
No related tags found
No related merge requests found
from __future__ import print_function
import xaal.lib
from xaal.lib import Device,tools
import logging
import platform
from . import HTU21D
......@@ -9,10 +9,10 @@ from . import HTU21D
PACKAGE_NAME = "xaal.htu21d"
logger = xaal.lib.tools.get_logger(PACKAGE_NAME,logging.DEBUG,"%s.log" % PACKAGE_NAME)
logger = tools.get_logger(PACKAGE_NAME,logging.DEBUG,"%s.log" % PACKAGE_NAME)
def build_dev(addr,devtype):
dev = xaal.lib.Device(devtype)
dev = Device(devtype)
dev.address = addr
dev.vendor_id = "IHSEV"
dev.version = 0.1
......@@ -35,10 +35,21 @@ def smooth(attribute,value,gap):
class GW:
def __init__(self,engine):
self.engine = engine
self.config()
self.setup()
def config(self):
cfg = tools.load_cfg(PACKAGE_NAME)
if not cfg:
logger.info('Missing config file, building a new one')
cfg = tools.new_cfg(PACKAGE_NAME)
cfg['config']['thermometer'] = tools.get_random_uuid()
cfg['config']['hygrometer'] = tools.get_random_uuid()
cfg.write()
self.cfg = cfg
def setup(self):
cfg = xaal.lib.tools.load_cfg_or_die(PACKAGE_NAME)['config']
cfg = self.cfg['config']
rate = float(cfg['refresh'])
self.engine.add_timer(self.process,rate)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment