diff --git a/pydbc/cgen/templates/dbc.tmpl b/pydbc/cgen/templates/dbc.tmpl index faeedec..4960134 100644 --- a/pydbc/cgen/templates/dbc.tmpl +++ b/pydbc/cgen/templates/dbc.tmpl @@ -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: diff --git a/pydbc/db/common.py b/pydbc/db/common.py index eb73943..a33daa1 100644 --- a/pydbc/db/common.py +++ b/pydbc/db/common.py @@ -4,7 +4,7 @@ __copyright__ = """ pySART - Simplified AUTOSAR-Toolkit for Python. - (C) 2010-2018 by Christoph Schueler + (C) 2010-2019 by Christoph Schueler All Rights Reserved @@ -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") @@ -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]):