armodel 1.3.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/connector2xlsx_cli.py +75 -0
- armodel/cli/connector_update_cli.py +77 -0
- armodel/cli/swc_list_cli.py +2 -2
- armodel/data_models/__init__.py +0 -0
- armodel/data_models/sw_connector.py +22 -0
- armodel/lib/__init__.py +1 -1
- armodel/lib/sw_component.py +34 -0
- armodel/models/__init__.py +8 -2
- armodel/models/annotation.py +20 -0
- armodel/models/ar_object.py +184 -0
- armodel/models/ar_package.py +144 -14
- armodel/models/ar_ref.py +74 -8
- armodel/models/bsw_module_template.py +97 -25
- armodel/models/calibration.py +119 -0
- armodel/models/common_structure.py +203 -36
- armodel/models/communication.py +17 -0
- 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 +86 -19
- armodel/models/end_to_end_protection.py +67 -0
- armodel/models/general_structure.py +72 -17
- armodel/models/global_constraints.py +40 -0
- armodel/models/implementation.py +80 -32
- armodel/models/m2_msr.py +82 -6
- 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 +48 -23
- 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 +257 -43
- armodel/models/unit.py +14 -0
- armodel/parser/abstract_arxml_parser.py +248 -0
- armodel/parser/arxml_parser.py +1550 -648
- armodel/parser/connector_xlsx_parser.py +190 -0
- armodel/parser/excel_parser.py +18 -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_object.py +152 -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_implementation.py +26 -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_arxml_parser.py +15 -0
- armodel/tests/test_armodel/parser/test_parse_bswmd.py +192 -0
- armodel/tests/test_armodel/parser/test_sw_components.py +93 -0
- armodel/writer/__init__.py +1 -0
- armodel/writer/abstract_arxml_writer.py +123 -0
- armodel/writer/arxml_writer.py +1755 -0
- {armodel-1.3.0.dist-info → armodel-1.4.3.dist-info}/METADATA +124 -4
- armodel-1.4.3.dist-info/RECORD +78 -0
- armodel-1.4.3.dist-info/entry_points.txt +7 -0
- armodel-1.3.0.dist-info/RECORD +0 -31
- armodel-1.3.0.dist-info/entry_points.txt +0 -4
- {armodel-1.3.0.dist-info → armodel-1.4.3.dist-info}/LICENSE +0 -0
- {armodel-1.3.0.dist-info → armodel-1.4.3.dist-info}/WHEEL +0 -0
- {armodel-1.3.0.dist-info → armodel-1.4.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1755 @@
|
|
|
1
|
+
import xml.etree.cElementTree as ET
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
from armodel.writer.abstract_arxml_writer import AbstractARXMLWriter
|
|
6
|
+
|
|
7
|
+
from ..models.data_def_properties import ValueList
|
|
8
|
+
from ..models.multilanguage_data import MultiLanguageOverviewParagraph, MultilanguageLongName
|
|
9
|
+
from ..models.record_layout import SwRecordLayout, SwRecordLayoutGroup, SwRecordLayoutV
|
|
10
|
+
from ..models.service_mapping import RoleBasedPortAssignment
|
|
11
|
+
from ..models.service_needs import NvBlockNeeds, RoleBasedDataAssignment
|
|
12
|
+
from ..models.data_prototype import ApplicationArrayElement, ApplicationCompositeElementDataPrototype, ApplicationRecordElement, AutosarDataPrototype, DataPrototype, ParameterDataPrototype, VariableDataPrototype
|
|
13
|
+
from ..models.bsw_module_template import BswCalledEntity, BswEvent, BswInternalBehavior, BswModeSenderPolicy, BswModuleDescription, BswModuleEntity, BswModuleEntry, BswSchedulableEntity, BswScheduleEvent, BswTimingEvent
|
|
14
|
+
from ..models.ar_package import AUTOSAR
|
|
15
|
+
from ..models.sw_component import ApplicationSwComponentType, AtomicSwComponentType, ComplexDeviceDriverSwComponentType, DataReceivedEvent, EcuAbstractionSwComponentType, InternalTriggerOccurredEvent, OperationInvokedEvent, ParameterAccess, PortAPIOption, PortGroup, RTEEvent, ServerCallPoint, ServiceDependency, ServiceSwComponentType, SwcModeSwitchEvent, SwcServiceDependency, SynchronousServerCallPoint, VariableAccess
|
|
16
|
+
from ..models.ar_package import ARPackage
|
|
17
|
+
from ..models.ar_ref import ApplicationCompositeElementInPortInterfaceInstanceRef, AutosarParameterRef, AutosarVariableRef, InnerPortGroupInCompositionInstanceRef, POperationInAtomicSwcInstanceRef, PPortInCompositionInstanceRef, RModeInAtomicSwcInstanceRef, ROperationInAtomicSwcInstanceRef, RPortInCompositionInstanceRef, RVariableInAtomicSwcInstanceRef, VariableDataPrototypeInSystemInstanceRef
|
|
18
|
+
from ..models.calibration import SwAxisGrouped, SwAxisIndividual, SwCalprmAxis, SwCalprmAxisSet, SwValueCont, SwValues
|
|
19
|
+
from ..models.common_structure import ApplicationValueSpecification, ArrayValueSpecification, ConstantReference, ModeDeclaration, ModeDeclarationGroup, ModeDeclarationGroupPrototype, NumericalValueSpecification, RecordValueSpecification, TextValueSpecification, ValueSpecification
|
|
20
|
+
from ..models.communication import CompositeNetworkRepresentation, TransmissionAcknowledgementRequest
|
|
21
|
+
from ..models.data_dictionary import SwAddrMethod, SwDataDefProps
|
|
22
|
+
from ..models.datatype import ApplicationArrayDataType, ApplicationCompositeDataType, ApplicationDataType, ApplicationPrimitiveDataType, ApplicationRecordDataType, AutosarDataType, BaseTypeDirectDefinition, DataTypeMappingSet, ImplementationDataType, SwBaseType
|
|
23
|
+
from ..models.general_structure import ARElement, AdminData, Identifiable, Limit, MultilanguageReferrable, Referrable, Sdg, SwcBswMapping, SwcBswRunnableMapping
|
|
24
|
+
from ..models.m2_msr import CompuConstTextContent, CompuMethod, CompuNominatorDenominator, CompuScale, CompuScaleConstantContents, CompuScaleRationalFormula, CompuScales
|
|
25
|
+
from ..models.port_prototype import ClientComSpec, NonqueuedReceiverComSpec, NonqueuedSenderComSpec, PPortComSpec, PPortPrototype, PortPrototype, QueuedReceiverComSpec, RPortComSpec, RPortPrototype, ReceiverComSpec, SenderComSpec, ServerComSpec
|
|
26
|
+
from ..models.sw_component import AssemblySwConnector, CompositionSwComponentType, DelegationSwConnector, SwComponentPrototype, SwComponentType, SwConnector
|
|
27
|
+
from ..models.annotation import Annotation
|
|
28
|
+
from ..models.end_to_end_protection import EndToEndDescription, EndToEndProtection, EndToEndProtectionSet, EndToEndProtectionVariablePrototype
|
|
29
|
+
from ..models.port_interface import ApplicationError, ClientServerInterface, ClientServerOperation, ModeSwitchInterface, PortInterface, SenderReceiverInterface, TriggerInterface
|
|
30
|
+
from ..models.unit import Unit
|
|
31
|
+
from ..models.implementation import AutosarEngineeringObject, BswImplementation, Code, EngineeringObject, Implementation, SwcImplementation
|
|
32
|
+
from ..models.common_structure import ConstantSpecification, ExecutableEntity, InternalBehavior, ResourceConsumption
|
|
33
|
+
from ..models.sw_component import RunnableEntity, SwcInternalBehavior, TimingEvent
|
|
34
|
+
from ..models.ar_object import ARLiteral
|
|
35
|
+
from ..models.global_constraints import DataConstr, InternalConstrs, PhysConstrs
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ARXMLWriter(AbstractARXMLWriter):
|
|
39
|
+
def __init__(self, options=None) -> None:
|
|
40
|
+
super().__init__(options)
|
|
41
|
+
|
|
42
|
+
def setShortName(self, parent: ET.Element, name: str) -> ET.Element:
|
|
43
|
+
sub_element = ET.SubElement(parent, "SHORT-NAME")
|
|
44
|
+
sub_element.text = name
|
|
45
|
+
|
|
46
|
+
return sub_element
|
|
47
|
+
|
|
48
|
+
def writeSd(self, parent: ET.Element, sdg: Sdg):
|
|
49
|
+
for sd in sdg.getSds():
|
|
50
|
+
sd_tag = ET.SubElement(parent, "SD")
|
|
51
|
+
sd_tag.attrib['GID'] = sd.gid
|
|
52
|
+
sd_tag.text = sd.value
|
|
53
|
+
|
|
54
|
+
def writeSdg(self, parent: ET.Element, admin_data: AdminData):
|
|
55
|
+
sdgs = admin_data.getSdgs()
|
|
56
|
+
if len(sdgs) > 0:
|
|
57
|
+
sdgs_tag = ET.SubElement(parent, "SDGS")
|
|
58
|
+
for sdg in sdgs:
|
|
59
|
+
sdg_tag = ET.SubElement(sdgs_tag, "SDG")
|
|
60
|
+
sdg_tag.attrib['GID'] = sdg.gid
|
|
61
|
+
self.writeSd(sdg_tag, sdg)
|
|
62
|
+
|
|
63
|
+
def writeChildLimitElement(self, element: ET.Element, key: str, limit: Limit):
|
|
64
|
+
if limit is not None:
|
|
65
|
+
limit_tag = ET.SubElement(element, key)
|
|
66
|
+
self.setARObjectAttributes(limit_tag, limit)
|
|
67
|
+
if limit.intervalType is not None:
|
|
68
|
+
limit_tag.attrib['INTERVAL-TYPE'] = limit.intervalType
|
|
69
|
+
limit_tag.text = limit.value
|
|
70
|
+
|
|
71
|
+
def writeReferable(self, element: ET.Element, referrable: Referrable):
|
|
72
|
+
self.setARObjectAttributes(element, referrable)
|
|
73
|
+
self.setShortName(element, referrable.short_name)
|
|
74
|
+
|
|
75
|
+
def setMultiLongName(self, element: ET.Element, key: str, long_name: MultilanguageLongName):
|
|
76
|
+
if long_name is not None:
|
|
77
|
+
long_name_tag = ET.SubElement(element, key)
|
|
78
|
+
self.setARObjectAttributes(long_name_tag, long_name)
|
|
79
|
+
for l4 in long_name.getL4s():
|
|
80
|
+
l4_tag = ET.SubElement(long_name_tag, "L-4")
|
|
81
|
+
self.setARObjectAttributes(l4_tag, l4)
|
|
82
|
+
if l4.l is not None:
|
|
83
|
+
l4_tag.attrib['L'] = l4.l
|
|
84
|
+
l4_tag.text = l4.value
|
|
85
|
+
|
|
86
|
+
def setMultiLanguageOverviewParagraph(self, element: ET.Element, key: str, paragraph: MultiLanguageOverviewParagraph):
|
|
87
|
+
if paragraph is not None:
|
|
88
|
+
long_name_tag = ET.SubElement(element, key)
|
|
89
|
+
self.setARObjectAttributes(long_name_tag, paragraph)
|
|
90
|
+
for l2 in paragraph.getL2s():
|
|
91
|
+
l2_tag = ET.SubElement(long_name_tag, "L-2")
|
|
92
|
+
self.setARObjectAttributes(l2_tag, l2)
|
|
93
|
+
if l2.l is not None:
|
|
94
|
+
l2_tag.attrib['L'] = l2.l
|
|
95
|
+
l2_tag.text = l2.value
|
|
96
|
+
|
|
97
|
+
def writeMultilanguageReferrable(self, element: ET.Element, referrable: MultilanguageReferrable):
|
|
98
|
+
self.writeReferable(element, referrable)
|
|
99
|
+
if referrable.long_name is not None:
|
|
100
|
+
self.setMultiLongName(element, "LONG-NAME", referrable.long_name)
|
|
101
|
+
|
|
102
|
+
def writeAdminData(self, element: ET.Element, admin_data: AdminData):
|
|
103
|
+
element = ET.SubElement(element, "ADMIN-DATA")
|
|
104
|
+
self.writeSdg(element, admin_data)
|
|
105
|
+
|
|
106
|
+
def writeIdentifiable(self, element: ET.Element, identifiable: Identifiable):
|
|
107
|
+
self.writeMultilanguageReferrable(element, identifiable)
|
|
108
|
+
self.setMultiLanguageOverviewParagraph(element, "DESC", identifiable.desc)
|
|
109
|
+
self.setChildElementOptionalLiteral(element, "CATEGORY", identifiable.category)
|
|
110
|
+
if identifiable.admin_data is not None:
|
|
111
|
+
self.writeAdminData(element, identifiable.admin_data)
|
|
112
|
+
|
|
113
|
+
def writeARElement(self, parent: ET.Element, ar_element: ARElement):
|
|
114
|
+
self.writeIdentifiable(parent, ar_element)
|
|
115
|
+
|
|
116
|
+
def writeTransmissionAcknowledgementRequest(self, element: ET.Element, acknowledge: TransmissionAcknowledgementRequest):
|
|
117
|
+
if (acknowledge != None):
|
|
118
|
+
child_element = ET.SubElement(element, "TRANSMISSION-ACKNOWLEDGE")
|
|
119
|
+
self.setARObjectAttributes(child_element, acknowledge)
|
|
120
|
+
if acknowledge.timeout != None:
|
|
121
|
+
self.setChildElementOptionalFloatValue(child_element, "TIMEOUT", acknowledge.timeout)
|
|
122
|
+
|
|
123
|
+
def writeSenderComSpec(self, element: ET.Element, com_spec: SenderComSpec):
|
|
124
|
+
representations = com_spec.getCompositeNetworkRepresentations()
|
|
125
|
+
if len(representations) > 0:
|
|
126
|
+
child_element = ET.SubElement(element, "COMPOSITE-NETWORK-REPRESENTATIONS")
|
|
127
|
+
for representation in representations:
|
|
128
|
+
self.setCompositeNetworkRepresentation(child_element, representation)
|
|
129
|
+
self.setChildElementOptionalRefType(element, "DATA-ELEMENT-REF", com_spec.data_element_ref)
|
|
130
|
+
self.setSwDataDefProps(element, "NETWORK-REPRESENTATION", com_spec.network_representation)
|
|
131
|
+
self.setChildElementOptionalLiteral(element, "HANDLE-OUT-OF-RANGE", com_spec.handle_out_of_range)
|
|
132
|
+
self.writeTransmissionAcknowledgementRequest(element, com_spec.transmission_acknowledge)
|
|
133
|
+
self.setChildElementOptionalBooleanValue(element, "USES-END-TO-END-PROTECTION", com_spec.uses_end_to_end_protection)
|
|
134
|
+
|
|
135
|
+
def writeNonqueuedSenderComSpec(self, com_specs_tag: ET.Element, com_spec: NonqueuedSenderComSpec):
|
|
136
|
+
com_spec_tag = ET.SubElement(com_specs_tag, "NONQUEUED-SENDER-COM-SPEC")
|
|
137
|
+
self.setARObjectAttributes(com_spec_tag, com_spec)
|
|
138
|
+
self.writeSenderComSpec(com_spec_tag, com_spec)
|
|
139
|
+
self.setInitValue(com_spec_tag, com_spec.init_value)
|
|
140
|
+
|
|
141
|
+
def writeServerComSpec(self, com_specs_tag: ET.Element, com_spec: ServerComSpec):
|
|
142
|
+
com_spec_tag = ET.SubElement(com_specs_tag, "SERVER-COM-SPEC")
|
|
143
|
+
self.setARObjectAttributes(com_spec_tag, com_spec)
|
|
144
|
+
self.setChildElementOptionalRefType(com_spec_tag, "OPERATION-REF", com_spec.operation_ref)
|
|
145
|
+
self.setChildElementOptionalNumericalValue(com_spec_tag, "QUEUE-LENGTH", com_spec.queue_length)
|
|
146
|
+
|
|
147
|
+
def writePPortComSpec(self, com_specs_tag: ET.Element, com_spec: PPortComSpec):
|
|
148
|
+
if isinstance(com_spec, NonqueuedSenderComSpec):
|
|
149
|
+
self.writeNonqueuedSenderComSpec(com_specs_tag, com_spec)
|
|
150
|
+
elif isinstance(com_spec, ServerComSpec):
|
|
151
|
+
self.writeServerComSpec(com_specs_tag, com_spec)
|
|
152
|
+
else:
|
|
153
|
+
raise NotImplementedError("Unsupported PPortComSpec %s" % type(com_spec))
|
|
154
|
+
|
|
155
|
+
def setApplicationCompositeElementInPortInterfaceInstanceRef(self, element: ET.Element, key:str, iref: ApplicationCompositeElementInPortInterfaceInstanceRef):
|
|
156
|
+
if iref is not None:
|
|
157
|
+
child_element = ET.SubElement(element, key)
|
|
158
|
+
self.setChildElementOptionalRefType(child_element, "ROOT-DATA-PROTOTYPE-REF", iref.root_data_prototype_ref)
|
|
159
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-DATA-PROTOTYPE-REF", iref.target_data_prototype_ref)
|
|
160
|
+
return iref
|
|
161
|
+
|
|
162
|
+
def setCompositeNetworkRepresentation(self, element: ET.Element, representation: CompositeNetworkRepresentation):
|
|
163
|
+
if representation is not None:
|
|
164
|
+
self.logger.debug("setCompositeNetworkRepresentation")
|
|
165
|
+
child_element = ET.SubElement(element, "COMPOSITE-NETWORK-REPRESENTATION")
|
|
166
|
+
self.setApplicationCompositeElementInPortInterfaceInstanceRef(child_element, "LEAF-ELEMENT-IREF", representation.leaf_element_iref)
|
|
167
|
+
self.setSwDataDefProps(child_element, "NETWORK-REPRESENTATION", representation.network_representation)
|
|
168
|
+
|
|
169
|
+
def writeReceiverComSpec(self, element: ET.Element, com_spec: ReceiverComSpec):
|
|
170
|
+
representations = com_spec.getCompositeNetworkRepresentations()
|
|
171
|
+
if len(representations) > 0:
|
|
172
|
+
child_element = ET.SubElement(element, "COMPOSITE-NETWORK-REPRESENTATIONS")
|
|
173
|
+
for representation in representations:
|
|
174
|
+
self.setCompositeNetworkRepresentation(child_element, representation)
|
|
175
|
+
self.setChildElementOptionalRefType(element, "DATA-ELEMENT-REF", com_spec.data_element_ref)
|
|
176
|
+
self.setSwDataDefProps(element, "NETWORK-REPRESENTATION", com_spec.network_representation)
|
|
177
|
+
self.setChildElementOptionalLiteral(element, "HANDLE-OUT-OF-RANGE", com_spec.handle_out_of_range)
|
|
178
|
+
self.setChildElementOptionalBooleanValue(element, "USES-END-TO-END-PROTECTION", com_spec.uses_end_to_end_protection)
|
|
179
|
+
|
|
180
|
+
def setSwValues(self, element: ET.Element, key: str, sw_values: SwValues):
|
|
181
|
+
if sw_values is not None:
|
|
182
|
+
child_element = ET.SubElement(element, key)
|
|
183
|
+
self.setARObjectAttributes(child_element, sw_values)
|
|
184
|
+
for v in sw_values.getVs():
|
|
185
|
+
self.setChildElementOptionalFloatValue(child_element, "V", v)
|
|
186
|
+
self.setChildElementOptionalLiteral(child_element, "VT", sw_values.vt)
|
|
187
|
+
|
|
188
|
+
def setValueList(self, element: ET.Element, key: str, value_list: ValueList):
|
|
189
|
+
if value_list is not None:
|
|
190
|
+
child_element = ET.SubElement(element, key)
|
|
191
|
+
self.setARObjectAttributes(child_element, value_list)
|
|
192
|
+
self.setChildElementOptionalFloatValue(child_element, "V", value_list.v)
|
|
193
|
+
|
|
194
|
+
def writeSwValueCont(self, element: ET.Element, cont: SwValueCont):
|
|
195
|
+
child_element = ET.SubElement(element, "SW-VALUE-CONT")
|
|
196
|
+
self.setARObjectAttributes(child_element, cont)
|
|
197
|
+
self.setChildElementOptionalRefType(child_element, "UNIT-REF", cont.unit_ref)
|
|
198
|
+
self.setValueList(child_element, "SW-ARRAYSIZE", cont.sw_arraysize)
|
|
199
|
+
self.setSwValues(child_element, "SW-VALUES-PHYS", cont.sw_values_phys)
|
|
200
|
+
|
|
201
|
+
def writeValueSpecification(self, element: ET.Element, value_spec: ValueSpecification):
|
|
202
|
+
self.setARObjectAttributes(element, value_spec)
|
|
203
|
+
if value_spec.short_label is not None:
|
|
204
|
+
self.setChildElementOptionalLiteral(element, "SHORT-LABEL", value_spec.short_label)
|
|
205
|
+
|
|
206
|
+
def setApplicationValueSpecification(self, element: ET.Element, value_spec: ApplicationValueSpecification):
|
|
207
|
+
value_spec_tag = ET.SubElement(element, "APPLICATION-VALUE-SPECIFICATION")
|
|
208
|
+
self.writeValueSpecification(value_spec_tag, value_spec)
|
|
209
|
+
self.setChildElementOptionalLiteral(value_spec_tag, "CATEGORY", value_spec.category)
|
|
210
|
+
self.writeSwValueCont(value_spec_tag, value_spec.sw_value_cont)
|
|
211
|
+
|
|
212
|
+
def setTextValueSpecification(self, element: ET.Element, value_spec: TextValueSpecification):
|
|
213
|
+
value_spec_tag = ET.SubElement(element, "TEXT-VALUE-SPECIFICATION")
|
|
214
|
+
self.writeValueSpecification(value_spec_tag, value_spec)
|
|
215
|
+
self.setChildElementOptionalLiteral(value_spec_tag, "VALUE", value_spec.value)
|
|
216
|
+
|
|
217
|
+
def setNumericalValueSpecification(self, element: ET.Element, value_spec: NumericalValueSpecification):
|
|
218
|
+
value_spec_tag = ET.SubElement(element, "NUMERICAL-VALUE-SPECIFICATION")
|
|
219
|
+
self.writeValueSpecification(value_spec_tag, value_spec)
|
|
220
|
+
self.setChildElementOptionalFloatValue(value_spec_tag, "VALUE", value_spec.value)
|
|
221
|
+
|
|
222
|
+
def setArrayValueSpecification(self, element: ET.Element, value_spec: ArrayValueSpecification):
|
|
223
|
+
value_spec_tag = ET.SubElement(element, "ARRAY-VALUE-SPECIFICATION")
|
|
224
|
+
self.writeValueSpecification(value_spec_tag, value_spec)
|
|
225
|
+
sub_elements = value_spec.get_elements()
|
|
226
|
+
if len(sub_elements) > 0:
|
|
227
|
+
elements_tag = ET.SubElement(value_spec_tag, "ELEMENTS")
|
|
228
|
+
for sub_element in sub_elements:
|
|
229
|
+
if isinstance(sub_element, NumericalValueSpecification):
|
|
230
|
+
self.setNumericalValueSpecification(elements_tag, sub_element)
|
|
231
|
+
elif isinstance(sub_element, ApplicationValueSpecification):
|
|
232
|
+
self.setApplicationValueSpecification(elements_tag, sub_element)
|
|
233
|
+
else:
|
|
234
|
+
raise NotImplementedError("Unsupported element type of <%s> of ArrayValueSpecification" % type(sub_element))
|
|
235
|
+
|
|
236
|
+
def setConstantReference(self, element: ET.Element, value_spec: ConstantReference):
|
|
237
|
+
value_spec_tag = ET.SubElement(element, "CONSTANT-REFERENCE")
|
|
238
|
+
self.writeValueSpecification(value_spec_tag, value_spec)
|
|
239
|
+
self.setChildElementOptionalRefType(value_spec_tag, "CONSTANT-REF", value_spec.constant_ref)
|
|
240
|
+
|
|
241
|
+
def setValueSpecification(self, element: ET.Element, value_spec: ValueSpecification):
|
|
242
|
+
if value_spec is not None:
|
|
243
|
+
if isinstance(value_spec, ApplicationValueSpecification):
|
|
244
|
+
self.setApplicationValueSpecification(element, value_spec)
|
|
245
|
+
elif isinstance(value_spec, TextValueSpecification):
|
|
246
|
+
self.setTextValueSpecification(element, value_spec)
|
|
247
|
+
elif isinstance(value_spec, ConstantReference):
|
|
248
|
+
self.setConstantReference(element, value_spec)
|
|
249
|
+
elif isinstance(value_spec, NumericalValueSpecification):
|
|
250
|
+
self.setNumericalValueSpecification(element, value_spec)
|
|
251
|
+
elif isinstance(value_spec, ArrayValueSpecification):
|
|
252
|
+
self.setArrayValueSpecification(element, value_spec)
|
|
253
|
+
elif isinstance(value_spec, RecordValueSpecification):
|
|
254
|
+
self.setRecordValueSpecification(element, value_spec)
|
|
255
|
+
else:
|
|
256
|
+
raise NotImplementedError("Unsupported ValueSpecification %s" % type(value_spec))
|
|
257
|
+
|
|
258
|
+
def setInitValue(self, element: ET.Element, init_value: ValueSpecification):
|
|
259
|
+
if init_value is not None:
|
|
260
|
+
child_element = ET.SubElement(element, "INIT-VALUE")
|
|
261
|
+
self.setValueSpecification(child_element, init_value)
|
|
262
|
+
|
|
263
|
+
def writeNonqueuedReceiverComSpec(self, element: ET.Element, com_spec: NonqueuedReceiverComSpec):
|
|
264
|
+
child_element = ET.SubElement(element, "NONQUEUED-RECEIVER-COM-SPEC")
|
|
265
|
+
self.setARObjectAttributes(child_element, com_spec)
|
|
266
|
+
self.writeReceiverComSpec(child_element, com_spec)
|
|
267
|
+
self.setChildElementOptionalFloatValue(child_element, "ALIVE-TIMEOUT", com_spec.alive_timeout)
|
|
268
|
+
self.setChildElementOptionalBooleanValue(child_element, "ENABLE-UPDATE", com_spec.enable_updated)
|
|
269
|
+
self.setChildElementOptionalBooleanValue(child_element, "HANDLE-NEVER-RECEIVED", com_spec.handle_never_received)
|
|
270
|
+
self.setChildElementOptionalLiteral(child_element, "HANDLE-TIMEOUT-TYPE", com_spec.handel_timeout_type)
|
|
271
|
+
self.setInitValue(child_element, com_spec.init_value)
|
|
272
|
+
|
|
273
|
+
def writeQueuedReceiverComSpec(self, element: ET.Element, com_spec: QueuedReceiverComSpec):
|
|
274
|
+
child_element = ET.SubElement(element, "QUEUED-RECEIVER-COM-SPEC")
|
|
275
|
+
self.setARObjectAttributes(child_element, com_spec)
|
|
276
|
+
self.writeReceiverComSpec(child_element, com_spec)
|
|
277
|
+
self.setChildElementOptionalNumericalValue(child_element, "QUEUE-LENGTH", com_spec.queue_length)
|
|
278
|
+
|
|
279
|
+
def writeClientComSpec(self, element: ET.Element, com_spec: ClientComSpec):
|
|
280
|
+
self.logger.debug("writeClientComSpec")
|
|
281
|
+
child_element = ET.SubElement(element, "CLIENT-COM-SPEC")
|
|
282
|
+
self.setARObjectAttributes(child_element, com_spec)
|
|
283
|
+
self.setChildElementOptionalRefType(child_element, "OPERATION-REF", com_spec.operation_ref)
|
|
284
|
+
|
|
285
|
+
def writeRPortComSpec(self, element: ET.Element, com_spec: RPortComSpec):
|
|
286
|
+
if isinstance(com_spec, NonqueuedReceiverComSpec):
|
|
287
|
+
self.writeNonqueuedReceiverComSpec(element, com_spec)
|
|
288
|
+
elif isinstance(com_spec, QueuedReceiverComSpec):
|
|
289
|
+
self.writeQueuedReceiverComSpec(element, com_spec)
|
|
290
|
+
elif isinstance(com_spec, ClientComSpec):
|
|
291
|
+
self.writeClientComSpec(element, com_spec)
|
|
292
|
+
else:
|
|
293
|
+
raise ValueError("Unsupported RPortComSpec %s" % type(com_spec))
|
|
294
|
+
|
|
295
|
+
def writePPortPrototype(self, ports_tag: ET.Element, prototype: PPortPrototype):
|
|
296
|
+
prototype_tag = ET.SubElement(ports_tag, "P-PORT-PROTOTYPE")
|
|
297
|
+
|
|
298
|
+
self.writeIdentifiable(prototype_tag, prototype)
|
|
299
|
+
self.logger.debug("writePPortPrototype %s" % prototype.short_name)
|
|
300
|
+
|
|
301
|
+
com_specs = prototype.getProvidedComSpecs()
|
|
302
|
+
if len(com_specs):
|
|
303
|
+
com_specs_tag = ET.SubElement(prototype_tag, "PROVIDED-COM-SPECS")
|
|
304
|
+
for com_spec in com_specs:
|
|
305
|
+
self.writePPortComSpec(com_specs_tag, com_spec)
|
|
306
|
+
|
|
307
|
+
self.setChildElementOptionalRefType(prototype_tag, "PROVIDED-INTERFACE-TREF", prototype.provided_interface_tref)
|
|
308
|
+
|
|
309
|
+
def writeRPortPrototype(self, ports_tag: ET.Element, prototype: RPortPrototype):
|
|
310
|
+
self.logger.debug("writeRPortPrototype %s" % prototype.short_name)
|
|
311
|
+
prototype_tag = ET.SubElement(ports_tag, "R-PORT-PROTOTYPE")
|
|
312
|
+
self.writeIdentifiable(prototype_tag, prototype)
|
|
313
|
+
com_specs = prototype.getRequiredComSpecs()
|
|
314
|
+
if len(com_specs) > 0:
|
|
315
|
+
com_specs_tag = ET.SubElement(prototype_tag, "REQUIRED-COM-SPECS")
|
|
316
|
+
for com_spec in com_specs:
|
|
317
|
+
self.writeRPortComSpec(com_specs_tag, com_spec)
|
|
318
|
+
self.setChildElementOptionalRefType(prototype_tag, "REQUIRED-INTERFACE-TREF", prototype.required_interface_tref)
|
|
319
|
+
|
|
320
|
+
def writePortPrototypes(self, ports_tag: ET.Element, port_prototypes: List[PortPrototype]):
|
|
321
|
+
for port_prototype in port_prototypes:
|
|
322
|
+
if isinstance(port_prototype, PPortPrototype):
|
|
323
|
+
self.writePPortPrototype(ports_tag, port_prototype)
|
|
324
|
+
elif isinstance(port_prototype, RPortPrototype):
|
|
325
|
+
self.writeRPortPrototype(ports_tag, port_prototype)
|
|
326
|
+
else:
|
|
327
|
+
self._raiseError("Invalid PortPrototype")
|
|
328
|
+
|
|
329
|
+
def writeInnerGroupIRef(self, element: ET.Element, inner_group_iref: InnerPortGroupInCompositionInstanceRef):
|
|
330
|
+
child_element = ET.SubElement(element, "INNER-GROUP-IREF")
|
|
331
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-REF", inner_group_iref.contextRef)
|
|
332
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-REF", inner_group_iref.targetRef)
|
|
333
|
+
|
|
334
|
+
def writePortGroupInnerGroupIRefs(self, element: ET.Element, parent: PortGroup):
|
|
335
|
+
irefs = parent.getInnerGroupIRefs()
|
|
336
|
+
if len(irefs) > 0:
|
|
337
|
+
child_element = ET.SubElement(element, "INNER-GROUP-IREFS")
|
|
338
|
+
for iref in irefs:
|
|
339
|
+
self.writeInnerGroupIRef(child_element, iref)
|
|
340
|
+
|
|
341
|
+
def writePortGroupOuterPortRefs(self, element: ET.Element, parent: PortGroup):
|
|
342
|
+
refs = parent.getOuterPortRefs()
|
|
343
|
+
if len(refs) > 0:
|
|
344
|
+
outer_ports_element = ET.SubElement(element, "OUTER-PORTS")
|
|
345
|
+
for ref in refs:
|
|
346
|
+
child_element = ET.SubElement(outer_ports_element, "PORT-PROTOTYPE-REF-CONDITIONAL")
|
|
347
|
+
self.setChildElementOptionalRefType(child_element, "PORT-PROTOTYPE-REF", ref)
|
|
348
|
+
|
|
349
|
+
def writePortGroup(self, element: ET.Element, port_group: PortGroup):
|
|
350
|
+
self.logger.debug("writePortGroup %s" % port_group.short_name)
|
|
351
|
+
child_element = ET.SubElement(element, "PORT-GROUP")
|
|
352
|
+
self.writeIdentifiable(child_element, port_group)
|
|
353
|
+
self.writePortGroupInnerGroupIRefs(child_element, port_group)
|
|
354
|
+
self.writePortGroupOuterPortRefs(child_element, port_group)
|
|
355
|
+
|
|
356
|
+
def writeSwComponentTypePortGroups(self, element: ET.Element, parent: SwComponentType):
|
|
357
|
+
port_groups = parent.getPortGroups()
|
|
358
|
+
if len(port_groups) > 0:
|
|
359
|
+
child_element = ET.SubElement(element, "PORT-GROUPS")
|
|
360
|
+
for port_group in port_groups:
|
|
361
|
+
self.writePortGroup(child_element, port_group)
|
|
362
|
+
|
|
363
|
+
def writeSwComponentType(self, element: ET.Element, sw_component: SwComponentType):
|
|
364
|
+
self.writeIdentifiable(element, sw_component)
|
|
365
|
+
port_prototypes = sw_component.getPortPrototypes()
|
|
366
|
+
if len(port_prototypes) > 0:
|
|
367
|
+
ports_tag = ET.SubElement(element, "PORTS")
|
|
368
|
+
self.writePortPrototypes(ports_tag, port_prototypes)
|
|
369
|
+
self.writeSwComponentTypePortGroups(element, sw_component)
|
|
370
|
+
|
|
371
|
+
def writeSwComponentPrototype(self, element: ET.Element, prototype: SwComponentPrototype):
|
|
372
|
+
prototype_tag = ET.SubElement(element, "SW-COMPONENT-PROTOTYPE")
|
|
373
|
+
self.writeIdentifiable(prototype_tag, prototype)
|
|
374
|
+
self.setChildElementOptionalRefType(prototype_tag, "TYPE-TREF", prototype.type_tref)
|
|
375
|
+
|
|
376
|
+
def writeSwComponentPrototypes(self, element: ET.Element, sw_component: CompositionSwComponentType):
|
|
377
|
+
components_tag = ET.SubElement(element, "COMPONENTS")
|
|
378
|
+
for prototype in sw_component.getSwComponentPrototypes():
|
|
379
|
+
self.writeSwComponentPrototype(components_tag, prototype)
|
|
380
|
+
|
|
381
|
+
def writeAssemblySwConnector(self, element: ET.Element, sw_connector: AssemblySwConnector):
|
|
382
|
+
connector_tag = ET.SubElement(element, "ASSEMBLY-SW-CONNECTOR")
|
|
383
|
+
self.writeIdentifiable(connector_tag, sw_connector)
|
|
384
|
+
|
|
385
|
+
if sw_connector.provider_iref is not None:
|
|
386
|
+
provider_iref_tag = ET.SubElement(connector_tag, "PROVIDER-IREF")
|
|
387
|
+
self.setARObjectAttributes(provider_iref_tag, sw_connector.provider_iref)
|
|
388
|
+
self.setChildElementOptionalRefType(provider_iref_tag, "CONTEXT-COMPONENT-REF", sw_connector.provider_iref.context_component_ref)
|
|
389
|
+
self.setChildElementOptionalRefType(provider_iref_tag, "TARGET-P-PORT-REF", sw_connector.provider_iref.target_p_port_ref)
|
|
390
|
+
|
|
391
|
+
if sw_connector.requester_iref is not None:
|
|
392
|
+
requester_iref_tag = ET.SubElement(connector_tag, "REQUESTER-IREF")
|
|
393
|
+
self.setARObjectAttributes(requester_iref_tag, sw_connector.requester_iref)
|
|
394
|
+
self.setChildElementOptionalRefType(requester_iref_tag, "CONTEXT-COMPONENT-REF", sw_connector.requester_iref.context_component_ref)
|
|
395
|
+
self.setChildElementOptionalRefType(requester_iref_tag, "TARGET-R-PORT-REF", sw_connector.requester_iref.target_r_port_ref)
|
|
396
|
+
|
|
397
|
+
def writeDelegationSwConnector(self, element: ET.Element, sw_connector: DelegationSwConnector):
|
|
398
|
+
connector_tag = ET.SubElement(element, "DELEGATION-SW-CONNECTOR")
|
|
399
|
+
self.writeIdentifiable(connector_tag, sw_connector)
|
|
400
|
+
|
|
401
|
+
if sw_connector.inner_port_iref is not None:
|
|
402
|
+
inner_port_iref_tag = ET.SubElement(connector_tag, "INNER-PORT-IREF")
|
|
403
|
+
if isinstance(sw_connector.inner_port_iref, PPortInCompositionInstanceRef):
|
|
404
|
+
instance_ref_tag = ET.SubElement(inner_port_iref_tag, "P-PORT-IN-COMPOSITION-INSTANCE-REF")
|
|
405
|
+
self.setChildElementOptionalRefType(instance_ref_tag, "CONTEXT-COMPONENT-REF", sw_connector.inner_port_iref.context_component_ref)
|
|
406
|
+
self.setChildElementOptionalRefType(instance_ref_tag, "TARGET-P-PORT-REF", sw_connector.inner_port_iref.target_p_port_ref)
|
|
407
|
+
elif isinstance(sw_connector.inner_port_iref, RPortInCompositionInstanceRef):
|
|
408
|
+
instance_ref_tag = ET.SubElement(inner_port_iref_tag, "R-PORT-IN-COMPOSITION-INSTANCE-REF")
|
|
409
|
+
self.setChildElementOptionalRefType(instance_ref_tag, "CONTEXT-COMPONENT-REF", sw_connector.inner_port_iref.context_component_ref)
|
|
410
|
+
self.setChildElementOptionalRefType(instance_ref_tag, "TARGET-R-PORT-REF", sw_connector.inner_port_iref.target_r_port_ref)
|
|
411
|
+
else:
|
|
412
|
+
self._raiseError("Invalid inner port of DelegationSwConnector <%s>" % sw_connector.short_name)
|
|
413
|
+
|
|
414
|
+
if sw_connector.outer_port_ref is not None:
|
|
415
|
+
self.setChildElementOptionalRefType(connector_tag, "OUTER-PORT-REF", sw_connector.outer_port_ref)
|
|
416
|
+
#self.writeChildOptionalRefElement(requester_iref_tag, "TARGET-R-PORT-REF", sw_connector.requester_iref.target_r_port_ref)
|
|
417
|
+
|
|
418
|
+
def writeSwConnector(self, element: ET.Element, sw_connector: SwConnector):
|
|
419
|
+
if isinstance(sw_connector, AssemblySwConnector):
|
|
420
|
+
self.writeAssemblySwConnector(element, sw_connector)
|
|
421
|
+
elif isinstance(sw_connector, DelegationSwConnector):
|
|
422
|
+
self.writeDelegationSwConnector(element, sw_connector)
|
|
423
|
+
else:
|
|
424
|
+
raise NotImplementedError("Unsupported Sw Connector %s")
|
|
425
|
+
|
|
426
|
+
def writeSwConnectors(self, element: ET.Element, sw_component: CompositionSwComponentType):
|
|
427
|
+
sw_connectors = sw_component.getSwConnectors()
|
|
428
|
+
if len(sw_connectors) > 0:
|
|
429
|
+
connectors_tag = ET.SubElement(element, "CONNECTORS")
|
|
430
|
+
for sw_connector in sw_connectors:
|
|
431
|
+
self.writeSwConnector(connectors_tag, sw_connector)
|
|
432
|
+
|
|
433
|
+
def writeCompositionSwComponentTypeDataTypeMappingSet(self, element: ET.Element, parent: CompositionSwComponentType):
|
|
434
|
+
data_type_mappings = parent.getDataTypeMappings()
|
|
435
|
+
if len(data_type_mappings) > 0:
|
|
436
|
+
child_element = ET.SubElement(element, "DATA-TYPE-MAPPING-REFS")
|
|
437
|
+
self.logger.debug("writeDataTypeMappingSet")
|
|
438
|
+
for data_type_mapping in data_type_mappings:
|
|
439
|
+
self.setChildElementOptionalRefType(child_element, "DATA-TYPE-MAPPING-REF", data_type_mapping)
|
|
440
|
+
|
|
441
|
+
def writeCompositionSwComponentType(self, parent: ET.Element, sw_component: CompositionSwComponentType):
|
|
442
|
+
child_element = ET.SubElement(parent, "COMPOSITION-SW-COMPONENT-TYPE")
|
|
443
|
+
|
|
444
|
+
self.writeSwComponentType(child_element, sw_component)
|
|
445
|
+
self.writeSwComponentPrototypes(child_element, sw_component)
|
|
446
|
+
self.writeSwConnectors(child_element, sw_component)
|
|
447
|
+
self.writeCompositionSwComponentTypeDataTypeMappingSet(child_element, sw_component)
|
|
448
|
+
|
|
449
|
+
def writeCompositionSwComponentTypes(self, element: ET.Element, ar_package: ARPackage):
|
|
450
|
+
for sw_component in ar_package.getCompositionSwComponentTypes():
|
|
451
|
+
self.writeCompositionSwComponentType(element, sw_component)
|
|
452
|
+
|
|
453
|
+
def writeGeneralAnnotation(self, element: ET.Element, annotation: Annotation):
|
|
454
|
+
self.setMultiLongName(element, "LABEL", annotation.label)
|
|
455
|
+
|
|
456
|
+
def writeAnnotations(self, element: ET.Element, props: SwDataDefProps) :
|
|
457
|
+
annotations = props.getAnnotations()
|
|
458
|
+
if len(annotations) > 0:
|
|
459
|
+
annotations_tag = ET.SubElement(element, "ANNOTATIONS")
|
|
460
|
+
for annotation in annotations:
|
|
461
|
+
annotation_tag = ET.SubElement(annotations_tag, "ANNOTATION")
|
|
462
|
+
self.writeGeneralAnnotation(annotation_tag, annotation)
|
|
463
|
+
|
|
464
|
+
def setSwAxisIndividual(self, element: ET.Element, props: SwAxisIndividual):
|
|
465
|
+
child_element = ET.SubElement(element, "SW-AXIS-INDIVIDUAL")
|
|
466
|
+
self.setARObjectAttributes(child_element, props)
|
|
467
|
+
self.setChildElementOptionalRefType(child_element, "INPUT-VARIABLE-TYPE-REF", props.inputVariableTypeRef)
|
|
468
|
+
self.setChildElementOptionalRefType(child_element, "COMPU-METHOD-REF", props.compuMethodRef)
|
|
469
|
+
self.setChildElementOptionalNumericalValue(child_element, "SW-MAX-AXIS-POINTS", props.swMaxAxisPoints)
|
|
470
|
+
self.setChildElementOptionalNumericalValue(child_element, "SW-MIN-AXIS-POINTS", props.swMinAxisPoints)
|
|
471
|
+
self.setChildElementOptionalRefType(child_element, "DATA-CONSTR-REF", props.dataConstrRef)
|
|
472
|
+
|
|
473
|
+
def setSwAxisGrouped(self, element: ET.Element, props: SwAxisGrouped):
|
|
474
|
+
child_element = ET.SubElement(element, "SW-AXIS-GROUPED")
|
|
475
|
+
self.setARObjectAttributes(child_element, props)
|
|
476
|
+
self.setChildElementOptionalRefType(child_element, "SHARED-AXIS-TYPE-REF", props.sharedAxisTypeRef)
|
|
477
|
+
|
|
478
|
+
def setSwCalprmAxis(self, element: ET.Element, axis: SwCalprmAxis):
|
|
479
|
+
if axis is not None:
|
|
480
|
+
child_element = ET.SubElement(element, "SW-CALPRM-AXIS")
|
|
481
|
+
self.setChildElementOptionalNumericalValue(child_element, "SW-AXIS-INDEX", axis.sw_axis_index)
|
|
482
|
+
self.setChildElementOptionalLiteral(child_element, "CATEGORY", axis.category)
|
|
483
|
+
if axis.sw_calprm_axis_type_props is not None:
|
|
484
|
+
if isinstance(axis.sw_calprm_axis_type_props, SwAxisIndividual):
|
|
485
|
+
self.setSwAxisIndividual(child_element, axis.sw_calprm_axis_type_props)
|
|
486
|
+
elif isinstance(axis.sw_calprm_axis_type_props, SwAxisGrouped):
|
|
487
|
+
self.setSwAxisGrouped(child_element, axis.sw_calprm_axis_type_props)
|
|
488
|
+
else:
|
|
489
|
+
self._raiseError("Unsupported SwCalprmAxisTypeProps %s" % type(axis.sw_calprm_axis_type_props))
|
|
490
|
+
|
|
491
|
+
def setSwCalprmAxisSet(self, element: ET.Element, key: str, set: SwCalprmAxisSet):
|
|
492
|
+
axises = set.getSwCalprmAxises()
|
|
493
|
+
if len(axises) > 0:
|
|
494
|
+
child_element = ET.SubElement(element, key)
|
|
495
|
+
for axis in axises:
|
|
496
|
+
self.setSwCalprmAxis(child_element, axis)
|
|
497
|
+
|
|
498
|
+
def setSwDataDefProps(self, element: ET.Element, key: str, sw_data_def_props: SwDataDefProps):
|
|
499
|
+
if sw_data_def_props is not None:
|
|
500
|
+
child_element = ET.SubElement(element, key)
|
|
501
|
+
self.setARObjectAttributes(child_element, sw_data_def_props)
|
|
502
|
+
sw_data_def_props_variants_tag = ET.SubElement(child_element, "SW-DATA-DEF-PROPS-VARIANTS")
|
|
503
|
+
sw_data_def_props_conditional_tag = ET.SubElement(sw_data_def_props_variants_tag, "SW-DATA-DEF-PROPS-CONDITIONAL")
|
|
504
|
+
self.setARObjectAttributes(sw_data_def_props_conditional_tag, sw_data_def_props.conditional)
|
|
505
|
+
self.writeAnnotations(sw_data_def_props_conditional_tag, sw_data_def_props)
|
|
506
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "BASE-TYPE-REF", sw_data_def_props.baseTypeRef)
|
|
507
|
+
self.setChildElementOptionalLiteral(sw_data_def_props_conditional_tag, "SW-CALIBRATION-ACCESS", sw_data_def_props.swCalibrationAccess)
|
|
508
|
+
self.setSwCalprmAxisSet(sw_data_def_props_conditional_tag, "SW-CALPRM-AXIS-SET", sw_data_def_props.swCalprmAxisSet)
|
|
509
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "COMPU-METHOD-REF", sw_data_def_props.compuMethodRef)
|
|
510
|
+
self.setChildElementOptionalLiteral(sw_data_def_props_conditional_tag, "SW-IMPL-POLICY", sw_data_def_props.swImplPolicy)
|
|
511
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "IMPLEMENTATION-DATA-TYPE-REF", sw_data_def_props.implementationDataTypeRef)
|
|
512
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "DATA-CONSTR-REF", sw_data_def_props.dataConstrRef)
|
|
513
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "SW-RECORD-LAYOUT-REF", sw_data_def_props.swRecordLayoutRef)
|
|
514
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "VALUE-AXIS-DATA-TYPE-REF", sw_data_def_props.valueAxisDataTypeRef)
|
|
515
|
+
self.setChildElementOptionalRefType(sw_data_def_props_conditional_tag, "UNIT-REF", sw_data_def_props.unitRef)
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
def writeApplicationDataType(self, element: ET.Element, data_type: ApplicationDataType):
|
|
519
|
+
self.writeAutosarDataType(element, data_type)
|
|
520
|
+
|
|
521
|
+
def writeApplicationCompositeDataType(self, element: ET.Element, data_type: ApplicationCompositeDataType):
|
|
522
|
+
self.writeApplicationDataType(element, data_type)
|
|
523
|
+
|
|
524
|
+
def writeAutosarDataType(self, element: ET.Element, data_type: AutosarDataType):
|
|
525
|
+
self.writeARElement(element, data_type)
|
|
526
|
+
self.setSwDataDefProps(element, "SW-DATA-DEF-PROPS", data_type.sw_data_def_props)
|
|
527
|
+
|
|
528
|
+
def writeApplicationPrimitiveDataType(self, element: ET.Element, data_type: ApplicationPrimitiveDataType):
|
|
529
|
+
self.logger.debug("writeApplicationPrimitiveDataType %s" % data_type.short_name)
|
|
530
|
+
data_type_tag = ET.SubElement(element, "APPLICATION-PRIMITIVE-DATA-TYPE")
|
|
531
|
+
self.writeApplicationDataType(data_type_tag, data_type)
|
|
532
|
+
|
|
533
|
+
def setDataPrototype(self, element: ET.Element, prototype: DataPrototype):
|
|
534
|
+
self.writeIdentifiable(element, prototype)
|
|
535
|
+
|
|
536
|
+
def setApplicationCompositeElementDataPrototype(self, element: ET.Element, prototype: ApplicationCompositeElementDataPrototype):
|
|
537
|
+
self.setDataPrototype(element, prototype)
|
|
538
|
+
self.setChildElementOptionalRefType(element, "TYPE-TREF", prototype.typeTRef)
|
|
539
|
+
|
|
540
|
+
def setApplicationRecordElement(self, element: ET.Element, prototype: ApplicationRecordElement):
|
|
541
|
+
self.setApplicationCompositeElementDataPrototype(element, prototype)
|
|
542
|
+
|
|
543
|
+
def writeApplicationRecordElements(self, element: ET.Element, data_type: ApplicationRecordDataType):
|
|
544
|
+
records = data_type.getApplicationRecordElements()
|
|
545
|
+
if len(records) > 0:
|
|
546
|
+
elements_tag = ET.SubElement(element, "ELEMENTS")
|
|
547
|
+
for record in records:
|
|
548
|
+
child_element = ET.SubElement(elements_tag, "APPLICATION-RECORD-ELEMENT")
|
|
549
|
+
self.setApplicationRecordElement(child_element, record)
|
|
550
|
+
|
|
551
|
+
def writeApplicationRecordDataType(self, element: ET.Element, data_type: ApplicationRecordDataType):
|
|
552
|
+
data_type_tag = ET.SubElement(element, "APPLICATION-RECORD-DATA-TYPE")
|
|
553
|
+
self.writeApplicationDataType(data_type_tag, data_type)
|
|
554
|
+
self.writeApplicationRecordElements(data_type_tag, data_type)
|
|
555
|
+
|
|
556
|
+
def writeApplicationDataTypes(self, parent: ET.Element, ar_package: ARPackage):
|
|
557
|
+
for data_type in ar_package.getApplicationDataType():
|
|
558
|
+
if isinstance(data_type, ApplicationPrimitiveDataType):
|
|
559
|
+
self.writeApplicationPrimitiveDataType(parent, data_type)
|
|
560
|
+
elif isinstance(data_type, ApplicationRecordDataType):
|
|
561
|
+
self.writeApplicationRecordDataType(parent, data_type)
|
|
562
|
+
else:
|
|
563
|
+
raise NotImplementedError("Unsupported ApplicationDataType <%s>" % type(data_type))
|
|
564
|
+
|
|
565
|
+
def writeBaseTypeDirectDefinition(self, element: ET.Element, base_type_definition: BaseTypeDirectDefinition):
|
|
566
|
+
self.setChildElementOptionalNumericalValue(element, "BASE-TYPE-SIZE", base_type_definition.base_type_size)
|
|
567
|
+
self.setChildElementOptionalLiteral(element, "BASE-TYPE-ENCODING", base_type_definition.base_type_encoding)
|
|
568
|
+
self.setChildElementOptionalNumericalValue(element, "MEM-ALIGNMENT", base_type_definition.mem_alignment)
|
|
569
|
+
self.setChildElementOptionalLiteral(element, "NATIVE-DECLARATION", base_type_definition.native_declaration)
|
|
570
|
+
|
|
571
|
+
def writeSwBaseType(self, element: ET.Element, base_type: SwBaseType):
|
|
572
|
+
data_type_tag = ET.SubElement(element, "SW-BASE-TYPE")
|
|
573
|
+
self.writeIdentifiable(data_type_tag, base_type)
|
|
574
|
+
self.writeBaseTypeDirectDefinition(data_type_tag, base_type.baseTypeDefinition)
|
|
575
|
+
|
|
576
|
+
def writeCompuScaleConstantContents(self, element: ET.Element, contents: CompuScaleConstantContents):
|
|
577
|
+
compu_const_tag = ET.SubElement(element, "COMPU-CONST")
|
|
578
|
+
if isinstance(contents.compu_const.compu_const_content_type, CompuConstTextContent):
|
|
579
|
+
self.setChildElementOptionalLiteral(compu_const_tag, "VT", contents.compu_const.compu_const_content_type.vt)
|
|
580
|
+
|
|
581
|
+
def writeCompuNominatorDenominator(self, element: ET.Element, key: str, parent: CompuNominatorDenominator):
|
|
582
|
+
child_element = ET.SubElement(element, key)
|
|
583
|
+
for v in parent.get_vs():
|
|
584
|
+
v_tag = ET.SubElement(child_element, "V")
|
|
585
|
+
v_tag.text = v
|
|
586
|
+
|
|
587
|
+
def writeCompuScaleRationalFormula(self, element: ET.Element, contents: CompuScaleRationalFormula):
|
|
588
|
+
if contents.compu_rational_coeffs is not None:
|
|
589
|
+
coeffs_tag = ET.SubElement(element, "COMPU-RATIONAL-COEFFS")
|
|
590
|
+
if contents.compu_rational_coeffs.compu_numerator:
|
|
591
|
+
self.writeCompuNominatorDenominator(coeffs_tag, "COMPU-NUMERATOR", contents.compu_rational_coeffs.compu_numerator)
|
|
592
|
+
if contents.compu_rational_coeffs.compu_denominator:
|
|
593
|
+
self.writeCompuNominatorDenominator(coeffs_tag, "COMPU-DENOMINATOR", contents.compu_rational_coeffs.compu_denominator)
|
|
594
|
+
|
|
595
|
+
def writeCompuScaleContents(self, element: ET.Element, compu_scale: CompuScale):
|
|
596
|
+
if isinstance(compu_scale.compuScaleContents, CompuScaleConstantContents):
|
|
597
|
+
self.writeCompuScaleConstantContents(element, compu_scale.compuScaleContents)
|
|
598
|
+
elif isinstance(compu_scale.compuScaleContents, CompuScaleRationalFormula):
|
|
599
|
+
self.writeCompuScaleRationalFormula(element, compu_scale.compuScaleContents)
|
|
600
|
+
else:
|
|
601
|
+
raise NotImplementedError("Unsupported CompuScaleContents %s" % type(compu_scale.compuScaleContents))
|
|
602
|
+
|
|
603
|
+
def writeCompuScales(self, element: ET.Element, compu_scales: CompuScales):
|
|
604
|
+
compu_scales_tag = ET.SubElement(element, "COMPU-SCALES")
|
|
605
|
+
for compu_scale in compu_scales.getCompuScales():
|
|
606
|
+
child_element = ET.SubElement(compu_scales_tag, "COMPU-SCALE")
|
|
607
|
+
self.setARObjectAttributes(child_element, compu_scale)
|
|
608
|
+
self.setChildElementOptionalLiteral(child_element, "SYMBOL", compu_scale.symbol)
|
|
609
|
+
self.writeChildLimitElement(child_element, "LOWER-LIMIT", compu_scale.lowerLimit)
|
|
610
|
+
self.writeChildLimitElement(child_element, "UPPER-LIMIT", compu_scale.upperLimit)
|
|
611
|
+
self.writeCompuScaleContents(child_element, compu_scale)
|
|
612
|
+
|
|
613
|
+
def writeCompuInternalToPhys(self, element: ET.Element, compu_method: CompuMethod):
|
|
614
|
+
if compu_method.compu_internal_to_phys is not None:
|
|
615
|
+
compu_internal_to_phys_tag = ET.SubElement(element, "COMPU-INTERNAL-TO-PHYS")
|
|
616
|
+
self.setARObjectAttributes(compu_internal_to_phys_tag, compu_method.compu_internal_to_phys)
|
|
617
|
+
if isinstance(compu_method.compu_internal_to_phys.compu_content, CompuScales):
|
|
618
|
+
self.writeCompuScales(compu_internal_to_phys_tag, compu_method.compu_internal_to_phys.compu_content)
|
|
619
|
+
|
|
620
|
+
def writeCompuMethod(self, element: ET.Element, compu_method: CompuMethod):
|
|
621
|
+
compu_method_tag = ET.SubElement(element, "COMPU-METHOD")
|
|
622
|
+
self.logger.debug("writeCompuMethods %s" % compu_method.short_name)
|
|
623
|
+
self.writeIdentifiable(compu_method_tag, compu_method)
|
|
624
|
+
self.setChildElementOptionalRefType(compu_method_tag, "UNIT-REF", compu_method.unit_ref)
|
|
625
|
+
self.writeCompuInternalToPhys(compu_method_tag, compu_method)
|
|
626
|
+
|
|
627
|
+
def setApplicationValueSpecification(self, element: ET.Element, spec: ApplicationValueSpecification):
|
|
628
|
+
spec_tag = ET.SubElement(element, "APPLICATION-VALUE-SPECIFICATION")
|
|
629
|
+
self.setChildElementOptionalLiteral(spec_tag, "SHORT-LABEL", spec.short_label)
|
|
630
|
+
self.setChildElementOptionalLiteral(spec_tag, "CATEGORY", spec.category)
|
|
631
|
+
self.writeSwValueCont(spec_tag, spec.sw_value_cont)
|
|
632
|
+
|
|
633
|
+
def setRecordValueSpecification(self, element: ET.Element, spec: RecordValueSpecification):
|
|
634
|
+
child_element = ET.SubElement(element, "RECORD-VALUE-SPECIFICATION")
|
|
635
|
+
self.setARObjectAttributes(child_element, spec)
|
|
636
|
+
self.setChildElementOptionalLiteral(child_element, "SHORT-LABEL", spec.short_label)
|
|
637
|
+
fields = spec.get_fields()
|
|
638
|
+
if len(fields) > 0:
|
|
639
|
+
fields_tag = ET.SubElement(child_element, "FIELDS")
|
|
640
|
+
for field in fields:
|
|
641
|
+
if isinstance(field, ApplicationValueSpecification):
|
|
642
|
+
self.setApplicationValueSpecification(fields_tag, field)
|
|
643
|
+
elif isinstance(field, NumericalValueSpecification):
|
|
644
|
+
self.setNumericalValueSpecification(fields_tag, field)
|
|
645
|
+
elif isinstance(field, TextValueSpecification):
|
|
646
|
+
self.setTextValueSpecification(fields_tag, field)
|
|
647
|
+
elif isinstance(field, ArrayValueSpecification):
|
|
648
|
+
self.setArrayValueSpecification(fields_tag, field)
|
|
649
|
+
else:
|
|
650
|
+
raise NotImplementedError("Unsupported Field <%s>" % type(field))
|
|
651
|
+
|
|
652
|
+
def writeConstantSpecification(self, element: ET.Element, spec: ConstantSpecification):
|
|
653
|
+
spec_tag = ET.SubElement(element, "CONSTANT-SPECIFICATION")
|
|
654
|
+
self.writeIdentifiable(spec_tag, spec)
|
|
655
|
+
|
|
656
|
+
if spec.value_spec is not None:
|
|
657
|
+
value_spec_tag = ET.SubElement(spec_tag, "VALUE-SPEC")
|
|
658
|
+
self.setValueSpecification(value_spec_tag, spec.value_spec)
|
|
659
|
+
|
|
660
|
+
def setInternalConstrs(self, element: ET.Element, constrs: InternalConstrs):
|
|
661
|
+
if constrs is not None:
|
|
662
|
+
constrs_tag = ET.SubElement(element, "INTERNAL-CONSTRS")
|
|
663
|
+
self.setARObjectAttributes(constrs_tag, constrs)
|
|
664
|
+
if constrs.lower_limit is not None:
|
|
665
|
+
self.writeChildLimitElement(constrs_tag, "LOWER-LIMIT", constrs.lower_limit)
|
|
666
|
+
if constrs.upper_limit is not None:
|
|
667
|
+
self.writeChildLimitElement(constrs_tag, "UPPER-LIMIT", constrs.upper_limit)
|
|
668
|
+
|
|
669
|
+
def setPhysConstrs(self, element: ET.Element, constrs: PhysConstrs):
|
|
670
|
+
if constrs is not None:
|
|
671
|
+
child_element = ET.SubElement(element, "PHYS-CONSTRS")
|
|
672
|
+
self.setARObjectAttributes(child_element, constrs)
|
|
673
|
+
if constrs.lower_limit is not None:
|
|
674
|
+
self.writeChildLimitElement(child_element, "LOWER-LIMIT", constrs.lower_limit)
|
|
675
|
+
if constrs.upper_limit is not None:
|
|
676
|
+
self.writeChildLimitElement(child_element, "UPPER-LIMIT", constrs.upper_limit)
|
|
677
|
+
self.setChildElementOptionalRefType(child_element, "UNIT-REF", constrs.unit_ref)
|
|
678
|
+
|
|
679
|
+
def writeDataConstrRules(self, element: ET.Element, parent: DataConstr):
|
|
680
|
+
rules = parent.getDataConstrRules()
|
|
681
|
+
if len(rules) > 0:
|
|
682
|
+
rules_tag = ET.SubElement(element, "DATA-CONSTR-RULES")
|
|
683
|
+
for rule in rules:
|
|
684
|
+
child_element = ET.SubElement(rules_tag, "DATA-CONSTR-RULE")
|
|
685
|
+
self.setARObjectAttributes(child_element, rule)
|
|
686
|
+
self.setChildElementOptionalNumericalValue(child_element, "CONSTR-LEVEL", rule.constrLevel)
|
|
687
|
+
self.setPhysConstrs(child_element, rule.physConstrs)
|
|
688
|
+
self.setInternalConstrs(child_element, rule.internalConstrs)
|
|
689
|
+
|
|
690
|
+
def writeDataConstr(self, element: ET.Element, constr: DataConstr):
|
|
691
|
+
child_element = ET.SubElement(element, "DATA-CONSTR")
|
|
692
|
+
self.writeIdentifiable(child_element, constr)
|
|
693
|
+
self.writeDataConstrRules(child_element, constr)
|
|
694
|
+
|
|
695
|
+
def writeUnit(self, element: ET.Element, unit: Unit):
|
|
696
|
+
self.logger.debug("writeUnit %s" % unit.short_name)
|
|
697
|
+
child_element = ET.SubElement(element, "UNIT")
|
|
698
|
+
self.writeIdentifiable(child_element, unit)
|
|
699
|
+
self.setChildElementOptionalLiteral(child_element, "DISPLAY-NAME", unit.display_name)
|
|
700
|
+
|
|
701
|
+
def setRModeInAtomicSwcInstanceRef(self, element: ET.Element, key: str, iref: RModeInAtomicSwcInstanceRef):
|
|
702
|
+
child_element = ET.SubElement(element, key)
|
|
703
|
+
self.setChildElementOptionalRefType(child_element, "BASE", iref.base_ref)
|
|
704
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-PORT-REF", iref.context_port_ref)
|
|
705
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF", iref.context_mode_declaration_group_prototype_ref)
|
|
706
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-MODE-DECLARATION-REF", iref.target_mode_declaration_ref)
|
|
707
|
+
|
|
708
|
+
def setPOperationInAtomicSwcInstanceRef(self, element: ET.Element, key: str, iref: POperationInAtomicSwcInstanceRef):
|
|
709
|
+
child_element = ET.SubElement(element, key)
|
|
710
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-P-PORT-REF", iref.context_p_port_ref)
|
|
711
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-PROVIDED-OPERATION-REF", iref.target_provided_operation_ref)
|
|
712
|
+
|
|
713
|
+
def setRTEEvent(self, element: ET.Element, event: RTEEvent):
|
|
714
|
+
self.writeIdentifiable(element, event)
|
|
715
|
+
irefs = event.getDisabledModeIRefs()
|
|
716
|
+
if len(irefs) > 0:
|
|
717
|
+
child_element = ET.SubElement(element, "DISABLED-MODE-IREFS")
|
|
718
|
+
for iref in irefs:
|
|
719
|
+
self.setRModeInAtomicSwcInstanceRef(child_element, "DISABLED-MODE-IREF", iref)
|
|
720
|
+
self.setChildElementOptionalRefType(element, "START-ON-EVENT-REF", event.start_on_event_ref)
|
|
721
|
+
|
|
722
|
+
def setTimingEvent(self, element: ET.Element, event: TimingEvent):
|
|
723
|
+
if event is not None:
|
|
724
|
+
child_element = ET.SubElement(element, "TIMING-EVENT")
|
|
725
|
+
self.setRTEEvent(child_element, event)
|
|
726
|
+
self.setChildElementOptionalFloatValue(child_element, "PERIOD", event.period)
|
|
727
|
+
|
|
728
|
+
def setOperationInvokedEvent(self, element: ET.Element, event: OperationInvokedEvent):
|
|
729
|
+
if event is not None:
|
|
730
|
+
child_element = ET.SubElement(element, "OPERATION-INVOKED-EVENT")
|
|
731
|
+
self.setRTEEvent(child_element, event)
|
|
732
|
+
self.setPOperationInAtomicSwcInstanceRef(child_element, "OPERATION-IREF", event.operation_iref)
|
|
733
|
+
|
|
734
|
+
def setSwcModeSwitchEvent(self, element: ET.Element, event: SwcModeSwitchEvent):
|
|
735
|
+
if event is not None:
|
|
736
|
+
child_element = ET.SubElement(element, "SWC-MODE-SWITCH-EVENT")
|
|
737
|
+
self.setRTEEvent(child_element, event)
|
|
738
|
+
self.setChildElementOptionalLiteral(child_element, "ACTIVATION", event.activation)
|
|
739
|
+
irefs = event.getModeIRefs()
|
|
740
|
+
if len(irefs) > 0:
|
|
741
|
+
mode_irefs_tag = ET.SubElement(child_element, "MODE-IREFS")
|
|
742
|
+
for iref in irefs:
|
|
743
|
+
self.setRModeInAtomicSwcInstanceRef(mode_irefs_tag, "MODE-IREF", iref)
|
|
744
|
+
|
|
745
|
+
def setRVariableInAtomicSwcInstanceRef(self, element: ET.Element, iref: RVariableInAtomicSwcInstanceRef):
|
|
746
|
+
if iref is not None:
|
|
747
|
+
child_element = ET.SubElement(element, "DATA-IREF")
|
|
748
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-R-PORT-REF", iref.context_r_port_ref)
|
|
749
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-DATA-ELEMENT-REF", iref.target_data_element_ref)
|
|
750
|
+
|
|
751
|
+
def setDataReceivedEvent(self, element: ET.Element, event: DataReceivedEvent):
|
|
752
|
+
if event is not None:
|
|
753
|
+
child_element = ET.SubElement(element, "DATA-RECEIVED-EVENT")
|
|
754
|
+
self.setRTEEvent(child_element, event)
|
|
755
|
+
self.setRVariableInAtomicSwcInstanceRef(child_element, event.data_iref)
|
|
756
|
+
|
|
757
|
+
def setInternalTriggerOccurredEvent(self, element: ET.Element, event: DataReceivedEvent):
|
|
758
|
+
pass
|
|
759
|
+
|
|
760
|
+
def writeRTEEvents(self, element: ET.Element, parent: SwcInternalBehavior):
|
|
761
|
+
events = parent.getRteEvents()
|
|
762
|
+
if len(events) > 0:
|
|
763
|
+
child_element = ET.SubElement(element, "EVENTS")
|
|
764
|
+
|
|
765
|
+
for event in events:
|
|
766
|
+
if isinstance(event, TimingEvent):
|
|
767
|
+
self.setTimingEvent(child_element, event)
|
|
768
|
+
elif isinstance(event, OperationInvokedEvent):
|
|
769
|
+
self.setOperationInvokedEvent(child_element, event)
|
|
770
|
+
elif isinstance(event, SwcModeSwitchEvent):
|
|
771
|
+
self.setSwcModeSwitchEvent(child_element, event)
|
|
772
|
+
elif isinstance(event, DataReceivedEvent):
|
|
773
|
+
self.setDataReceivedEvent(child_element, event)
|
|
774
|
+
elif isinstance(event, InternalTriggerOccurredEvent):
|
|
775
|
+
self.setInternalTriggerOccurredEvent(child_element, event)
|
|
776
|
+
else:
|
|
777
|
+
raise NotImplementedError("Unsupported Event <%s>" % type(event))
|
|
778
|
+
|
|
779
|
+
def writeExclusiveAreas(self, element: ET.Element, behavior: InternalBehavior):
|
|
780
|
+
areas = behavior.getExclusiveAreas()
|
|
781
|
+
if len(areas) > 0:
|
|
782
|
+
areas_tag = ET.SubElement(element, "EXCLUSIVE-AREAS")
|
|
783
|
+
for area in areas:
|
|
784
|
+
child_element = ET.SubElement(areas_tag, "EXCLUSIVE-AREA")
|
|
785
|
+
self.writeIdentifiable(child_element, area)
|
|
786
|
+
|
|
787
|
+
def writeDataTypeMappingRefs(self, element: ET.Element, behavior: InternalBehavior):
|
|
788
|
+
refs = behavior.getDataTypeMappingRefs()
|
|
789
|
+
if len(refs) > 0:
|
|
790
|
+
refs_tag = ET.SubElement(element, "DATA-TYPE-MAPPING-REFS")
|
|
791
|
+
for ref in refs:
|
|
792
|
+
self.setChildElementOptionalRefType(refs_tag, "DATA-TYPE-MAPPING-REF", ref)
|
|
793
|
+
|
|
794
|
+
def writeInternalBehavior(self, element: ET.Element, behavior: InternalBehavior):
|
|
795
|
+
self.writeIdentifiable(element, behavior)
|
|
796
|
+
self.writeDataTypeMappingRefs(element, behavior)
|
|
797
|
+
self.writeExclusiveAreas(element, behavior)
|
|
798
|
+
|
|
799
|
+
def writeExecutableEntity(self, element: ET.Element, entity: ExecutableEntity):
|
|
800
|
+
if entity is not None:
|
|
801
|
+
self.setChildElementOptionalFloatValue(element, "MINIMUM-START-INTERVAL", entity.minimum_start_interval)
|
|
802
|
+
|
|
803
|
+
def setAutosarVariableRef(self, element: ET.Element, ref: AutosarVariableRef):
|
|
804
|
+
if ref is not None:
|
|
805
|
+
child_element = ET.SubElement(element, "ACCESSED-VARIABLE")
|
|
806
|
+
if ref.autosar_variable_iref is not None:
|
|
807
|
+
child_element = ET.SubElement(child_element, "AUTOSAR-VARIABLE-IREF")
|
|
808
|
+
self.setChildElementOptionalRefType(child_element, "PORT-PROTOTYPE-REF", ref.autosar_variable_iref.port_prototype_ref)
|
|
809
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-DATA-PROTOTYPE-REF", ref.autosar_variable_iref.target_data_prototype_ref)
|
|
810
|
+
if ref.local_variable_ref is not None:
|
|
811
|
+
self.setChildElementOptionalRefType(child_element, "LOCAL-VARIABLE-REF", ref.local_variable_ref)
|
|
812
|
+
|
|
813
|
+
def setVariableAccess(self, element: ET.Element, access: VariableAccess):
|
|
814
|
+
child_element = ET.SubElement(element, "VARIABLE-ACCESS")
|
|
815
|
+
self.writeIdentifiable(child_element, access)
|
|
816
|
+
self.setAutosarVariableRef(child_element, access.accessed_variable_ref)
|
|
817
|
+
|
|
818
|
+
def writeDataReadAccesses(self, element: ET.Element, entity: RunnableEntity):
|
|
819
|
+
#accesses = entity.getDataReadAccesses():
|
|
820
|
+
pass
|
|
821
|
+
|
|
822
|
+
def setAutosarParameterRef(self, element: ET.Element, key: str, parameter_ref: AutosarParameterRef):
|
|
823
|
+
if parameter_ref is not None:
|
|
824
|
+
child_element = ET.SubElement(element, key)
|
|
825
|
+
self.setChildElementOptionalRefType(child_element, "LOCAL-PARAMETER-REF", parameter_ref.local_parameter_ref)
|
|
826
|
+
|
|
827
|
+
def writeParameterAccess(self, element: ET.Element, parameter_access: ParameterAccess):
|
|
828
|
+
child_element = ET.SubElement(element, "PARAMETER-ACCESS")
|
|
829
|
+
self.writeIdentifiable(child_element, parameter_access)
|
|
830
|
+
self.setAutosarParameterRef(child_element, "ACCESSED-PARAMETER", parameter_access.accessed_parameter)
|
|
831
|
+
|
|
832
|
+
def writeParameterAccesses(self, element: ET.Element, entity: RunnableEntity):
|
|
833
|
+
parameter_accesses = entity.getParameterAccesses()
|
|
834
|
+
if len(parameter_accesses) > 0:
|
|
835
|
+
child_element = ET.SubElement(element, "PARAMETER-ACCESSS")
|
|
836
|
+
for parameter_access in parameter_accesses:
|
|
837
|
+
self.writeParameterAccess(child_element, parameter_access)
|
|
838
|
+
|
|
839
|
+
def writeDataReceivePointByArguments(self, element: ET.Element, entity: RunnableEntity):
|
|
840
|
+
accesses = entity.getDataReceivePointByArguments()
|
|
841
|
+
if len(accesses) > 0:
|
|
842
|
+
child_element = ET.SubElement(element, "DATA-RECEIVE-POINT-BY-ARGUMENTS")
|
|
843
|
+
for access in accesses:
|
|
844
|
+
self.setVariableAccess(child_element, access)
|
|
845
|
+
|
|
846
|
+
def writeDataSendPoints(self, element: ET.Element, entity: RunnableEntity):
|
|
847
|
+
points = entity.getDataSendPoints()
|
|
848
|
+
if len(points) > 0:
|
|
849
|
+
child_element = ET.SubElement(element, "DATA-SEND-POINTS")
|
|
850
|
+
for point in points:
|
|
851
|
+
self.setVariableAccess(child_element, point)
|
|
852
|
+
|
|
853
|
+
def writeDataWriteAccesses(self, element: ET.Element, entity: RunnableEntity):
|
|
854
|
+
points = entity.getDataWriteAccesses()
|
|
855
|
+
if len(points) > 0:
|
|
856
|
+
child_element = ET.SubElement(element, "DATA-WRITE-ACCESSS")
|
|
857
|
+
for point in points:
|
|
858
|
+
self.setVariableAccess(child_element, point)
|
|
859
|
+
|
|
860
|
+
def writeReadLocalVariables(self, element: ET.Element, entity: RunnableEntity):
|
|
861
|
+
variables = entity.getReadLocalVariables()
|
|
862
|
+
if len(variables) > 0:
|
|
863
|
+
child_element = ET.SubElement(element, "READ-LOCAL-VARIABLES")
|
|
864
|
+
for access in variables:
|
|
865
|
+
self.setVariableAccess(child_element, access)
|
|
866
|
+
|
|
867
|
+
def writeROperationInAtomicSwcInstanceRef(self, element: ET.Element, key: str, iref: ROperationInAtomicSwcInstanceRef):
|
|
868
|
+
if iref is not None:
|
|
869
|
+
child_element = ET.SubElement(element, key)
|
|
870
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-R-PORT-REF", iref.context_r_port_ref)
|
|
871
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-REQUIRED-OPERATION-REF", iref.target_required_operation_ref)
|
|
872
|
+
|
|
873
|
+
def writeServerCallPoint(self, element: ET.Element, call_point: ServerCallPoint):
|
|
874
|
+
self.writeROperationInAtomicSwcInstanceRef(element, "OPERATION-IREF", call_point.operation_iref)
|
|
875
|
+
self.setChildElementOptionalFloatValue(element, "TIMEOUT", call_point.timeout)
|
|
876
|
+
|
|
877
|
+
def writeSynchronousServerCallPoint(self, element: ET.Element, call_point: SynchronousServerCallPoint):
|
|
878
|
+
child_element = ET.SubElement(element, "SYNCHRONOUS-SERVER-CALL-POINT")
|
|
879
|
+
self.writeIdentifiable(child_element, call_point)
|
|
880
|
+
self.writeServerCallPoint(child_element, call_point)
|
|
881
|
+
|
|
882
|
+
def writeServerCallPoints(self, element: ET.Element, entity: RunnableEntity):
|
|
883
|
+
call_points = entity.getServerCallPoints()
|
|
884
|
+
if len(call_points) > 0:
|
|
885
|
+
child_element = ET.SubElement(element, "SERVER-CALL-POINTS")
|
|
886
|
+
for call_point in call_points:
|
|
887
|
+
if isinstance(call_point, SynchronousServerCallPoint):
|
|
888
|
+
self.writeSynchronousServerCallPoint(child_element, call_point)
|
|
889
|
+
else:
|
|
890
|
+
self._raiseError("Unsupported ServerCallPoint type <%s>" % type(call_point))
|
|
891
|
+
|
|
892
|
+
def writeWrittenLocalVariable(self, element: ET.Element, entity: RunnableEntity):
|
|
893
|
+
variables = entity.getWrittenLocalVariables()
|
|
894
|
+
if len(variables) > 0:
|
|
895
|
+
child_element = ET.SubElement(element, "WRITTEN-LOCAL-VARIABLES")
|
|
896
|
+
for access in variables:
|
|
897
|
+
self.setVariableAccess(child_element, access)
|
|
898
|
+
|
|
899
|
+
def writeRunnableEntity(self, element: ET.Element, entity: RunnableEntity):
|
|
900
|
+
if entity is not None:
|
|
901
|
+
child_element = ET.SubElement(element, "RUNNABLE-ENTITY")
|
|
902
|
+
self.writeIdentifiable(child_element, entity)
|
|
903
|
+
self.writeExecutableEntity(child_element, entity)
|
|
904
|
+
self.setChildElementOptionalBooleanValue(child_element, "CAN-BE-INVOKED-CONCURRENTLY", entity.can_be_invoked_concurrently)
|
|
905
|
+
self.writeParameterAccesses(child_element, entity)
|
|
906
|
+
self.writeDataReceivePointByArguments(child_element, entity)
|
|
907
|
+
self.writeDataSendPoints(child_element, entity)
|
|
908
|
+
self.writeDataWriteAccesses(child_element, entity)
|
|
909
|
+
self.writeReadLocalVariables(child_element, entity)
|
|
910
|
+
self.writeServerCallPoints(child_element, entity)
|
|
911
|
+
self.setChildElementOptionalLiteral(child_element, "SYMBOL", entity.symbol)
|
|
912
|
+
self.writeWrittenLocalVariable(child_element, entity)
|
|
913
|
+
|
|
914
|
+
def writeSwcInternalBehaviorRunnableEntities(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
915
|
+
entities = behavior.getRunnableEntities()
|
|
916
|
+
if len(entities) > 0:
|
|
917
|
+
runnables_tag = ET.SubElement(element, "RUNNABLES")
|
|
918
|
+
for entity in entities:
|
|
919
|
+
if isinstance(entity, RunnableEntity):
|
|
920
|
+
self.writeRunnableEntity(runnables_tag, entity)
|
|
921
|
+
else:
|
|
922
|
+
raise NotImplementedError("Unsupported RunnableEntity <%s>" % type(entity))
|
|
923
|
+
|
|
924
|
+
def writeExplicitInterRunnableVariables(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
925
|
+
prototypes = behavior.getExplicitInterRunnableVariables()
|
|
926
|
+
if len(prototypes) > 0:
|
|
927
|
+
child_element = ET.SubElement(element, "EXPLICIT-INTER-RUNNABLE-VARIABLES")
|
|
928
|
+
for prototype in prototypes:
|
|
929
|
+
if isinstance(prototype, VariableDataPrototype):
|
|
930
|
+
self.writeVariableDataPrototype(child_element, prototype)
|
|
931
|
+
else:
|
|
932
|
+
self._raiseError("Unsupported ExplicitInterRunnableVariables <%s>" % type(prototype))
|
|
933
|
+
|
|
934
|
+
def writePerInstanceMemories(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
935
|
+
memories = behavior.getPerInstanceMemories()
|
|
936
|
+
if len(memories) > 0:
|
|
937
|
+
memories_tag = ET.SubElement(element, "PER-INSTANCE-MEMORYS")
|
|
938
|
+
for memory in memories:
|
|
939
|
+
child_element = ET.SubElement(memories_tag, "PER-INSTANCE-MEMORY")
|
|
940
|
+
self.writeIdentifiable(child_element, memory)
|
|
941
|
+
self.setChildElementOptionalLiteral(child_element, "INIT-VALUE", memory.init_value)
|
|
942
|
+
self.setSwDataDefProps(child_element, "SW-DATA-DEF-PROPS", memory.sw_data_def_props)
|
|
943
|
+
self.setChildElementOptionalLiteral(child_element, "TYPE", memory.type)
|
|
944
|
+
self.setChildElementOptionalLiteral (child_element, "TYPE-DEFINITION", memory.type_definition)
|
|
945
|
+
|
|
946
|
+
def writeParameterDataPrototype(self, element: ET.Element, prototype: ParameterDataPrototype):
|
|
947
|
+
child_element = ET.SubElement(element, "PARAMETER-DATA-PROTOTYPE")
|
|
948
|
+
self.writeIdentifiable(child_element, prototype)
|
|
949
|
+
self.writeAutosarDataPrototype(child_element, prototype)
|
|
950
|
+
self.setInitValue(child_element, prototype.init_value)
|
|
951
|
+
|
|
952
|
+
def writeParameterDataPrototypes(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
953
|
+
prototypes = behavior.getParameterDataPrototypes()
|
|
954
|
+
if len(prototypes) > 0:
|
|
955
|
+
child_element = ET.SubElement(element, "PER-INSTANCE-PARAMETERS")
|
|
956
|
+
for prototype in prototypes:
|
|
957
|
+
self.writeParameterDataPrototype(child_element, prototype)
|
|
958
|
+
|
|
959
|
+
def writePortDefinedArgumentValues(self, element: ET.Element, option: PortAPIOption) :
|
|
960
|
+
argument_values = option.getPortArgValues()
|
|
961
|
+
if len(argument_values) > 0:
|
|
962
|
+
child_element = ET.SubElement(element, "PORT-ARG-VALUES")
|
|
963
|
+
for argument_value in argument_values:
|
|
964
|
+
child_element = ET.SubElement(child_element, "PORT-DEFINED-ARGUMENT-VALUE")
|
|
965
|
+
if argument_value.value is not None:
|
|
966
|
+
value_tag = ET.SubElement(child_element, "VALUE")
|
|
967
|
+
self.setValueSpecification(value_tag, argument_value.value)
|
|
968
|
+
self.setChildElementOptionalRefType(child_element, "VALUE-TYPE-TREF", argument_value.value_type)
|
|
969
|
+
|
|
970
|
+
def writePortAPIOptions(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
971
|
+
options = behavior.getPortAPIOptions()
|
|
972
|
+
if len(options) > 0:
|
|
973
|
+
port_api_options_tag = ET.SubElement(element, "PORT-API-OPTIONS")
|
|
974
|
+
for option in options:
|
|
975
|
+
child_element = ET.SubElement(port_api_options_tag, "PORT-API-OPTION")
|
|
976
|
+
self.setChildElementOptionalBooleanValue(child_element, "ENABLE-TAKE-ADDRESS", option.enable_take_address)
|
|
977
|
+
self.setChildElementOptionalBooleanValue(child_element, "INDIRECT-API", option.indirect_api)
|
|
978
|
+
self.writePortDefinedArgumentValues(child_element, option)
|
|
979
|
+
self.setChildElementOptionalRefType(child_element, "PORT-REF", option.port_ref)
|
|
980
|
+
|
|
981
|
+
def writeServiceDependency(self, element: ET.Element, dependency: ServiceDependency):
|
|
982
|
+
self.writeIdentifiable(element, dependency)
|
|
983
|
+
|
|
984
|
+
def writeRoleBasedDataAssignment(self, element: ET.Element, assignment: RoleBasedDataAssignment):
|
|
985
|
+
child_element = ET.SubElement(element, "ROLE-BASED-DATA-ASSIGNMENT")
|
|
986
|
+
self.setChildElementOptionalLiteral(child_element, "ROLE", assignment.role)
|
|
987
|
+
self.setAutosarParameterRef(child_element, "USED-PARAMETER-ELEMENT", assignment.used_parameter_element)
|
|
988
|
+
self.setChildElementOptionalRefType(child_element, "USED-PIM-REF", assignment.used_pim_ref)
|
|
989
|
+
|
|
990
|
+
def writeRoleBasedPortAssignment(self, element: ET.Element, assignment: RoleBasedPortAssignment):
|
|
991
|
+
child_element = ET.SubElement(element, "ROLE-BASED-PORT-ASSIGNMENT")
|
|
992
|
+
self.setChildElementOptionalRefType(child_element, "PORT-PROTOTYPE-REF", assignment.port_prototype_ref)
|
|
993
|
+
self.setChildElementOptionalLiteral(child_element, "ROLE", assignment.role)
|
|
994
|
+
|
|
995
|
+
def writeSwcServiceDependencyAssignedData(self, element: ET.Element, dependency: SwcServiceDependency):
|
|
996
|
+
assigned_data = dependency.getAssignedData()
|
|
997
|
+
if len(assigned_data) > 0:
|
|
998
|
+
child_element = ET.SubElement(element, "ASSIGNED-DATAS")
|
|
999
|
+
for data in assigned_data:
|
|
1000
|
+
if isinstance(data, RoleBasedDataAssignment):
|
|
1001
|
+
self.writeRoleBasedDataAssignment(child_element, data)
|
|
1002
|
+
else:
|
|
1003
|
+
self._raiseError("Unsupported Assigned Data <%s>" % type(data))
|
|
1004
|
+
|
|
1005
|
+
def writeSwcServiceDependencyAssignedPorts(self, element: ET.Element, dependency: SwcServiceDependency):
|
|
1006
|
+
assigned_data = dependency.getAssignedPorts()
|
|
1007
|
+
if len(assigned_data) > 0:
|
|
1008
|
+
child_element = ET.SubElement(element, "ASSIGNED-PORTS")
|
|
1009
|
+
for data in assigned_data:
|
|
1010
|
+
if isinstance(data, RoleBasedPortAssignment):
|
|
1011
|
+
self.writeRoleBasedPortAssignment(child_element, data)
|
|
1012
|
+
else:
|
|
1013
|
+
self._raiseError("Unsupported Assigned Data <%s>" % type(data))
|
|
1014
|
+
|
|
1015
|
+
def writeNvBlockNeeds(self, element: ET.Element, needs: NvBlockNeeds):
|
|
1016
|
+
child_element = ET.SubElement(element, "NV-BLOCK-NEEDS")
|
|
1017
|
+
self.logger.debug("writeNvBlockNeeds %s" % needs.short_name)
|
|
1018
|
+
self.writeIdentifiable(child_element, needs)
|
|
1019
|
+
self.setChildElementOptionalBooleanValue(child_element, "CALC-RAM-BLOCK-CRC", needs.calc_ram_block_crc)
|
|
1020
|
+
self.setChildElementOptionalBooleanValue(child_element, "CHECK-STATIC-BLOCK-ID", needs.check_static_block_id)
|
|
1021
|
+
self.setChildElementOptionalNumericalValue(child_element, "N-DATA-SETS", needs.n_data_sets)
|
|
1022
|
+
self.setChildElementOptionalNumericalValue(child_element, "N-ROM-BLOCKS", needs.n_rom_blocks)
|
|
1023
|
+
self.setChildElementOptionalBooleanValue(child_element, "READONLY", needs.readonly)
|
|
1024
|
+
self.setChildElementOptionalLiteral(child_element, "RELIABILITY", needs.reliability)
|
|
1025
|
+
self.setChildElementOptionalBooleanValue(child_element, "RESISTANT-TO-CHANGED-SW", needs.resistant_to_changed_sw)
|
|
1026
|
+
self.setChildElementOptionalBooleanValue(child_element, "RESTORE-AT-START", needs.restore_at_start)
|
|
1027
|
+
self.setChildElementOptionalBooleanValue(child_element, "STORE-AT-SHUTDOWN", needs.store_at_shutdown)
|
|
1028
|
+
self.setChildElementOptionalBooleanValue(child_element, "WRITE-ONLY-ONCE", needs.write_only_once)
|
|
1029
|
+
self.setChildElementOptionalBooleanValue(child_element, "WRITE-VERIFICATION", needs.write_verification)
|
|
1030
|
+
self.setChildElementOptionalLiteral(child_element, "WRITING-PRIORITY", needs.writing_priority)
|
|
1031
|
+
|
|
1032
|
+
def writeSwcServiceDependencyServiceNeeds(self, element: ET.Element, parent: SwcServiceDependency):
|
|
1033
|
+
needs = parent.getServiceNeeds()
|
|
1034
|
+
if len(needs) > 0:
|
|
1035
|
+
child_element = ET.SubElement(element, "SERVICE-NEEDS")
|
|
1036
|
+
for need in needs:
|
|
1037
|
+
if isinstance(need, NvBlockNeeds):
|
|
1038
|
+
self.writeNvBlockNeeds(child_element, need)
|
|
1039
|
+
else:
|
|
1040
|
+
self._raiseError("Unsupported service needs <%s>" % type(need))
|
|
1041
|
+
|
|
1042
|
+
def writeSwcServiceDependency(self, element: ET.Element, dependency: SwcServiceDependency):
|
|
1043
|
+
child_element = ET.SubElement(element, "SWC-SERVICE-DEPENDENCY")
|
|
1044
|
+
self.writeServiceDependency(child_element, dependency)
|
|
1045
|
+
self.writeSwcServiceDependencyAssignedData(child_element, dependency)
|
|
1046
|
+
self.writeSwcServiceDependencyAssignedPorts(child_element, dependency)
|
|
1047
|
+
self.writeSwcServiceDependencyServiceNeeds(child_element, dependency)
|
|
1048
|
+
|
|
1049
|
+
def writeSwcInternalBehaviorServiceDependencies(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
1050
|
+
dependencies = behavior.getSwcServiceDependencies()
|
|
1051
|
+
if len(dependencies) > 0:
|
|
1052
|
+
child_element = ET.SubElement(element, "SERVICE-DEPENDENCYS")
|
|
1053
|
+
for dependency in dependencies:
|
|
1054
|
+
if isinstance(dependency, SwcServiceDependency):
|
|
1055
|
+
self.writeSwcServiceDependency(child_element, dependency)
|
|
1056
|
+
else:
|
|
1057
|
+
self._raiseError("Unsupported ServiceDependency <%s>" % type(dependency))
|
|
1058
|
+
|
|
1059
|
+
def writeSwcInternalBehavior(self, element: ET.Element, behavior: SwcInternalBehavior):
|
|
1060
|
+
self.logger.debug("writeSwInternalBehavior %s" % behavior.short_name)
|
|
1061
|
+
|
|
1062
|
+
child_element = ET.SubElement(element, "SWC-INTERNAL-BEHAVIOR")
|
|
1063
|
+
self.writeInternalBehavior(child_element, behavior)
|
|
1064
|
+
self.writeRTEEvents(child_element, behavior)
|
|
1065
|
+
self.writeExplicitInterRunnableVariables(child_element, behavior)
|
|
1066
|
+
self.setChildElementOptionalLiteral(child_element, "HANDLE-TERMINATION-AND-RESTART", behavior.handle_termination_and_restart)
|
|
1067
|
+
self.writePerInstanceMemories(child_element, behavior)
|
|
1068
|
+
self.writeParameterDataPrototypes(child_element, behavior)
|
|
1069
|
+
self.writePortAPIOptions(child_element, behavior)
|
|
1070
|
+
self.writeSwcInternalBehaviorRunnableEntities(child_element, behavior)
|
|
1071
|
+
self.writeSwcInternalBehaviorServiceDependencies(child_element, behavior)
|
|
1072
|
+
self.setChildElementOptionalBooleanValue(child_element, "SUPPORTS-MULTIPLE-INSTANTIATION", behavior.supports_multiple_instantiation)
|
|
1073
|
+
|
|
1074
|
+
def writeAtomicSwComponentTypeInternalBehaviors(self, element: ET.Element, behavior: InternalBehavior):
|
|
1075
|
+
if behavior is not None:
|
|
1076
|
+
behaviors_tag = ET.SubElement(element, "INTERNAL-BEHAVIORS")
|
|
1077
|
+
if isinstance(behavior, SwcInternalBehavior):
|
|
1078
|
+
self.writeSwcInternalBehavior(behaviors_tag, behavior)
|
|
1079
|
+
else:
|
|
1080
|
+
self._raiseError("Unsupported Internal Behaviors <%s>" % type(behavior))
|
|
1081
|
+
|
|
1082
|
+
def writeAtomicSwComponentType(self, element: ET.Element, sw_component: AtomicSwComponentType):
|
|
1083
|
+
self.writeSwComponentType(element, sw_component)
|
|
1084
|
+
self.writeAtomicSwComponentTypeInternalBehaviors(element, sw_component.internal_behavior)
|
|
1085
|
+
|
|
1086
|
+
def writeComplexDeviceDriverSwComponentType(self, element: ET.Element, sw_component: ComplexDeviceDriverSwComponentType):
|
|
1087
|
+
self.logger.debug("writeComplexDeviceDriverSwComponentType %s" % sw_component.short_name)
|
|
1088
|
+
child_element = ET.SubElement(element, "COMPLEX-DEVICE-DRIVER-SW-COMPONENT-TYPE")
|
|
1089
|
+
self.writeAtomicSwComponentType(child_element, sw_component)
|
|
1090
|
+
|
|
1091
|
+
def writeArtifactDescriptors(self, element: ET.Element, code_desc: Code):
|
|
1092
|
+
artifact_descriptors = code_desc.getArtifactDescriptors()
|
|
1093
|
+
if len(artifact_descriptors) > 0:
|
|
1094
|
+
artifact_descs_tag = ET.SubElement(element, "ARTIFACT-DESCRIPTORS")
|
|
1095
|
+
for artifact_desc in artifact_descriptors:
|
|
1096
|
+
artifact_desc_tag = ET.SubElement(artifact_descs_tag, "AUTOSAR-ENGINEERING-OBJECT")
|
|
1097
|
+
self.logger.debug("writeArtifactDescriptor %s", artifact_desc.short_label)
|
|
1098
|
+
self.setARObjectAttributes(artifact_desc_tag, artifact_desc)
|
|
1099
|
+
self.setChildElementOptionalLiteral(artifact_desc_tag, "SHORT-LABEL", artifact_desc.short_label)
|
|
1100
|
+
self.setChildElementOptionalLiteral(artifact_desc_tag, "CATEGORY", artifact_desc.category)
|
|
1101
|
+
|
|
1102
|
+
def setCode(self, element: ET.SubElement, code_desc: Code):
|
|
1103
|
+
self.logger.debug("setCode %s" % code_desc.short_name)
|
|
1104
|
+
child_element = ET.SubElement(element, "CODE")
|
|
1105
|
+
self.writeIdentifiable(child_element, code_desc)
|
|
1106
|
+
self.writeArtifactDescriptor(child_element, code_desc)
|
|
1107
|
+
|
|
1108
|
+
def writeCodeDescriptors(self, element: ET.Element, impl: Implementation):
|
|
1109
|
+
descs = impl.getCodeDescriptors()
|
|
1110
|
+
if len(descs) > 0:
|
|
1111
|
+
child_element = ET.SubElement(element, "CODE-DESCRIPTORS")
|
|
1112
|
+
for desc in descs:
|
|
1113
|
+
if isinstance(desc, Code):
|
|
1114
|
+
self.setCode(child_element, desc)
|
|
1115
|
+
else:
|
|
1116
|
+
self._raiseError("Unsupported Code Descriptor <%s>" % type(desc))
|
|
1117
|
+
|
|
1118
|
+
def setMemorySectionOptions(self, element: ET.Element, options: List[ARLiteral]):
|
|
1119
|
+
if len(options) > 0:
|
|
1120
|
+
child_element = ET.SubElement(element, "OPTIONS")
|
|
1121
|
+
for option in options:
|
|
1122
|
+
self.setChildElementOptionalLiteral(child_element, "OPTION", option)
|
|
1123
|
+
|
|
1124
|
+
def writeMemorySections(self, element: ET.Element, consumption: ResourceConsumption):
|
|
1125
|
+
memory_sections = consumption.getMemorySections()
|
|
1126
|
+
if len(memory_sections) > 0:
|
|
1127
|
+
sections_tag = ET.SubElement(element, "MEMORY-SECTIONS")
|
|
1128
|
+
for memory_section in memory_sections:
|
|
1129
|
+
child_element = ET.SubElement(sections_tag, "MEMORY-SECTION")
|
|
1130
|
+
self.writeIdentifiable(child_element, memory_section)
|
|
1131
|
+
self.setChildElementOptionalLiteral(child_element, "ALIGNMENT", memory_section.alignment)
|
|
1132
|
+
self.setMemorySectionOptions(child_element, memory_section.getOptions())
|
|
1133
|
+
self.setChildElementOptionalNumericalValue(child_element, "SIZE", memory_section.size)
|
|
1134
|
+
self.setChildElementOptionalRefType(child_element, "SW-ADDRMETHOD-REF", memory_section.swAddrMethodRef)
|
|
1135
|
+
self.setChildElementOptionalLiteral(child_element, "SYMBOL", memory_section.symbol)
|
|
1136
|
+
self.logger.debug("writeMemorySections %s" % memory_section.short_name)
|
|
1137
|
+
|
|
1138
|
+
def setResourceConsumption(self, element: ET.Element, consumption: ResourceConsumption):
|
|
1139
|
+
if consumption is not None:
|
|
1140
|
+
child_element = ET.SubElement(element, "RESOURCE-CONSUMPTION")
|
|
1141
|
+
self.writeIdentifiable(child_element, consumption)
|
|
1142
|
+
self.writeMemorySections(child_element, consumption)
|
|
1143
|
+
|
|
1144
|
+
def writeImplementation(self, element: ET.Element, impl: Implementation):
|
|
1145
|
+
self.writeIdentifiable(element, impl)
|
|
1146
|
+
self.writeCodeDescriptors(element, impl)
|
|
1147
|
+
self.setChildElementOptionalLiteral(element, "PROGRAMMING-LANGUAGE", impl.programming_language)
|
|
1148
|
+
self.setResourceConsumption(element, impl.getResourceConsumption())
|
|
1149
|
+
self.setChildElementOptionalLiteral(element, "SW-VERSION", impl.sw_version)
|
|
1150
|
+
self.setChildElementOptionalRefType(element, "SWC-BSW-MAPPING-REF", impl.swc_bsw_mapping_ref)
|
|
1151
|
+
self.setChildElementOptionalLiteral(element, "USED-CODE-GENERATOR", impl.used_code_generator)
|
|
1152
|
+
self.setChildElementOptionalNumericalValue(element, "VENDOR-ID", impl.vendor_id)
|
|
1153
|
+
|
|
1154
|
+
def writeSwcImplementation(self, element: ET.Element, impl: SwcImplementation):
|
|
1155
|
+
self.logger.debug("writeSwcImplementation %s" % impl.short_name)
|
|
1156
|
+
child_element = ET.SubElement(element, "SWC-IMPLEMENTATION")
|
|
1157
|
+
self.writeImplementation(child_element, impl)
|
|
1158
|
+
self.setChildElementOptionalRefType(child_element, "BEHAVIOR-REF", impl.behavior_ref)
|
|
1159
|
+
|
|
1160
|
+
def writeEndToEndDescriptionDataId(self, element: ET.Element, parent: EndToEndDescription):
|
|
1161
|
+
data_ids = parent.getDataIds()
|
|
1162
|
+
if len(data_ids) > 0:
|
|
1163
|
+
child_element = ET.SubElement(element, "DATA-IDS")
|
|
1164
|
+
for data_id in data_ids:
|
|
1165
|
+
self.setChildElementOptionalNumericalValue(child_element, "DATA-ID", data_id)
|
|
1166
|
+
|
|
1167
|
+
def setEndToEndDescription(self, element: ET.Element, key: str, desc: EndToEndDescription):
|
|
1168
|
+
if desc is not None:
|
|
1169
|
+
child_element = ET.SubElement(element, key)
|
|
1170
|
+
self.setChildElementOptionalLiteral(child_element, "CATEGORY", desc.category)
|
|
1171
|
+
self.writeEndToEndDescriptionDataId(child_element, desc)
|
|
1172
|
+
self.setChildElementOptionalNumericalValue(child_element, "DATA-ID-MODE", desc.dataIdMode)
|
|
1173
|
+
self.setChildElementOptionalNumericalValue(child_element, "MAX-DELTA-COUNTER-INIT", desc.maxDeltaCounterInit)
|
|
1174
|
+
self.setChildElementOptionalNumericalValue(child_element, "CRC-OFFSET", desc.crcOffset)
|
|
1175
|
+
self.setChildElementOptionalNumericalValue(child_element, "COUNTER-OFFSET", desc.counterOffset)
|
|
1176
|
+
|
|
1177
|
+
def setVariableDataPrototypeInSystemInstanceRef(self, element: ET.Element, key: str, iref: VariableDataPrototypeInSystemInstanceRef):
|
|
1178
|
+
if iref is not None:
|
|
1179
|
+
child_element = ET.SubElement(element, key)
|
|
1180
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-COMPONENT-REF", iref.contextComponentRef)
|
|
1181
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-COMPOSITION-REF", iref.contextCompositionRef)
|
|
1182
|
+
self.setChildElementOptionalRefType(child_element, "CONTEXT-PORT-REF", iref.contextPortRef)
|
|
1183
|
+
self.setChildElementOptionalRefType(child_element, "TARGET-DATA-PROTOTYPE-REF", iref.targetDataPrototypeRef)
|
|
1184
|
+
|
|
1185
|
+
def setEndToEndProtectionVariablePrototype(self, element: ET.Element, key: str, prototype: EndToEndProtectionVariablePrototype):
|
|
1186
|
+
if prototype is not None:
|
|
1187
|
+
child_element = ET.SubElement(element, key)
|
|
1188
|
+
irefs = prototype.getReceiverIrefs()
|
|
1189
|
+
if len(irefs) > 0:
|
|
1190
|
+
child_element = ET.SubElement(child_element, "RECEIVER-IREFS")
|
|
1191
|
+
for iref in irefs:
|
|
1192
|
+
self.setVariableDataPrototypeInSystemInstanceRef(child_element, "RECEIVER-IREF", iref)
|
|
1193
|
+
self.setVariableDataPrototypeInSystemInstanceRef(child_element, "SENDER-IREF", prototype.senderIRef)
|
|
1194
|
+
|
|
1195
|
+
def writeEndToEndProtectionVariablePrototypes(self, element: ET.Element, parent: EndToEndProtection):
|
|
1196
|
+
prototypes = parent.getEndToEndProtectionVariablePrototypes()
|
|
1197
|
+
if len(prototypes) > 0:
|
|
1198
|
+
child_element = ET.SubElement(element, "END-TO-END-PROTECTION-VARIABLE-PROTOTYPES")
|
|
1199
|
+
for prototype in prototypes:
|
|
1200
|
+
if isinstance(prototype, EndToEndProtectionVariablePrototype):
|
|
1201
|
+
self.setEndToEndProtectionVariablePrototype(child_element, "END-TO-END-PROTECTION-VARIABLE-PROTOTYPE", prototype)
|
|
1202
|
+
else:
|
|
1203
|
+
self._raiseError("Unsupported End To End Protection Variable Prototype <%s>" % type(prototype))
|
|
1204
|
+
|
|
1205
|
+
def setEndToEndProtection(self, element: ET.Element, protection: EndToEndProtection):
|
|
1206
|
+
if protection is not None:
|
|
1207
|
+
child_element = ET.SubElement(element, "END-TO-END-PROTECTION")
|
|
1208
|
+
self.writeIdentifiable(child_element, protection)
|
|
1209
|
+
self.setEndToEndDescription(child_element, "END-TO-END-PROFILE", protection.endToEndProfile)
|
|
1210
|
+
self.writeEndToEndProtectionVariablePrototypes(child_element, protection)
|
|
1211
|
+
|
|
1212
|
+
def writeEndToEndProtections(self, element: ET.Element, protection_set: EndToEndProtectionSet):
|
|
1213
|
+
protections = protection_set.getEndToEndProtections()
|
|
1214
|
+
if len(protections) > 0:
|
|
1215
|
+
child_element = ET.SubElement(element, "END-TO-END-PROTECTIONS")
|
|
1216
|
+
for protection in protections:
|
|
1217
|
+
if isinstance(protection, EndToEndProtection):
|
|
1218
|
+
self.setEndToEndProtection(child_element, protection)
|
|
1219
|
+
|
|
1220
|
+
def writeEndToEndProtectionSet(self, element: ET.Element, protection_set: EndToEndProtectionSet):
|
|
1221
|
+
self.logger.debug("writeEndToEndProtectionSet %s" % protection_set.short_name)
|
|
1222
|
+
child_element = ET.SubElement(element, "END-TO-END-PROTECTION-SET")
|
|
1223
|
+
self.writeIdentifiable(child_element, protection_set)
|
|
1224
|
+
self.writeEndToEndProtections(child_element, protection_set)
|
|
1225
|
+
|
|
1226
|
+
def writeAutosarDataPrototype(self, element: ET.Element, prototype: AutosarDataPrototype):
|
|
1227
|
+
self.setChildElementOptionalRefType(element, "TYPE-TREF", prototype.type_tref)
|
|
1228
|
+
|
|
1229
|
+
def writeVariableDataPrototype(self, element: ET.Element, prototype: VariableDataPrototype):
|
|
1230
|
+
self.logger.debug("writeVariableDataPrototype %s" % prototype.short_name)
|
|
1231
|
+
child_element = ET.SubElement(element, "VARIABLE-DATA-PROTOTYPE")
|
|
1232
|
+
self.writeIdentifiable(child_element, prototype)
|
|
1233
|
+
self.setSwDataDefProps(child_element, "SW-DATA-DEF-PROPS", prototype.sw_data_def_props)
|
|
1234
|
+
self.writeAutosarDataPrototype(child_element, prototype)
|
|
1235
|
+
self.setInitValue(child_element, prototype.init_value)
|
|
1236
|
+
|
|
1237
|
+
def writeDataElements(self, element: ET.Element, sr_interface: SenderReceiverInterface):
|
|
1238
|
+
data_elements = sr_interface.getDataElements()
|
|
1239
|
+
if len(data_elements) > 0:
|
|
1240
|
+
data_elements_tag = ET.SubElement(element, "DATA-ELEMENTS")
|
|
1241
|
+
for data_element in data_elements:
|
|
1242
|
+
if isinstance(data_element, VariableDataPrototype):
|
|
1243
|
+
self.writeVariableDataPrototype(data_elements_tag, data_element)
|
|
1244
|
+
else:
|
|
1245
|
+
self._raiseError("Unsupported Data Element <%s>" % type(data_element))
|
|
1246
|
+
|
|
1247
|
+
def writeSenderReceiverInterface(self, element: ET.Element, sr_interface: SenderReceiverInterface):
|
|
1248
|
+
self.logger.debug("writeSenderReceiverInterface %s" % sr_interface.short_name)
|
|
1249
|
+
child_element = ET.SubElement(element, "SENDER-RECEIVER-INTERFACE")
|
|
1250
|
+
self.writeIdentifiable(child_element, sr_interface)
|
|
1251
|
+
self.setChildElementOptionalBooleanValue(child_element, "IS-SERVICE", sr_interface.is_service)
|
|
1252
|
+
self.writeDataElements(child_element, sr_interface)
|
|
1253
|
+
|
|
1254
|
+
def writerBswModuleDescriptionImplementedEntry(self, element: ET.Element, desc: BswModuleDescription):
|
|
1255
|
+
entries = desc.getImplementedEntries()
|
|
1256
|
+
if len(entries) > 0:
|
|
1257
|
+
entries_tag = ET.SubElement(element, "PROVIDED-ENTRYS")
|
|
1258
|
+
for entry in entries:
|
|
1259
|
+
entry_tag = ET.SubElement(entries_tag, "BSW-MODULE-ENTRY-REF-CONDITIONAL")
|
|
1260
|
+
self.setChildElementOptionalRefType(entry_tag, "BSW-MODULE-ENTRY-REF", entry)
|
|
1261
|
+
|
|
1262
|
+
def setModeDeclarationGroupPrototype(self, element: ET.Element, prototype: ModeDeclarationGroupPrototype):
|
|
1263
|
+
self.writeIdentifiable(element, prototype)
|
|
1264
|
+
self.setChildElementOptionalRefType(element, "TYPE-TREF", prototype.type_tref)
|
|
1265
|
+
|
|
1266
|
+
def writeProvidedModeGroup(self, element: ET.Element, parent: BswModuleDescription):
|
|
1267
|
+
mode_groups = parent.getProvidedModeGroups()
|
|
1268
|
+
if len(mode_groups) > 0:
|
|
1269
|
+
mode_groups_tag = ET.SubElement(element, "PROVIDED-MODE-GROUPS")
|
|
1270
|
+
for mode_group in mode_groups:
|
|
1271
|
+
child_element = ET.SubElement(mode_groups_tag, "MODE-DECLARATION-GROUP-PROTOTYPE")
|
|
1272
|
+
self.setModeDeclarationGroupPrototype(child_element, mode_group)
|
|
1273
|
+
|
|
1274
|
+
def writeCanEnterExclusiveAreaRefs(self, element: ET.Element, entity: ExecutableEntity):
|
|
1275
|
+
refs = entity.getCanEnterExclusiveAreaRefs()
|
|
1276
|
+
if len(refs) > 0:
|
|
1277
|
+
child_element = ET.SubElement(element, "CAN-ENTER-EXCLUSIVE-AREA-REFS")
|
|
1278
|
+
for ref in refs:
|
|
1279
|
+
self.setChildElementOptionalRefType(child_element, "CAN-ENTER-EXCLUSIVE-AREA-REF", ref)
|
|
1280
|
+
|
|
1281
|
+
def setExecutableEntity(self, element: ET.Element, entity: ExecutableEntity):
|
|
1282
|
+
self.writeIdentifiable(element, entity)
|
|
1283
|
+
self.writeCanEnterExclusiveAreaRefs(element, entity)
|
|
1284
|
+
self.setChildElementOptionalFloatValue(element, "MINIMUM-START-INTERVAL", entity.minimum_start_interval)
|
|
1285
|
+
|
|
1286
|
+
def writeBswModuleEntityManagedModeGroup(self, element: ET.Element, entity: BswModuleEntity):
|
|
1287
|
+
mode_group_refs = entity.getManagedModeGroupRefs()
|
|
1288
|
+
if len(mode_group_refs) > 0:
|
|
1289
|
+
mode_groups_tag = ET.SubElement(element, "MANAGED-MODE-GROUPS")
|
|
1290
|
+
for mode_group_ref in mode_group_refs:
|
|
1291
|
+
child_element = ET.SubElement(mode_groups_tag, "MODE-DECLARATION-GROUP-PROTOTYPE-REF-CONDITIONAL")
|
|
1292
|
+
self.setChildElementOptionalRefType(child_element, "MODE-DECLARATION-GROUP-PROTOTYPE-REF", mode_group_ref)
|
|
1293
|
+
|
|
1294
|
+
def setBswModuleEntity(self, element: ET.Element, entity: BswModuleEntity):
|
|
1295
|
+
self.setExecutableEntity(element, entity)
|
|
1296
|
+
self.setChildElementOptionalRefType(element, "IMPLEMENTED-ENTRY-REF", entity.implemented_entry_ref)
|
|
1297
|
+
self.writeBswModuleEntityManagedModeGroup(element, entity)
|
|
1298
|
+
|
|
1299
|
+
def setBswCalledEntity(self, element: ET.Element, entity: BswCalledEntity):
|
|
1300
|
+
self.logger.debug("setBswCalledEntity %s" % entity.short_name)
|
|
1301
|
+
child_element = ET.SubElement(element, "BSW-CALLED-ENTITY")
|
|
1302
|
+
self.setBswModuleEntity(child_element, entity)
|
|
1303
|
+
|
|
1304
|
+
def setBswSchedulableEntity(self, element: ET.Element, entity: BswSchedulableEntity):
|
|
1305
|
+
self.logger.debug("setBswCalledEntity %s" % entity.short_name)
|
|
1306
|
+
child_element = ET.SubElement(element, "BSW-SCHEDULABLE-ENTITY")
|
|
1307
|
+
self.setBswModuleEntity(child_element, entity)
|
|
1308
|
+
|
|
1309
|
+
def writeBswInternalBehaviorBswModuleEntities(self, element: ET.Element, parent: BswInternalBehavior):
|
|
1310
|
+
entities = parent.getBswModuleEntities()
|
|
1311
|
+
if len(entities) > 0:
|
|
1312
|
+
child_element = ET.SubElement(element, "ENTITYS")
|
|
1313
|
+
for entity in entities:
|
|
1314
|
+
if isinstance(entity, BswCalledEntity):
|
|
1315
|
+
self.setBswCalledEntity(child_element, entity)
|
|
1316
|
+
elif isinstance(entity, BswSchedulableEntity):
|
|
1317
|
+
self.setBswSchedulableEntity(child_element, entity)
|
|
1318
|
+
else:
|
|
1319
|
+
self._raiseError("Unsupported BswModuleEntity <%s>" % type(entity))
|
|
1320
|
+
|
|
1321
|
+
def setBswEvent(self, element: ET.Element, event: BswEvent):
|
|
1322
|
+
self.writeIdentifiable(element, event)
|
|
1323
|
+
self.setChildElementOptionalRefType(element, "STARTS-ON-EVENT-REF", event.startsOnEventRef)
|
|
1324
|
+
|
|
1325
|
+
def setBswScheduleEvent(self, element: ET.Element, event: BswScheduleEvent):
|
|
1326
|
+
self.setBswEvent(element, event)
|
|
1327
|
+
|
|
1328
|
+
def setBswTimingEvent(self, element: ET.Element, event: BswTimingEvent):
|
|
1329
|
+
self.logger.debug("setBswTimingEvent %s" % event.short_name)
|
|
1330
|
+
child_element = ET.SubElement(element, "BSW-TIMING-EVENT")
|
|
1331
|
+
self.setBswScheduleEvent(child_element, event)
|
|
1332
|
+
self.setChildElementOptionalFloatValue(child_element, "PERIOD", event.period)
|
|
1333
|
+
|
|
1334
|
+
def writeBswInternalBehaviorBswEvents(self, element: ET.Element, parent: BswInternalBehavior):
|
|
1335
|
+
events = parent.getBswEvents()
|
|
1336
|
+
if len(events) > 0:
|
|
1337
|
+
child_element = ET.SubElement(element, "EVENTS")
|
|
1338
|
+
for event in events:
|
|
1339
|
+
if isinstance(event, BswTimingEvent):
|
|
1340
|
+
self.setBswTimingEvent(child_element, event)
|
|
1341
|
+
else:
|
|
1342
|
+
self._raiseError("Unsupported BswModuleEntity <%s>" % type(event))
|
|
1343
|
+
|
|
1344
|
+
def setBswModeSenderPolicy(self, element: ET.Element, policy: BswModeSenderPolicy):
|
|
1345
|
+
child_element = ET.SubElement(element, "BSW-MODE-SENDER-POLICY")
|
|
1346
|
+
self.setChildElementOptionalRefType(child_element, "PROVIDED-MODE-GROUP-REF", policy.getProvidedModeGroupRef())
|
|
1347
|
+
self.setChildElementOptionalNumericalValue(child_element, "QUEUE-LENGTH", policy.getQueueLength())
|
|
1348
|
+
|
|
1349
|
+
def writeBswInternalBehaviorModeSenderPolicy(self, element: ET.Element, parent: BswInternalBehavior):
|
|
1350
|
+
policies = parent.getModeSenderPolicies()
|
|
1351
|
+
if len(policies) > 0:
|
|
1352
|
+
child_element = ET.SubElement(element, "MODE-SENDER-POLICYS")
|
|
1353
|
+
for policy in policies:
|
|
1354
|
+
if isinstance(policy, BswModeSenderPolicy):
|
|
1355
|
+
self.setBswModeSenderPolicy(child_element, policy)
|
|
1356
|
+
else:
|
|
1357
|
+
self._raiseError("Unsupported ModeSenderPolicy type <%s>." % type(policy))
|
|
1358
|
+
|
|
1359
|
+
def setBswInternalBehavior(self, element: ET.Element, behavior: BswInternalBehavior):
|
|
1360
|
+
child_element = ET.SubElement(element, "BSW-INTERNAL-BEHAVIOR")
|
|
1361
|
+
self.writeInternalBehavior(child_element, behavior)
|
|
1362
|
+
self.writeBswInternalBehaviorBswModuleEntities(child_element, behavior)
|
|
1363
|
+
self.writeBswInternalBehaviorBswEvents(child_element, behavior)
|
|
1364
|
+
self.writeBswInternalBehaviorModeSenderPolicy(child_element, behavior)
|
|
1365
|
+
|
|
1366
|
+
def writeBswModuleDescriptionInternalBehaviors(self, element: ET.Element, behaviors: List[InternalBehavior]):
|
|
1367
|
+
if len(behaviors) > 0:
|
|
1368
|
+
child_element = ET.SubElement(element, "INTERNAL-BEHAVIORS")
|
|
1369
|
+
for behavior in behaviors:
|
|
1370
|
+
if isinstance(behavior, BswInternalBehavior):
|
|
1371
|
+
self.setBswInternalBehavior(child_element, behavior)
|
|
1372
|
+
else:
|
|
1373
|
+
self._raiseError("Unsupported BswInternalBehavior <%s>" % type(behavior))
|
|
1374
|
+
|
|
1375
|
+
def writeBswModuleDescription(self, element: ET.Element, desc: BswModuleDescription):
|
|
1376
|
+
self.logger.debug("writeBswModuleDescription %s" % desc.short_name)
|
|
1377
|
+
child_element = ET.SubElement(element, "BSW-MODULE-DESCRIPTION")
|
|
1378
|
+
self.writeIdentifiable(child_element, desc)
|
|
1379
|
+
self.setChildElementOptionalNumericalValue(child_element, "MODULE-ID", desc.module_id)
|
|
1380
|
+
self.writerBswModuleDescriptionImplementedEntry(child_element, desc)
|
|
1381
|
+
self.writeProvidedModeGroup(child_element, desc)
|
|
1382
|
+
#self.readRequiredModeGroup(element, bsw_module_description)
|
|
1383
|
+
self.writeBswModuleDescriptionInternalBehaviors(child_element, desc.getBswInternalBehaviors())
|
|
1384
|
+
|
|
1385
|
+
def writeBswModuleEntityManagedModeGroup(self, element: ET.Element, entity: BswModuleEntity):
|
|
1386
|
+
mode_group_refs = entity.getManagedModeGroupRefs()
|
|
1387
|
+
if len(mode_group_refs) > 0:
|
|
1388
|
+
mode_groups_tag = ET.SubElement(element, "MANAGED-MODE-GROUPS")
|
|
1389
|
+
for mode_group_ref in mode_group_refs:
|
|
1390
|
+
child_element = ET.SubElement(mode_groups_tag, "MODE-DECLARATION-GROUP-PROTOTYPE-REF-CONDITIONAL")
|
|
1391
|
+
self.setChildElementOptionalRefType(child_element, "MODE-DECLARATION-GROUP-PROTOTYPE-REF", mode_group_ref)
|
|
1392
|
+
|
|
1393
|
+
def writeBswModuleEntry(self, element: ET.Element, entry: BswModuleEntry):
|
|
1394
|
+
self.logger.debug("writeBswModuleDescription %s" % entry.short_name)
|
|
1395
|
+
child_element = ET.SubElement(element, "BSW-MODULE-ENTRY")
|
|
1396
|
+
self.writeIdentifiable(child_element, entry)
|
|
1397
|
+
self.setChildElementOptionalNumericalValue(child_element, "SERVICE-ID", entry.service_id)
|
|
1398
|
+
self.setChildElementOptionalBooleanValue(child_element, "IS-REENTRANT", entry.is_reentrant)
|
|
1399
|
+
self.setChildElementOptionalBooleanValue(child_element, "IS-SYNCHRONOUS", entry.is_synchronous)
|
|
1400
|
+
self.setChildElementOptionalLiteral(child_element, "CALL-TYPE", entry.call_type)
|
|
1401
|
+
self.setChildElementOptionalLiteral(child_element, "EXECUTION-CONTEXT", entry.execution_context)
|
|
1402
|
+
self.setChildElementOptionalLiteral(child_element, "SW-SERVICE-IMPL-POLICY", entry.sw_service_impl_policy)
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
def setSwcBswRunnableMapping(self, element: ET.SubElement, mapping: SwcBswRunnableMapping):
|
|
1406
|
+
child_element = ET.SubElement(element, "SWC-BSW-RUNNABLE-MAPPING")
|
|
1407
|
+
self.setChildElementOptionalRefType(child_element, "BSW-ENTITY-REF", mapping.bswEntityRef)
|
|
1408
|
+
self.setChildElementOptionalRefType(child_element, "SWC-RUNNABLE-REF", mapping.swcRunnableRef)
|
|
1409
|
+
|
|
1410
|
+
def writeSwcBswRunnableMappings(self, element: ET.Element, parent: SwcBswMapping):
|
|
1411
|
+
runnable_mappings = parent.getRunnableMappings()
|
|
1412
|
+
if len(runnable_mappings) > 0:
|
|
1413
|
+
child_element = ET.SubElement(element, "RUNNABLE-MAPPINGS")
|
|
1414
|
+
for mapping in runnable_mappings:
|
|
1415
|
+
if isinstance(mapping, SwcBswRunnableMapping):
|
|
1416
|
+
self.setSwcBswRunnableMapping(child_element, mapping)
|
|
1417
|
+
else:
|
|
1418
|
+
self._raiseError("Unsupported Runnable Mapping <%s>" % type(mapping))
|
|
1419
|
+
|
|
1420
|
+
def setSwcBswMapping(self, element: ET.Element, mapping: SwcBswMapping):
|
|
1421
|
+
self.logger.debug("writeBswModuleDescription %s" % mapping.short_name)
|
|
1422
|
+
child_element = ET.SubElement(element, "SWC-BSW-MAPPING")
|
|
1423
|
+
self.writeIdentifiable(child_element, mapping)
|
|
1424
|
+
self.setChildElementOptionalRefType(child_element, "BSW-BEHAVIOR-REF", mapping.bswBehaviorRef)
|
|
1425
|
+
self.writeSwcBswRunnableMappings(child_element, mapping)
|
|
1426
|
+
self.setChildElementOptionalRefType(child_element, "SWC-BEHAVIOR-REF", mapping.swcBehaviorRef)
|
|
1427
|
+
|
|
1428
|
+
def writeEngineeringObject(self, element: ET.Element, engineering_obj: EngineeringObject):
|
|
1429
|
+
self.setARObjectAttributes(element, engineering_obj)
|
|
1430
|
+
self.setChildElementOptionalLiteral(element, "SHORT-LABEL", engineering_obj.short_label)
|
|
1431
|
+
self.setChildElementOptionalLiteral(element, "CATEGORY", engineering_obj.category)
|
|
1432
|
+
|
|
1433
|
+
def setAutosarEngineeringObject(self, element: ET.Element, obj: AutosarEngineeringObject):
|
|
1434
|
+
self.logger.debug("readArtifactDescriptor %s", obj.short_label)
|
|
1435
|
+
child_element = ET.SubElement(element, "AUTOSAR-ENGINEERING-OBJECT")
|
|
1436
|
+
self.writeEngineeringObject(child_element, obj)
|
|
1437
|
+
|
|
1438
|
+
def writeArtifactDescriptor(self, element: ET.Element, code_desc: Code):
|
|
1439
|
+
artifact_descs = code_desc.getArtifactDescriptors()
|
|
1440
|
+
if len(artifact_descs) > 0:
|
|
1441
|
+
child_element = ET.SubElement(element, "ARTIFACT-DESCRIPTORS")
|
|
1442
|
+
for artifact_desc in artifact_descs:
|
|
1443
|
+
if isinstance(artifact_desc, AutosarEngineeringObject):
|
|
1444
|
+
self.setAutosarEngineeringObject(child_element, artifact_desc)
|
|
1445
|
+
else:
|
|
1446
|
+
self._raiseError("Unsupported Artifact descriptor <%s>" % type(artifact_desc))
|
|
1447
|
+
|
|
1448
|
+
def writeBswImplementationVendorSpecificModuleDefRefs(self, element: ET.Element, parent: BswImplementation):
|
|
1449
|
+
refs = parent.getVendorSpecificModuleDefRefs()
|
|
1450
|
+
if len(refs) > 0:
|
|
1451
|
+
child_element = ET.SubElement(element, "VENDOR-SPECIFIC-MODULE-DEF-REFS")
|
|
1452
|
+
if child_element != None:
|
|
1453
|
+
for ref in refs:
|
|
1454
|
+
self.setChildElementOptionalRefType(child_element, "VENDOR-SPECIFIC-MODULE-DEF-REF", ref)
|
|
1455
|
+
|
|
1456
|
+
def writeBswImplementation(self, element: ET.Element, impl: BswImplementation):
|
|
1457
|
+
self.logger.debug("writeBswModuleDescription %s" % impl.short_name)
|
|
1458
|
+
child_element = ET.SubElement(element, "BSW-IMPLEMENTATION")
|
|
1459
|
+
self.writeImplementation(child_element, impl)
|
|
1460
|
+
self.setChildElementOptionalLiteral(child_element, "AR-RELEASE-VERSION", impl.ar_release_version)
|
|
1461
|
+
self.setChildElementOptionalRefType(child_element, "BEHAVIOR-REF", impl.behavior_ref)
|
|
1462
|
+
self.writeBswImplementationVendorSpecificModuleDefRefs(child_element, impl)
|
|
1463
|
+
|
|
1464
|
+
def writeImplementationDataTypeElements(self, element: ET.Element, parent: ImplementationDataType):
|
|
1465
|
+
sub_elements = parent.getImplementationDataTypeElements()
|
|
1466
|
+
if len(sub_elements) > 0:
|
|
1467
|
+
sub_elements_tag = ET.SubElement(element, "SUB-ELEMENTS")
|
|
1468
|
+
for type_element in sub_elements:
|
|
1469
|
+
child_element = ET.SubElement(sub_elements_tag, "IMPLEMENTATION-DATA-TYPE-ELEMENT")
|
|
1470
|
+
self.writeIdentifiable(child_element, type_element)
|
|
1471
|
+
self.setSwDataDefProps(child_element, "SW-DATA-DEF-PROPS", type_element.sw_data_def_props)
|
|
1472
|
+
|
|
1473
|
+
def writeImplementationDataType(self, element: ET.Element, data_type: ImplementationDataType):
|
|
1474
|
+
self.logger.debug("writeImplementationDataType %s" % data_type.short_name)
|
|
1475
|
+
child_element = ET.SubElement(element, "IMPLEMENTATION-DATA-TYPE")
|
|
1476
|
+
self.writeAutosarDataType(child_element, data_type)
|
|
1477
|
+
self.setChildElementOptionalLiteral(child_element, "TYPE-EMITTER", data_type.getTypeEmitter())
|
|
1478
|
+
self.writeImplementationDataTypeElements(child_element, data_type)
|
|
1479
|
+
|
|
1480
|
+
def writeArgumentDataPrototypes(self, element: ET.Element, parent: ClientServerOperation):
|
|
1481
|
+
arguments = parent.getArgumentDataPrototypes()
|
|
1482
|
+
if len(arguments) > 0:
|
|
1483
|
+
arguments_tag = ET.SubElement(element, "ARGUMENTS")
|
|
1484
|
+
for prototype in arguments:
|
|
1485
|
+
child_element = ET.SubElement(arguments_tag, "ARGUMENT-DATA-PROTOTYPE")
|
|
1486
|
+
self.writeIdentifiable(child_element, prototype)
|
|
1487
|
+
self.setChildElementOptionalRefType(child_element, "TYPE-TREF", prototype.type_tref)
|
|
1488
|
+
self.setChildElementOptionalLiteral(child_element, "DIRECTION", prototype.direction)
|
|
1489
|
+
|
|
1490
|
+
def writePossibleErrorRefs(self, element: ET.Element, parent: ClientServerOperation):
|
|
1491
|
+
error_refs = parent.getPossbileErrorRefs()
|
|
1492
|
+
if len(error_refs) > 0:
|
|
1493
|
+
error_refs_tag = ET.SubElement(element, "POSSIBLE-ERROR-REFS")
|
|
1494
|
+
for error_ref in error_refs:
|
|
1495
|
+
self.setChildElementOptionalRefType(error_refs_tag, "POSSIBLE-ERROR-REF", error_ref)
|
|
1496
|
+
|
|
1497
|
+
def writeClientServerOperation(self, element: ET.Element, operation: ClientServerOperation):
|
|
1498
|
+
self.logger.debug("writeClientServerOperation %s" % operation.short_name)
|
|
1499
|
+
child_element = ET.SubElement(element, "CLIENT-SERVER-OPERATION")
|
|
1500
|
+
self.writeIdentifiable(child_element, operation)
|
|
1501
|
+
self.writeArgumentDataPrototypes(child_element, operation)
|
|
1502
|
+
self.writePossibleErrorRefs(child_element, operation)
|
|
1503
|
+
|
|
1504
|
+
def writeOperations(self, element: ET.Element, parent: ClientServerInterface):
|
|
1505
|
+
operations = parent.getOperations()
|
|
1506
|
+
if len(operations) > 0:
|
|
1507
|
+
operations_tag = ET.SubElement(element, "OPERATIONS")
|
|
1508
|
+
for operation in operations:
|
|
1509
|
+
if isinstance(operation, ClientServerOperation):
|
|
1510
|
+
self.writeClientServerOperation(operations_tag, operation)
|
|
1511
|
+
else:
|
|
1512
|
+
self._raiseError("Unsupported Operation <%s>" % type(operation))
|
|
1513
|
+
|
|
1514
|
+
def writeApplicationError(self, element: ET.Element, error: ApplicationError):
|
|
1515
|
+
self.logger.debug("writeApplicationError %s" % error.short_name)
|
|
1516
|
+
child_element = ET.SubElement(element, "APPLICATION-ERROR")
|
|
1517
|
+
self.writeIdentifiable(child_element, error)
|
|
1518
|
+
self.setChildElementOptionalNumericalValue(child_element, "ERROR-CODE", error.error_code)
|
|
1519
|
+
|
|
1520
|
+
def writePossibleErrors(self, element: ET.Element, parent: ClientServerInterface):
|
|
1521
|
+
errors = parent.getPossibleErrors()
|
|
1522
|
+
if len(errors) > 0:
|
|
1523
|
+
errors_tag = ET.SubElement(element, "POSSIBLE-ERRORS")
|
|
1524
|
+
for error in errors:
|
|
1525
|
+
if isinstance(error, ApplicationError):
|
|
1526
|
+
self.writeApplicationError(errors_tag, error)
|
|
1527
|
+
else:
|
|
1528
|
+
self._raiseError("Unsupported PossibleError %s" % type(error))
|
|
1529
|
+
|
|
1530
|
+
def setPortInterface(self, element: ET.Element, port_interface: PortInterface):
|
|
1531
|
+
self.writeIdentifiable(element, port_interface)
|
|
1532
|
+
self.setChildElementOptionalBooleanValue(element, "IS-SERVICE", port_interface.is_service)
|
|
1533
|
+
self.setChildElementOptionalLiteral(element, "SERVICE-KIND", port_interface.serviceKind)
|
|
1534
|
+
|
|
1535
|
+
def writeClientServerInterface(self, element: ET.Element, cs_interface: ClientServerInterface):
|
|
1536
|
+
self.logger.debug("writeClientServerInterface %s" % cs_interface.short_name)
|
|
1537
|
+
child_element = ET.SubElement(element, "CLIENT-SERVER-INTERFACE")
|
|
1538
|
+
self.setPortInterface(child_element, cs_interface)
|
|
1539
|
+
self.writeOperations(child_element, cs_interface)
|
|
1540
|
+
self.writePossibleErrors(child_element, cs_interface)
|
|
1541
|
+
|
|
1542
|
+
def writeApplicationSwComponentType(self, element: ET.Element, sw_component: ApplicationSwComponentType):
|
|
1543
|
+
self.logger.debug("writeApplicationSwComponentType %s" % sw_component.short_name)
|
|
1544
|
+
child_element = ET.SubElement(element, "APPLICATION-SW-COMPONENT-TYPE")
|
|
1545
|
+
self.writeAtomicSwComponentType(child_element, sw_component)
|
|
1546
|
+
|
|
1547
|
+
def writeEcuAbstractionSwComponentType(self, element: ET.Element, sw_component: EcuAbstractionSwComponentType):
|
|
1548
|
+
self.logger.debug("writeEcuAbstractionSwComponentType %s" % sw_component.short_name)
|
|
1549
|
+
child_element = ET.SubElement(element, "ECU-ABSTRACTION-SW-COMPONENT-TYPE")
|
|
1550
|
+
self.writeAtomicSwComponentType(child_element, sw_component)
|
|
1551
|
+
|
|
1552
|
+
def setApplicationArrayElement(self, element: ET.Element, prototype: ApplicationArrayElement):
|
|
1553
|
+
if prototype is not None:
|
|
1554
|
+
child_element = ET.SubElement(element, "ELEMENT")
|
|
1555
|
+
self.setApplicationCompositeElementDataPrototype(child_element, prototype)
|
|
1556
|
+
self.setChildElementOptionalLiteral(child_element, "ARRAY-SIZE-SEMANTICS", prototype.arraySizeSemantics)
|
|
1557
|
+
self.setChildElementOptionalNumericalValue(child_element, "MAX-NUMBER-OF-ELEMENTS", prototype.maxNumberOfElements)
|
|
1558
|
+
|
|
1559
|
+
def writeApplicationArrayDataType(self, element: ET.Element, data_type: ApplicationArrayDataType):
|
|
1560
|
+
self.logger.debug("writeApplicationArrayDataType %s" % data_type.short_name)
|
|
1561
|
+
child_element = ET.SubElement(element, "APPLICATION-ARRAY-DATA-TYPE")
|
|
1562
|
+
self.writeApplicationCompositeDataType(child_element, data_type)
|
|
1563
|
+
self.setApplicationArrayElement(child_element, data_type.element)
|
|
1564
|
+
|
|
1565
|
+
def setSwRecordLayoutV(self, element: ET.Element, key: str, layout_v: SwRecordLayoutV):
|
|
1566
|
+
if layout_v is not None:
|
|
1567
|
+
child_element = ET.SubElement(element, key)
|
|
1568
|
+
self.setChildElementOptionalLiteral(child_element, "SHORT-LABEL", layout_v.shortLabel)
|
|
1569
|
+
self.setChildElementOptionalRefType(child_element, "BASE-TYPE-REF", layout_v.baseTypeRef)
|
|
1570
|
+
self.setChildElementOptionalNumericalValue(child_element, "SW-RECORD-LAYOUT-V-AXIS", layout_v.swRecordLayoutVAxis)
|
|
1571
|
+
self.setChildElementOptionalLiteral(child_element, "SW-RECORD-LAYOUT-V-PROP", layout_v.swRecordLayoutVProp)
|
|
1572
|
+
self.setChildElementOptionalLiteral(child_element, "SW-RECORD-LAYOUT-V-INDEX", layout_v.swRecordLayoutVIndex)
|
|
1573
|
+
|
|
1574
|
+
def setSwRecordLayoutGroup(self, element: ET.Element, key: str, group: SwRecordLayoutGroup):
|
|
1575
|
+
if group is not None:
|
|
1576
|
+
child_element = ET.SubElement(element, key)
|
|
1577
|
+
self.setChildElementOptionalLiteral(child_element, "SHORT-LABEL", group.shortLabel)
|
|
1578
|
+
self.setChildElementOptionalLiteral(child_element, "CATEGORY", group.category)
|
|
1579
|
+
self.setChildElementOptionalNumericalValue(child_element, "SW-RECORD-LAYOUT-GROUP-AXIS", group.swRecordLayoutGroupAxis)
|
|
1580
|
+
self.setChildElementOptionalLiteral(child_element, "SW-RECORD-LAYOUT-GROUP-INDEX", group.swRecordLayoutGroupIndex)
|
|
1581
|
+
self.setChildElementOptionalLiteral(child_element, "SW-RECORD-LAYOUT-GROUP-FROM", group.swRecordLayoutGroupFrom)
|
|
1582
|
+
self.setChildElementOptionalLiteral(child_element, "SW-RECORD-LAYOUT-GROUP-TO", group.swRecordLayoutGroupTo)
|
|
1583
|
+
self.setSwRecordLayoutV(child_element, "SW-RECORD-LAYOUT-V", group.swRecordLayoutGroupContentType.swRecordLayoutV)
|
|
1584
|
+
self.setSwRecordLayoutGroup(child_element, "SW-RECORD-LAYOUT-GROUP", group.swRecordLayoutGroupContentType.swRecordLayoutGroup)
|
|
1585
|
+
return group
|
|
1586
|
+
|
|
1587
|
+
def writeSwRecordLayout(self, element: ET.Element, layout: SwRecordLayout):
|
|
1588
|
+
self.logger.debug("writeSwRecordLayout %s" % layout.short_name)
|
|
1589
|
+
child_element = ET.SubElement(element, "SW-RECORD-LAYOUT")
|
|
1590
|
+
self.writeIdentifiable(child_element, layout)
|
|
1591
|
+
self.setSwRecordLayoutGroup(child_element, "SW-RECORD-LAYOUT-GROUP", layout.swRecordLayoutGroup)
|
|
1592
|
+
|
|
1593
|
+
def writeSwAddrMethod(self, element: ET.Element, method: SwAddrMethod):
|
|
1594
|
+
self.logger.debug("writeSwAddrMethod %s" % method.short_name)
|
|
1595
|
+
child_element = ET.SubElement(element, "SW-RECORD-LAYOUT")
|
|
1596
|
+
|
|
1597
|
+
def writeTriggerInterface(self, element: ET.Element, trigger_if: TriggerInterface):
|
|
1598
|
+
self.logger.debug("writeTriggerInterface %s" % trigger_if.short_name)
|
|
1599
|
+
child_element = ET.SubElement(element, "SW-RECORD-LAYOUT")
|
|
1600
|
+
|
|
1601
|
+
def writeServiceSwComponentType(self, element: ET.Element, sw_component: ServiceSwComponentType):
|
|
1602
|
+
self.logger.debug("writeServiceSwComponentType %s" % sw_component.short_name)
|
|
1603
|
+
child_element = ET.SubElement(element, "SERVICE-SW-COMPONENT-TYPE")
|
|
1604
|
+
self.writeAtomicSwComponentType(child_element, sw_component)
|
|
1605
|
+
|
|
1606
|
+
def writeDataTypeMaps(self, element: ET.Element, parent: DataTypeMappingSet):
|
|
1607
|
+
maps = parent.getDataTypeMaps()
|
|
1608
|
+
if len(maps) > 0:
|
|
1609
|
+
maps_tag = ET.SubElement(element, "DATA-TYPE-MAPS")
|
|
1610
|
+
for map in maps:
|
|
1611
|
+
child_element = ET.SubElement(maps_tag, "DATA-TYPE-MAP")
|
|
1612
|
+
self.setARObjectAttributes(child_element, map)
|
|
1613
|
+
self.setChildElementOptionalRefType(child_element, "APPLICATION-DATA-TYPE-REF", map.application_data_type_ref)
|
|
1614
|
+
self.setChildElementOptionalRefType(child_element, "IMPLEMENTATION-DATA-TYPE-REF", map.implementation_data_type_ref)
|
|
1615
|
+
|
|
1616
|
+
def writeModeRequestTypeMaps(self, element: ET.Element, parent: DataTypeMappingSet):
|
|
1617
|
+
maps = parent.getModeRequestTypeMaps()
|
|
1618
|
+
if len(maps) > 0:
|
|
1619
|
+
maps_tag = ET.SubElement(element, "MODE-REQUEST-TYPE-MAPS")
|
|
1620
|
+
for map in maps:
|
|
1621
|
+
child_element = ET.SubElement(maps_tag, "MODE-REQUEST-TYPE-MAP")
|
|
1622
|
+
self.setChildElementOptionalRefType(child_element, "IMPLEMENTATION-DATA-TYPE-REF", map.implementation_data_type_ref)
|
|
1623
|
+
self.setChildElementOptionalRefType(child_element, "MODE-GROUP-REF", map.mode_group_ref)
|
|
1624
|
+
|
|
1625
|
+
def writeDataTypeMappingSet(self, element: ET.Element, mapping_set: DataTypeMappingSet):
|
|
1626
|
+
self.logger.debug("writeDataTypeMappingSet %s" % mapping_set.short_name)
|
|
1627
|
+
child_element = ET.SubElement(element, "DATA-TYPE-MAPPING-SET")
|
|
1628
|
+
self.writeIdentifiable(child_element, mapping_set)
|
|
1629
|
+
self.writeDataTypeMaps(child_element, mapping_set)
|
|
1630
|
+
self.writeModeRequestTypeMaps(child_element, mapping_set)
|
|
1631
|
+
|
|
1632
|
+
def setModeDeclaration(self, element: ET.Element, mode_declaration: ModeDeclaration):
|
|
1633
|
+
child_element = ET.SubElement(element, "MODE-DECLARATION")
|
|
1634
|
+
self.writeIdentifiable(child_element, mode_declaration)
|
|
1635
|
+
self.setChildElementOptionalNumericalValue(child_element, "VALUE", mode_declaration.getValue())
|
|
1636
|
+
|
|
1637
|
+
def writeModeDeclarationGroupModeDeclaration(self, element: ET.Element, parent: ModeDeclarationGroup):
|
|
1638
|
+
mode_declarations = parent.getModeDeclarations()
|
|
1639
|
+
if len(mode_declarations) > 0:
|
|
1640
|
+
child_element = ET.SubElement(element, "MODE-DECLARATIONS")
|
|
1641
|
+
for mode_declaration in mode_declarations:
|
|
1642
|
+
self.setModeDeclaration(child_element, mode_declaration)
|
|
1643
|
+
|
|
1644
|
+
def writeModeDeclarationGroup(self, element: ET.Element, group: ModeDeclarationGroup):
|
|
1645
|
+
self.logger.debug("writeModeDeclarationGroup %s" % group.short_name)
|
|
1646
|
+
child_element = ET.SubElement(element, "MODE-DECLARATION-GROUP")
|
|
1647
|
+
self.writeIdentifiable(child_element, group)
|
|
1648
|
+
self.setChildElementOptionalRefType(child_element, "INITIAL-MODE-REF", group._initial_mode_ref)
|
|
1649
|
+
self.writeModeDeclarationGroupModeDeclaration(child_element, group)
|
|
1650
|
+
self.setChildElementOptionalNumericalValue(child_element, "ON-TRANSITION-VALUE", group.getOnTransitionValue())
|
|
1651
|
+
|
|
1652
|
+
def writeModeSwitchInterfaceModeGroup(self, element: ET.Element, parent: ModeSwitchInterface):
|
|
1653
|
+
mode_groups = parent.getModeGroups()
|
|
1654
|
+
if len(mode_groups) > 0:
|
|
1655
|
+
mode_group = mode_groups[0]
|
|
1656
|
+
child_element = ET.SubElement(element, "MODE-GROUP")
|
|
1657
|
+
self.writeIdentifiable(child_element, mode_group)
|
|
1658
|
+
self.setChildElementOptionalRefType(child_element, "TYPE-TREF", mode_group.type_tref)
|
|
1659
|
+
|
|
1660
|
+
def writeModeSwitchInterface(self, element: ET.Element, mode_interface: ModeSwitchInterface):
|
|
1661
|
+
self.logger.debug("writeModeSwitchInterface %s" % mode_interface.short_name)
|
|
1662
|
+
child_element = ET.SubElement(element, "MODE-SWITCH-INTERFACE")
|
|
1663
|
+
self.setPortInterface(child_element, mode_interface)
|
|
1664
|
+
self.writeModeSwitchInterfaceModeGroup(child_element, mode_interface)
|
|
1665
|
+
|
|
1666
|
+
def writeARPackageElement(self, element: ET.Element, ar_element: ARElement):
|
|
1667
|
+
if isinstance(ar_element, ComplexDeviceDriverSwComponentType):
|
|
1668
|
+
self.writeComplexDeviceDriverSwComponentType(element, ar_element)
|
|
1669
|
+
elif isinstance(ar_element, SwcImplementation):
|
|
1670
|
+
self.writeSwcImplementation(element, ar_element)
|
|
1671
|
+
elif isinstance(ar_element, CompositionSwComponentType):
|
|
1672
|
+
self.writeCompositionSwComponentType(element, ar_element)
|
|
1673
|
+
elif isinstance(ar_element, ApplicationPrimitiveDataType):
|
|
1674
|
+
self.writeApplicationPrimitiveDataType(element, ar_element)
|
|
1675
|
+
elif isinstance(ar_element, ApplicationRecordDataType):
|
|
1676
|
+
self.writeApplicationRecordDataType(element, ar_element)
|
|
1677
|
+
elif isinstance(ar_element, SwBaseType):
|
|
1678
|
+
self.writeSwBaseType(element, ar_element)
|
|
1679
|
+
elif isinstance(ar_element, CompuMethod):
|
|
1680
|
+
self.writeCompuMethod(element, ar_element)
|
|
1681
|
+
elif isinstance(ar_element, ConstantSpecification):
|
|
1682
|
+
self.writeConstantSpecification(element, ar_element)
|
|
1683
|
+
elif isinstance(ar_element, DataConstr):
|
|
1684
|
+
self.writeDataConstr(element, ar_element)
|
|
1685
|
+
elif isinstance(ar_element, EndToEndProtectionSet):
|
|
1686
|
+
self.writeEndToEndProtectionSet(element, ar_element)
|
|
1687
|
+
elif isinstance(ar_element, SenderReceiverInterface):
|
|
1688
|
+
self.writeSenderReceiverInterface(element, ar_element)
|
|
1689
|
+
elif isinstance(ar_element, Unit):
|
|
1690
|
+
self.writeUnit(element, ar_element)
|
|
1691
|
+
elif isinstance(ar_element, BswModuleDescription):
|
|
1692
|
+
self.writeBswModuleDescription(element, ar_element)
|
|
1693
|
+
elif isinstance(ar_element, BswModuleEntry):
|
|
1694
|
+
self.writeBswModuleEntry(element, ar_element)
|
|
1695
|
+
elif isinstance(ar_element, SwcBswMapping):
|
|
1696
|
+
self.setSwcBswMapping(element, ar_element)
|
|
1697
|
+
elif isinstance(ar_element, BswImplementation):
|
|
1698
|
+
self.writeBswImplementation(element, ar_element)
|
|
1699
|
+
elif isinstance(ar_element, ImplementationDataType):
|
|
1700
|
+
self.writeImplementationDataType(element, ar_element)
|
|
1701
|
+
elif isinstance(ar_element, ClientServerInterface):
|
|
1702
|
+
self.writeClientServerInterface(element, ar_element)
|
|
1703
|
+
elif isinstance(ar_element, ApplicationSwComponentType):
|
|
1704
|
+
self.writeApplicationSwComponentType(element, ar_element)
|
|
1705
|
+
elif isinstance(ar_element, EcuAbstractionSwComponentType):
|
|
1706
|
+
self.writeEcuAbstractionSwComponentType(element, ar_element)
|
|
1707
|
+
elif isinstance(ar_element, ApplicationArrayDataType):
|
|
1708
|
+
self.writeApplicationArrayDataType(element, ar_element)
|
|
1709
|
+
elif isinstance(ar_element, SwRecordLayout):
|
|
1710
|
+
self.writeSwRecordLayout(element, ar_element)
|
|
1711
|
+
elif isinstance(ar_element, SwAddrMethod):
|
|
1712
|
+
self.writeSwAddrMethod(element, ar_element)
|
|
1713
|
+
elif isinstance(ar_element, TriggerInterface):
|
|
1714
|
+
self.writeTriggerInterface(element, ar_element)
|
|
1715
|
+
elif isinstance(ar_element, ServiceSwComponentType):
|
|
1716
|
+
self.writeServiceSwComponentType(element, ar_element)
|
|
1717
|
+
elif isinstance(ar_element, DataTypeMappingSet):
|
|
1718
|
+
self.writeDataTypeMappingSet(element, ar_element)
|
|
1719
|
+
elif isinstance(ar_element, ModeDeclarationGroup):
|
|
1720
|
+
self.writeModeDeclarationGroup(element, ar_element)
|
|
1721
|
+
elif isinstance(ar_element, ModeSwitchInterface):
|
|
1722
|
+
self.writeModeSwitchInterface(element, ar_element)
|
|
1723
|
+
else:
|
|
1724
|
+
raise NotImplementedError("Unsupported Elements of ARPackage <%s>" % type(ar_element))
|
|
1725
|
+
|
|
1726
|
+
def writeARPackages(self, element: ET.Element, pkgs: List[ARPackage]):
|
|
1727
|
+
if len(pkgs) > 0:
|
|
1728
|
+
pkgs_tag = ET.SubElement(element, "AR-PACKAGES")
|
|
1729
|
+
|
|
1730
|
+
for pkg in pkgs:
|
|
1731
|
+
pkg_tag = ET.SubElement(pkgs_tag, "AR-PACKAGE")
|
|
1732
|
+
|
|
1733
|
+
self.writeIdentifiable(pkg_tag, pkg)
|
|
1734
|
+
self.logger.debug("writeARPackage %s" % pkg.full_name)
|
|
1735
|
+
|
|
1736
|
+
if pkg.getTotalElement() > 0:
|
|
1737
|
+
elements_tag = ET.SubElement(pkg_tag, "ELEMENTS")
|
|
1738
|
+
|
|
1739
|
+
for ar_element in pkg.getElements():
|
|
1740
|
+
if not isinstance(ar_element, ARPackage):
|
|
1741
|
+
self.writeARPackageElement(elements_tag, ar_element)
|
|
1742
|
+
|
|
1743
|
+
self.writeARPackages(pkg_tag, pkg.getARPackages())
|
|
1744
|
+
|
|
1745
|
+
def save(self, filename, document: AUTOSAR):
|
|
1746
|
+
self.logger.info("Save %s ..." % filename)
|
|
1747
|
+
|
|
1748
|
+
root = ET.Element("AUTOSAR", self.nsmap)
|
|
1749
|
+
root.attrib["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
|
|
1750
|
+
root.attrib["xsi:schemaLocation"] = document.schema_location
|
|
1751
|
+
|
|
1752
|
+
self.writeARPackages(root, document.getARPackages())
|
|
1753
|
+
|
|
1754
|
+
self.saveToFile(filename, root)
|
|
1755
|
+
|