Skip to content

Commit

Permalink
[WIP] Iss230 support for long names (#293)
Browse files Browse the repository at this point in the history
fixes #230 
parts from #236
* add support for long ECU names
* fix long enviroment names
refactor: remove import *
refactor: create small sub-functions for dbc creation
  • Loading branch information
ebroecker authored Feb 22, 2019
1 parent 4ec6fd4 commit 04b9e2a
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 160 deletions.
3 changes: 2 additions & 1 deletion requirements.test.py3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ tox==3.2.1
virtualenv==16.0.0
xlwt==1.3.0
xlrd==1.1.0
lxml
lxml==4.3.1

21 changes: 21 additions & 0 deletions src/canmatrix/canmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def add_attribute(self, attribute, value):
"""
self.attributes[attribute] = value

def del_attribute(self, attribute):
if attribute in self.attributes:
del self.attributes[attribute]

def add_comment(self, comment):
"""
Set Board unit comment.
Expand Down Expand Up @@ -1143,6 +1147,7 @@ class CanMatrix(object):
signal_defines = attr.ib(type=dict, factory=dict)
frame_defines = attr.ib(type=dict, factory=dict)
global_defines = attr.ib(type=dict, factory=dict)
env_defines = attr.ib(type=dict, factory=dict)
ecu_defines = attr.ib(type=dict, factory=dict)
value_tables = attr.ib(type=dict, factory=dict)
env_vars = attr.ib(type=dict, factory=dict)
Expand All @@ -1157,6 +1162,12 @@ def __iter__(self):
def add_env_var(self, name, envVarDict):
self.env_vars[name] = envVarDict

def add_env_attribute(self, env_name, attribute_name, attribute_value):
if env_name in self.env_vars:
if not "attributes" in self.env_vars[env_name]:
self.env_vars[env_name]["attributes"] = dict()
self.env_vars[env_name]["attributes"][attribute_name] = attribute_value

@property
def contains_fd(self):
for frame in self.frames:
Expand Down Expand Up @@ -1234,6 +1245,16 @@ def add_ecu_defines(self, type, definition):
if type not in self.ecu_defines:
self.ecu_defines[type] = Define(definition)

def add_env_defines(self, type, definition):
"""
Add enviroment variable-attribute definition to canmatrix.
:param str type: enviroment variable type
:param str definition: enviroment variable definition as string
"""
if type not in self.env_defines:
self.env_defines[type] = Define(definition)

def add_global_defines(self, type, definition):
"""
Add global-attribute definition to canmatrix.
Expand Down
Loading

0 comments on commit 04b9e2a

Please sign in to comment.