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

Introducing new schemas.

WARNING: 
========
Version 0.7 introduce a lot of changes in schemas.
Most devices in the SVN are not ready. 
I should fix that, one after one.



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2458 b32b6428-25c9-4566-ad07-03861ab6144f
parent 6da8375c
No related branches found
No related tags found
No related merge requests found
#=====================================================================
def ${name}(addr=None):
"""${doc}"""
if (addr==None):addr = tools.get_random_uuid()
addr = addr or tools.get_random_uuid()
dev = Device('${devtype}',addr)
% if (len(attributes) !=0):
# -- Attributes --
% for attr in attributes:
# ${attributes[attr]['description']}
% for attr in attributes:
<% dm = datamodel[attributes[attr]] %># ${dm['description']}
dev.new_attribute('${attr}')
% endfor
% endif
......@@ -16,7 +16,7 @@ def ${name}(addr=None):
# -- Methods --
% for meth in methods:
<%
keys = list(methods[meth]['parameters'].keys())
keys = list(methods[meth].get('in',{}).keys())
tmp = map(lambda x: '_%s' % x,keys)
args = ','.join(tmp)
buf= ""
......
......@@ -3,8 +3,21 @@ import sys
import os
import ujson
from pprint import pprint
SCHEMA_DIR='/home/jkx/Devel/xaal_schemas'
BLACK_LIST=['json-online-validator.sh','Makefile','schema','xAAL_05_application-layer','xAAL_05_security-layer','xAAL_06_application-layer.cddl','xAAL_06_security-layer.cddl','xAAL_schema','.svn','schemarepository.basic_notice.txt','skels','.vscode']
SCHEMA_DIR = '/home/jkx/Devel/xaal_schemas/branches/schemas-0.7'
BLACK_LIST=['application-layer.cddl',
'cache.basic.notice',
'lamp.basic.notice',
'lamp.color.notice',
'lamp.dimmer.notice',
'Makefile',
'metadatadb.basic.notice',
'powerrelay.basic.notice',
'schema.cddl',
'security-layer.cddl',
'shutter.position.notice',
'validate_schema',
]
def name_to_method(name):
if name.endswith('.basic'):
......@@ -68,6 +81,7 @@ class Schemas:
tmpMethods = {}
tmpAttr = {}
tmpNotifs = {}
tmpDataModel = {}
for e in ext:
_dict = self.load(e)
......@@ -83,9 +97,14 @@ class Schemas:
tmp = _dict["notifications"]
tmpNotifs.update(tmp)
if "datamodel" in _dict.keys():
tmp = _dict["datamodel"]
tmpDataModel.update(tmp)
res["methods"] = tmpMethods
res["attributes"] = tmpAttr
res["notifications"] = tmpNotifs
res["datamodel"] = tmpDataModel
return res
......@@ -114,6 +133,9 @@ class DeviceBuilder:
def is_basic_notification(self,value):
return value in self.basic['notifications']
def is_basic_datamodel(self,value):
return value in self.basic['datamodel']
def get_schema(self,name):
return self.schemas.get(name)
......@@ -133,14 +155,23 @@ class DeviceBuilder:
dict_ = data['methods'][k]
#print("%s: %s %s" % (k,dict_['description'],list(dict_['parameters'].keys())))
methods.update({k:dict_})
datamodel = {}
for k in data['datamodel']:
if not self.is_basic_datamodel(k):
dict_ = data['datamodel'][k]
datamodel.update({k:dict_})
args = {}
args['name'] = name_to_method(name)
args['doc'] = data['description']
args['devtype'] = name
args['attributes'] = attributes
args['methods'] = methods
args['datamodel'] = datamodel
print(tmpl.render(**args))
#return args
def build_all(self):
devs = self.schemas.get_devtypes()
......@@ -153,13 +184,11 @@ class DeviceBuilder:
db = DeviceBuilder()
#r = db.get_schema('thermometer.basic')
#r = db.build('lamp.dimmer')
#pprint(r)
#db.build('lamp.dimmer')
#db.build('mediaplayer.basic')
#db.build(sys.argv[1])
print("from xaal.lib import Device,tools")
print("import logging")
print("logger = logging.getLogger(__name__)")
print("from xaal.lib import tools")
print()
head = open('./head.txt','r').read()
print(head)
db.build_all()
This diff is collapsed.
"""
Autogenerated devices skeletons. This file is generated from the json schemas
at https://redmine.telecom-bretagne.eu/svn/xaal/schemas/branches/schemas-0.7
This python module is updated frequently according to schemas
"""
from xaal.lib import Device,tools
import logging
logger = logging.getLogger(__name__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment