odxtools 5.3.0__py3-none-any.whl → 5.3.1__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.
Files changed (44) hide show
  1. odxtools/determinenumberofitems.py +18 -0
  2. odxtools/diagdatadictionaryspec.py +14 -4
  3. odxtools/diaglayer.py +54 -59
  4. odxtools/dynamiclengthfield.py +59 -0
  5. odxtools/element.py +2 -4
  6. odxtools/endofpdufield.py +6 -77
  7. odxtools/field.py +94 -0
  8. odxtools/multiplexer.py +6 -18
  9. odxtools/multiplexerswitchkey.py +8 -43
  10. odxtools/odxtypes.py +1 -1
  11. odxtools/parameters/lengthkeyparameter.py +1 -1
  12. odxtools/parameters/parameterwithdop.py +6 -1
  13. odxtools/positioneddataobjectproperty.py +74 -0
  14. odxtools/tablerow.py +1 -2
  15. odxtools/templates/macros/printAudience.xml.jinja2 +3 -9
  16. odxtools/templates/macros/printCompanyData.xml.jinja2 +4 -27
  17. odxtools/templates/macros/printComparam.xml.jinja2 +4 -18
  18. odxtools/templates/macros/printDOP.xml.jinja2 +3 -9
  19. odxtools/templates/macros/printDynamicLengthField.xml.jinja2 +22 -0
  20. odxtools/templates/macros/printElementID.xml.jinja2 +6 -6
  21. odxtools/templates/macros/printEndOfPdu.xml.jinja2 +3 -2
  22. odxtools/templates/macros/printEnvData.xml.jinja2 +2 -2
  23. odxtools/templates/macros/printEnvDataDesc.xml.jinja2 +3 -2
  24. odxtools/templates/macros/printFunctionalClass.xml.jinja2 +3 -9
  25. odxtools/templates/macros/printMux.xml.jinja2 +5 -6
  26. odxtools/templates/macros/printParam.xml.jinja2 +2 -7
  27. odxtools/templates/macros/printRequest.xml.jinja2 +2 -9
  28. odxtools/templates/macros/printResponse.xml.jinja2 +2 -9
  29. odxtools/templates/macros/printService.xml.jinja2 +2 -9
  30. odxtools/templates/macros/printSpecialData.xml.jinja2 +1 -1
  31. odxtools/templates/macros/printState.xml.jinja2 +3 -9
  32. odxtools/templates/macros/printStateChart.xml.jinja2 +2 -9
  33. odxtools/templates/macros/printStateTransition.xml.jinja2 +3 -9
  34. odxtools/templates/macros/printStructure.xml.jinja2 +2 -4
  35. odxtools/templates/macros/printTable.xml.jinja2 +2 -7
  36. odxtools/templates/macros/printUnitSpec.xml.jinja2 +3 -3
  37. odxtools/templates/macros/printVariant.xml.jinja2 +10 -9
  38. odxtools/version.py +4 -2
  39. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/METADATA +1 -1
  40. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/RECORD +44 -39
  41. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/LICENSE +0 -0
  42. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/WHEEL +0 -0
  43. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/entry_points.txt +0 -0
  44. {odxtools-5.3.0.dist-info → odxtools-5.3.1.dist-info}/top_level.txt +0 -0
@@ -10,7 +10,7 @@ from .parameter import ParameterType
10
10
  from .parameterwithdop import ParameterWithDOP
11
11
 
12
12
  if TYPE_CHECKING:
13
- from diaglayer import DiagLayer
13
+ from ..diaglayer import DiagLayer
14
14
 
15
15
 
16
16
  @dataclass
@@ -46,7 +46,12 @@ class ParameterWithDOP(Parameter):
46
46
  if self.dop_snref:
47
47
  spec = diag_layer.diag_data_dictionary_spec
48
48
  self._dop = (
49
- spec.data_object_props.get(self.dop_snref) or spec.structures.get(self.dop_snref))
49
+ spec.end_of_pdu_fields.get(self.dop_snref) or
50
+ spec.dynamic_length_fields.get(self.dop_snref) or
51
+ spec.data_object_props.get(self.dop_snref) or spec.structures.get(self.dop_snref) or
52
+ spec.muxs.get(self.dop_snref) or spec.dtc_dops.get(self.dop_snref) or
53
+ spec.muxs.get(self.dop_snref) or spec.env_data_descs.get(self.dop_snref) or
54
+ spec.env_datas.get(self.dop_snref))
50
55
 
51
56
  @property
52
57
  def dop(self) -> Optional[DopBase]:
@@ -0,0 +1,74 @@
1
+ # SPDX-License-Identifier: MIT
2
+ from dataclasses import dataclass
3
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
4
+ from xml.etree import ElementTree
5
+
6
+ from .dataobjectproperty import DataObjectProperty
7
+ from .decodestate import DecodeState
8
+ from .encodestate import EncodeState
9
+ from .exceptions import odxrequire
10
+ from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef
11
+
12
+ if TYPE_CHECKING:
13
+ from .diaglayer import DiagLayer
14
+
15
+
16
+ @dataclass
17
+ class PositionedDataObjectProperty:
18
+ """
19
+ This class represents a wrapper for DataObjectProperty that adds position information
20
+ used by Switch Key in the Multiplexer.
21
+ used by Number Of Items in the DynamicLengthField.
22
+ """
23
+
24
+ byte_position: int
25
+ bit_position: Optional[int]
26
+ dop_ref: OdxLinkRef
27
+
28
+ def __post_init__(self):
29
+ self._dop: DataObjectProperty = None # type: ignore
30
+
31
+ @staticmethod
32
+ def from_et(et_element: ElementTree.Element,
33
+ doc_frags: List[OdxDocFragment]) -> "PositionedDataObjectProperty":
34
+ byte_position = int(odxrequire(et_element.findtext("BYTE-POSITION", "0")))
35
+ bit_position_str = et_element.findtext("BIT-POSITION")
36
+ bit_position = int(bit_position_str) if bit_position_str is not None else None
37
+ dop_ref = odxrequire(OdxLinkRef.from_et(et_element.find("DATA-OBJECT-PROP-REF"), doc_frags))
38
+
39
+ return PositionedDataObjectProperty(
40
+ byte_position=byte_position,
41
+ bit_position=bit_position,
42
+ dop_ref=dop_ref,
43
+ )
44
+
45
+ @property
46
+ def dop(self) -> DataObjectProperty:
47
+ return self._dop
48
+
49
+ def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
50
+ return {}
51
+
52
+ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
53
+ self._dop = odxrequire(odxlinks.resolve(self.dop_ref, DataObjectProperty))
54
+
55
+ def _resolve_snrefs(self, diag_layer: "DiagLayer") -> None:
56
+ pass
57
+
58
+ def convert_physical_to_bytes(self, physical_value, encode_state: EncodeState) -> bytes:
59
+
60
+ bit_position = self.bit_position if self.bit_position is not None else 0
61
+ dop_bytes = self.dop.convert_physical_to_bytes(physical_value, encode_state, bit_position)
62
+
63
+ return b'\0' * self.byte_position + dop_bytes
64
+
65
+ def convert_bytes_to_physical(self, decode_state: DecodeState) -> Tuple[Any, int]:
66
+
67
+ byte_code = decode_state.coded_message[decode_state.next_byte_position:]
68
+ state = DecodeState(
69
+ coded_message=byte_code[self.byte_position:],
70
+ parameter_values=dict(),
71
+ next_byte_position=0,
72
+ )
73
+ bit_position_int = (self.bit_position if self.bit_position is not None else 0)
74
+ return self.dop.convert_bytes_to_physical(state, bit_position=bit_position_int)
odxtools/tablerow.py CHANGED
@@ -3,11 +3,10 @@ from dataclasses import dataclass
3
3
  from typing import TYPE_CHECKING, Any, Dict, List, Optional
4
4
  from xml.etree import ElementTree
5
5
 
6
- from odxtools.element import IdentifiableElement
7
-
8
6
  from .basicstructure import BasicStructure
9
7
  from .createsdgs import create_sdgs_from_et
10
8
  from .dataobjectproperty import DataObjectProperty
9
+ from .element import IdentifiableElement
11
10
  from .exceptions import odxassert, odxrequire
12
11
  from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef
13
12
  from .odxtypes import AtomicOdxType
@@ -3,17 +3,11 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printAdditionalAudience(audience) -%}
7
9
  <ADDITIONAL-AUDIENCE ID="{{audience.odx_id.local_id}}">
8
- <SHORT-NAME>{{audience.short_name}}</SHORT-NAME>
9
- {%- if audience.long_name %}
10
- <LONG-NAME>{{audience.long_name}}</LONG-NAME>
11
- {%- endif %}
12
- {%- if audience.description is string and audience.description.strip() %}
13
- <DESC>
14
- {{audience.description}}
15
- </DESC>
16
- {%- endif %}
10
+ {{ peid.printElementID(audience)|indent(1) }}
17
11
  </ADDITIONAL-AUDIENCE>
18
12
  {%- endmacro -%}
19
13
 
@@ -3,19 +3,12 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
7
8
 
8
9
  {%- macro printCompanyData(company_data) -%}
9
10
  <COMPANY-DATA ID="{{company_data.odx_id.local_id}}">
10
- <SHORT-NAME>{{company_data.short_name|e}}</SHORT-NAME>
11
- {%- if company_data.long_name is not none %}
12
- <LONG-NAME>{{company_data.long_name|e}}</LONG-NAME>
13
- {%- endif %}
14
- {%- if company_data.description is not none %}
15
- <DESC>
16
- {{company_data.description}}
17
- </DESC>
18
- {%- endif %}
11
+ {{ peid.printElementID(company_data)|indent(1) }}
19
12
  {%- if company_data.roles is not none %}
20
13
  <ROLES>
21
14
  {%- for role in company_data.roles %}
@@ -27,15 +20,7 @@
27
20
  <TEAM-MEMBERS>
28
21
  {%- for team_member in company_data.team_members %}
29
22
  <TEAM-MEMBER ID="{{team_member.odx_id.local_id}}">
30
- <SHORT-NAME>{{team_member.short_name|e}}</SHORT-NAME>
31
- {%- if company_data.long_name is not none %}
32
- <LONG-NAME>{{team_member.long_name|e}}</LONG-NAME>
33
- {%- endif %}
34
- {%- if company_data.description is not none %}
35
- <DESC>
36
- {{team_member.description}}
37
- </DESC>
38
- {%- endif %}
23
+ {{ peid.printElementID(team_member)|indent(3) }}
39
24
  {%- if team_member.roles is not none %}
40
25
  <ROLES>
41
26
  {%- for role in team_member.roles %}
@@ -75,15 +60,7 @@
75
60
  <RELATED-DOC>
76
61
  {%- if rd.xdoc is not none %}
77
62
  <XDOC>
78
- <SHORT-NAME>{{rd.xdoc.short_name|e}}</SHORT-NAME>
79
- {%- if rd.xdoc.long_name is not none %}
80
- <LONG-NAME>{{rd.xdoc.long_name|e}}</LONG-NAME>
81
- {%- endif %}
82
- {%- if rd.xdoc.description is not none %}
83
- <DESC>
84
- {{rd.xdoc.description}}
85
- </DESC>
86
- {%- endif %}
63
+ {{ peid.printElementID(rd.xdoc)|indent(5) }}
87
64
  {%- if rd.xdoc.number is not none %}
88
65
  <NUMBER>{{rd.xdoc.number|e}}</NUMBER>
89
66
  {%- endif %}
@@ -3,6 +3,8 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printComplexValue(cv) %}
7
9
  <COMPLEX-VALUE>
8
10
  {%- for val in cv %}
@@ -41,15 +43,7 @@
41
43
  CPTYPE="{{cp.cptype.value}}"
42
44
  {{make_xml_attrib("DISPLAY-LEVEL", cp.display_level)}}
43
45
  CPUSAGE="{{cp.cpusage.value}}">
44
- <SHORT-NAME>{{cp.short_name}}</SHORT-NAME>
45
- {%- if cp.long_name and cp.long_name.strip() %}
46
- <LONG-NAME>{{cp.long_name|e}}</LONG-NAME>
47
- {%- endif %}
48
- {%- if cp.description and cp.description.strip() %}
49
- <DESC>
50
- {{cp.description}}
51
- </DESC>
52
- {%- endif %}
46
+ {{ peid.printElementID(cp)|indent(1) }}
53
47
  <PHYSICAL-DEFAULT-VALUE>{{cp.physical_default_value}}</PHYSICAL-DEFAULT-VALUE>
54
48
  <DATA-OBJECT-PROP-REF ID-REF="{{cp.dop_ref.ref_id}}" />
55
49
  </COMPARAM>
@@ -63,15 +57,7 @@
63
57
  CPUSAGE="{{cp.cpusage.value}}"
64
58
  {{make_bool_xml_attrib("ALLOW-MULTIPLE-VALUES", cp.allow_multiple_values_raw)}}
65
59
  {#- #}>
66
- <SHORT-NAME>{{cp.short_name}}</SHORT-NAME>
67
- {%- if cp.long_name and cp.long_name.strip() %}
68
- <LONG-NAME>{{cp.long_name|e}}</LONG-NAME>
69
- {%- endif %}
70
- {%- if cp.description and cp.description.strip() %}
71
- <DESC>
72
- {{cp.description}}
73
- </DESC>
74
- {%- endif %}
60
+ {{ peid.printElementID(cp)|indent(1) }}
75
61
  {%- for sub_cp in cp.comparams %}
76
62
  {{- printGenericComparam(sub_cp) | indent(1, first=True) }}
77
63
  {%- endfor %}
@@ -3,6 +3,7 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printAdminData.xml.jinja2') as pad %}
7
8
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
8
9
 
@@ -164,13 +165,7 @@
164
165
 
165
166
  {%- macro printDOP(dop, tag_name) %}
166
167
  <{{tag_name}} ID="{{dop.odx_id.local_id}}">
167
- <SHORT-NAME>{{dop.short_name}}</SHORT-NAME>
168
- {%- if dop.long_name %}
169
- <LONG-NAME>{{dop.long_name|e}}</LONG-NAME>
170
- {%- endif %}
171
- {%- if dop.description %}
172
- <DESC>{{dop.description}}</DESC>
173
- {%- endif %}
168
+ {{ peid.printElementID(dop)|indent(1) }}
174
169
  {%- if dop.admin_data %}
175
170
  {{- pad.printAdminData(dop.admin_data)|indent(2, first=True) }}
176
171
  {%- endif %}
@@ -192,8 +187,7 @@
192
187
 
193
188
  {%- macro printDTCDOP(dop) %}
194
189
  <DTC-DOP ID="{{dop.odx_id.local_id}}">
195
- <SHORT-NAME>{{dop.short_name}}</SHORT-NAME>
196
- <LONG-NAME>{{dop.long_name|e}}</LONG-NAME>
190
+ {{ peid.printElementID(dop)|indent(1) }}
197
191
  {{- psd.printSpecialDataGroups(dop.sdgs)|indent(1, first=True) }}
198
192
  {{- printDiagCodedType(dop.diag_coded_type)|indent(1, first=True) }}
199
193
  {{- printPhysicalType(dop.physical_type)|indent(1, first=True) }}
@@ -0,0 +1,22 @@
1
+ {#- -*- mode: sgml; tab-width: 1; indent-tabs-mode: nil -*-
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ -#}
5
+
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
8
+ {%- macro printDynamicLengthField(dlf) -%}
9
+ <DYNAMIC-LENGTH-FIELD ID="{{dlf.odx_id.local_id}}">
10
+ {{ peid.printElementID(dlf)|indent(1) }}
11
+ <BASIC-STRUCTURE-REF ID-REF="{{dlf.structure_ref.ref_id}}" />
12
+ <OFFSET>{{dlf.offset}}</OFFSET>
13
+ <DETERMINE-NUMBER-OF-ITEMS>
14
+ {%- set dni = dlf.determine_number_of_items %}
15
+ <BYTE-POSITION>{{dni.byte_position}}</BYTE-POSITION>
16
+ {%- if dni.bit_position is not none %}
17
+ <BIT-POSITION>{{dni.bit_position}}</BIT-POSITION>
18
+ {%- endif %}
19
+ <DATA-OBJECT-PROP-REF ID-REF="{{dni.dop_ref.ref_id}}" />
20
+ </DETERMINE-NUMBER-OF-ITEMS>
21
+ </DYNAMIC-LENGTH-FIELD>
22
+ {%- endmacro -%}
@@ -3,12 +3,12 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
- {%- macro printElementID(element) -%}
7
- <SHORT-NAME>{{ element.short_name }}</SHORT-NAME>
8
- {%- if element.long_name is string and element.long_name.strip() %}
9
- <LONG-NAME>{{ element.long_name|e }}</LONG-NAME>
6
+ {%- macro printElementID(obj) -%}
7
+ <SHORT-NAME>{{ obj.short_name }}</SHORT-NAME>
8
+ {%- if obj.long_name %}
9
+ <LONG-NAME>{{ obj.long_name|e }}</LONG-NAME>
10
10
  {%- endif %}
11
- {%- if element.description is string and element.description.strip() %}
12
- <DESC>{{ element.description }}</DESC>
11
+ {%- if obj.description %}
12
+ <DESC>{{ obj.description }}</DESC>
13
13
  {%- endif %}
14
14
  {%- endmacro -%}
@@ -3,10 +3,11 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printEndOfPdu(eopdu) -%}
7
9
  <END-OF-PDU-FIELD ID="{{eopdu.odx_id.local_id}}">
8
- <SHORT-NAME>{{eopdu.short_name}}</SHORT-NAME>
9
- <LONG-NAME>{{eopdu.long_name|e}}</LONG-NAME>
10
+ {{ peid.printElementID(eopdu)|indent(1) }}
10
11
  <BASIC-STRUCTURE-REF ID-REF="{{eopdu.structure_ref.ref_id}}" />
11
12
  </END-OF-PDU-FIELD>
12
13
  {%- endmacro -%}
@@ -3,12 +3,12 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printParam.xml.jinja2') as pparam %}
7
8
 
8
9
  {%- macro printEnvData(env_data) %}
9
10
  <ENV-DATA ID="{{env_data.odx_id.local_id}}">
10
- <SHORT-NAME>{{env_data.short_name}}</SHORT-NAME>
11
- <LONG-NAME>{{env_data.long_name}}</LONG-NAME>
11
+ {{ peid.printElementID(env_data)|indent(1) }}
12
12
  <PARAMS>
13
13
  {%- for param in env_data.parameters %}
14
14
  {{pparam.printParam(param) | indent(6, first=True) }}
@@ -3,10 +3,11 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printEnvDataDesc(env_data_desc) %}
7
9
  <ENV-DATA-DESC ID="{{env_data_desc.odx_id.local_id}}">
8
- <SHORT-NAME>{{env_data_desc.short_name}}</SHORT-NAME>
9
- <LONG-NAME>{{env_data_desc.long_name}}</LONG-NAME>
10
+ {{ peid.printElementID(env_data_desc)|indent(1) }}
10
11
  <PARAM-SNREF SHORT-NAME="{{env_data_desc.param_snref}}"/>
11
12
  <ENV-DATA-REFS>
12
13
  {%- for env_data_ref in env_data_desc.env_data_refs %}
@@ -4,16 +4,10 @@
4
4
  # SPDX-License-Identifier: MIT
5
5
  -#}
6
6
 
7
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
8
+
7
9
  {%- macro printFunctionalClass(fc) -%}
8
10
  <FUNCT-CLASS ID="{{fc.odx_id.local_id}}">
9
- <SHORT-NAME>{{fc.short_name}}</SHORT-NAME>
10
- {%- if fc.long_name is string and fc.long_name.strip() %}
11
- <LONG-NAME>{{fc.long_name}}</LONG-NAME>
12
- {%- endif %}
13
- {%- if fc.description is string and fc.description.strip() %}
14
- <DESC>
15
- {{fc.description}}
16
- </DESC>
17
- {%- endif %}
11
+ {{ peid.printElementID(fc)|indent(1) }}
18
12
  </FUNCT-CLASS>
19
13
  {%- endmacro -%}
@@ -3,10 +3,11 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printMux(mux) %}
7
9
  <MUX ID="{{mux.odx_id.local_id}}">
8
- <SHORT-NAME>{{mux.short_name}}</SHORT-NAME>
9
- <LONG-NAME>{{mux.long_name|e}}</LONG-NAME>
10
+ {{ peid.printElementID(mux)|indent(1) }}
10
11
  <BYTE-POSITION>{{mux.byte_position}}</BYTE-POSITION>
11
12
  <SWITCH-KEY>
12
13
  <BYTE-POSITION>{{mux.switch_key.byte_position}}</BYTE-POSITION>
@@ -17,8 +18,7 @@
17
18
  </SWITCH-KEY>
18
19
  {%- if mux.default_case is not none %}
19
20
  <DEFAULT-CASE>
20
- <SHORT-NAME>{{mux.default_case.short_name}}</SHORT-NAME>
21
- <LONG-NAME>{{mux.default_case.long_name}}</LONG-NAME>
21
+ {{ peid.printElementID(mux.default_case)|indent(4) }}
22
22
  {%- if mux.default_case.structure_ref is not none %}
23
23
  <STRUCTURE-REF ID-REF="{{mux.default_case.structure_ref.ref_id}}"/>
24
24
  {%- endif %}
@@ -31,8 +31,7 @@
31
31
  <CASES>
32
32
  {%- for case in mux.cases %}
33
33
  <CASE>
34
- <SHORT-NAME>{{case.short_name}}</SHORT-NAME>
35
- <LONG-NAME>{{case.long_name}}</LONG-NAME>
34
+ {{ peid.printElementID(case)|indent(6) }}
36
35
  {%- if case.structure_ref is not none %}
37
36
  <STRUCTURE-REF ID-REF="{{case.structure_ref.ref_id}}"/>
38
37
  {%- endif %}
@@ -3,6 +3,7 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printDOP.xml.jinja2') as pdop %}
7
8
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
8
9
 
@@ -19,13 +20,7 @@
19
20
  {%- else %}
20
21
  <PARAM {{semattrib}} xsi:type="{{param.parameter_type}}">
21
22
  {%- endif%}
22
- <SHORT-NAME>{{param.short_name}}</SHORT-NAME>
23
- {%- if param.long_name %}
24
- <LONG-NAME>{{param.long_name|e}}</LONG-NAME>
25
- {%- endif %}
26
- {%- if param.description %}
27
- <DESC>{{param.description}}</DESC>
28
- {%- endif %}
23
+ {{ peid.printElementID(param)|indent(1) }}
29
24
  {{- psd.printSpecialDataGroups(param.sdgs)|indent(1, first=True) }}
30
25
  {%- if param.byte_position is not none %}
31
26
  <BYTE-POSITION>{{param.byte_position}}</BYTE-POSITION>
@@ -3,21 +3,14 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printDOP.xml.jinja2') as pdop %}
7
8
  {%- import('macros/printParam.xml.jinja2') as pp %}
8
9
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
9
10
 
10
11
  {%- macro printRequest(request) -%}
11
12
  <REQUEST ID="{{request.odx_id.local_id}}">
12
- <SHORT-NAME>{{request.short_name}}</SHORT-NAME>
13
- {%- if request.long_name %}
14
- <LONG-NAME>{{request.long_name|e}}</LONG-NAME>
15
- {%- endif %}
16
- {%- if request.description and request.description.strip() %}
17
- <DESC>
18
- {{request.description}}
19
- </DESC>
20
- {%- endif %}
13
+ {{ peid.printElementID(request)|indent(1) }}
21
14
  {%- if request.parameters %}
22
15
  <PARAMS>
23
16
  {%- for param in request.parameters -%}
@@ -3,20 +3,13 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printParam.xml.jinja2') as pp %}
7
8
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
8
9
 
9
10
  {%- macro printResponse(resp, tag_name="POS-RESPONSE") -%}
10
11
  <{{tag_name}} ID="{{resp.odx_id.local_id}}">
11
- <SHORT-NAME>{{resp.short_name}}</SHORT-NAME>
12
- {%- if resp.long_name %}
13
- <LONG-NAME>{{resp.long_name|e}}</LONG-NAME>
14
- {%- endif %}
15
- {%- if resp.description and resp.description.strip() %}
16
- <DESC>
17
- {{resp.description}}
18
- </DESC>
19
- {%- endif %}
12
+ {{ peid.printElementID(resp)|indent(1) }}
20
13
  {%- if resp.parameters %}
21
14
  <PARAMS>
22
15
  {%- for param in resp.parameters -%}
@@ -3,6 +3,7 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printAdminData.xml.jinja2') as pad %}
7
8
  {%- import('macros/printAudience.xml.jinja2') as paud %}
8
9
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
@@ -14,15 +15,7 @@
14
15
  {%- set semattrib = " SEMANTIC=\"UNKNOWN\"" -%}
15
16
  {%- endif -%}
16
17
  <DIAG-SERVICE ID="{{service.odx_id.local_id}}" {{semattrib}}>
17
- <SHORT-NAME>{{service.short_name}}</SHORT-NAME>
18
- {%- if service.long_name and service.long_name.strip() %}
19
- <LONG-NAME>{{service.long_name|e}}</LONG-NAME>
20
- {%- endif %}
21
- {%- if service.description and service.description.strip() %}
22
- <DESC>
23
- {{service.description}}
24
- </DESC>
25
- {%- endif %}
18
+ {{ peid.printElementID(service)|indent(1) }}
26
19
  {%- if service.admin_data %}
27
20
  {{- pad.printAdminData(service.admin_data)|indent(1, first=True) }}
28
21
  {%- endif %}
@@ -18,7 +18,7 @@
18
18
 
19
19
  {%- macro printSdgCaption(sdg_caption) %}
20
20
  <SDG-CAPTION ID="{{sdg_caption.odx_id.local_id}}">
21
- {{ peid.printElementID(sdg_caption) | indent(1) }}
21
+ {{ peid.printElementID(sdg_caption)|indent(1) }}
22
22
  </SDG-CAPTION>
23
23
  {%- endmacro %}
24
24
 
@@ -3,16 +3,10 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printState(state) -%}
7
9
  <STATE ID="{{state.odx_id.local_id}}">
8
- <SHORT-NAME>{{state.short_name}}</SHORT-NAME>
9
- {%- if state.long_name %}
10
- <LONG-NAME>{{state.long_name}}</LONG-NAME>
11
- {%- endif %}
12
- {%- if state.description is string and state.description.strip() %}
13
- <DESC>
14
- {{state.description}}
15
- </DESC>
16
- {%- endif %}
10
+ {{ peid.printElementID(state)|indent(1) }}
17
11
  </STATE>
18
12
  {%- endmacro -%}
@@ -3,19 +3,13 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printState.xml.jinja2') as ps %}
7
8
  {%- import('macros/printStateTransition.xml.jinja2') as pst %}
8
9
 
9
10
  {%- macro printStateChart(state_chart) -%}
10
11
  <STATE-CHART ID="{{state_chart.odx_id.local_id}}">
11
- <SHORT-NAME>{{state_chart.short_name}}</SHORT-NAME>
12
- {%- if state_chart.long_name %}
13
- <LONG-NAME>{{state_chart.long_name}}</LONG-NAME>
14
- {%- endif %}
15
- {%- if state_chart.description is string and state_chart.description.strip() %}
16
- <DESC>
17
- {{state_chart.description}}
18
- </DESC>
12
+ {{ peid.printElementID(state_chart)|indent(1) }}
19
13
  <SEMANTIC>{{state_chart.semantic}}</SEMANTIC>
20
14
  {%- if state_chart.state_transitions %}
21
15
  <STATE-TRANSITIONS>
@@ -32,6 +26,5 @@
32
26
  {%- endfor %}
33
27
  </STATES>
34
28
  {%- endif %}
35
- {%- endif %}
36
29
  </STATE-CHART>
37
30
  {%- endmacro -%}
@@ -3,17 +3,11 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
7
+
6
8
  {%- macro printStateTransition(state_transition) -%}
7
9
  <STATE-TRANSITION ID="{{state_transition.odx_id.local_id}}">
8
- <SHORT-NAME>{{state_transition.short_name}}</SHORT-NAME>
9
- {%- if state_transition.long_name %}
10
- <LONG-NAME>{{state_transition.long_name}}</LONG-NAME>
11
- {%- endif %}
12
- {%- if state_transition.description is string and state_transition.description.strip() %}
13
- <DESC>
14
- {{state_transition.description}}
15
- </DESC>
16
- {%- endif %}
10
+ {{ peid.printElementID(state_transition)|indent(1) }}
17
11
  <SOURCE-SNREF SHORT-NAME="{{state_transition.source_snref}}" />
18
12
  <TARGET-SNREF SHORT-NAME="{{state_transition.target_snref}}" />
19
13
  </STATE-TRANSITION>
@@ -3,14 +3,12 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printParam.xml.jinja2') as pp %}
7
8
 
8
9
  {%- macro printStructure(st) -%}
9
10
  <STRUCTURE ID="{{st.odx_id.local_id}}">
10
- <SHORT-NAME>{{st.short_name}}</SHORT-NAME>
11
- {%- if st.long_name %}
12
- <LONG-NAME>{{st.long_name|e}}</LONG-NAME>
13
- {%- endif %}
11
+ {{ peid.printElementID(st)|indent(1) }}
14
12
  {%- if st.byte_size is not none %}
15
13
  <BYTE-SIZE>{{st.byte_size}}</BYTE-SIZE>
16
14
  {%- endif %}
@@ -3,18 +3,13 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  -#}
5
5
 
6
+ {%- import('macros/printElementID.xml.jinja2') as peid %}
6
7
  {%- import('macros/printSpecialData.xml.jinja2') as psd %}
7
8
 
8
9
  {%- macro printTable(table) %}
9
10
  <TABLE ID="{{table.odx_id.local_id}}"
10
11
  {{-make_xml_attrib("SEMANTIC", table.semantic)}}>
11
- <SHORT-NAME>{{table.short_name}}</SHORT-NAME>
12
- {%- if table.long_name %}
13
- <LONG-NAME>{{table.long_name|e}}</LONG-NAME>
14
- {%- endif %}
15
- {%- if table.description %}
16
- <DESC>{{table.description}}</DESC>
17
- {%- endif %}
12
+ {{ peid.printElementID(table)|indent(1) }}
18
13
  {%- if table.key_dop_ref %}
19
14
  <KEY-DOP-REF ID-REF="{{ table.key_dop_ref.ref_id }}" />
20
15
  {%- endif %}
@@ -37,7 +37,7 @@
37
37
  {%- macro printUnit(unit) -%}
38
38
  <UNIT ID="{{unit.odx_id.local_id}}"
39
39
  {{-make_xml_attrib("OID", unit.oid)}}>
40
- {{ peid.printElementID(unit) }}
40
+ {{ peid.printElementID(unit)|indent(1) }}
41
41
  <DISPLAY-NAME>{{ unit.display_name }}</DISPLAY-NAME>
42
42
  {%- if unit.factor_si_to_unit is not none %}
43
43
  <FACTOR-SI-TO-UNIT>{{ unit.factor_si_to_unit }}</FACTOR-SI-TO-UNIT>
@@ -53,7 +53,7 @@
53
53
 
54
54
  {%- macro printUnitGroup(group) -%}
55
55
  <UNIT-GROUP {%- if group.oid %} OID="{{group.oid}}" {%- endif %}>
56
- {{ peid.printElementID(group) }}
56
+ {{ peid.printElementID(group)|indent(1) }}
57
57
  <CATEGORY>{{ group.category.value }}</CATEGORY>
58
58
  {%- if group.unit_refs %}
59
59
  <UNIT-REFS>
@@ -68,7 +68,7 @@
68
68
  {%- macro printPhysicalDimesion(dim) -%}
69
69
  <PHYSICAL-DIMENSION ID="{{dim.odx_id.local_id}}"
70
70
  {{-make_xml_attrib("OID",dim.oid)}}>
71
- {{ peid.printElementID(dim) }}
71
+ {{ peid.printElementID(dim)|indent(1) }}
72
72
  {%- if dim.length_exp %}
73
73
  <LENGTH-EXP>{{ dim.length_exp }}</LENGTH-EXP>
74
74
  {%- endif %}