Skip to content

Commit

Permalink
Add signal groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jan 7, 2019
1 parent 8ed3933 commit e0c5797
Show file tree
Hide file tree
Showing 5 changed files with 1,331 additions and 1,180 deletions.
19 changes: 16 additions & 3 deletions pydbc/dbc.g4
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ dbcfile:
environmentVariables // EV_
environmentVariablesData // ENVVAR_DATA_
signalTypes // SGTYPE_
// SGTYPE_VAL_
// BA_DEF_SGTYPE_
// BA_SGTYPE_
// SIG_TYPE_REF_
comments // CM_
attributeDefinitions // BA_DEF_
customAttributeDefinitions // BA_DEF_REL_
Expand All @@ -43,7 +47,7 @@ dbcfile:
attributeValues // BA_
customAttributeValues // BA_REL_
valueDescriptions // VAL_

signalGroups // SIG_GROUP_
categoryDefinitions // CAT_DEF_
categories // CAT_
//filter
Expand Down Expand Up @@ -258,13 +262,22 @@ customAttributeValues:

customAttributeValueForObject:
'BA_REL' attributeName = stringValue (
attributeValue
| (attrType = 'BU_BO_REL_' nodeName = identifierValue nodeAddress = intValue attrValue = attributeValue)
( attrType = 'BU_BO_REL_' nodeName = identifierValue nodeAddress = intValue attrValue = attributeValue)
| (attrType = 'BU_SG_REL_' nodeName = identifierValue 'SG_' messageID = intValue signalName = identifierValue attrValue = attributeValue)
| (attrType = 'BU_EV_REL_' evName = identifierValue evValue = attributeValue) // ???
) ';'
;

signalGroups:
(items += signalGroup)*
;

signalGroup:
'SIG_GROUP_' messageID = intValue groupName = identifierValue gvalue = intValue ':'
(signals += identifierValue)*
';'
;

categoryDefinitions:
(items += categoryDefinition)*
;
Expand Down
21 changes: 21 additions & 0 deletions pydbc/dbcListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ def exitDbcfile(self, ctx):
attributeDefaults = ctx.attributeDefaults().value,
customAttributeDefaults = ctx.customAttributeDefaults().value,
attributeValues = ctx.attributeValues().value,
customAttributeValues = ctx.customAttributeValues().value,
valueDescriptions = ctx.valueDescriptions().value,
categoryDefinitions = ctx.categoryDefinitions().value,
categories = ctx.categories().value,
signalGroups = ctx.signalGroups().value,
signalExtendedValueTypeList = ctx.signalExtendedValueTypeList().value
)

Expand Down Expand Up @@ -327,6 +329,25 @@ def exitAttributeValueForObject(self, ctx):
di = dict(type = "NETWORK", value = evValue)
ctx.value = dict(name = attributeName, **di)

def exitCustomAttributeValues(self, ctx):
print("CustomAttributeValues", ctx.items)

def exitCustomAttributeValueForObject(self, ctx):
print("customAttributeValueForObject", ctx.attrType.value)

def exitSignalGroups(self, ctx):
items = [x.value for x in ctx.items]
print("SignalGroups", items)
ctx.value = items

def exitSignalGroup(self, ctx):
messageID = ctx.messageID.value
groupName = ctx.groupName.value
gvalue = ctx.gvalue.value
signals = [x.value for x in ctx.signals]
ctx.value = dict(messageID = messageID, groupName = groupName, gvalue = gvalue, signals = signals)


def exitCategoryDefinitions(self, ctx):
ctx.value = [x.value for x in ctx.items]

Expand Down
Loading

0 comments on commit e0c5797

Please sign in to comment.