Skip to content

Commit

Permalink
Add relative attribute values stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jan 14, 2019
1 parent ef6296f commit afcc4d9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
36 changes: 36 additions & 0 deletions pydbc/cgen/templates/dbc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,42 @@ ${int(attr['Num_Value'])}\
%endif
;
%endfor
%for attr in db.relativeAttributeValues():
<% attrDef = list(db.attributeDefintion(attr['Attribute_Definition']))[0] %>\
BA_REL_ "${attrDef['Name']}" \
%if attrDef['Objecttype'] == 5:
BU_BO_REL_ \
%elif attrDef['Objecttype'] == 6:
BU_SG_REL_ \
%elif attrDef['Objecttype'] == 7:
BU_EV_REL_ \
%endif
${db.fetchNodenameByRid(attr['Opt_Object_ID_1'])} \
%if attrDef['Objecttype'] == 6:
SG_ \
%endif
%if attrDef['Objecttype'] in (5, 6):
${attr['Opt_Object_ID_2']} \
%endif
%if attrDef['Objecttype'] == 6:
<% signal = db.fetchSignalByRid(attr['Object_ID']) %>\
${signal['Name']} \
%elif attrDef['Objecttype'] == 7:
${db.fetchEnvvarNameByRid(attr['Object_ID'])} \
%endif
%if attrDef['Valuetype'] == 0:
${int(attr['Num_Value'])}\
%elif attrDef['Valuetype'] == 1:
${int(attr['Num_Value'])}\
%elif attrDef['Valuetype'] == 2:
${"{:.14G}".format(attr['Num_Value'])}\
%elif attrDef['Valuetype'] == 3:
"${attr['String_Value']}"\
%elif attrDef['Valuetype'] == 4:
${int(attr['Num_Value'])}\
%endif
;
%endfor
%for vt in db.valueTablesLocal():
VAL_ \
%if vt['Object_Type'] == 0:
Expand Down
9 changes: 7 additions & 2 deletions pydbc/db/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__copyright__ = """
pySART - Simplified AUTOSAR-Toolkit for Python.
(C) 2010-2018 by Christoph Schueler <cpu12.gems.googlemail.com>
(C) 2010-2019 by Christoph Schueler <cpu12.gems.googlemail.com>
All Rights Reserved
Expand Down Expand Up @@ -204,6 +204,10 @@ def attributeValues(self):
cur = self.getCursor()
yield from self.db.fetchFromTable(cur, "Attribute_Value")

def relativeAttributeValues(self):
cur = self.getCursor()
yield from self.db.fetchFromTable(cur, "AttributeRel_Value")

def environmentVariables(self):
cur = self.getCursor()
yield from self.db.fetchFromTable(cur, "EnvVar")
Expand Down Expand Up @@ -256,9 +260,10 @@ def multipleTransmitters(self):
rows = cur.fetchall()
if rows:
messages = {r[0]:r[1] for r in rows}
key ="({})".format(','.join([str(k) for k in messages.keys()]))
stmt = """SELECT node, message, name FROM Node_TxMessage AS t1, Node AS t2 WHERE t1.Node = t2.rid
AND message IN {};
""".format(tuple(messages.keys()))
""".format(key)
cur.execute(stmt)
items = cur.fetchall()
for kr, item in itertools.groupby(items, lambda n: n[1]):
Expand Down

0 comments on commit afcc4d9

Please sign in to comment.