Skip to content

Commit d062918

Browse files
committed
Minor fixes and cleanup
1 parent c2c5f89 commit d062918

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

autosar/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import autosar.builder
1111
import autosar.port
1212
from abc import (ABC,abstractmethod)
13-
from autosar.base import splitRef
13+
import autosar.base
1414
import autosar.bsw.com
1515
import autosar.bsw.os
1616
import autosar.util
@@ -25,7 +25,7 @@ def workspace(version=3.0, patch = 2, schema=None, attributes=None, useDefaultWr
2525
return autosar.Workspace(version, patch, schema, attributes, useDefaultWriters)
2626

2727

28-
28+
2929

3030
def splitRef(ref):
3131
return autosar.base.splitRef(ref)
@@ -37,27 +37,29 @@ def ApplicationError(name, errorCode, parent=None, adminData=None):
3737
return autosar.portinterface.ApplicationError(name, errorCode, parent, adminData)
3838

3939
def ModeGroup(name, typeRef, parent=None, adminData=None):
40-
return autosar.portinterface.ModeGroup(name, typeRef, parent, adminData)
41-
42-
def CompuMethodConst(name, elements, parent=None, adminData=None):
43-
return autosar.datatype.CompuMethodConst(name, elements, parent, adminData)
40+
return autosar.mode.ModeGroup(name, typeRef, parent, adminData)
4441

4542
def ParameterDataPrototype(name, typeRef, swAddressMethodRef=None, swCalibrationAccess=None, initValue = None, parent=None, adminData=None):
4643
return autosar.element.ParameterDataPrototype(name, typeRef, swAddressMethodRef, swCalibrationAccess, initValue, parent, adminData)
4744

4845

4946
#template support
5047
class Template(ABC):
51-
48+
5249
usageCount = 0 #number of times this template have been applied
53-
50+
static_ref = ''
51+
52+
@classmethod
53+
def ref(cls, ws):
54+
return cls.static_ref
55+
5456
@classmethod
5557
def get(cls, ws):
5658
ref = cls.ref(ws)
5759
if ws.find(ref) is None:
5860
ws.apply(cls)
5961
return ws.find(ref)
60-
62+
6163
@classmethod
6264
@abstractmethod
6365
def apply(cls, ws, **kwargs):

autosar/package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def createModeSwitchInterface(self, name, modeGroup = None, isService=False, adm
208208
assert (ws is not None)
209209
modeDeclarationGroup = ws.find(modeGroup.typeRef, role='ModeDclrGroup')
210210
if modeDeclarationGroup is None:
211-
raise ValueError('invalid type reference: '+dataElements.typeRef)
211+
raise ValueError('invalid type reference: '+modeGroup.typeRef)
212212
modeGroup.typeRef=modeDeclarationGroup.ref #normalize reference string
213213
portInterface.modeGroup = modeGroup
214214
modeGroup.parent = portInterface

autosar/util/dcf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def save_dcf(self, dest_dir, dcf_name, xml_file_map, schema = None, force = True
293293
elem = xml_file_map[key]
294294
extension = '' if key.lower().endswith('.arxml') else '.arxml'
295295
file_name = key + extension
296-
lines.extend(self.indent(self._single_file_ref(file_name, elem['root']),1))
296+
lines.extend(self.indent(self._single_file_ref(file_name),1))
297297
lines.append('</DCF>')
298298
with open(dest_file, 'w') as fp:
299299
fp.write('\n'.join(lines))
@@ -306,13 +306,13 @@ def _component_file_ref(self, component_name):
306306
lines.append('</FILEREF>')
307307
return lines
308308

309-
def _single_file_ref(self, file_name, root_item, directory=None):
309+
def _single_file_ref(self, file_name, directory=None):
310310
if directory is not None:
311311
file_path = os.path.join(directory, file_name)
312312
else:
313313
file_path = file_name
314314
lines = ['<FILEREF>']
315-
lines.append(self.indent('<ARXML ROOTITEM="{}" TYPE="">{}</ARXML>'.format(root_item.upper(), file_path),1))
315+
lines.append(self.indent('<ARXML>{}</ARXML>'.format(file_path),1))
316316
lines.append('</FILEREF>')
317317
return lines
318318

autosar/workspace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ def append(self,elem):
339339
if isinstance(elem,autosar.package.Package):
340340
self.packages.append(elem)
341341
elem.parent=self
342+
self.map['packages'][elem.name] = elem
342343
else:
343344
raise ValueError(type(elem))
344345

0 commit comments

Comments
 (0)