armodel 1.7.5__py3-none-any.whl → 1.7.7__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/models/M2/AUTOSARTemplates/AutosarTopLevelStructure.py +41 -2
- armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswBehavior.py +47 -6
- armodel/models/M2/AUTOSARTemplates/CommonStructure/Filter.py +17 -7
- armodel/models/M2/AUTOSARTemplates/CommonStructure/ImplementationDataTypes.py +2 -2
- armodel/models/M2/AUTOSARTemplates/CommonStructure/ResourceConsumption/MemorySectionUsage.py +4 -0
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/ARPackage.py +8 -2
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/Identifiable.py +9 -3
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/PrimitiveTypes.py +30 -1
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Communication.py +19 -5
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Components/__init__.py +53 -0
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Composition/__init__.py +2 -2
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Datatype/DataPrototypes.py +41 -16
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Datatype/Datatypes.py +10 -3
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/RTEEvents.py +26 -8
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/__init__.py +19 -5
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/DoIp.py +29 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/ECUResourceMapping.py +44 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Can/CanTopology.py +165 -4
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/EthernetTopology.py +409 -17
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/ServiceInstances.py +356 -8
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Lin/LinTopology.py +2 -4
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Multiplatform.py +76 -10
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreCommunication.py +483 -54
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreTopology.py +45 -23
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/EcuInstance.py +10 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/NetworkManagement.py +245 -130
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/SWmapping.py +27 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/TransportProtocols.py +633 -5
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/__init__.py +22 -11
- armodel/models/M2/MSR/AsamHdo/AdminData.py +1 -2
- armodel/models/M2/MSR/AsamHdo/ComputationMethod.py +3 -1
- armodel/models/M2/MSR/AsamHdo/SpecialData.py +35 -8
- armodel/models/M2/MSR/DataDictionary/RecordLayout.py +0 -3
- armodel/models/__init__.py +4 -0
- armodel/parser/abstract_arxml_parser.py +8 -5
- armodel/parser/arxml_parser.py +1229 -572
- armodel/tests/test_armodel/models/test_bsw_module_template.py +5 -3
- armodel/tests/test_armodel/models/test_datatype.py +1 -1
- armodel/tests/test_armodel/parser/test_bsw_module_descriiption.py +218 -0
- armodel/tests/test_armodel/parser/test_sw_components.py +22 -1
- armodel/writer/abstract_arxml_writer.py +7 -6
- armodel/writer/arxml_writer.py +1037 -187
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/METADATA +62 -3
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/RECORD +48 -44
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/LICENSE +0 -0
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/WHEEL +0 -0
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/entry_points.txt +0 -0
- {armodel-1.7.5.dist-info → armodel-1.7.7.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
3
|
from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswOverview import BswModuleDescription
|
|
4
|
-
|
|
5
4
|
from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswBehavior import BswCalledEntity, BswModuleEntity
|
|
6
|
-
|
|
7
5
|
from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswInterfaces import BswModuleEntry
|
|
6
|
+
from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.PrimitiveTypes import CategoryString
|
|
8
7
|
from .... import AUTOSAR
|
|
9
8
|
|
|
10
9
|
class TestBswModuleDescription:
|
|
@@ -24,7 +23,10 @@ class TestBswModuleDescription:
|
|
|
24
23
|
#assert(str(err.value) == "Invalid category <invalid> of BswModuleDescription <bsw_module>")
|
|
25
24
|
|
|
26
25
|
bsw_module_description.setCategory("BSW_MODULE")
|
|
27
|
-
assert(bsw_module_description.getCategory() == "BSW_MODULE")
|
|
26
|
+
assert(bsw_module_description.getCategory().getValue() == "BSW_MODULE")
|
|
27
|
+
|
|
28
|
+
bsw_module_description.setCategory(CategoryString().setValue("BSW_MODULE"))
|
|
29
|
+
assert(bsw_module_description.getCategory().getValue() == "BSW_MODULE")
|
|
28
30
|
|
|
29
31
|
class Test_M2_AUTOSARTemplates_BswModuleTemplate_BswInterfaces:
|
|
30
32
|
def test_BswModuleEntry(self):
|
|
@@ -144,7 +144,7 @@ class Test_M2_AUTOSARTemplates_SWComponentTemplate_Datatype_Datatypes:
|
|
|
144
144
|
|
|
145
145
|
assert(data_type.parent == ar_root)
|
|
146
146
|
assert(data_type.short_name == "ApplicationArrayDataType")
|
|
147
|
-
assert(data_type.
|
|
147
|
+
assert(data_type.dynamicArraySizeProfile == None)
|
|
148
148
|
assert(data_type.element == None)
|
|
149
149
|
|
|
150
150
|
def test_ApplicationRecordDataType(self):
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import filecmp
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswBehavior import BswInternalBehavior
|
|
5
|
+
from ....models.M2.AUTOSARTemplates.BswModuleTemplate.BswImplementation import BswImplementation
|
|
6
|
+
from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.EngineeringObject import AutosarEngineeringObject
|
|
7
|
+
from ....models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.ARPackage import ARPackage
|
|
8
|
+
|
|
9
|
+
from .... import AUTOSAR
|
|
10
|
+
from .... import ARXMLParser, ARXMLWriter
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
class TestBswMD:
|
|
15
|
+
def setup_method(self):
|
|
16
|
+
logger = logging.getLogger()
|
|
17
|
+
formatter = logging.Formatter('[%(levelname)s] : %(message)s')
|
|
18
|
+
logging.basicConfig(format='[%(levelname)s] : %(message)s', level = logging.DEBUG)
|
|
19
|
+
log_file = 'pytest_armodel.log'
|
|
20
|
+
|
|
21
|
+
file_handler = logging.FileHandler(log_file)
|
|
22
|
+
file_handler.setFormatter(formatter)
|
|
23
|
+
file_handler.setLevel(logging.DEBUG)
|
|
24
|
+
logger.addHandler(file_handler)
|
|
25
|
+
|
|
26
|
+
document = AUTOSAR.getInstance()
|
|
27
|
+
document.clear()
|
|
28
|
+
parser = ARXMLParser()
|
|
29
|
+
parser.load("src/armodel/tests/test_files/BswM_Bswmd.arxml", document)
|
|
30
|
+
|
|
31
|
+
def test_ar_packages(self):
|
|
32
|
+
document = AUTOSAR.getInstance()
|
|
33
|
+
root_pkgs = sorted(document.getARPackages(), key = lambda pkg: pkg.short_name)
|
|
34
|
+
assert(len(root_pkgs) == 2)
|
|
35
|
+
assert(root_pkgs[0].getShortName() == "AUTOSAR_BswM")
|
|
36
|
+
assert(root_pkgs[1].getShortName() == "EB_BswM_TxDxM1I14R0")
|
|
37
|
+
|
|
38
|
+
root_pkg_0_pkgs = sorted(root_pkgs[0].getARPackages(), key = lambda pkg: pkg.short_name)
|
|
39
|
+
assert(len(root_pkg_0_pkgs) == 3)
|
|
40
|
+
|
|
41
|
+
bsw_module_desc_pkg = root_pkg_0_pkgs[0] # type:ARPackage
|
|
42
|
+
assert(bsw_module_desc_pkg.getShortName() == "BswModuleDescriptions")
|
|
43
|
+
|
|
44
|
+
root_pkg_1_pkgs = root_pkgs[1].getARPackages()
|
|
45
|
+
assert(len(root_pkg_1_pkgs) == 1)
|
|
46
|
+
|
|
47
|
+
def test_bsw_module_description(self):
|
|
48
|
+
document = AUTOSAR.getInstance()
|
|
49
|
+
|
|
50
|
+
pkg = document.find("/AUTOSAR_BswM/BswModuleDescriptions") # type: ARPackage
|
|
51
|
+
bsw_module_descs = pkg.getBswModuleDescriptions()
|
|
52
|
+
assert(len(bsw_module_descs) == 1)
|
|
53
|
+
|
|
54
|
+
bsw_module_desc = bsw_module_descs[0]
|
|
55
|
+
assert(bsw_module_desc.getShortName() == "BswM")
|
|
56
|
+
assert(bsw_module_desc.moduleId.getText() == "34")
|
|
57
|
+
assert(bsw_module_desc.moduleId.getValue() == 34)
|
|
58
|
+
|
|
59
|
+
# verify the provided entries
|
|
60
|
+
assert(len(bsw_module_desc.implementedEntryRefs) == 2)
|
|
61
|
+
assert(bsw_module_desc.implementedEntryRefs[0].getDest() == "BSW-MODULE-ENTRY")
|
|
62
|
+
assert(bsw_module_desc.implementedEntryRefs[0].getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_Init")
|
|
63
|
+
assert(bsw_module_desc.implementedEntryRefs[1].getDest() == "BSW-MODULE-ENTRY")
|
|
64
|
+
assert(bsw_module_desc.implementedEntryRefs[1].getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_MainFunction")
|
|
65
|
+
|
|
66
|
+
assert(len(bsw_module_desc.getBswInternalBehaviors()) == 1)
|
|
67
|
+
behavior = bsw_module_desc.getBswInternalBehaviors()[0]
|
|
68
|
+
assert(behavior.short_name == "InternalBehavior_0")
|
|
69
|
+
|
|
70
|
+
assert(len(behavior.getDataTypeMappingRefs()) == 1)
|
|
71
|
+
data_type_mapping_ref = behavior.getDataTypeMappingRefs()[0]
|
|
72
|
+
assert(data_type_mapping_ref.getDest() == "DATA-TYPE-MAPPING-SET")
|
|
73
|
+
assert(data_type_mapping_ref.getValue() == "/BswMMode/DataTypeMappingSets/BswMModeMapping")
|
|
74
|
+
|
|
75
|
+
assert(len(behavior.getExclusiveAreas()) == 1)
|
|
76
|
+
assert(behavior.getExclusiveAreas()[0].short_name == "SCHM_BSWM_EXCLUSIVE_AREA")
|
|
77
|
+
|
|
78
|
+
assert(len(behavior.getBswSchedulableEntities()) == 1)
|
|
79
|
+
entity = behavior.getBswSchedulableEntities()[0]
|
|
80
|
+
assert(entity.short_name == "BswM_MainFunction")
|
|
81
|
+
assert(entity.minimumStartInterval is not None)
|
|
82
|
+
assert(entity.minimumStartIntervalMs is not None)
|
|
83
|
+
assert(len(entity.getCanEnterExclusiveAreaRefs()) == 1)
|
|
84
|
+
assert(entity.getCanEnterExclusiveAreaRefs()[0].getDest() == "EXCLUSIVE-AREA")
|
|
85
|
+
assert(entity.getCanEnterExclusiveAreaRefs()[0].getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/SCHM_BSWM_EXCLUSIVE_AREA")
|
|
86
|
+
assert(entity.implementedEntryRef.getDest() == "BSW-MODULE-ENTRY")
|
|
87
|
+
assert(entity.implementedEntryRef.getValue() == "/AUTOSAR_BswM/BswModuleEntrys/BswM_MainFunction")
|
|
88
|
+
|
|
89
|
+
assert(len(behavior.getBswTimingEvents()) == 1)
|
|
90
|
+
event = behavior.getBswTimingEvents()[0]
|
|
91
|
+
assert(event.short_name == "TimingEvent_MainFunction")
|
|
92
|
+
assert(event.startsOnEventRef.getDest() == "BSW-SCHEDULABLE-ENTITY")
|
|
93
|
+
assert(event.startsOnEventRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/BswM_MainFunction")
|
|
94
|
+
assert(event.period.getValue() == 0.02)
|
|
95
|
+
assert(event.period.getText() == "0.02")
|
|
96
|
+
assert(event.periodMs == 20)
|
|
97
|
+
|
|
98
|
+
def test_bsw_module_entries(self):
|
|
99
|
+
document = AUTOSAR.getInstance()
|
|
100
|
+
|
|
101
|
+
pkg = document.find("/AUTOSAR_BswM/BswModuleEntrys") # type: ARPackage
|
|
102
|
+
entries = sorted(pkg.getBswModuleEntries(), key= lambda entry: entry.short_name)
|
|
103
|
+
assert(len(entries) == 2)
|
|
104
|
+
|
|
105
|
+
assert(entries[0].getShortName() == "BswM_Init")
|
|
106
|
+
assert(entries[0].getServiceId().getValue() == 0)
|
|
107
|
+
assert(entries[0].getIsReentrant().getValue() == False)
|
|
108
|
+
assert(entries[0].getIsSynchronous().getValue() == True)
|
|
109
|
+
assert(entries[0].getCallType().getText() == "REGULAR")
|
|
110
|
+
assert(entries[0].getExecutionContext().getText() == "UNSPECIFIED")
|
|
111
|
+
assert(entries[0].getSwServiceImplPolicy().getText() == "STANDARD")
|
|
112
|
+
|
|
113
|
+
assert(entries[1].getShortName() == "BswM_MainFunction")
|
|
114
|
+
assert(entries[1].getServiceId().getValue() == 3)
|
|
115
|
+
assert(entries[1].getIsReentrant().getValue() == False)
|
|
116
|
+
assert(entries[1].getIsSynchronous().getValue() == True)
|
|
117
|
+
assert(entries[1].getCallType().getText() == "SCHEDULED")
|
|
118
|
+
assert(entries[1].getExecutionContext().getText() == "TASK")
|
|
119
|
+
assert(entries[1].getSwServiceImplPolicy().getText() == "STANDARD")
|
|
120
|
+
|
|
121
|
+
def test_bsw_module_swc_bsw_mapping(self):
|
|
122
|
+
document = AUTOSAR.getInstance()
|
|
123
|
+
|
|
124
|
+
pkg = document.find("/AUTOSAR_BswM/SwcBswMappings") # type: ARPackage
|
|
125
|
+
mappings = pkg.getSwcBswMappings()
|
|
126
|
+
assert(len(mappings) == 1)
|
|
127
|
+
|
|
128
|
+
assert(mappings[0].bswBehaviorRef.getDest() == "BSW-INTERNAL-BEHAVIOR")
|
|
129
|
+
assert(mappings[0].bswBehaviorRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
|
|
130
|
+
|
|
131
|
+
assert(len(mappings[0].getRunnableMappings()) == 1)
|
|
132
|
+
runnable_mapping = mappings[0].getRunnableMappings()[0]
|
|
133
|
+
assert(runnable_mapping.getBswEntityRef().getDest() == "BSW-SCHEDULABLE-ENTITY")
|
|
134
|
+
assert(runnable_mapping.getBswEntityRef().getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0/BswM_MainFunction")
|
|
135
|
+
assert(runnable_mapping.getSwcRunnableRef().getDest() == "RUNNABLE-ENTITY")
|
|
136
|
+
assert(runnable_mapping.getSwcRunnableRef().getValue() == "/AUTOSAR_BswM/SwComponentTypes/BswM/BswMInternalBehavior/RES_MainFunction")
|
|
137
|
+
|
|
138
|
+
def test_bsw_module_implementation(self):
|
|
139
|
+
document = AUTOSAR.getInstance()
|
|
140
|
+
|
|
141
|
+
pkg = document.find("/EB_BswM_TxDxM1I14R0/Implementations") # type: ARPackage
|
|
142
|
+
assert(len(pkg.getBswImplementations()) == 1)
|
|
143
|
+
impl = pkg.getBswImplementations()[0]
|
|
144
|
+
assert(impl.short_name == "BswImplementation_0")
|
|
145
|
+
assert(len(impl.getCodeDescriptors()) == 1)
|
|
146
|
+
|
|
147
|
+
code_desc = impl.getCodeDescriptors()[0]
|
|
148
|
+
assert(code_desc.short_name == "Files")
|
|
149
|
+
assert(len(code_desc.getArtifactDescriptors()) == 21)
|
|
150
|
+
assert(len(code_desc.getArtifactDescriptors("SWSRC")) == 4)
|
|
151
|
+
assert(len(code_desc.getArtifactDescriptors("SWHDR")) == 15)
|
|
152
|
+
assert(len(code_desc.getArtifactDescriptors("SWMAKE")) == 2)
|
|
153
|
+
|
|
154
|
+
artifact_descs = sorted(code_desc.getArtifactDescriptors("SWMAKE"), key = lambda o: o.getShortLabel().getValue()) # type: List[AutosarEngineeringObject]
|
|
155
|
+
assert(artifact_descs[0].getShortLabel().getValue() == "make::BswM_defs.mak")
|
|
156
|
+
assert(artifact_descs[0].getCategory().getValue() == "SWMAKE")
|
|
157
|
+
assert(artifact_descs[1].getShortLabel().getValue() == "make::BswM_rules.mak")
|
|
158
|
+
assert(artifact_descs[1].getCategory().getValue() == "SWMAKE")
|
|
159
|
+
|
|
160
|
+
assert(impl.programmingLanguage.getValue() == "C")
|
|
161
|
+
|
|
162
|
+
assert(impl.resourceConsumption.short_name == "ResourceConsumption")
|
|
163
|
+
assert(len(impl.resourceConsumption.getMemorySections()) == 8)
|
|
164
|
+
|
|
165
|
+
section = impl.resourceConsumption.getMemorySection("CODE")
|
|
166
|
+
assert(section.short_name == "CODE")
|
|
167
|
+
assert(section.alignment == None)
|
|
168
|
+
assert(section.swAddrMethodRef.getDest() == "SW-ADDR-METHOD")
|
|
169
|
+
assert(section.swAddrMethodRef.getValue() == "/AUTOSAR_MemMap/SwAddrMethods/CODE")
|
|
170
|
+
|
|
171
|
+
section = impl.resourceConsumption.getMemorySection("VAR_NO_INIT_UNSPECIFIED")
|
|
172
|
+
assert(section.short_name == "VAR_NO_INIT_UNSPECIFIED")
|
|
173
|
+
assert(section.alignment.getText() == "UNSPECIFIED")
|
|
174
|
+
assert(section.swAddrMethodRef.getDest() == "SW-ADDR-METHOD")
|
|
175
|
+
assert(section.swAddrMethodRef.getValue() == "/AUTOSAR_MemMap/SwAddrMethods/VAR_NOINIT")
|
|
176
|
+
|
|
177
|
+
assert(impl.vendorId.getValue() == 1)
|
|
178
|
+
assert(impl.swVersion.getValue() == "1.14.1")
|
|
179
|
+
assert(impl.swcBswMappingRef.getDest() == "SWC-BSW-MAPPING")
|
|
180
|
+
assert(impl.swcBswMappingRef.getValue() == "/AUTOSAR_BswM/SwcBswMappings/SwcBswMapping_0")
|
|
181
|
+
assert(impl.arReleaseVersion.getValue() == "4.0.3")
|
|
182
|
+
assert(impl.behaviorRef.getDest() == "BSW-INTERNAL-BEHAVIOR")
|
|
183
|
+
assert(impl.behaviorRef.getValue() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
|
|
184
|
+
|
|
185
|
+
def test_get_implementation(self):
|
|
186
|
+
document = AUTOSAR.getInstance()
|
|
187
|
+
impl = document.getImplementation("/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
|
|
188
|
+
assert(impl.getFullName() == "/EB_BswM_TxDxM1I14R0/Implementations/BswImplementation_0")
|
|
189
|
+
assert(isinstance(impl, BswImplementation))
|
|
190
|
+
|
|
191
|
+
def test_get_behavior(self):
|
|
192
|
+
document = AUTOSAR.getInstance()
|
|
193
|
+
behavior = document.getBehavior("/EB_BswM_TxDxM1I14R0/Implementations/BswImplementation_0")
|
|
194
|
+
assert(behavior.getFullName() == "/AUTOSAR_BswM/BswModuleDescriptions/BswM/InternalBehavior_0")
|
|
195
|
+
assert(isinstance(behavior, BswInternalBehavior))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def test_load_save(self):
|
|
199
|
+
document = AUTOSAR.getInstance()
|
|
200
|
+
document.clear()
|
|
201
|
+
parser = ARXMLParser()
|
|
202
|
+
parser.load("src/armodel/tests/test_files/SoftwareComponents.arxml", document)
|
|
203
|
+
|
|
204
|
+
writer = ARXMLWriter()
|
|
205
|
+
writer.save("data/generated.arxml", document)
|
|
206
|
+
|
|
207
|
+
assert(filecmp.cmp("src/armodel/tests/test_files/SoftwareComponents.arxml", "data/generated.arxml", shallow = False) == True)
|
|
208
|
+
|
|
209
|
+
def test_bswm_bswmd_arxml_loading_and_saving(self):
|
|
210
|
+
document = AUTOSAR.getInstance()
|
|
211
|
+
document.clear()
|
|
212
|
+
parser = ARXMLParser()
|
|
213
|
+
parser.load("src/armodel/tests/test_files/BswM_Bswmd.arxml", document)
|
|
214
|
+
|
|
215
|
+
writer = ARXMLWriter()
|
|
216
|
+
writer.save("data/generated_BswM_Bswmd.arxml", document)
|
|
217
|
+
|
|
218
|
+
assert(filecmp.cmp("src/armodel/tests/test_files/BswM_Bswmd.arxml", "data/generated_BswM_Bswmd.arxml", shallow = False) == True)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import filecmp
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
from ....models.M2.AUTOSARTemplates.CommonStructure.InternalBehavior import InternalBehavior
|
|
4
|
+
from ....models.M2.AUTOSARTemplates.SWComponentTemplate.SwcImplementation import SwcImplementation
|
|
5
|
+
from ....models.M2.AUTOSARTemplates.SWComponentTemplate.Components import AtomicSwComponentType, CompositionSwComponentType
|
|
3
6
|
from ....writer.arxml_writer import ARXMLWriter
|
|
4
7
|
from ....parser.arxml_parser import ARXMLParser
|
|
5
8
|
from ....models.M2.AUTOSARTemplates.AutosarTopLevelStructure import AUTOSAR
|
|
@@ -18,6 +21,24 @@ class TestSWComponents:
|
|
|
18
21
|
assert(len(root_pkgs) == 1)
|
|
19
22
|
assert("DemoApplication" == root_pkgs[0].getShortName())
|
|
20
23
|
|
|
24
|
+
def test_sw_component(self):
|
|
25
|
+
document = AUTOSAR.getInstance()
|
|
26
|
+
sw_component = document.find("/DemoApplication/SwComponentTypes/SWC_CyclicCounter")
|
|
27
|
+
assert(sw_component.getShortName() == 'SWC_CyclicCounter')
|
|
28
|
+
assert(isinstance(sw_component, AtomicSwComponentType))
|
|
29
|
+
|
|
30
|
+
def test_get_implementation(self):
|
|
31
|
+
document = AUTOSAR.getInstance()
|
|
32
|
+
impl = document.getImplementation("/DemoApplication/SwComponentTypes/SWC_CyclicCounter/IB_SWC_CyclicCounter")
|
|
33
|
+
assert(impl.getFullName() == "/DemoApplication/SwcImplementations/Impl_SWC_CyclicCounter")
|
|
34
|
+
assert(isinstance(impl, SwcImplementation))
|
|
35
|
+
|
|
36
|
+
def test_get_behavior(self):
|
|
37
|
+
document = AUTOSAR.getInstance()
|
|
38
|
+
behavior = document.getBehavior("/DemoApplication/SwcImplementations/Impl_SWC_CyclicCounter")
|
|
39
|
+
assert(behavior.getFullName() == "/DemoApplication/SwComponentTypes/SWC_CyclicCounter/IB_SWC_CyclicCounter")
|
|
40
|
+
assert(isinstance(behavior, InternalBehavior))
|
|
41
|
+
|
|
21
42
|
def test_composition_sw_component_types(self):
|
|
22
43
|
document = AUTOSAR.getInstance()
|
|
23
44
|
sw_component = document.find("/DemoApplication/SwComponentTypes/TopLevelComposition")
|
|
@@ -45,7 +45,7 @@ class AbstractARXMLWriter:
|
|
|
45
45
|
else:
|
|
46
46
|
raise NotImplementedError(error_msg)
|
|
47
47
|
|
|
48
|
-
def
|
|
48
|
+
def writeARObjectAttributes(self, element: ET.Element, ar_obj: ARObject):
|
|
49
49
|
if ar_obj.timestamp is not None:
|
|
50
50
|
self.logger.debug("Timestamp: %s" % ar_obj.timestamp)
|
|
51
51
|
element.attrib['T'] = ar_obj.timestamp
|
|
@@ -70,7 +70,7 @@ class AbstractARXMLWriter:
|
|
|
70
70
|
def setChildElementOptionalNumericalValue(self, element: ET.Element, key: str, numerical: ARNumerical):
|
|
71
71
|
if numerical is not None:
|
|
72
72
|
child_element = ET.SubElement(element, key)
|
|
73
|
-
self.
|
|
73
|
+
self.writeARObjectAttributes(child_element, numerical)
|
|
74
74
|
child_element.text = numerical._text
|
|
75
75
|
|
|
76
76
|
def setChildElementOptionalIntegerValue(self, element: ET.Element, key: str, value: Integer):
|
|
@@ -82,7 +82,7 @@ class AbstractARXMLWriter:
|
|
|
82
82
|
def setChildElementOptionalLiteral(self, element: ET.Element, key: str, literal: ARLiteral):
|
|
83
83
|
if literal is not None:
|
|
84
84
|
child_element = ET.SubElement(element, key)
|
|
85
|
-
self.
|
|
85
|
+
self.writeARObjectAttributes(child_element, literal)
|
|
86
86
|
if literal._value is not None:
|
|
87
87
|
child_element.text = str(literal._value)
|
|
88
88
|
|
|
@@ -104,7 +104,7 @@ class AbstractARXMLWriter:
|
|
|
104
104
|
def setChildElementOptionalFloatValue(self, element: ET.Element, key: str, value: ARFloat):
|
|
105
105
|
if value is not None:
|
|
106
106
|
child_element = ET.SubElement(element, key)
|
|
107
|
-
self.
|
|
107
|
+
self.writeARObjectAttributes(child_element, value)
|
|
108
108
|
child_element.text = value.getText()
|
|
109
109
|
|
|
110
110
|
def setChildElementOptionalTimeValue(self, element: ET.Element, key: str, value: TimeValue):
|
|
@@ -114,7 +114,7 @@ class AbstractARXMLWriter:
|
|
|
114
114
|
child_element = None
|
|
115
115
|
if value is not None:
|
|
116
116
|
child_element = ET.SubElement(element, key)
|
|
117
|
-
self.
|
|
117
|
+
self.writeARObjectAttributes(child_element, value)
|
|
118
118
|
child_element.text = value.getText()
|
|
119
119
|
return element
|
|
120
120
|
|
|
@@ -122,13 +122,14 @@ class AbstractARXMLWriter:
|
|
|
122
122
|
child_element = None
|
|
123
123
|
if value is not None:
|
|
124
124
|
child_element = ET.SubElement(element, key)
|
|
125
|
-
self.
|
|
125
|
+
self.writeARObjectAttributes(child_element, value)
|
|
126
126
|
child_element.text = value.getText()
|
|
127
127
|
return element
|
|
128
128
|
|
|
129
129
|
def patch_xml(self, xml: str) -> str:
|
|
130
130
|
xml = re.sub(r"\<([\w-]+)\/\>",r"<\1></\1>", xml)
|
|
131
131
|
xml = re.sub(r"<(([\w-]+)\s+\w+=\"[\w-]+\")\/>", r"<\1></\2>", xml)
|
|
132
|
+
xml = re.sub(r""", '"', xml)
|
|
132
133
|
return xml
|
|
133
134
|
|
|
134
135
|
def saveToFile(self, filename, root: ET.Element):
|