mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2024-12-19 04:58:01 +00:00
minor fixes and style changes for CUL868IPE
This commit is contained in:
parent
b8d7b6c530
commit
035755154e
@ -19,8 +19,8 @@
|
||||
"sim_period": 3,
|
||||
"cul_device": "/dev/ttyACM0",
|
||||
"device_mappings": {
|
||||
"ZBS12345678": "Fenster",
|
||||
"ZBS12341234": "Dach",
|
||||
"S300TH_1": "Fenster",
|
||||
"S300TH_2": "Dach",
|
||||
"FS20_ST3_16108_1": "Wohnzimmer"
|
||||
},
|
||||
"devices": [
|
||||
|
@ -18,6 +18,11 @@
|
||||
"sim": false,
|
||||
"sim_period": 3,
|
||||
"cul_device": "/dev/ttyACM0",
|
||||
"device_mappings": {
|
||||
"S300TH_1": "Fenster",
|
||||
"S300TH_2": "Dach",
|
||||
"FS20_ST3_16108_1": "Wohnzimmer"
|
||||
},
|
||||
"devices": [
|
||||
"fs20:16108-1",
|
||||
"fs20:16108-0"
|
||||
|
@ -41,13 +41,12 @@ ssl_certs = config.get("ssl_certs", {})
|
||||
s = config.get("sim", False)
|
||||
p = int(config.get("sim_period"))
|
||||
cul_device = get_value('cul_device', (unicode, str), default_device, args, config)
|
||||
device_mappings = get_value('device_mappings', dict, {}, args, config)
|
||||
device_mappings = get_value('device_mappings', dict, {}, args, config)
|
||||
devices = get_value('devices', list, [], args, config)
|
||||
|
||||
# start
|
||||
app = CUL868IPE(
|
||||
devices, device=cul_device, sim=s, sim_period=p,
|
||||
device_mappings=device_mappings,
|
||||
devices, device=cul_device, sim=s, sim_period=p, device_mappings=device_mappings,
|
||||
name=nm, cse_base=cb, poas=poas,
|
||||
originator_pre=originator_pre, **ssl_certs
|
||||
)
|
||||
|
@ -6,14 +6,13 @@ from random import choice
|
||||
from gevent import spawn
|
||||
|
||||
from futile.logging import LoggerMixin
|
||||
from .parsers import (EM1000EMParser, S300THParser, FS20Parser, HMSParser,
|
||||
SIMParser)
|
||||
from .parsers import (EM1000EMParser, S300THParser, FS20Parser, HMSParser, SIMParser)
|
||||
|
||||
|
||||
def _hex(n):
|
||||
s = hex(n)[2:]
|
||||
l = len(s)
|
||||
return s.zfill(l + l % 2)
|
||||
len_s = len(s)
|
||||
return s.zfill(len_s + len_s % 2)
|
||||
|
||||
|
||||
class CUL868Coordinator(LoggerMixin):
|
||||
@ -39,9 +38,9 @@ class CUL868Coordinator(LoggerMixin):
|
||||
}
|
||||
|
||||
self.sim_parsers = {
|
||||
# "K": SIMParser(),
|
||||
"K": SIMParser(),
|
||||
# "E": SIMParser(),
|
||||
"F": SIMParser(),
|
||||
# "F": SIMParser(),
|
||||
# "H": SIMParser()
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import time
|
||||
from collections import namedtuple
|
||||
|
||||
from cul_868_coordinator import CUL868Coordinator
|
||||
from openmtc_app.onem2m import XAE
|
||||
from openmtc_onem2m.model import Container
|
||||
from collections import namedtuple
|
||||
from cul_868_coordinator import CUL868Coordinator
|
||||
|
||||
BAUD_RATE = 9600
|
||||
NODE_DISCOVER_INTERVAL = 6
|
||||
@ -15,8 +16,8 @@ class CUL868IPE(XAE):
|
||||
max_nr_of_instances = 30
|
||||
default_access_right = False
|
||||
|
||||
def __init__(self, cul_devices, device="/dev/ttyACM0",
|
||||
sim=False, sim_period=3, device_mappings={}, *args, **kw):
|
||||
def __init__(self, cul_devices, device="/dev/ttyACM0", sim=False, sim_period=3,
|
||||
device_mappings=None, *args, **kw):
|
||||
super(CUL868IPE, self).__init__(*args, **kw)
|
||||
self.device = device
|
||||
|
||||
@ -37,7 +38,7 @@ class CUL868IPE(XAE):
|
||||
self.sim = sim
|
||||
self.sim_period = sim_period
|
||||
|
||||
self.device_mappings = device_mappings
|
||||
self.device_mappings = device_mappings or {}
|
||||
|
||||
self._old_fs20_values = {}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class SIMParser(Parser):
|
||||
if line == 'K':
|
||||
dev_id = '1'
|
||||
temperature = random.uniform(0, 30)
|
||||
humidity = random.uniform(0, 30)
|
||||
humidity = random.uniform(5, 95)
|
||||
return dev_id, S300THData(temperature, humidity)
|
||||
elif line == 'F':
|
||||
dev_id = '21111111-132' + choice(['1', '2'])
|
||||
|
@ -1,7 +1,5 @@
|
||||
from parsers import S300THParser, EM1000EMParser, FS20Parser
|
||||
|
||||
__author__ = 'ren-local'
|
||||
|
||||
|
||||
def test_parsers():
|
||||
# ('1', S300THData(temperature=22.5, humidity=31.3))
|
||||
|
Loading…
Reference in New Issue
Block a user