armodel 1.4.0__py3-none-any.whl → 1.4.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- armodel/__init__.py +2 -1
- armodel/cli/arxml_dump_cli.py +8 -6
- armodel/cli/arxml_format_cli.py +72 -0
- armodel/cli/connector_update_cli.py +11 -4
- armodel/data_models/__init__.py +0 -0
- armodel/data_models/sw_connector.py +22 -0
- armodel/lib/data_analyzer.py +1 -1
- armodel/models/__init__.py +3 -2
- armodel/models/annotation.py +20 -0
- armodel/models/ar_object.py +163 -18
- armodel/models/ar_package.py +110 -14
- armodel/models/ar_ref.py +62 -6
- armodel/models/bsw_module_template.py +97 -26
- armodel/models/calibration.py +107 -4
- armodel/models/common_structure.py +112 -37
- armodel/models/communication.py +10 -1
- armodel/models/data_def_properties.py +16 -0
- armodel/models/data_dictionary.py +46 -9
- armodel/models/data_prototype.py +24 -5
- armodel/models/datatype.py +69 -20
- armodel/models/end_to_end_protection.py +67 -0
- armodel/models/general_structure.py +25 -15
- armodel/models/global_constraints.py +4 -4
- armodel/models/implementation.py +80 -32
- armodel/models/m2_msr.py +6 -4
- armodel/models/multilanguage_data.py +42 -0
- armodel/models/per_instance_memory.py +14 -0
- armodel/models/port_interface.py +27 -4
- armodel/models/port_prototype.py +37 -17
- armodel/models/record_layout.py +118 -0
- armodel/models/service_mapping.py +11 -0
- armodel/models/service_needs.py +48 -0
- armodel/models/sw_component.py +224 -39
- armodel/parser/abstract_arxml_parser.py +248 -0
- armodel/parser/arxml_parser.py +1280 -810
- armodel/parser/connector_xlsx_parser.py +190 -0
- armodel/parser/excel_parser.py +18 -0
- armodel/tests/test_armodel/models/test_ar_object.py +152 -0
- armodel/tests/test_armodel/models/test_ar_package.py +1 -1
- armodel/tests/test_armodel/models/test_common_structure.py +2 -2
- armodel/tests/test_armodel/models/test_data_dictionary.py +7 -7
- armodel/tests/test_armodel/models/test_data_prototype.py +2 -2
- armodel/tests/test_armodel/models/test_datatype.py +4 -4
- armodel/tests/test_armodel/models/test_general_structure.py +1 -1
- armodel/tests/test_armodel/models/test_implementation.py +26 -0
- armodel/tests/test_armodel/models/test_m2_msr.py +4 -4
- armodel/tests/test_armodel/parser/test_arxml_parser.py +15 -0
- armodel/tests/test_armodel/parser/test_parse_bswmd.py +70 -46
- armodel/tests/test_armodel/parser/test_sw_components.py +93 -0
- armodel/writer/abstract_arxml_writer.py +123 -0
- armodel/writer/arxml_writer.py +1464 -350
- {armodel-1.4.0.dist-info → armodel-1.4.3.dist-info}/METADATA +90 -3
- armodel-1.4.3.dist-info/RECORD +78 -0
- {armodel-1.4.0.dist-info → armodel-1.4.3.dist-info}/WHEEL +1 -1
- {armodel-1.4.0.dist-info → armodel-1.4.3.dist-info}/entry_points.txt +2 -0
- armodel-1.4.0.dist-info/RECORD +0 -60
- {armodel-1.4.0.dist-info → armodel-1.4.3.dist-info}/LICENSE +0 -0
- {armodel-1.4.0.dist-info → armodel-1.4.3.dist-info}/top_level.txt +0 -0
armodel/__init__.py
CHANGED
armodel/cli/arxml_dump_cli.py
CHANGED
|
@@ -35,12 +35,12 @@ def show_type(indent: int, data_type: ImplementationDataType):
|
|
|
35
35
|
print("%s-Implementation Type: %s (%s)" % (" " * indent, data_type.short_name, data_type.parent.full_name))
|
|
36
36
|
print("%s : %s" % (" " * indent, data_type.category))
|
|
37
37
|
if (data_type.sw_data_def_props != None):
|
|
38
|
-
if (data_type.sw_data_def_props.
|
|
39
|
-
base_type_ref = data_type.sw_data_def_props.
|
|
38
|
+
if (data_type.sw_data_def_props.baseTypeRef != None):
|
|
39
|
+
base_type_ref = data_type.sw_data_def_props.baseTypeRef
|
|
40
40
|
print("%s : %s (%s)" % (" " * indent, base_type_ref.value, base_type_ref.dest))
|
|
41
41
|
|
|
42
|
-
if (data_type.sw_data_def_props.
|
|
43
|
-
implementation_data_type_ref = data_type.sw_data_def_props.
|
|
42
|
+
if (data_type.sw_data_def_props.implementationDataTypeRef != None):
|
|
43
|
+
implementation_data_type_ref = data_type.sw_data_def_props.implementationDataTypeRef
|
|
44
44
|
print("%s : %s (%s)" % (" " * indent, implementation_data_type_ref.value, implementation_data_type_ref.dest))
|
|
45
45
|
|
|
46
46
|
def show_data_type_mapping(indent: int, mapping_set: DataTypeMappingSet):
|
|
@@ -104,8 +104,8 @@ def show_bsw_internal_behavior(indent: int, behavior: BswInternalBehavior):
|
|
|
104
104
|
|
|
105
105
|
for event in behavior.getBswTimingEvents():
|
|
106
106
|
print("%s-%s" % (" " * (indent + 2), event.short_name))
|
|
107
|
-
print("%s-%s: %s" % (" " * (indent + 4), "StartsOnEventRef", event.
|
|
108
|
-
starts_on_event = document.find(event.
|
|
107
|
+
print("%s-%s: %s" % (" " * (indent + 4), "StartsOnEventRef", event.startsOnEventRef.value))
|
|
108
|
+
starts_on_event = document.find(event.startsOnEventRef.value) # type: BswModuleEntity
|
|
109
109
|
print("%s-%s: %s" % (" " * (indent + 4), "StartsOnEvent", starts_on_event.short_name))
|
|
110
110
|
print("%s-%s: %s" % (" " * (indent + 4), "ImplementedEntryRef", starts_on_event.implemented_entry_ref.value))
|
|
111
111
|
implemented_entry = document.find(starts_on_event.implemented_entry_ref.value) # type: BswModuleEntry
|
|
@@ -121,6 +121,8 @@ def show_bsw_module_description(indent: int, description: BswModuleDescription):
|
|
|
121
121
|
def show_ar_package(indent: int, ar_package: ARPackage):
|
|
122
122
|
print("%s-%s (Pkg)" % (" " * indent, ar_package.short_name))
|
|
123
123
|
|
|
124
|
+
for sub_package in ar_package.getARPackages():
|
|
125
|
+
show_ar_package(indent + 2, sub_package)
|
|
124
126
|
#for data_type in ar_package.getImplementationDataTypes():
|
|
125
127
|
# show_type(indent + 2, data_type)
|
|
126
128
|
#for mapping_set in ar_package.getDataTypeMappingSets():
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import pkg_resources
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
import os.path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from ..models.ar_package import AUTOSAR
|
|
9
|
+
from ..parser.arxml_parser import ARXMLParser
|
|
10
|
+
from ..parser.connector_xlsx_parser import ConnectorXlsReader
|
|
11
|
+
|
|
12
|
+
from ..lib import InputFileParser
|
|
13
|
+
from ..writer import ARXMLWriter
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
version = pkg_resources.require("armodel")[0].version
|
|
17
|
+
|
|
18
|
+
ap = argparse.ArgumentParser()
|
|
19
|
+
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
20
|
+
ap.add_argument("-w", "--warning", required= False, help= "Skip the error and report it as warning message", action= "store_true")
|
|
21
|
+
ap.add_argument("INPUT", help = "The path of AUTOSAR ARXML file")
|
|
22
|
+
ap.add_argument("OUTPUT", help = "The path of output ARXML file")
|
|
23
|
+
|
|
24
|
+
args = ap.parse_args()
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger()
|
|
27
|
+
|
|
28
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
29
|
+
|
|
30
|
+
stdout_handler = logging.StreamHandler(sys.stderr)
|
|
31
|
+
stdout_handler.setFormatter(formatter)
|
|
32
|
+
|
|
33
|
+
base_path = os.path.dirname(args.OUTPUT)
|
|
34
|
+
log_file = os.path.join(base_path, 'arxml_format.log')
|
|
35
|
+
|
|
36
|
+
if os.path.exists(log_file):
|
|
37
|
+
os.remove(log_file)
|
|
38
|
+
|
|
39
|
+
file_handler = logging.FileHandler(log_file)
|
|
40
|
+
file_handler.setFormatter(formatter)
|
|
41
|
+
|
|
42
|
+
logger.setLevel(logging.DEBUG)
|
|
43
|
+
file_handler.setLevel(logging.DEBUG)
|
|
44
|
+
|
|
45
|
+
if args.verbose:
|
|
46
|
+
stdout_handler.setLevel(logging.DEBUG)
|
|
47
|
+
|
|
48
|
+
else:
|
|
49
|
+
stdout_handler.setLevel(logging.INFO)
|
|
50
|
+
|
|
51
|
+
logger.addHandler(file_handler)
|
|
52
|
+
logger.addHandler(stdout_handler)
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
options = {}
|
|
56
|
+
if args.warning:
|
|
57
|
+
options['warning'] = True
|
|
58
|
+
|
|
59
|
+
document = AUTOSAR().getInstance()
|
|
60
|
+
parser = ARXMLParser(options)
|
|
61
|
+
parser.load(args.INPUT, document)
|
|
62
|
+
|
|
63
|
+
writer = ARXMLWriter()
|
|
64
|
+
writer.save(args.OUTPUT, document)
|
|
65
|
+
|
|
66
|
+
except Exception as e:
|
|
67
|
+
#print(e)
|
|
68
|
+
logger.error(e)
|
|
69
|
+
raise e
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
main()
|
|
@@ -4,8 +4,10 @@ import logging
|
|
|
4
4
|
import sys
|
|
5
5
|
import os.path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
from
|
|
7
|
+
|
|
8
|
+
from ..models.ar_package import AUTOSAR
|
|
9
|
+
from ..parser.arxml_parser import ARXMLParser
|
|
10
|
+
from ..parser.connector_xlsx_parser import ConnectorXlsReader
|
|
9
11
|
|
|
10
12
|
from ..lib import InputFileParser
|
|
11
13
|
from ..writer import ARXMLWriter
|
|
@@ -16,9 +18,9 @@ def main():
|
|
|
16
18
|
ap = argparse.ArgumentParser()
|
|
17
19
|
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
18
20
|
ap.add_argument("-w", "--warning", required= False, help= "Skip the error and report it as warning message", action= "store_true")
|
|
19
|
-
ap.add_argument("INPUT", help = "The path of
|
|
21
|
+
ap.add_argument("INPUT", help = "The path of input ARXML file")
|
|
20
22
|
ap.add_argument("MAPPING", help = "The path of connector excel file which exports with connector2xlsx")
|
|
21
|
-
ap.add_argument("OUTPUT", help = "The path of output
|
|
23
|
+
ap.add_argument("OUTPUT", help = "The path of output ARXML file")
|
|
22
24
|
|
|
23
25
|
args = ap.parse_args()
|
|
24
26
|
|
|
@@ -59,11 +61,16 @@ def main():
|
|
|
59
61
|
parser = ARXMLParser(options)
|
|
60
62
|
parser.load(args.INPUT, document)
|
|
61
63
|
|
|
64
|
+
reader = ConnectorXlsReader()
|
|
65
|
+
reader.read(args.MAPPING)
|
|
66
|
+
reader.update(document)
|
|
67
|
+
|
|
62
68
|
writer = ARXMLWriter()
|
|
63
69
|
writer.save(args.OUTPUT, document)
|
|
64
70
|
|
|
65
71
|
except Exception as e:
|
|
66
72
|
#print(e)
|
|
73
|
+
logger.error(e)
|
|
67
74
|
raise e
|
|
68
75
|
|
|
69
76
|
if __name__ == "__main__":
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class SwConnectorData:
|
|
2
|
+
def __init__(self) -> None:
|
|
3
|
+
self.short_name = ""
|
|
4
|
+
|
|
5
|
+
class DelegationSwConnectorData(SwConnectorData):
|
|
6
|
+
def __init__(self) -> None:
|
|
7
|
+
super().__init__()
|
|
8
|
+
|
|
9
|
+
self.inner_swc = ""
|
|
10
|
+
self.inner_pport = ""
|
|
11
|
+
self.inner_rport = ""
|
|
12
|
+
self.outer_pport = ""
|
|
13
|
+
self.outer_rport = ""
|
|
14
|
+
|
|
15
|
+
class AssemblySwConnectorData(SwConnectorData):
|
|
16
|
+
def __init__(self) -> None:
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
self.provider_swc= ""
|
|
20
|
+
self.pport = ""
|
|
21
|
+
self.requester_swc = ""
|
|
22
|
+
self.rport = ""
|
armodel/lib/data_analyzer.py
CHANGED
|
@@ -29,6 +29,6 @@ class SwComponentAnalyzer:
|
|
|
29
29
|
|
|
30
30
|
for swc in sorted(swc_list, key = lambda o: o.short_name):
|
|
31
31
|
if option['format'] == 'long':
|
|
32
|
-
logger.info("%s
|
|
32
|
+
logger.info("%s" % swc.full_name)
|
|
33
33
|
else:
|
|
34
34
|
logger.info("%s" % swc.short_name)
|
armodel/models/__init__.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
from .annotation import *
|
|
2
|
+
from .ar_object import *
|
|
1
3
|
from .general_structure import *
|
|
2
4
|
from .common_structure import *
|
|
3
5
|
from .sw_component import *
|
|
4
|
-
from .ar_package import
|
|
6
|
+
from .ar_package import *
|
|
5
7
|
from .ar_ref import *
|
|
6
8
|
from .datatype import *
|
|
7
9
|
from .port_prototype import *
|
|
@@ -13,6 +15,5 @@ from .implementation import *
|
|
|
13
15
|
from .bsw_module_template import *
|
|
14
16
|
from .communication import *
|
|
15
17
|
from .calibration import *
|
|
16
|
-
from .ar_object import *
|
|
17
18
|
from .global_constraints import *
|
|
18
19
|
from .unit import *
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
from abc import ABCMeta
|
|
3
|
+
|
|
4
|
+
from .multilanguage_data import MultilanguageLongName
|
|
5
|
+
from .ar_object import ARObject
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class GeneralAnnotation(ARObject, metaclass=ABCMeta):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
if type(self) == ARObject:
|
|
11
|
+
raise NotImplementedError("GeneralAnnotation is an abstract class.")
|
|
12
|
+
|
|
13
|
+
self.label = None # type: MultilanguageLongName
|
|
14
|
+
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
class Annotation(GeneralAnnotation):
|
|
18
|
+
def __init__(self):
|
|
19
|
+
super().__init__()
|
|
20
|
+
|
armodel/models/ar_object.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
from abc import ABCMeta
|
|
2
|
-
|
|
2
|
+
import re
|
|
3
|
+
from typing import Dict, List
|
|
4
|
+
|
|
5
|
+
import xml.etree.cElementTree as ET
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
class ARObject(metaclass=ABCMeta):
|
|
5
9
|
def __init__(self):
|
|
@@ -12,38 +16,179 @@ class ARObject(metaclass=ABCMeta):
|
|
|
12
16
|
self.timestamp = None # type: str
|
|
13
17
|
self.uuid = None # type: str
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
def getTagName(self, tag: str, nsmap: Dict) -> str:
|
|
20
|
+
return tag.replace("{%s}" % nsmap["xmlns"], "")
|
|
21
|
+
|
|
16
22
|
class ARType(metaclass=ABCMeta):
|
|
17
23
|
def __init__(self) -> None:
|
|
18
24
|
self.timestamp = None # type: str
|
|
19
25
|
self.uuid = None # type: str
|
|
26
|
+
self._value = None
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
def
|
|
23
|
-
|
|
28
|
+
@property
|
|
29
|
+
def value(self):
|
|
30
|
+
return self._value
|
|
31
|
+
|
|
32
|
+
@value.setter
|
|
33
|
+
def value(self, val):
|
|
34
|
+
self._value = val
|
|
35
|
+
|
|
36
|
+
def getValue(self):
|
|
37
|
+
return self.value
|
|
38
|
+
|
|
39
|
+
def setValue(self, val):
|
|
40
|
+
self.value = val
|
|
24
41
|
|
|
25
|
-
|
|
42
|
+
def getText(self) -> str:
|
|
43
|
+
return str(self)
|
|
44
|
+
|
|
45
|
+
|
|
26
46
|
class ARLiteral(ARType):
|
|
27
47
|
def __init__(self) -> None:
|
|
28
48
|
super().__init__()
|
|
29
49
|
|
|
30
|
-
|
|
50
|
+
@property
|
|
51
|
+
def value(self) -> str:
|
|
52
|
+
if self._value is None:
|
|
53
|
+
return ""
|
|
54
|
+
return self._value
|
|
55
|
+
|
|
56
|
+
@value.setter
|
|
57
|
+
def value(self, val: any):
|
|
58
|
+
if isinstance(val, str):
|
|
59
|
+
self._value = val
|
|
60
|
+
else:
|
|
61
|
+
self._value = str(val)
|
|
62
|
+
|
|
63
|
+
def __str__(self) -> str:
|
|
64
|
+
return self.value
|
|
65
|
+
|
|
66
|
+
def upper(self) -> str:
|
|
67
|
+
return self.value.upper()
|
|
31
68
|
|
|
32
|
-
class
|
|
33
|
-
def __init__(self):
|
|
69
|
+
class ARNumerical(ARType):
|
|
70
|
+
def __init__(self) -> None:
|
|
34
71
|
super().__init__()
|
|
35
72
|
|
|
36
|
-
self.
|
|
37
|
-
self.value = ""
|
|
73
|
+
self._text = None # type: str
|
|
38
74
|
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
def _convertStringToNumberValue(self, value: str) -> int:
|
|
76
|
+
m = re.match(r"0x([0-9a-f]+)", value, re.I)
|
|
77
|
+
if (m):
|
|
78
|
+
return int(m.group(1), 16)
|
|
79
|
+
return int(value)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def value(self) -> int:
|
|
83
|
+
return self._value
|
|
84
|
+
|
|
85
|
+
@value.setter
|
|
86
|
+
def value(self, val: any):
|
|
87
|
+
if isinstance(val, int):
|
|
88
|
+
self._value = val
|
|
89
|
+
elif isinstance(val, str):
|
|
90
|
+
self._text = val
|
|
91
|
+
self._value = self._convertStringToNumberValue(val)
|
|
92
|
+
else:
|
|
93
|
+
raise ValueError("Unsupported Type <%s>", type(val))
|
|
94
|
+
|
|
95
|
+
def __str__(self) -> str:
|
|
96
|
+
if self._text is not None:
|
|
97
|
+
return self._text
|
|
98
|
+
else:
|
|
99
|
+
return str(self._value)
|
|
100
|
+
|
|
101
|
+
class ARPositiveInteger(ARNumerical):
|
|
102
|
+
def __init__(self) -> None:
|
|
41
103
|
super().__init__()
|
|
42
104
|
|
|
43
|
-
|
|
105
|
+
@property
|
|
106
|
+
def value(self) -> int:
|
|
107
|
+
return self._value
|
|
108
|
+
|
|
109
|
+
@value.setter
|
|
110
|
+
def value(self, val: any):
|
|
111
|
+
if isinstance(val, int):
|
|
112
|
+
if val < 0:
|
|
113
|
+
raise ValueError("Invalid Positive Integer <%s>" % val)
|
|
114
|
+
self._value = val
|
|
115
|
+
elif isinstance(val, str):
|
|
116
|
+
self._text = val
|
|
117
|
+
self._value = self._convertStringToNumberValue(val)
|
|
118
|
+
else:
|
|
119
|
+
raise ValueError("Unsupported Type <%s>", type(val))
|
|
120
|
+
|
|
121
|
+
class ARFloat(ARType):
|
|
122
|
+
def __init__(self) -> None:
|
|
123
|
+
super().__init__()
|
|
124
|
+
|
|
125
|
+
self._text = None # type: str
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def value(self) -> float:
|
|
129
|
+
return self._value
|
|
130
|
+
|
|
131
|
+
@value.setter
|
|
132
|
+
def value(self, val: any):
|
|
133
|
+
if isinstance(val, float):
|
|
134
|
+
self._value = val
|
|
135
|
+
elif isinstance(val, int):
|
|
136
|
+
self._value = val * 1.0
|
|
137
|
+
elif isinstance(val, str):
|
|
138
|
+
self._text = val
|
|
139
|
+
self._value = float(val)
|
|
140
|
+
else:
|
|
141
|
+
raise ValueError("Unsupported Type <%s>", type(val))
|
|
142
|
+
|
|
143
|
+
def __str__(self) -> str:
|
|
144
|
+
if self._text is not None:
|
|
145
|
+
return self._text
|
|
146
|
+
else:
|
|
147
|
+
return str(self._value)
|
|
148
|
+
|
|
149
|
+
class ARBoolean(ARType):
|
|
150
|
+
def __init__(self) -> None:
|
|
151
|
+
super().__init__()
|
|
152
|
+
|
|
153
|
+
self._text = None
|
|
154
|
+
|
|
155
|
+
def _convertNumberToBoolean(self, value: int) -> bool:
|
|
156
|
+
if value == 0:
|
|
157
|
+
return False
|
|
158
|
+
return True
|
|
159
|
+
|
|
160
|
+
def _convertStringToBoolean(self, value: str) -> bool:
|
|
161
|
+
value = value.lower()
|
|
162
|
+
if value == "true":
|
|
163
|
+
return True
|
|
164
|
+
elif value == "false":
|
|
165
|
+
return False
|
|
166
|
+
else:
|
|
167
|
+
return self._convertNumberToBoolean(int(value))
|
|
44
168
|
|
|
45
|
-
|
|
46
|
-
|
|
169
|
+
@property
|
|
170
|
+
def value(self) -> int:
|
|
171
|
+
return self._value
|
|
172
|
+
|
|
173
|
+
@value.setter
|
|
174
|
+
def value(self, val: any):
|
|
175
|
+
if isinstance(val, bool):
|
|
176
|
+
self._value = val
|
|
177
|
+
elif isinstance(val, int):
|
|
178
|
+
self._value = self._convertNumberToBoolean(val)
|
|
179
|
+
self._text = str(val)
|
|
180
|
+
elif isinstance(val, str):
|
|
181
|
+
self._text = val
|
|
182
|
+
self._value = self._convertStringToBoolean(val)
|
|
183
|
+
else:
|
|
184
|
+
raise ValueError("Unsupported Type <%s>", type(val))
|
|
47
185
|
|
|
48
|
-
def
|
|
49
|
-
|
|
186
|
+
def __str__(self) -> str:
|
|
187
|
+
if self._text is not None:
|
|
188
|
+
return self._text
|
|
189
|
+
else:
|
|
190
|
+
if self._value:
|
|
191
|
+
return "true"
|
|
192
|
+
else:
|
|
193
|
+
return "false"
|
|
194
|
+
|
armodel/models/ar_package.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import Dict, List
|
|
2
2
|
|
|
3
|
+
from .data_dictionary import SwAddrMethod
|
|
4
|
+
from .record_layout import SwRecordLayout
|
|
5
|
+
from .end_to_end_protection import EndToEndProtectionSet
|
|
3
6
|
from .unit import Unit
|
|
4
7
|
from .general_structure import Identifiable, ARObject, Referrable, CollectableElement, SwcBswMapping
|
|
5
|
-
from .port_interface import SenderReceiverInterface, ClientServerInterface
|
|
6
|
-
from .sw_component import SwComponentType, EcuAbstractionSwComponentType, AtomicSwComponentType, ApplicationSwComponentType
|
|
7
|
-
from .
|
|
8
|
+
from .port_interface import ModeSwitchInterface, SenderReceiverInterface, ClientServerInterface, TriggerInterface
|
|
9
|
+
from .sw_component import SwComponentType, EcuAbstractionSwComponentType, AtomicSwComponentType, ApplicationSwComponentType
|
|
10
|
+
from .sw_component import ServiceSwComponentType, CompositionSwComponentType, SensorActuatorSwComponentType, ComplexDeviceDriverSwComponentType
|
|
11
|
+
from .datatype import ApplicationArrayDataType, ImplementationDataType, ApplicationDataType, DataTypeMappingSet, DataTypeMap, SwBaseType, ApplicationPrimitiveDataType, ApplicationRecordDataType
|
|
8
12
|
from .m2_msr import CompuMethod
|
|
9
|
-
from .common_structure import ConstantSpecification
|
|
13
|
+
from .common_structure import ConstantSpecification, ModeDeclarationGroup
|
|
10
14
|
from .implementation import BswImplementation, SwcImplementation, Implementation
|
|
11
15
|
from .bsw_module_template import BswModuleDescription, BswModuleEntry
|
|
12
16
|
from .global_constraints import DataConstr
|
|
@@ -16,14 +20,28 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
16
20
|
Identifiable.__init__(self, parent, short_name)
|
|
17
21
|
CollectableElement.__init__(self)
|
|
18
22
|
|
|
23
|
+
self._ar_packages = {} # type: Dict[str, ARPackage]
|
|
24
|
+
|
|
19
25
|
def getARPackages(self): # type: (...) -> List[ARPackage]
|
|
20
|
-
return list(
|
|
26
|
+
return list(sorted(self._ar_packages.values(), key= lambda a: a.short_name))
|
|
27
|
+
#return list(filter(lambda e: isinstance(e, ARPackage), self.elements.values()))
|
|
21
28
|
|
|
22
29
|
def createARPackage(self, short_name: str):
|
|
30
|
+
'''
|
|
23
31
|
if (short_name not in self.elements):
|
|
24
32
|
ar_package = ARPackage(self, short_name)
|
|
25
33
|
self.elements[short_name] = ar_package
|
|
26
34
|
return self.elements[short_name]
|
|
35
|
+
'''
|
|
36
|
+
if short_name not in self._ar_packages:
|
|
37
|
+
ar_package = ARPackage(self, short_name)
|
|
38
|
+
self._ar_packages[short_name] = ar_package
|
|
39
|
+
return self._ar_packages[short_name]
|
|
40
|
+
|
|
41
|
+
def getElement(self, short_name: str) -> Referrable:
|
|
42
|
+
if (short_name in self._ar_packages):
|
|
43
|
+
return self._ar_packages[short_name]
|
|
44
|
+
return CollectableElement.getElement(self, short_name)
|
|
27
45
|
|
|
28
46
|
def createEcuAbstractionSwComponentType(self, short_name: str) -> EcuAbstractionSwComponentType:
|
|
29
47
|
if (short_name not in self.elements):
|
|
@@ -32,10 +50,16 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
32
50
|
return self.elements[short_name]
|
|
33
51
|
|
|
34
52
|
def createApplicationSwComponentType(self, short_name: str) -> ApplicationSwComponentType:
|
|
35
|
-
if
|
|
53
|
+
if short_name not in self.elements:
|
|
36
54
|
sw_component = ApplicationSwComponentType(self, short_name)
|
|
37
55
|
self.elements[short_name] = sw_component
|
|
38
56
|
return self.elements[short_name]
|
|
57
|
+
|
|
58
|
+
def createComplexDeviceDriverSwComponentType(self, short_name: str) -> ComplexDeviceDriverSwComponentType:
|
|
59
|
+
if short_name not in self.elements:
|
|
60
|
+
sw_component = ComplexDeviceDriverSwComponentType(self, short_name)
|
|
61
|
+
self.elements[short_name] = sw_component
|
|
62
|
+
return self.elements[short_name]
|
|
39
63
|
|
|
40
64
|
def createServiceSwComponentType(self, short_name: str) -> ServiceSwComponentType:
|
|
41
65
|
if (short_name not in self.elements):
|
|
@@ -150,6 +174,48 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
150
174
|
spec = Unit(self, short_name)
|
|
151
175
|
self.elements[short_name] = spec
|
|
152
176
|
return self.elements[short_name]
|
|
177
|
+
|
|
178
|
+
def createEndToEndProtectionSet(self, short_name: str) -> EndToEndProtectionSet:
|
|
179
|
+
if (short_name not in self.elements):
|
|
180
|
+
spec = EndToEndProtectionSet(self, short_name)
|
|
181
|
+
self.elements[short_name] = spec
|
|
182
|
+
return self.elements[short_name]
|
|
183
|
+
|
|
184
|
+
def createApplicationArrayDataType(self, short_name: str) -> ApplicationArrayDataType:
|
|
185
|
+
if (short_name not in self.elements):
|
|
186
|
+
spec = ApplicationArrayDataType(self, short_name)
|
|
187
|
+
self.elements[short_name] = spec
|
|
188
|
+
return self.elements[short_name]
|
|
189
|
+
|
|
190
|
+
def createSwRecordLayout(self, short_name: str) -> SwRecordLayout:
|
|
191
|
+
if (short_name not in self.elements):
|
|
192
|
+
spec = SwRecordLayout(self, short_name)
|
|
193
|
+
self.elements[short_name] = spec
|
|
194
|
+
return self.elements[short_name]
|
|
195
|
+
|
|
196
|
+
def createSwAddrMethod(self, short_name: str) -> SwAddrMethod:
|
|
197
|
+
if (short_name not in self.elements):
|
|
198
|
+
spec = SwAddrMethod(self, short_name)
|
|
199
|
+
self.elements[short_name] = spec
|
|
200
|
+
return self.elements[short_name]
|
|
201
|
+
|
|
202
|
+
def createTriggerInterface(self, short_name: str) -> TriggerInterface:
|
|
203
|
+
if (short_name not in self.elements):
|
|
204
|
+
spec = TriggerInterface(self, short_name)
|
|
205
|
+
self.elements[short_name] = spec
|
|
206
|
+
return self.elements[short_name]
|
|
207
|
+
|
|
208
|
+
def createModeDeclarationGroup(self, short_name: str) -> ModeDeclarationGroup:
|
|
209
|
+
if (short_name not in self.elements):
|
|
210
|
+
spec = ModeDeclarationGroup(self, short_name)
|
|
211
|
+
self.elements[short_name] = spec
|
|
212
|
+
return self.elements[short_name]
|
|
213
|
+
|
|
214
|
+
def createModeSwitchInterface(self, short_name: str) -> ModeSwitchInterface:
|
|
215
|
+
if (short_name not in self.elements):
|
|
216
|
+
spec = ModeSwitchInterface(self, short_name)
|
|
217
|
+
self.elements[short_name] = spec
|
|
218
|
+
return self.elements[short_name]
|
|
153
219
|
|
|
154
220
|
def getApplicationPrimitiveDataTypes(self) -> List[ApplicationPrimitiveDataType]:
|
|
155
221
|
return list(filter(lambda a: isinstance(a, ApplicationPrimitiveDataType), self.elements.values()))
|
|
@@ -174,6 +240,9 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
174
240
|
|
|
175
241
|
def getCompositionSwComponentTypes(self) -> List[CompositionSwComponentType]:
|
|
176
242
|
return list(filter(lambda a : isinstance(a, CompositionSwComponentType), self.elements.values()))
|
|
243
|
+
|
|
244
|
+
def getComplexDeviceDriverSwComponentTypes(self) -> List[ComplexDeviceDriverSwComponentType]:
|
|
245
|
+
return list(sorted(filter(lambda a : isinstance(a, ComplexDeviceDriverSwComponentType), self.elements.values()), key = lambda a: a.short_name))
|
|
177
246
|
|
|
178
247
|
def getSenderReceiverInterfaces(self) -> List[SenderReceiverInterface]:
|
|
179
248
|
return list(filter(lambda a : isinstance(a, SenderReceiverInterface), self.elements.values()))
|
|
@@ -213,6 +282,24 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
213
282
|
|
|
214
283
|
def getUnits(self) -> List[Unit]:
|
|
215
284
|
return list(filter(lambda a: isinstance(a, Unit), self.elements.values()))
|
|
285
|
+
|
|
286
|
+
def getApplicationArrayDataTypes(self) -> List[ApplicationArrayDataType]:
|
|
287
|
+
return list(sorted(filter(lambda a : isinstance(a, ApplicationArrayDataType), self.elements.values()), key = lambda a: a.short_name))
|
|
288
|
+
|
|
289
|
+
def getSwRecordLayouts(self) -> List[SwRecordLayout]:
|
|
290
|
+
return list(sorted(filter(lambda a : isinstance(a, SwRecordLayout), self.elements.values()), key = lambda a: a.short_name))
|
|
291
|
+
|
|
292
|
+
def getSwAddrMethods(self) -> List[SwAddrMethod]:
|
|
293
|
+
return list(sorted(filter(lambda a : isinstance(a, SwAddrMethod), self.elements.values()), key = lambda a: a.short_name))
|
|
294
|
+
|
|
295
|
+
def getTriggerInterfaces(self) -> List[TriggerInterface]:
|
|
296
|
+
return list(sorted(filter(lambda a : isinstance(a, TriggerInterface), self.elements.values()), key = lambda a: a.short_name))
|
|
297
|
+
|
|
298
|
+
def getModeDeclarationGroups(self) -> List[ModeDeclarationGroup]:
|
|
299
|
+
return list(sorted(filter(lambda a : isinstance(a, ModeDeclarationGroup), self.elements.values()), key = lambda a: a.short_name))
|
|
300
|
+
|
|
301
|
+
def getModeSwitchInterfaces(self) -> List[ModeSwitchInterface]:
|
|
302
|
+
return list(sorted(filter(lambda a : isinstance(a, ModeSwitchInterface), self.elements.values()), key = lambda a: a.short_name))
|
|
216
303
|
|
|
217
304
|
class AUTOSAR (CollectableElement):
|
|
218
305
|
__instance = None
|
|
@@ -228,26 +315,35 @@ class AUTOSAR (CollectableElement):
|
|
|
228
315
|
raise Exception("The AUTOSAR is singleton!")
|
|
229
316
|
CollectableElement.__init__(self)
|
|
230
317
|
|
|
231
|
-
self.
|
|
318
|
+
self.schema_location = ""
|
|
232
319
|
self._appl_impl_type_maps = {}
|
|
233
320
|
self._impl_appl_type_maps = {}
|
|
234
321
|
AUTOSAR.__instance = self
|
|
235
322
|
|
|
323
|
+
self._ar_packages = {} # type: Dict[str, ARPackage]
|
|
324
|
+
|
|
236
325
|
@property
|
|
237
326
|
def full_name(self):
|
|
238
327
|
return ""
|
|
239
328
|
|
|
240
329
|
def clear(self):
|
|
330
|
+
self._ar_packages = {}
|
|
241
331
|
self.elements = {}
|
|
242
332
|
|
|
333
|
+
def getElement(self, short_name: str) -> Referrable:
|
|
334
|
+
if (short_name in self._ar_packages):
|
|
335
|
+
return self._ar_packages[short_name]
|
|
336
|
+
return CollectableElement.getElement(self, short_name)
|
|
337
|
+
|
|
243
338
|
def getARPackages(self) -> List[ARPackage]:
|
|
244
|
-
return list(filter(lambda e: isinstance(e, ARPackage), self.elements.values()))
|
|
339
|
+
#return list(filter(lambda e: isinstance(e, ARPackage), self.elements.values()))
|
|
340
|
+
return list(sorted(self._ar_packages.values(), key= lambda a: a.short_name))
|
|
245
341
|
|
|
246
342
|
def createARPackage(self, short_name: str) -> ARPackage:
|
|
247
|
-
if (short_name not in self.
|
|
343
|
+
if (short_name not in self._ar_packages):
|
|
248
344
|
ar_package = ARPackage(self, short_name)
|
|
249
|
-
self.
|
|
250
|
-
return self.
|
|
345
|
+
self._ar_packages[short_name] = ar_package
|
|
346
|
+
return self._ar_packages[short_name]
|
|
251
347
|
|
|
252
348
|
def find(self, referred_name: str) -> Referrable:
|
|
253
349
|
short_name_list = referred_name.split("/")
|
|
@@ -264,11 +360,11 @@ class AUTOSAR (CollectableElement):
|
|
|
264
360
|
def getDataType(self, data_type: ImplementationDataType) -> ImplementationDataType:
|
|
265
361
|
if (isinstance(data_type, ImplementationDataType) or isinstance(data_type, SwBaseType)):
|
|
266
362
|
if (data_type.category == ImplementationDataType.CATEGORY_TYPE_REFERENCE):
|
|
267
|
-
referred_type = self.find(data_type.sw_data_def_props.
|
|
363
|
+
referred_type = self.find(data_type.sw_data_def_props.implementationDataTypeRef.value)
|
|
268
364
|
return self.getDataType(referred_type)
|
|
269
365
|
if (data_type.category == ImplementationDataType.CATEGORY_DATA_REFERENCE):
|
|
270
366
|
if (data_type.sw_data_def_props.sw_pointer_target_props.target_category == "VALUE"):
|
|
271
|
-
referred_type = self.find(data_type.sw_data_def_props.sw_pointer_target_props.sw_data_def_props.
|
|
367
|
+
referred_type = self.find(data_type.sw_data_def_props.sw_pointer_target_props.sw_data_def_props.baseTypeRef.value)
|
|
272
368
|
return self.getDataType(referred_type)
|
|
273
369
|
return data_type
|
|
274
370
|
else:
|