armodel 1.4.0__py3-none-any.whl → 1.5.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/__init__.py +2 -1
- armodel/cli/arxml_dump_cli.py +9 -7
- 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 +228 -24
- armodel/models/ar_ref.py +85 -6
- armodel/models/bsw_module_template.py +113 -27
- armodel/models/calibration.py +107 -4
- armodel/models/common_structure.py +142 -52
- 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/fibex/__init__.py +0 -0
- armodel/models/fibex/can_communication.py +6 -0
- armodel/models/fibex/fibex_4_multiplatform.py +145 -0
- armodel/models/fibex/fibex_core.py +341 -0
- armodel/models/fibex/lin_communication.py +17 -0
- armodel/models/fibex/lin_topology.py +7 -0
- armodel/models/general_structure.py +44 -18
- armodel/models/global_constraints.py +4 -4
- armodel/models/implementation.py +79 -32
- armodel/models/internal_behavior.py +63 -0
- armodel/models/m2_msr.py +6 -4
- armodel/models/mode_declaration.py +8 -0
- 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 +57 -19
- armodel/models/record_layout.py +118 -0
- armodel/models/rpt_scenario.py +20 -0
- armodel/models/service_mapping.py +11 -0
- armodel/models/service_needs.py +48 -0
- armodel/models/sw_component.py +293 -45
- armodel/models/system_template/__init__.py +0 -0
- armodel/models/system_template/network_management.py +7 -0
- armodel/models/system_template/transport_protocols.py +7 -0
- armodel/models/timing.py +91 -0
- armodel/parser/abstract_arxml_parser.py +248 -0
- armodel/parser/arxml_parser.py +1571 -844
- 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 +3 -3
- armodel/tests/test_armodel/models/test_datatype.py +11 -11
- 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/models/test_port_interface.py +5 -5
- armodel/tests/test_armodel/parser/test_arxml_parser.py +15 -0
- armodel/tests/test_armodel/parser/test_parse_bswmd.py +74 -42
- armodel/tests/test_armodel/parser/test_sw_components.py +93 -0
- armodel/writer/abstract_arxml_writer.py +123 -0
- armodel/writer/arxml_writer.py +1701 -358
- {armodel-1.4.0.dist-info → armodel-1.5.0.dist-info}/METADATA +114 -3
- armodel-1.5.0.dist-info/RECORD +91 -0
- {armodel-1.4.0.dist-info → armodel-1.5.0.dist-info}/WHEEL +1 -1
- {armodel-1.4.0.dist-info → armodel-1.5.0.dist-info}/entry_points.txt +2 -0
- armodel-1.4.0.dist-info/RECORD +0 -60
- {armodel-1.4.0.dist-info → armodel-1.5.0.dist-info}/LICENSE +0 -0
- {armodel-1.4.0.dist-info → armodel-1.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
from openpyxl import Workbook
|
|
3
|
+
from openpyxl.worksheet.worksheet import Worksheet
|
|
4
|
+
|
|
5
|
+
import openpyxl
|
|
6
|
+
import re
|
|
7
|
+
|
|
8
|
+
from ..parser.excel_parser import AbstractExcelParser
|
|
9
|
+
from ..data_models.sw_connector import AssemblySwConnectorData, DelegationSwConnectorData, SwConnectorData
|
|
10
|
+
from ..models.ar_ref import PPortInCompositionInstanceRef, RPortInCompositionInstanceRef, RefType
|
|
11
|
+
from ..models.sw_component import CompositionSwComponentType
|
|
12
|
+
from ..models.ar_package import AUTOSAR, ARPackage
|
|
13
|
+
|
|
14
|
+
class ConnectorXls:
|
|
15
|
+
|
|
16
|
+
COL_SHORT_NAME = 'Short Name'
|
|
17
|
+
COL_INNER_SW_C = 'Inner SW-C'
|
|
18
|
+
COL_INNER_PPORT = 'Inner PPort'
|
|
19
|
+
COL_OUTER_PPORT = 'Outer PPort'
|
|
20
|
+
COL_INNER_RPORT = 'Inner RPort'
|
|
21
|
+
COL_OUTER_RPORT = 'Outer RPort'
|
|
22
|
+
|
|
23
|
+
COL_PROVIDER_SW_C = "Provide SW-C"
|
|
24
|
+
COL_PPORT = "PPort"
|
|
25
|
+
COL_REQUESTER_SW_C = "Request SW-C"
|
|
26
|
+
COL_RPORT = "RPort"
|
|
27
|
+
|
|
28
|
+
class ConnectorXlsReader(AbstractExcelParser):
|
|
29
|
+
def __init__(self) -> None:
|
|
30
|
+
super().__init__()
|
|
31
|
+
|
|
32
|
+
self.column_delegation_sw_connectors = {
|
|
33
|
+
ConnectorXls.COL_SHORT_NAME: -1,
|
|
34
|
+
ConnectorXls.COL_INNER_SW_C: -1,
|
|
35
|
+
ConnectorXls.COL_INNER_PPORT: -1,
|
|
36
|
+
ConnectorXls.COL_OUTER_PPORT: -1,
|
|
37
|
+
ConnectorXls.COL_INNER_RPORT: -1,
|
|
38
|
+
ConnectorXls.COL_OUTER_RPORT: -1,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
self.column_assembly_sw_connectors = {
|
|
42
|
+
ConnectorXls.COL_SHORT_NAME: -1,
|
|
43
|
+
ConnectorXls.COL_PROVIDER_SW_C: -1,
|
|
44
|
+
ConnectorXls.COL_PPORT: -1,
|
|
45
|
+
ConnectorXls.COL_REQUESTER_SW_C: -1,
|
|
46
|
+
ConnectorXls.COL_RPORT: -1,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
self.sw_connectors = {} # type: Dict[str, List[DelegationSwConnectorData]]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def getCompositionSwComponentList(self) -> List[str]:
|
|
53
|
+
return self.sw_connectors.keys()
|
|
54
|
+
|
|
55
|
+
def getSwConnectorList(self, swc: str) -> List[SwConnectorData]:
|
|
56
|
+
if swc not in self.sw_connectors:
|
|
57
|
+
self.sw_connectors[swc] = []
|
|
58
|
+
return self.sw_connectors[swc]
|
|
59
|
+
#return sorted(self.sw_connectors[swc], key = lambda o: o.short_name)
|
|
60
|
+
|
|
61
|
+
def readDelegationSwConnectors(self, sheet: Worksheet, swc: str, start_row: int, column_list: Dict[str, int]):
|
|
62
|
+
connectors = self.getSwConnectorList(swc)
|
|
63
|
+
for row in sheet.iter_rows(min_row = start_row, values_only= True):
|
|
64
|
+
connector = DelegationSwConnectorData()
|
|
65
|
+
connector.short_name = row[column_list[ConnectorXls.COL_SHORT_NAME]]
|
|
66
|
+
connector.inner_swc = row[column_list[ConnectorXls.COL_INNER_SW_C]]
|
|
67
|
+
connector.inner_pport = row[column_list[ConnectorXls.COL_INNER_PPORT]]
|
|
68
|
+
connector.inner_rport = row[column_list[ConnectorXls.COL_INNER_RPORT]]
|
|
69
|
+
connector.outer_pport = row[column_list[ConnectorXls.COL_OUTER_PPORT]]
|
|
70
|
+
connector.outer_rport = row[column_list[ConnectorXls.COL_OUTER_RPORT]]
|
|
71
|
+
connectors.append(connector)
|
|
72
|
+
self._logger.debug("ShortName: %s" % connector.short_name)
|
|
73
|
+
|
|
74
|
+
def readAssemblySwConnectors(self, sheet: Worksheet, swc: str, start_row: int, column_list: Dict[str, int]):
|
|
75
|
+
connectors = self.getSwConnectorList(swc)
|
|
76
|
+
for row in sheet.iter_rows(min_row = start_row, values_only= True):
|
|
77
|
+
connector = AssemblySwConnectorData()
|
|
78
|
+
connector.short_name = row[column_list[ConnectorXls.COL_SHORT_NAME]]
|
|
79
|
+
connector.provider_swc = row[column_list[ConnectorXls.COL_PROVIDER_SW_C]]
|
|
80
|
+
connector.pport = row[column_list[ConnectorXls.COL_PPORT]]
|
|
81
|
+
connector.requester_swc = row[column_list[ConnectorXls.COL_REQUESTER_SW_C]]
|
|
82
|
+
connector.rport = row[column_list[ConnectorXls.COL_RPORT]]
|
|
83
|
+
connectors.append(connector)
|
|
84
|
+
self._logger.debug("ShortName: %s" % connector.short_name)
|
|
85
|
+
|
|
86
|
+
def parseDelegationSWConnectors(self, sheet: Worksheet, swc: str):
|
|
87
|
+
self._logger.debug("Parse all DelegationSwConnector of %s" % swc)
|
|
88
|
+
|
|
89
|
+
self.getColumnTitles(sheet, 1, self.column_delegation_sw_connectors)
|
|
90
|
+
self.checkColumnTitles(self.column_delegation_sw_connectors, "Invalid DelegationSwConnectors Excel and column <%s> cannot be located.")
|
|
91
|
+
self.readDelegationSwConnectors(sheet, swc, 2, self.column_delegation_sw_connectors)
|
|
92
|
+
|
|
93
|
+
def parseAssemblySWConnectors(self, sheet: Worksheet, swc: str):
|
|
94
|
+
self._logger.debug("Parse all AssemblySwConnector of %s" % swc)
|
|
95
|
+
|
|
96
|
+
self.getColumnTitles(sheet, 1, self.column_assembly_sw_connectors)
|
|
97
|
+
self.checkColumnTitles(self.column_assembly_sw_connectors, "Invalid AssemblySwConnectors Excel and column <%s> cannot be located.")
|
|
98
|
+
self.readAssemblySwConnectors(sheet, swc, 2, self.column_assembly_sw_connectors)
|
|
99
|
+
|
|
100
|
+
def read(self, excel_file: str):
|
|
101
|
+
self._logger.info("Parse excel file <%s>" % excel_file)
|
|
102
|
+
|
|
103
|
+
wb = openpyxl.load_workbook(excel_file, data_only=True)
|
|
104
|
+
|
|
105
|
+
for name in wb.sheetnames:
|
|
106
|
+
m = re.match(r'(\w+)\s+-\s+(AC|DC)', name)
|
|
107
|
+
if m:
|
|
108
|
+
if m.group(2) == "DC":
|
|
109
|
+
self.parseDelegationSWConnectors(wb[name], m.group(1))
|
|
110
|
+
elif m.group(2) == "AC":
|
|
111
|
+
self.parseAssemblySWConnectors(wb[name], m.group(1))
|
|
112
|
+
else:
|
|
113
|
+
raise ValueError("Invalid sheet")
|
|
114
|
+
|
|
115
|
+
def _addAssemblySwConnector(self, swc: CompositionSwComponentType, connector: AssemblySwConnectorData):
|
|
116
|
+
sw_connector = swc.createAssemblySwConnector(connector.short_name)
|
|
117
|
+
|
|
118
|
+
sw_connector.provider_iref = PPortInCompositionInstanceRef()
|
|
119
|
+
sw_connector.provider_iref.context_component_ref = RefType()
|
|
120
|
+
sw_connector.provider_iref.target_p_port_ref = RefType()
|
|
121
|
+
sw_connector.provider_iref.context_component_ref.dest = "SW-COMPONENT-PROTOTYPE"
|
|
122
|
+
sw_connector.provider_iref.context_component_ref.value = connector.provider_swc
|
|
123
|
+
sw_connector.provider_iref.target_p_port_ref.dest = "P-PORT-PROTOTYPE"
|
|
124
|
+
sw_connector.provider_iref.target_p_port_ref.value = connector.pport
|
|
125
|
+
|
|
126
|
+
sw_connector.requester_iref = RPortInCompositionInstanceRef()
|
|
127
|
+
sw_connector.requester_iref.context_component_ref = RefType()
|
|
128
|
+
sw_connector.requester_iref.target_r_port_ref = RefType()
|
|
129
|
+
sw_connector.requester_iref.context_component_ref.dest = "SW-COMPONENT-PROTOTYPE"
|
|
130
|
+
sw_connector.requester_iref.context_component_ref.value = connector.requester_swc
|
|
131
|
+
sw_connector.requester_iref.target_r_port_ref.dest = "R-PORT-PROTOTYPE"
|
|
132
|
+
sw_connector.requester_iref.target_r_port_ref.value = connector.rport
|
|
133
|
+
|
|
134
|
+
def _addDelegationSwConnector(self, swc: CompositionSwComponentType, connector: DelegationSwConnectorData):
|
|
135
|
+
sw_connector = swc.createDelegationSwConnector(connector.short_name)
|
|
136
|
+
if connector.inner_pport is not None and connector.outer_pport is not None:
|
|
137
|
+
sw_connector.inner_port_iref = PPortInCompositionInstanceRef()
|
|
138
|
+
sw_connector.inner_port_iref.context_component_ref = RefType()
|
|
139
|
+
sw_connector.inner_port_iref.target_p_port_ref = RefType()
|
|
140
|
+
sw_connector.outer_port_ref = RefType()
|
|
141
|
+
sw_connector.inner_port_iref.context_component_ref.dest = "SW-COMPONENT-PROTOTYPE"
|
|
142
|
+
sw_connector.inner_port_iref.context_component_ref.value = connector.inner_swc
|
|
143
|
+
sw_connector.inner_port_iref.target_p_port_ref.dest = "P-PORT-PROTOTYPE"
|
|
144
|
+
sw_connector.inner_port_iref.target_p_port_ref.value = connector.inner_pport
|
|
145
|
+
sw_connector.outer_port_ref.dest = "P-PORT-PROTOTYPE"
|
|
146
|
+
sw_connector.outer_port_ref.value = connector.outer_pport
|
|
147
|
+
elif connector.inner_rport is not None and connector.outer_rport is not None:
|
|
148
|
+
sw_connector.inner_port_iref = RPortInCompositionInstanceRef()
|
|
149
|
+
sw_connector.inner_port_iref.context_component_ref = RefType()
|
|
150
|
+
sw_connector.inner_port_iref.target_r_port_ref = RefType()
|
|
151
|
+
sw_connector.outer_port_ref = RefType()
|
|
152
|
+
sw_connector.inner_port_iref.context_component_ref.dest = "SW-COMPONENT-PROTOTYPE"
|
|
153
|
+
sw_connector.inner_port_iref.context_component_ref.value = connector.inner_swc
|
|
154
|
+
sw_connector.inner_port_iref.target_r_port_ref.dest = "R-PORT-PROTOTYPE"
|
|
155
|
+
sw_connector.inner_port_iref.target_r_port_ref.value = connector.inner_rport
|
|
156
|
+
sw_connector.outer_port_ref.dest = "R-PORT-PROTOTYPE"
|
|
157
|
+
sw_connector.outer_port_ref.value = connector.outer_rport
|
|
158
|
+
else:
|
|
159
|
+
raise ValueError("Invalid DelegationSwConnector Configuration")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _updateCompositionSwComponent(self, swc: CompositionSwComponentType):
|
|
163
|
+
# remove all the sw connector first
|
|
164
|
+
swc.removeAllAssemblySwConnector()
|
|
165
|
+
swc.removeAllDelegationSwConnector()
|
|
166
|
+
|
|
167
|
+
connectors = self.getSwConnectorList(swc.short_name)
|
|
168
|
+
|
|
169
|
+
for connector in connectors:
|
|
170
|
+
#self._logger.info("Update %s" % connector.short_name)
|
|
171
|
+
if isinstance(connector, AssemblySwConnectorData):
|
|
172
|
+
self._addAssemblySwConnector(swc, connector)
|
|
173
|
+
elif isinstance(connector, DelegationSwConnectorData):
|
|
174
|
+
self._addDelegationSwConnector(swc, connector)
|
|
175
|
+
else:
|
|
176
|
+
raise ValueError("Invalid connector information")
|
|
177
|
+
|
|
178
|
+
def _locateCompositionSwComponent(self, swc_name: str, parent: ARPackage):
|
|
179
|
+
for swc in parent.getSwComponentTypes():
|
|
180
|
+
if swc.short_name == swc_name:
|
|
181
|
+
self._updateCompositionSwComponent(swc)
|
|
182
|
+
for pkg in parent.getARPackages():
|
|
183
|
+
self._locateCompositionSwComponent(swc_name, pkg)
|
|
184
|
+
|
|
185
|
+
def update(self, document: AUTOSAR):
|
|
186
|
+
for name in self.getCompositionSwComponentList():
|
|
187
|
+
for pkg in document.getARPackages():
|
|
188
|
+
self._locateCompositionSwComponent(name, pkg)
|
|
189
|
+
|
|
190
|
+
|
armodel/parser/excel_parser.py
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
from openpyxl.worksheet.worksheet import Worksheet
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
class AbstractExcelParser:
|
|
6
|
+
def __init__(self) -> None:
|
|
7
|
+
self._logger = logging.getLogger()
|
|
8
|
+
|
|
9
|
+
def getColumnTitles(self, sheet: Worksheet, title_row:int, column_list: Dict[str, int]):
|
|
10
|
+
for column in range(1, sheet.max_column + 1):
|
|
11
|
+
value = sheet.cell(title_row, column).value
|
|
12
|
+
if value in column_list:
|
|
13
|
+
column_list[value] = column - 1
|
|
14
|
+
|
|
15
|
+
def checkColumnTitles(self, column_list: Dict[str, int], message: str):
|
|
16
|
+
for key, value in column_list.items():
|
|
17
|
+
if value == -1:
|
|
18
|
+
raise ValueError(message % key)
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
|
|
2
|
+
from ....models.ar_object import ARBoolean, ARFloat, ARLiteral, ARNumerical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestARObject:
|
|
6
|
+
|
|
7
|
+
def test_ARNumerical(self):
|
|
8
|
+
numerical = ARNumerical()
|
|
9
|
+
numerical.value = 123
|
|
10
|
+
assert(numerical.value == 123)
|
|
11
|
+
assert(numerical.getValue() == 123)
|
|
12
|
+
assert(str(numerical) == "123")
|
|
13
|
+
assert(numerical.getText() == "123")
|
|
14
|
+
|
|
15
|
+
numerical = ARNumerical()
|
|
16
|
+
numerical.setValue(123)
|
|
17
|
+
assert(numerical.value == 123)
|
|
18
|
+
assert(numerical.getValue() == 123)
|
|
19
|
+
assert(str(numerical) == "123")
|
|
20
|
+
assert(numerical.getText() == "123")
|
|
21
|
+
|
|
22
|
+
numerical = ARNumerical()
|
|
23
|
+
numerical.value = "1234"
|
|
24
|
+
assert(numerical.value == 1234)
|
|
25
|
+
assert(numerical.getValue() == 1234)
|
|
26
|
+
assert(str(numerical) == "1234")
|
|
27
|
+
assert(numerical.getText() == "1234")
|
|
28
|
+
|
|
29
|
+
numerical = ARNumerical()
|
|
30
|
+
numerical.setValue("0xFF")
|
|
31
|
+
assert(numerical.value == 255)
|
|
32
|
+
assert(numerical.getValue() == 255)
|
|
33
|
+
assert(str(numerical) == "0xFF")
|
|
34
|
+
assert(numerical.getText() == "0xFF")
|
|
35
|
+
|
|
36
|
+
def test_ARLiteral(self):
|
|
37
|
+
literal = ARLiteral()
|
|
38
|
+
assert(literal.value == "")
|
|
39
|
+
assert(str(literal) == "")
|
|
40
|
+
assert(literal.getValue() == "")
|
|
41
|
+
assert(literal.getText() == "")
|
|
42
|
+
|
|
43
|
+
literal = ARLiteral()
|
|
44
|
+
literal.value = "Literal"
|
|
45
|
+
assert(literal.value == "Literal")
|
|
46
|
+
assert(str(literal) == "Literal")
|
|
47
|
+
assert(literal.getValue() == "Literal")
|
|
48
|
+
assert(literal.getText() == "Literal")
|
|
49
|
+
|
|
50
|
+
literal = ARLiteral()
|
|
51
|
+
literal.setValue("Literal1")
|
|
52
|
+
assert(literal.value == "Literal1")
|
|
53
|
+
assert(str(literal) == "Literal1")
|
|
54
|
+
assert(literal.getValue() == "Literal1")
|
|
55
|
+
assert(literal.getText() == "Literal1")
|
|
56
|
+
|
|
57
|
+
literal = ARLiteral()
|
|
58
|
+
literal.setValue(1234)
|
|
59
|
+
assert(literal.value == "1234")
|
|
60
|
+
assert(str(literal) == "1234")
|
|
61
|
+
assert(literal.getValue() == "1234")
|
|
62
|
+
assert(literal.getText() == "1234")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_ARFloat(self):
|
|
66
|
+
numerical = ARFloat()
|
|
67
|
+
numerical.value = 123
|
|
68
|
+
assert(numerical.value == 123.0)
|
|
69
|
+
assert(numerical.getValue() == 123.0)
|
|
70
|
+
assert(str(numerical) == "123.0")
|
|
71
|
+
assert(numerical.getText() == "123.0")
|
|
72
|
+
|
|
73
|
+
numerical = ARFloat()
|
|
74
|
+
numerical.setValue(123)
|
|
75
|
+
assert(numerical.value == 123)
|
|
76
|
+
assert(numerical.getValue() == 123)
|
|
77
|
+
assert(str(numerical) == "123.0")
|
|
78
|
+
assert(numerical.getText() == "123.0")
|
|
79
|
+
|
|
80
|
+
numerical = ARFloat()
|
|
81
|
+
numerical.value = 1234.12
|
|
82
|
+
assert(numerical.value == 1234.12)
|
|
83
|
+
assert(numerical.getValue() == 1234.12)
|
|
84
|
+
assert(str(numerical) == "1234.12")
|
|
85
|
+
assert(numerical.getText() == "1234.12")
|
|
86
|
+
|
|
87
|
+
numerical = ARFloat()
|
|
88
|
+
numerical.value = "1234.12"
|
|
89
|
+
assert(numerical.value == 1234.12)
|
|
90
|
+
assert(numerical.getValue() == 1234.12)
|
|
91
|
+
assert(str(numerical) == "1234.12")
|
|
92
|
+
assert(numerical.getText() == "1234.12")
|
|
93
|
+
|
|
94
|
+
numerical = ARFloat()
|
|
95
|
+
numerical.value = "1234.0"
|
|
96
|
+
assert(numerical.value == 1234)
|
|
97
|
+
assert(numerical.getValue() == 1234)
|
|
98
|
+
assert(str(numerical) == "1234.0")
|
|
99
|
+
assert(numerical.getText() == "1234.0")
|
|
100
|
+
|
|
101
|
+
numerical = ARFloat()
|
|
102
|
+
numerical.value = "1234.000000"
|
|
103
|
+
assert(numerical.value == 1234)
|
|
104
|
+
assert(numerical.getValue() == 1234)
|
|
105
|
+
assert(str(numerical) == "1234.000000")
|
|
106
|
+
assert(numerical.getText() == "1234.000000")
|
|
107
|
+
|
|
108
|
+
def test_ARBoolean(self):
|
|
109
|
+
flag = ARBoolean()
|
|
110
|
+
flag.value = False
|
|
111
|
+
assert(flag.value == False)
|
|
112
|
+
assert(flag.getValue() == False)
|
|
113
|
+
assert(str(flag) == "false")
|
|
114
|
+
assert(flag.getText() == "false")
|
|
115
|
+
|
|
116
|
+
flag = ARBoolean()
|
|
117
|
+
flag.value = 0
|
|
118
|
+
assert(flag.value == False)
|
|
119
|
+
assert(flag.getValue() == False)
|
|
120
|
+
assert(str(flag) == "0")
|
|
121
|
+
assert(flag.getText() == "0")
|
|
122
|
+
|
|
123
|
+
flag = ARBoolean()
|
|
124
|
+
flag.value = "0"
|
|
125
|
+
assert(flag.value == False)
|
|
126
|
+
assert(flag.getValue() == False)
|
|
127
|
+
assert(str(flag) == "0")
|
|
128
|
+
assert(flag.getText() == "0")
|
|
129
|
+
|
|
130
|
+
flag = ARBoolean()
|
|
131
|
+
flag.value = True
|
|
132
|
+
assert(flag.value == True)
|
|
133
|
+
assert(flag.getValue() == True)
|
|
134
|
+
assert(str(flag) == "true")
|
|
135
|
+
assert(flag.getText() == "true")
|
|
136
|
+
|
|
137
|
+
flag = ARBoolean()
|
|
138
|
+
flag.value = 1
|
|
139
|
+
assert(flag.value == True)
|
|
140
|
+
assert(flag.getValue() == True)
|
|
141
|
+
assert(str(flag) == "1")
|
|
142
|
+
assert(flag.getText() == "1")
|
|
143
|
+
|
|
144
|
+
flag = ARBoolean()
|
|
145
|
+
flag.value = "100"
|
|
146
|
+
assert(flag.value == True)
|
|
147
|
+
assert(flag.getValue() == True)
|
|
148
|
+
assert(str(flag) == "100")
|
|
149
|
+
assert(flag.getText() == "100")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
@@ -29,7 +29,7 @@ class TestAUTOSAR:
|
|
|
29
29
|
assert (isinstance(document, CollectableElement))
|
|
30
30
|
assert (isinstance(document, AUTOSAR))
|
|
31
31
|
assert (len(document.getARPackages()) == 0)
|
|
32
|
-
assert (document.
|
|
32
|
+
assert (document.schema_location == "")
|
|
33
33
|
assert (document.full_name == "")
|
|
34
34
|
|
|
35
35
|
def test_create_autosar_package(self):
|
|
@@ -51,8 +51,8 @@ class Test_M2_AUTOSARTemplates_CommonStructure_ImplementationDataTypes:
|
|
|
51
51
|
data_type = ImplementationDataTypeElement(ar_root, "implementation_data_type")
|
|
52
52
|
|
|
53
53
|
assert(data_type.short_name == "implementation_data_type")
|
|
54
|
-
assert(data_type.
|
|
55
|
-
assert(data_type.
|
|
54
|
+
assert(data_type.arraySize == None)
|
|
55
|
+
assert(data_type.isOptional == None)
|
|
56
56
|
|
|
57
57
|
assert(isinstance(data_type, ARObject))
|
|
58
58
|
assert(isinstance(data_type, AbstractImplementationDataTypeElement))
|
|
@@ -10,12 +10,12 @@ class Test_M2_MSR_DataDictionary_DataDefProperties:
|
|
|
10
10
|
assert(isinstance(props, ARObject))
|
|
11
11
|
assert(isinstance(props, SwDataDefProps))
|
|
12
12
|
|
|
13
|
-
assert(props.
|
|
14
|
-
assert(props.
|
|
15
|
-
assert(props.
|
|
16
|
-
assert(props.
|
|
17
|
-
assert(props.
|
|
18
|
-
assert(props.
|
|
13
|
+
assert(props.baseTypeRef == None)
|
|
14
|
+
assert(props.compuMethodRef == None)
|
|
15
|
+
assert(props.dataConstrRef == None)
|
|
16
|
+
assert(props.implementationDataTypeRef == None)
|
|
17
|
+
assert(props.swImplPolicy == None)
|
|
18
|
+
assert(props.swCalibrationAccess == None)
|
|
19
19
|
assert(props.sw_pointer_target_props == None)
|
|
20
20
|
|
|
21
21
|
def test_SwPointerTargetProps(self):
|
|
@@ -26,4 +26,4 @@ class Test_M2_MSR_DataDictionary_DataDefProperties:
|
|
|
26
26
|
|
|
27
27
|
assert(props.function_pointer_signature == None)
|
|
28
28
|
assert(props.sw_data_def_props == None)
|
|
29
|
-
assert(props.target_category ==
|
|
29
|
+
assert(props.target_category == None)
|
|
@@ -42,9 +42,9 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_DataPrototypes:
|
|
|
42
42
|
assert(isinstance(prototype, MultilanguageReferrable))
|
|
43
43
|
assert(isinstance(prototype, Referrable))
|
|
44
44
|
|
|
45
|
-
assert(prototype.
|
|
45
|
+
assert(prototype._parent == ar_root)
|
|
46
46
|
assert(prototype.short_name == "prototype")
|
|
47
|
-
assert(
|
|
47
|
+
assert(prototype.type_tref is None)
|
|
48
48
|
|
|
49
49
|
def test_ApplicationCompositeElementDataPrototype(self):
|
|
50
50
|
with pytest.raises(NotImplementedError) as err:
|
|
@@ -83,4 +83,4 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_DataPrototypes:
|
|
|
83
83
|
assert(isinstance(prototype, Referrable))
|
|
84
84
|
assert(isinstance(prototype, ApplicationRecordElement))
|
|
85
85
|
|
|
86
|
-
assert(prototype.
|
|
86
|
+
assert(prototype.isOptional == None)
|
|
@@ -26,7 +26,7 @@ class Test_M2_AUTOSARTemplates_CommonStructure_Implementation:
|
|
|
26
26
|
assert(isinstance(prototype, Referrable))
|
|
27
27
|
assert(isinstance(prototype, SymbolProps))
|
|
28
28
|
|
|
29
|
-
assert(prototype.
|
|
29
|
+
assert(prototype._parent == ar_root)
|
|
30
30
|
assert(prototype.short_name == "SymbolProps")
|
|
31
31
|
assert(prototype.symbol == "")
|
|
32
32
|
|
|
@@ -52,9 +52,9 @@ class Test_M2_MSR_AsamHdo_BaseTypes:
|
|
|
52
52
|
assert(isinstance(base_type, Referrable))
|
|
53
53
|
assert(isinstance(base_type, SwBaseType))
|
|
54
54
|
|
|
55
|
-
assert(base_type.
|
|
55
|
+
assert(base_type._parent == ar_root)
|
|
56
56
|
assert(base_type.short_name == "SwBaseType")
|
|
57
|
-
assert(isinstance(base_type.
|
|
57
|
+
assert(isinstance(base_type.baseTypeDefinition, BaseTypeDirectDefinition))
|
|
58
58
|
|
|
59
59
|
class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
60
60
|
def test_AtpType(self):
|
|
@@ -97,7 +97,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
|
97
97
|
assert(isinstance(data_type, Referrable))
|
|
98
98
|
assert(isinstance(data_type, ApplicationPrimitiveDataType))
|
|
99
99
|
|
|
100
|
-
assert(data_type.
|
|
100
|
+
assert(data_type._parent == ar_root)
|
|
101
101
|
assert(data_type.short_name == "ApplicationPrimitiveDataType")
|
|
102
102
|
assert(data_type.sw_data_def_props == None)
|
|
103
103
|
|
|
@@ -128,9 +128,9 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
|
128
128
|
assert(isinstance(data_type, Referrable))
|
|
129
129
|
assert(isinstance(data_type, ApplicationArrayDataType))
|
|
130
130
|
|
|
131
|
-
assert(data_type.
|
|
131
|
+
assert(data_type._parent == ar_root)
|
|
132
132
|
assert(data_type.short_name == "ApplicationArrayDataType")
|
|
133
|
-
assert(data_type.dynamic_array_size_profile ==
|
|
133
|
+
assert(data_type.dynamic_array_size_profile == None)
|
|
134
134
|
assert(data_type.element == None)
|
|
135
135
|
|
|
136
136
|
def test_ApplicationRecordDataType(self):
|
|
@@ -153,7 +153,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
|
153
153
|
assert(isinstance(data_type, Referrable))
|
|
154
154
|
assert(isinstance(data_type, ApplicationRecordDataType))
|
|
155
155
|
|
|
156
|
-
assert(data_type.
|
|
156
|
+
assert(data_type._parent == ar_root)
|
|
157
157
|
assert(data_type.short_name == "ApplicationRecordDataType")
|
|
158
158
|
|
|
159
159
|
element = data_type.createApplicationRecordElement("element")
|
|
@@ -185,9 +185,9 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
|
185
185
|
assert(isinstance(data_type_mapping_set, Referrable))
|
|
186
186
|
assert(isinstance(data_type_mapping_set, DataTypeMappingSet))
|
|
187
187
|
|
|
188
|
-
assert(data_type_mapping_set.
|
|
188
|
+
assert(data_type_mapping_set._parent == ar_root)
|
|
189
189
|
assert(data_type_mapping_set.short_name == "DataTypeMappingSet")
|
|
190
|
-
assert(len(data_type_mapping_set.
|
|
190
|
+
assert(len(data_type_mapping_set._dataTypeMaps) == 0)
|
|
191
191
|
|
|
192
192
|
data_type_map = DataTypeMap()
|
|
193
193
|
data_type_mapping_set.addDataTypeMap(data_type_map)
|
|
@@ -224,11 +224,11 @@ class Test_M2_AUTOSARTemplates_CommonStructure_ImplementationDataTypes:
|
|
|
224
224
|
assert(isinstance(data_type, Referrable))
|
|
225
225
|
assert(isinstance(data_type, ImplementationDataType))
|
|
226
226
|
|
|
227
|
-
assert(data_type.
|
|
227
|
+
assert(data_type._parent == ar_root)
|
|
228
228
|
assert(data_type.short_name == "ImplementationDataType")
|
|
229
229
|
assert(data_type.sub_elements == [])
|
|
230
230
|
assert(data_type.symbol_props == None)
|
|
231
|
-
assert(data_type.
|
|
231
|
+
assert(data_type._type_emitter == None)
|
|
232
232
|
|
|
233
233
|
element = data_type.createImplementationDataTypeElement("ImplementationDataTypeElement")
|
|
234
234
|
assert(isinstance(element, ImplementationDataTypeElement))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
from ....models.implementation import AutosarEngineeringObject, Code
|
|
3
|
+
from ....models.ar_package import AUTOSAR
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestImplementation:
|
|
7
|
+
def test_code(self):
|
|
8
|
+
document = AUTOSAR.getInstance()
|
|
9
|
+
ar_root = document.createARPackage("AUTOSAR")
|
|
10
|
+
code = Code(ar_root, "code")
|
|
11
|
+
assert(code.short_name == "code")
|
|
12
|
+
|
|
13
|
+
data = [
|
|
14
|
+
["Autosar::include::BswM.h", "SWHDR"],
|
|
15
|
+
["Autosar::src::BswM.c", "SWSRC"]
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
for item in data:
|
|
19
|
+
engineering_obj = AutosarEngineeringObject()
|
|
20
|
+
engineering_obj.setShortLabel(item[0])\
|
|
21
|
+
.setCategory(item[1])
|
|
22
|
+
code.addArtifactDescriptor(engineering_obj)
|
|
23
|
+
|
|
24
|
+
assert(len(code.getArtifactDescriptors()) == 2)
|
|
25
|
+
assert(len(code.getArtifactDescriptors("SWHDR")) == 1)
|
|
26
|
+
assert(len(code.getArtifactDescriptors("SWSRC")) == 1)
|
|
@@ -57,10 +57,10 @@ class Test_M2_MSR_AsamHdo_ComputationMethod:
|
|
|
57
57
|
assert(isinstance(compu_scale, CompuScale))
|
|
58
58
|
|
|
59
59
|
assert(compu_scale.compu_content == None)
|
|
60
|
-
assert(compu_scale.
|
|
61
|
-
assert(compu_scale.
|
|
62
|
-
assert(compu_scale.
|
|
63
|
-
assert(compu_scale.
|
|
60
|
+
assert(compu_scale.lowerLimit == None)
|
|
61
|
+
assert(compu_scale.upperLimit == None)
|
|
62
|
+
assert(compu_scale.compuInverseValue == None)
|
|
63
|
+
assert(compu_scale.compuScaleContents == None)
|
|
64
64
|
|
|
65
65
|
def test_CompuScales(self):
|
|
66
66
|
compu_scales = CompuScales()
|
|
@@ -40,7 +40,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
|
|
|
40
40
|
assert(isinstance(data_if, Referrable))
|
|
41
41
|
assert(isinstance(data_if, NvDataInterface))
|
|
42
42
|
|
|
43
|
-
assert(data_if.
|
|
43
|
+
assert(data_if._parent == ar_root)
|
|
44
44
|
assert(data_if.short_name == "NvDataInterface")
|
|
45
45
|
|
|
46
46
|
def test_ParameterInterface(self):
|
|
@@ -63,7 +63,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
|
|
|
63
63
|
assert(isinstance(data_if, Referrable))
|
|
64
64
|
assert(isinstance(data_if, ParameterInterface))
|
|
65
65
|
|
|
66
|
-
assert(data_if.
|
|
66
|
+
assert(data_if._parent == ar_root)
|
|
67
67
|
assert(data_if.short_name == "ParameterInterface")
|
|
68
68
|
|
|
69
69
|
def test_SenderReceiverInterface(self):
|
|
@@ -87,7 +87,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
|
|
|
87
87
|
assert(isinstance(sr_if, SenderReceiverInterface))
|
|
88
88
|
|
|
89
89
|
assert(sr_if.short_name == "sr_if")
|
|
90
|
-
assert(sr_if.
|
|
90
|
+
assert(sr_if._parent == ar_root)
|
|
91
91
|
assert(len(sr_if.getDataElements()) == 0)
|
|
92
92
|
|
|
93
93
|
element = sr_if.createDataElement("element")
|
|
@@ -117,7 +117,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
|
|
|
117
117
|
assert(isinstance(prototype, Referrable))
|
|
118
118
|
assert(isinstance(prototype, ArgumentDataPrototype))
|
|
119
119
|
|
|
120
|
-
assert(prototype.
|
|
120
|
+
assert(prototype._parent == ar_root)
|
|
121
121
|
assert(prototype.short_name == "ArgumentDataPrototype")
|
|
122
122
|
assert(prototype.direction == "")
|
|
123
123
|
assert(prototype.server_argument_impl_policy == "")
|
|
@@ -133,7 +133,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_PortInterface:
|
|
|
133
133
|
assert(isinstance(app_error, Referrable))
|
|
134
134
|
assert(isinstance(app_error, ApplicationError))
|
|
135
135
|
|
|
136
|
-
assert(app_error.
|
|
136
|
+
assert(app_error._parent == ar_root)
|
|
137
137
|
assert(app_error.short_name == "ApplicationError")
|
|
138
138
|
|
|
139
139
|
def test_ClientServerOperation(self):
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
from ....parser.arxml_parser import ARXMLParser
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestARXMLParser:
|
|
6
|
+
def test_convert_find_key(self):
|
|
7
|
+
parser = ARXMLParser()
|
|
8
|
+
assert(parser.convert_find_key("ELEMENTS") == "xmlns:ELEMENTS")
|
|
9
|
+
assert(parser.convert_find_key("ELEMENTS/*") == "xmlns:ELEMENTS/*")
|
|
10
|
+
assert(parser.convert_find_key("./ELEMENTS") == "./xmlns:ELEMENTS")
|
|
11
|
+
assert(parser.convert_find_key("./ELEMENTS/*") == "./xmlns:ELEMENTS/*")
|
|
12
|
+
assert(parser.convert_find_key("A/B") == "xmlns:A/xmlns:B")
|
|
13
|
+
assert(parser.convert_find_key("A/B/*") == "xmlns:A/xmlns:B/*")
|
|
14
|
+
assert(parser.convert_find_key("./A/B") == "./xmlns:A/xmlns:B")
|
|
15
|
+
assert(parser.convert_find_key("./A/B/*") == "./xmlns:A/xmlns:B/*")
|