armodel 1.2.0__py3-none-any.whl → 1.4.0__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/cli/arxml_dump_cli.py +8 -8
- armodel/cli/connector2xlsx_cli.py +75 -0
- armodel/cli/connector_update_cli.py +70 -0
- armodel/cli/swc_list_cli.py +81 -0
- armodel/lib/__init__.py +3 -0
- armodel/lib/cli_args_parser.py +36 -0
- armodel/lib/data_analyzer.py +34 -0
- armodel/lib/sw_component.py +34 -0
- armodel/models/__init__.py +6 -1
- armodel/models/ar_object.py +40 -1
- armodel/models/ar_package.py +35 -1
- armodel/models/ar_ref.py +12 -2
- armodel/models/bsw_module_template.py +3 -2
- armodel/models/calibration.py +16 -0
- armodel/models/common_structure.py +92 -0
- armodel/models/communication.py +8 -0
- armodel/models/datatype.py +23 -5
- armodel/models/general_structure.py +48 -3
- armodel/models/global_constraints.py +40 -0
- armodel/models/m2_msr.py +76 -2
- armodel/models/port_prototype.py +21 -16
- armodel/models/sw_component.py +49 -18
- armodel/models/unit.py +14 -0
- armodel/parser/arxml_parser.py +595 -151
- armodel/parser/excel_parser.py +0 -0
- armodel/report/__init__.py +1 -0
- armodel/report/connector_xls_report.py +76 -0
- armodel/report/excel_report.py +42 -0
- armodel/tests/__init__.py +0 -0
- armodel/tests/test_armodel/__init__.py +0 -0
- armodel/tests/test_armodel/models/__init__.py +0 -0
- armodel/tests/test_armodel/models/test_ar_package.py +294 -0
- armodel/tests/test_armodel/models/test_ar_ref.py +74 -0
- armodel/tests/test_armodel/models/test_bsw_module_template.py +46 -0
- armodel/tests/test_armodel/models/test_common_structure.py +73 -0
- armodel/tests/test_armodel/models/test_data_dictionary.py +29 -0
- armodel/tests/test_armodel/models/test_data_prototype.py +86 -0
- armodel/tests/test_armodel/models/test_datatype.py +239 -0
- armodel/tests/test_armodel/models/test_general_structure.py +50 -0
- armodel/tests/test_armodel/models/test_m2_msr.py +77 -0
- armodel/tests/test_armodel/models/test_port_interface.py +198 -0
- armodel/tests/test_armodel/models/test_port_prototype.py +14 -0
- armodel/tests/test_armodel/parser/__init__.py +0 -0
- armodel/tests/test_armodel/parser/test_parse_bswmd.py +168 -0
- armodel/writer/__init__.py +1 -0
- armodel/writer/arxml_writer.py +641 -0
- {armodel-1.2.0.dist-info → armodel-1.4.0.dist-info}/METADATA +69 -5
- armodel-1.4.0.dist-info/RECORD +60 -0
- {armodel-1.2.0.dist-info → armodel-1.4.0.dist-info}/WHEEL +1 -1
- armodel-1.4.0.dist-info/entry_points.txt +5 -0
- armodel-1.2.0.dist-info/RECORD +0 -27
- armodel-1.2.0.dist-info/entry_points.txt +0 -3
- {armodel-1.2.0.dist-info → armodel-1.4.0.dist-info}/LICENSE +0 -0
- {armodel-1.2.0.dist-info → armodel-1.4.0.dist-info}/top_level.txt +0 -0
armodel/cli/arxml_dump_cli.py
CHANGED
|
@@ -17,16 +17,16 @@ def show_variable_access(indent:int, variable_access: VariableAccess):
|
|
|
17
17
|
print("%s: %s" % (" " * indent, autosar_variable_in_impl_datatype.port_prototype.value))
|
|
18
18
|
print("%s: %s" % (" " * indent, autosar_variable_in_impl_datatype.target_data_prototype.value))
|
|
19
19
|
|
|
20
|
-
def show_port(indent:int,
|
|
21
|
-
if (isinstance(
|
|
22
|
-
print("%s-RPort: %s (%s)" % (" " * indent,
|
|
23
|
-
for client_com_spec in
|
|
20
|
+
def show_port(indent:int, port_prototype: PortPrototype):
|
|
21
|
+
if (isinstance(port_prototype, RPortPrototype)):
|
|
22
|
+
print("%s-RPort: %s (%s)" % (" " * indent, port_prototype.short_name, port_prototype.required_interface_tref.value))
|
|
23
|
+
for client_com_spec in port_prototype.getClientComSpecs():
|
|
24
24
|
print("%s : %s (ClientComSpec)" % (" " * (indent + 2), client_com_spec.operation_ref.value))
|
|
25
|
-
for com_spec in
|
|
25
|
+
for com_spec in port_prototype.getNonqueuedReceiverComSpecs():
|
|
26
26
|
print("%s : %s (NonqueuedReceiverComSpec)" % (" " * (indent + 2), com_spec.data_element_ref.value))
|
|
27
|
-
elif (isinstance(
|
|
28
|
-
print("%s-PPort: %s (%s)" % (" " * indent,
|
|
29
|
-
for com_spec in
|
|
27
|
+
elif (isinstance(port_prototype, PPortPrototype)):
|
|
28
|
+
print("%s-PPort: %s (%s)" % (" " * indent, port_prototype.short_name, port_prototype.provided_interface_tref.value))
|
|
29
|
+
for com_spec in port_prototype.getNonqueuedSenderComSpecs():
|
|
30
30
|
print("%s : %s (NonqueuedSenderComSpec)" % (" " * (indent + 2), com_spec.data_element_ref.value))
|
|
31
31
|
else:
|
|
32
32
|
raise ValueError("Unsupported Port prototype")
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import pkg_resources
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
import os.path
|
|
6
|
+
|
|
7
|
+
from armodel import AUTOSAR
|
|
8
|
+
from armodel.parser import ARXMLParser
|
|
9
|
+
|
|
10
|
+
from ..lib import InputFileParser
|
|
11
|
+
from ..report import ConnectorXlsReport
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
version = pkg_resources.require("armodel")[0].version
|
|
15
|
+
|
|
16
|
+
ap = argparse.ArgumentParser()
|
|
17
|
+
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
18
|
+
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 AUTOSAR XML", nargs='+')
|
|
20
|
+
ap.add_argument("OUTPUT", help = "The path of output excel file")
|
|
21
|
+
|
|
22
|
+
args = ap.parse_args()
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger()
|
|
25
|
+
|
|
26
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
27
|
+
|
|
28
|
+
stdout_handler = logging.StreamHandler(sys.stderr)
|
|
29
|
+
stdout_handler.setFormatter(formatter)
|
|
30
|
+
|
|
31
|
+
base_path = os.path.dirname(args.OUTPUT)
|
|
32
|
+
log_file = os.path.join(base_path, 'connector.log')
|
|
33
|
+
|
|
34
|
+
if os.path.exists(log_file):
|
|
35
|
+
os.remove(log_file)
|
|
36
|
+
|
|
37
|
+
file_handler = logging.FileHandler(log_file)
|
|
38
|
+
file_handler.setFormatter(formatter)
|
|
39
|
+
|
|
40
|
+
logger.setLevel(logging.DEBUG)
|
|
41
|
+
file_handler.setLevel(logging.DEBUG)
|
|
42
|
+
|
|
43
|
+
if args.verbose:
|
|
44
|
+
stdout_handler.setLevel(logging.DEBUG)
|
|
45
|
+
|
|
46
|
+
else:
|
|
47
|
+
stdout_handler.setLevel(logging.INFO)
|
|
48
|
+
|
|
49
|
+
logger.addHandler(file_handler)
|
|
50
|
+
logger.addHandler(stdout_handler)
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
parser = InputFileParser(args.INPUT)
|
|
54
|
+
filenames = parser.parse()
|
|
55
|
+
|
|
56
|
+
options = {}
|
|
57
|
+
if args.warning:
|
|
58
|
+
options['warning'] = True
|
|
59
|
+
|
|
60
|
+
document = AUTOSAR().getInstance()
|
|
61
|
+
parser = ARXMLParser(options)
|
|
62
|
+
|
|
63
|
+
for filename in filenames:
|
|
64
|
+
parser.load(filename, document)
|
|
65
|
+
|
|
66
|
+
writer = ConnectorXlsReport()
|
|
67
|
+
writer.import_data(document)
|
|
68
|
+
writer.write(args.OUTPUT)
|
|
69
|
+
|
|
70
|
+
except Exception as e:
|
|
71
|
+
#print(e)
|
|
72
|
+
raise e
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import pkg_resources
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
import os.path
|
|
6
|
+
|
|
7
|
+
from armodel import AUTOSAR
|
|
8
|
+
from armodel.parser import ARXMLParser
|
|
9
|
+
|
|
10
|
+
from ..lib import InputFileParser
|
|
11
|
+
from ..writer import ARXMLWriter
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
version = pkg_resources.require("armodel")[0].version
|
|
15
|
+
|
|
16
|
+
ap = argparse.ArgumentParser()
|
|
17
|
+
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
18
|
+
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 AUTOSAR ARXML file")
|
|
20
|
+
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 excel file")
|
|
22
|
+
|
|
23
|
+
args = ap.parse_args()
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger()
|
|
26
|
+
|
|
27
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
28
|
+
|
|
29
|
+
stdout_handler = logging.StreamHandler(sys.stderr)
|
|
30
|
+
stdout_handler.setFormatter(formatter)
|
|
31
|
+
|
|
32
|
+
base_path = os.path.dirname(args.OUTPUT)
|
|
33
|
+
log_file = os.path.join(base_path, 'connector_update.log')
|
|
34
|
+
|
|
35
|
+
if os.path.exists(log_file):
|
|
36
|
+
os.remove(log_file)
|
|
37
|
+
|
|
38
|
+
file_handler = logging.FileHandler(log_file)
|
|
39
|
+
file_handler.setFormatter(formatter)
|
|
40
|
+
|
|
41
|
+
logger.setLevel(logging.DEBUG)
|
|
42
|
+
file_handler.setLevel(logging.DEBUG)
|
|
43
|
+
|
|
44
|
+
if args.verbose:
|
|
45
|
+
stdout_handler.setLevel(logging.DEBUG)
|
|
46
|
+
|
|
47
|
+
else:
|
|
48
|
+
stdout_handler.setLevel(logging.INFO)
|
|
49
|
+
|
|
50
|
+
logger.addHandler(file_handler)
|
|
51
|
+
logger.addHandler(stdout_handler)
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
options = {}
|
|
55
|
+
if args.warning:
|
|
56
|
+
options['warning'] = True
|
|
57
|
+
|
|
58
|
+
document = AUTOSAR().getInstance()
|
|
59
|
+
parser = ARXMLParser(options)
|
|
60
|
+
parser.load(args.INPUT, document)
|
|
61
|
+
|
|
62
|
+
writer = ARXMLWriter()
|
|
63
|
+
writer.save(args.OUTPUT, document)
|
|
64
|
+
|
|
65
|
+
except Exception as e:
|
|
66
|
+
#print(e)
|
|
67
|
+
raise e
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
main()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import pkg_resources
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
import os.path
|
|
6
|
+
|
|
7
|
+
from armodel import AUTOSAR, ARPackage
|
|
8
|
+
from armodel.parser import ARXMLParser
|
|
9
|
+
|
|
10
|
+
from ..lib import InputFileParser, SwComponentAnalyzer
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
version = pkg_resources.require("armodel")[0].version
|
|
14
|
+
|
|
15
|
+
ap = argparse.ArgumentParser()
|
|
16
|
+
ap.add_argument("-v", "--verbose", required= False, help= "Print debug information", action= "store_true")
|
|
17
|
+
ap.add_argument("-f", "--format", required= False, help= "Specify the short or long name of Sw-C. [short|long]")
|
|
18
|
+
ap.add_argument("--filter", required= False, help = "Set the filter condition. [CompositionSwComponent]")
|
|
19
|
+
ap.add_argument("INPUT", help = "The path of AUTOSAR XML", nargs='+')
|
|
20
|
+
|
|
21
|
+
args = ap.parse_args()
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger()
|
|
24
|
+
|
|
25
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
26
|
+
|
|
27
|
+
stdout_handler = logging.StreamHandler(sys.stderr)
|
|
28
|
+
stdout_handler.setFormatter(formatter)
|
|
29
|
+
|
|
30
|
+
#base_path = os.path.dirname(args.Output)
|
|
31
|
+
log_file = os.path.join(".", 'swc-list.log')
|
|
32
|
+
|
|
33
|
+
if os.path.exists(log_file):
|
|
34
|
+
os.remove(log_file)
|
|
35
|
+
|
|
36
|
+
file_handler = logging.FileHandler(log_file)
|
|
37
|
+
file_handler.setFormatter(formatter)
|
|
38
|
+
|
|
39
|
+
logger.setLevel(logging.DEBUG)
|
|
40
|
+
file_handler.setLevel(logging.DEBUG)
|
|
41
|
+
|
|
42
|
+
if args.verbose:
|
|
43
|
+
stdout_handler.setLevel(logging.DEBUG)
|
|
44
|
+
|
|
45
|
+
else:
|
|
46
|
+
stdout_handler.setLevel(logging.INFO)
|
|
47
|
+
|
|
48
|
+
logger.addHandler(file_handler)
|
|
49
|
+
logger.addHandler(stdout_handler)
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
parser = InputFileParser(args.INPUT)
|
|
53
|
+
filenames = parser.parse()
|
|
54
|
+
|
|
55
|
+
document = AUTOSAR().getInstance()
|
|
56
|
+
parser = ARXMLParser({'warning': True})
|
|
57
|
+
|
|
58
|
+
format = "short"
|
|
59
|
+
if args.format is not None and args.format.lower() == "long":
|
|
60
|
+
format = "long"
|
|
61
|
+
|
|
62
|
+
for filename in filenames:
|
|
63
|
+
parser.load(filename, document)
|
|
64
|
+
|
|
65
|
+
filter = ""
|
|
66
|
+
if args.filter is not None and args.filter.lower() == "compositionswcomponent":
|
|
67
|
+
filter = "CompositionSwComponent"
|
|
68
|
+
|
|
69
|
+
analyzer = SwComponentAnalyzer()
|
|
70
|
+
analyzer.import_data(document)
|
|
71
|
+
analyzer.print_out({
|
|
72
|
+
'format': format,
|
|
73
|
+
'filter': filter,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
except Exception as e:
|
|
77
|
+
#print(e)
|
|
78
|
+
raise e
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
armodel/lib/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import os, re
|
|
5
|
+
|
|
6
|
+
class InputFileParser:
|
|
7
|
+
def __init__(self, args: List[str]) -> None:
|
|
8
|
+
self._args = args
|
|
9
|
+
self._filenames = [] # type: List[str]
|
|
10
|
+
self._logger = logging.getLogger()
|
|
11
|
+
|
|
12
|
+
def _parse_file_list(self, file):
|
|
13
|
+
with open(file) as f_in:
|
|
14
|
+
for line in f_in:
|
|
15
|
+
self._filenames.append(line.strip())
|
|
16
|
+
|
|
17
|
+
def _parse_dir_files(self, dir_name):
|
|
18
|
+
for (root, _, files) in os.walk(dir_name, topdown=False):
|
|
19
|
+
for file in files:
|
|
20
|
+
m = re.match(r'.*\.arxml$', file, re.I)
|
|
21
|
+
|
|
22
|
+
if m:
|
|
23
|
+
self._filenames.append(os.path.join(root, file))
|
|
24
|
+
|
|
25
|
+
def parse(self) -> List[str]:
|
|
26
|
+
for input_file in self._args:
|
|
27
|
+
if os.path.isdir(input_file):
|
|
28
|
+
self._parse_dir_files(input_file)
|
|
29
|
+
else:
|
|
30
|
+
if input_file[0] == "@":
|
|
31
|
+
self._logger.debug("Parse ARXML list file %s " % input_file)
|
|
32
|
+
self._parse_file_list(input_file[1:])
|
|
33
|
+
else:
|
|
34
|
+
self._filenames.append(input_file)
|
|
35
|
+
|
|
36
|
+
return self._filenames
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
from ..models import AUTOSAR, ARPackage, AtomicSwComponentType, CompositionSwComponentType
|
|
5
|
+
|
|
6
|
+
class SwComponentAnalyzer:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self.swcs = [] # type: List[AtomicSwComponentType]
|
|
9
|
+
|
|
10
|
+
def parse_pkg(self, parent: ARPackage):
|
|
11
|
+
for pkg in parent.getARPackages():
|
|
12
|
+
self.parse_pkg(pkg)
|
|
13
|
+
for swc in parent.getSwComponentTypes():
|
|
14
|
+
self.swcs.append(swc)
|
|
15
|
+
|
|
16
|
+
def import_data(self, document: AUTOSAR):
|
|
17
|
+
for pkg in document.getARPackages():
|
|
18
|
+
self.parse_pkg(pkg)
|
|
19
|
+
|
|
20
|
+
def print_out(self, option = {}):
|
|
21
|
+
logger = logging.getLogger()
|
|
22
|
+
|
|
23
|
+
logger.info("== SW-C LIST ==")
|
|
24
|
+
|
|
25
|
+
if option['filter'] == 'CompositionSwComponent':
|
|
26
|
+
swc_list = filter(lambda o: isinstance(o, CompositionSwComponentType), self.swcs)
|
|
27
|
+
else:
|
|
28
|
+
swc_list = self.swcs
|
|
29
|
+
|
|
30
|
+
for swc in sorted(swc_list, key = lambda o: o.short_name):
|
|
31
|
+
if option['format'] == 'long':
|
|
32
|
+
logger.info("%s (%s)" % (swc.full_name, type(swc)))
|
|
33
|
+
else:
|
|
34
|
+
logger.info("%s" % swc.short_name)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
from ..models import AUTOSAR, ARPackage, AtomicSwComponentType, CompositionSwComponentType
|
|
5
|
+
|
|
6
|
+
class SwComponentAnalyzer:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self.swcs = [] # type: List[AtomicSwComponentType]
|
|
9
|
+
|
|
10
|
+
def parse_pkg(self, parent: ARPackage):
|
|
11
|
+
for pkg in parent.getARPackages():
|
|
12
|
+
self.parse_pkg(pkg)
|
|
13
|
+
for swc in parent.getSwComponentTypes():
|
|
14
|
+
self.swcs.append(swc)
|
|
15
|
+
|
|
16
|
+
def import_data(self, document: AUTOSAR):
|
|
17
|
+
for pkg in document.getARPackages():
|
|
18
|
+
self.parse_pkg(pkg)
|
|
19
|
+
|
|
20
|
+
def print_out(self, option = {}):
|
|
21
|
+
logger = logging.getLogger()
|
|
22
|
+
|
|
23
|
+
logger.info("== SW-C LIST ==")
|
|
24
|
+
|
|
25
|
+
if option['filter'] == 'CompositionSwComponent':
|
|
26
|
+
swc_list = filter(lambda o: isinstance(o, CompositionSwComponentType), self.swcs)
|
|
27
|
+
else:
|
|
28
|
+
swc_list = self.swcs
|
|
29
|
+
|
|
30
|
+
for swc in sorted(swc_list, key = lambda o: o.short_name):
|
|
31
|
+
if option['format'] == 'long':
|
|
32
|
+
logger.info("%s" % swc.full_name)
|
|
33
|
+
else:
|
|
34
|
+
logger.info("%s" % swc.short_name)
|
armodel/models/__init__.py
CHANGED
|
@@ -10,4 +10,9 @@ from .data_dictionary import *
|
|
|
10
10
|
from .port_interface import *
|
|
11
11
|
from .m2_msr import *
|
|
12
12
|
from .implementation import *
|
|
13
|
-
from .bsw_module_template import *
|
|
13
|
+
from .bsw_module_template import *
|
|
14
|
+
from .communication import *
|
|
15
|
+
from .calibration import *
|
|
16
|
+
from .ar_object import *
|
|
17
|
+
from .global_constraints import *
|
|
18
|
+
from .unit import *
|
armodel/models/ar_object.py
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
from abc import ABCMeta
|
|
2
|
+
from typing import List
|
|
2
3
|
|
|
3
4
|
class ARObject(metaclass=ABCMeta):
|
|
4
5
|
def __init__(self):
|
|
5
6
|
if type(self) == ARObject:
|
|
6
7
|
raise NotImplementedError("ARObject is an abstract class.")
|
|
7
8
|
|
|
8
|
-
self.parent = None
|
|
9
|
+
self.parent = None # type: ARObject
|
|
9
10
|
self.checksum = None # type: str
|
|
11
|
+
|
|
10
12
|
self.timestamp = None # type: str
|
|
13
|
+
self.uuid = None # type: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ARType(metaclass=ABCMeta):
|
|
17
|
+
def __init__(self) -> None:
|
|
18
|
+
self.timestamp = None # type: str
|
|
19
|
+
self.uuid = None # type: str
|
|
20
|
+
|
|
21
|
+
class ARBoolean(ARType):
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
super().__init__()
|
|
24
|
+
|
|
25
|
+
self.value = "" # type: bool
|
|
26
|
+
class ARLiteral(ARType):
|
|
27
|
+
def __init__(self) -> None:
|
|
28
|
+
super().__init__()
|
|
29
|
+
|
|
30
|
+
self.value = "" # type: str
|
|
31
|
+
|
|
32
|
+
class LLongName(ARObject):
|
|
33
|
+
def __init__(self):
|
|
34
|
+
super().__init__()
|
|
35
|
+
|
|
36
|
+
self.l = ""
|
|
37
|
+
self.value = ""
|
|
38
|
+
|
|
39
|
+
class MultilanguageLongName(ARObject):
|
|
40
|
+
def __init__(self):
|
|
41
|
+
super().__init__()
|
|
42
|
+
|
|
43
|
+
self.l4 = [] # type:List[LLongName]
|
|
44
|
+
|
|
45
|
+
def add_l4(self, l4: LLongName):
|
|
46
|
+
self.l4.append(l4)
|
|
47
|
+
|
|
48
|
+
def get_l4s(self) -> List[LLongName]:
|
|
49
|
+
return self.l4
|
armodel/models/ar_package.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
from typing import List
|
|
2
|
+
|
|
3
|
+
from .unit import Unit
|
|
2
4
|
from .general_structure import Identifiable, ARObject, Referrable, CollectableElement, SwcBswMapping
|
|
3
5
|
from .port_interface import SenderReceiverInterface, ClientServerInterface
|
|
4
6
|
from .sw_component import SwComponentType, EcuAbstractionSwComponentType, AtomicSwComponentType, ApplicationSwComponentType, ServiceSwComponentType, CompositionSwComponentType, SensorActuatorSwComponentType
|
|
5
7
|
from .datatype import ImplementationDataType, ApplicationDataType, DataTypeMappingSet, DataTypeMap, SwBaseType, ApplicationPrimitiveDataType, ApplicationRecordDataType
|
|
6
8
|
from .m2_msr import CompuMethod
|
|
9
|
+
from .common_structure import ConstantSpecification
|
|
7
10
|
from .implementation import BswImplementation, SwcImplementation, Implementation
|
|
8
11
|
from .bsw_module_template import BswModuleDescription, BswModuleEntry
|
|
12
|
+
from .global_constraints import DataConstr
|
|
9
13
|
|
|
10
14
|
class ARPackage(Identifiable, CollectableElement):
|
|
11
15
|
def __init__(self, parent: ARObject, short_name: str):
|
|
@@ -128,9 +132,30 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
128
132
|
sw_component = SwcBswMapping(self, short_name)
|
|
129
133
|
self.elements[short_name] = sw_component
|
|
130
134
|
return self.elements[short_name]
|
|
135
|
+
|
|
136
|
+
def createConstantSpecification(self, short_name: str) -> ConstantSpecification:
|
|
137
|
+
if (short_name not in self.elements):
|
|
138
|
+
spec = ConstantSpecification(self, short_name)
|
|
139
|
+
self.elements[short_name] = spec
|
|
140
|
+
return self.elements[short_name]
|
|
141
|
+
|
|
142
|
+
def createDataConstr(self, short_name: str) -> DataConstr:
|
|
143
|
+
if (short_name not in self.elements):
|
|
144
|
+
spec = DataConstr(self, short_name)
|
|
145
|
+
self.elements[short_name] = spec
|
|
146
|
+
return self.elements[short_name]
|
|
147
|
+
|
|
148
|
+
def createUnit(self, short_name: str) -> Unit:
|
|
149
|
+
if (short_name not in self.elements):
|
|
150
|
+
spec = Unit(self, short_name)
|
|
151
|
+
self.elements[short_name] = spec
|
|
152
|
+
return self.elements[short_name]
|
|
131
153
|
|
|
132
154
|
def getApplicationPrimitiveDataTypes(self) -> List[ApplicationPrimitiveDataType]:
|
|
133
155
|
return list(filter(lambda a: isinstance(a, ApplicationPrimitiveDataType), self.elements.values()))
|
|
156
|
+
|
|
157
|
+
def getApplicationDataType(self) -> List[ApplicationDataType]:
|
|
158
|
+
return list(sorted(filter(lambda a: isinstance(a, ApplicationDataType), self.elements.values()), key= lambda o:o.short_name))
|
|
134
159
|
|
|
135
160
|
def getImplementationDataTypes(self) -> List[ImplementationDataType]:
|
|
136
161
|
return list(filter(lambda a: isinstance(a, ImplementationDataType), self.elements.values()))
|
|
@@ -179,8 +204,17 @@ class ARPackage(Identifiable, CollectableElement):
|
|
|
179
204
|
|
|
180
205
|
def getSwcBswMappings(self) -> List[SwcBswMapping]:
|
|
181
206
|
return list(filter(lambda a: isinstance(a, SwcBswMapping), self.elements.values()))
|
|
207
|
+
|
|
208
|
+
def getConstantSpecifications(self) -> List[ConstantSpecification]:
|
|
209
|
+
return list(filter(lambda a: isinstance(a, ConstantSpecification), self.elements.values()))
|
|
210
|
+
|
|
211
|
+
def getDataConstrs(self) -> List[DataConstr]:
|
|
212
|
+
return list(filter(lambda a: isinstance(a, DataConstr), self.elements.values()))
|
|
213
|
+
|
|
214
|
+
def getUnits(self) -> List[Unit]:
|
|
215
|
+
return list(filter(lambda a: isinstance(a, Unit), self.elements.values()))
|
|
182
216
|
|
|
183
|
-
class AUTOSAR (
|
|
217
|
+
class AUTOSAR (CollectableElement):
|
|
184
218
|
__instance = None
|
|
185
219
|
|
|
186
220
|
@staticmethod
|
armodel/models/ar_ref.py
CHANGED
|
@@ -24,13 +24,23 @@ class AtpInstanceRef(ARObject, metaclass=ABCMeta):
|
|
|
24
24
|
raise NotImplementedError("AtpInstanceRef is an abstract class.")
|
|
25
25
|
super().__init__()
|
|
26
26
|
|
|
27
|
-
class
|
|
27
|
+
class PortInCompositionTypeInstanceRef(AtpInstanceRef, metaclass=ABCMeta):
|
|
28
|
+
def __init__(self):
|
|
29
|
+
if type(self) == PortInCompositionTypeInstanceRef:
|
|
30
|
+
raise NotImplementedError("PortInCompositionTypeInstanceRef is an abstract class.")
|
|
31
|
+
super().__init__()
|
|
32
|
+
|
|
33
|
+
self.abstract_context_component_ref = None # type: RefType
|
|
34
|
+
self.base_ref = None # type: RefType
|
|
35
|
+
self.target_port_ref = None # type: RefType
|
|
36
|
+
|
|
37
|
+
class PPortInCompositionInstanceRef(PortInCompositionTypeInstanceRef):
|
|
28
38
|
def __init__(self):
|
|
29
39
|
super().__init__()
|
|
30
40
|
self.context_component_ref = None # type: RefType
|
|
31
41
|
self.target_p_port_ref = None # type: RefType
|
|
32
42
|
|
|
33
|
-
class
|
|
43
|
+
class RPortInCompositionInstanceRef(PortInCompositionTypeInstanceRef):
|
|
34
44
|
def __init__(self):
|
|
35
45
|
super().__init__()
|
|
36
46
|
self.context_component_ref = None # type: RefType
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from abc import ABCMeta
|
|
2
2
|
from typing import List
|
|
3
3
|
from .general_structure import AtpStructureElement, ARObject, ARElement
|
|
4
|
+
from .ar_object import ARBoolean
|
|
4
5
|
from .common_structure import ExecutableEntity, ModeDeclarationGroupPrototype, InternalBehavior, Identifiable
|
|
5
6
|
from .ar_ref import RefType
|
|
6
7
|
|
|
@@ -222,8 +223,8 @@ class BswModuleEntry(ARElement):
|
|
|
222
223
|
super().__init__(parent, short_name)
|
|
223
224
|
|
|
224
225
|
self.service_id = None # type: int
|
|
225
|
-
self.is_reentrant = None # type:
|
|
226
|
-
self.is_synchronous = None # type:
|
|
226
|
+
self.is_reentrant = None # type: ARBoolean
|
|
227
|
+
self.is_synchronous = None # type: ARBoolean
|
|
227
228
|
self.call_type = None # type: str
|
|
228
229
|
self._execution_context = None # type: str
|
|
229
230
|
self._sw_service_impl_policy = None # type: str
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from .ar_object import ARObject
|
|
2
|
+
from .ar_ref import RefType
|
|
3
|
+
|
|
4
|
+
class SwValues(ARObject):
|
|
5
|
+
def __init__(self):
|
|
6
|
+
super().__init__()
|
|
7
|
+
|
|
8
|
+
self.v = None # type: float
|
|
9
|
+
|
|
10
|
+
class SwValueCont(ARObject):
|
|
11
|
+
def __init__(self):
|
|
12
|
+
super().__init__()
|
|
13
|
+
|
|
14
|
+
self.unit_ref = None # type: RefType
|
|
15
|
+
self.sw_values_phys = None # type: SwValues
|
|
16
|
+
|
|
@@ -10,13 +10,105 @@ from .ar_ref import RefType
|
|
|
10
10
|
import re
|
|
11
11
|
|
|
12
12
|
class ValueSpecification(ARObject, metaclass=ABCMeta):
|
|
13
|
+
'''
|
|
14
|
+
Base class for expressions leading to a value which can be used to initialize a data object.
|
|
15
|
+
|
|
16
|
+
Base : ARObject
|
|
17
|
+
Subclasses : AbstractRuleBasedValueSpecification, ApplicationValueSpecification, CompositeValueSpecification,
|
|
18
|
+
ConstantReference, NotAvailableValueSpecification, NumericalValueSpecification, ReferenceValueSpecification,
|
|
19
|
+
TextValueSpecification
|
|
20
|
+
'''
|
|
13
21
|
def __init__(self):
|
|
14
22
|
if type(self) == ValueSpecification:
|
|
15
23
|
raise NotImplementedError("ValueSpecification is an abstract class.")
|
|
24
|
+
|
|
16
25
|
super().__init__()
|
|
17
26
|
|
|
18
27
|
self.short_label = None
|
|
19
28
|
|
|
29
|
+
class CompositeRuleBasedValueArgument(ValueSpecification, metaclass=ABCMeta):
|
|
30
|
+
'''
|
|
31
|
+
This meta-class has the ability to serve as the abstract base class for ValueSpecifications that can be
|
|
32
|
+
used for compound primitive data types.
|
|
33
|
+
|
|
34
|
+
Base : ARObject
|
|
35
|
+
Subclasses : ApplicationRuleBasedValueSpecification, ApplicationValueSpecification
|
|
36
|
+
'''
|
|
37
|
+
def __init__(self):
|
|
38
|
+
if type(self) == CompositeRuleBasedValueArgument:
|
|
39
|
+
raise NotImplementedError("CompositeRuleBasedValueArgument is an abstract class.")
|
|
40
|
+
|
|
41
|
+
super().__init__()
|
|
42
|
+
|
|
43
|
+
class CompositeValueSpecification(ValueSpecification, metaclass=ABCMeta):
|
|
44
|
+
'''
|
|
45
|
+
This abstract meta-class acts a base class for ValueSpecifications that have a composite form.
|
|
46
|
+
|
|
47
|
+
Base : ARObject, ValueSpecification
|
|
48
|
+
Subclasses : ArrayValueSpecification, RecordValueSpecification
|
|
49
|
+
'''
|
|
50
|
+
def __init__(self):
|
|
51
|
+
if type(self) == CompositeValueSpecification:
|
|
52
|
+
raise NotImplementedError("CompositeValueSpecification is an abstract class.")
|
|
53
|
+
|
|
54
|
+
super().__init__()
|
|
55
|
+
|
|
56
|
+
class ApplicationValueSpecification(CompositeRuleBasedValueArgument):
|
|
57
|
+
'''
|
|
58
|
+
This meta-class represents values for DataPrototypes typed by ApplicationDataTypes (this includes in
|
|
59
|
+
particular compound primitives).
|
|
60
|
+
For further details refer to ASAM CDF 2.0. This meta-class corresponds to some extent with
|
|
61
|
+
SW-INSTANCE in ASAM CDF 2.0.
|
|
62
|
+
|
|
63
|
+
Base ARObject, CompositeRuleBasedValueArgument, ValueSpecification
|
|
64
|
+
'''
|
|
65
|
+
def __init__(self):
|
|
66
|
+
super().__init__()
|
|
67
|
+
|
|
68
|
+
self.category = None
|
|
69
|
+
self.sw_Axis_cont = []
|
|
70
|
+
self.sw_value_cont = None
|
|
71
|
+
|
|
72
|
+
class RecordValueSpecification(CompositeValueSpecification):
|
|
73
|
+
'''
|
|
74
|
+
Specifies the values for a record.
|
|
75
|
+
|
|
76
|
+
Base : ARObject, CompositeValueSpecification, ValueSpecification
|
|
77
|
+
'''
|
|
78
|
+
def __init__(self):
|
|
79
|
+
super().__init__()
|
|
80
|
+
|
|
81
|
+
self._fields = []
|
|
82
|
+
|
|
83
|
+
def add_field(self, field: ValueSpecification):
|
|
84
|
+
self._fields.append(field)
|
|
85
|
+
|
|
86
|
+
def get_fields(self) -> List[ValueSpecification]:
|
|
87
|
+
return self._fields
|
|
88
|
+
|
|
89
|
+
class TextValueSpecification(ValueSpecification):
|
|
90
|
+
def __init__(self):
|
|
91
|
+
super().__init__()
|
|
92
|
+
|
|
93
|
+
self.value = None # type: str
|
|
94
|
+
|
|
95
|
+
class NumericalValueSpecification(ValueSpecification):
|
|
96
|
+
def __init__(self):
|
|
97
|
+
super().__init__()
|
|
98
|
+
|
|
99
|
+
self.value = None # type: float
|
|
100
|
+
|
|
101
|
+
class ArrayValueSpecification(ValueSpecification):
|
|
102
|
+
def __init__(self):
|
|
103
|
+
super().__init__()
|
|
104
|
+
|
|
105
|
+
self._element = [] # type: List[ValueSpecification]
|
|
106
|
+
|
|
107
|
+
def add_element(self, element: ValueSpecification):
|
|
108
|
+
self._element.append(element)
|
|
109
|
+
|
|
110
|
+
def get_elements(self) -> List[ValueSpecification]:
|
|
111
|
+
return self._element
|
|
20
112
|
|
|
21
113
|
class ConstantSpecification(ARElement):
|
|
22
114
|
def __init__(self, parent, short_name):
|