Skip to content

Commit 04b9e2a

Browse files
authored
[WIP] Iss230 support for long names (#293)
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
1 parent 4ec6fd4 commit 04b9e2a

File tree

5 files changed

+288
-160
lines changed

5 files changed

+288
-160
lines changed

requirements.test.py3.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ tox==3.2.1
1414
virtualenv==16.0.0
1515
xlwt==1.3.0
1616
xlrd==1.1.0
17-
lxml
17+
lxml==4.3.1
18+

src/canmatrix/canmatrix.py

+21
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def add_attribute(self, attribute, value):
9696
"""
9797
self.attributes[attribute] = value
9898

99+
def del_attribute(self, attribute):
100+
if attribute in self.attributes:
101+
del self.attributes[attribute]
102+
99103
def add_comment(self, comment):
100104
"""
101105
Set Board unit comment.
@@ -1143,6 +1147,7 @@ class CanMatrix(object):
11431147
signal_defines = attr.ib(type=dict, factory=dict)
11441148
frame_defines = attr.ib(type=dict, factory=dict)
11451149
global_defines = attr.ib(type=dict, factory=dict)
1150+
env_defines = attr.ib(type=dict, factory=dict)
11461151
ecu_defines = attr.ib(type=dict, factory=dict)
11471152
value_tables = attr.ib(type=dict, factory=dict)
11481153
env_vars = attr.ib(type=dict, factory=dict)
@@ -1157,6 +1162,12 @@ def __iter__(self):
11571162
def add_env_var(self, name, envVarDict):
11581163
self.env_vars[name] = envVarDict
11591164

1165+
def add_env_attribute(self, env_name, attribute_name, attribute_value):
1166+
if env_name in self.env_vars:
1167+
if not "attributes" in self.env_vars[env_name]:
1168+
self.env_vars[env_name]["attributes"] = dict()
1169+
self.env_vars[env_name]["attributes"][attribute_name] = attribute_value
1170+
11601171
@property
11611172
def contains_fd(self):
11621173
for frame in self.frames:
@@ -1234,6 +1245,16 @@ def add_ecu_defines(self, type, definition):
12341245
if type not in self.ecu_defines:
12351246
self.ecu_defines[type] = Define(definition)
12361247

1248+
def add_env_defines(self, type, definition):
1249+
"""
1250+
Add enviroment variable-attribute definition to canmatrix.
1251+
1252+
:param str type: enviroment variable type
1253+
:param str definition: enviroment variable definition as string
1254+
"""
1255+
if type not in self.env_defines:
1256+
self.env_defines[type] = Define(definition)
1257+
12371258
def add_global_defines(self, type, definition):
12381259
"""
12391260
Add global-attribute definition to canmatrix.

0 commit comments

Comments
 (0)