odxtools 6.7.0__py3-none-any.whl → 9.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odxtools/__init__.py +6 -4
- odxtools/additionalaudience.py +3 -5
- odxtools/admindata.py +5 -7
- odxtools/audience.py +10 -13
- odxtools/basecomparam.py +3 -5
- odxtools/basicstructure.py +55 -240
- odxtools/cli/_parser_utils.py +1 -1
- odxtools/cli/_print_utils.py +168 -134
- odxtools/cli/browse.py +111 -92
- odxtools/cli/compare.py +90 -71
- odxtools/cli/list.py +24 -15
- odxtools/cli/snoop.py +28 -5
- odxtools/codec.py +211 -0
- odxtools/commrelation.py +122 -0
- odxtools/companydata.py +5 -7
- odxtools/companydocinfo.py +7 -8
- odxtools/companyrevisioninfo.py +3 -5
- odxtools/companyspecificinfo.py +8 -9
- odxtools/comparam.py +4 -6
- odxtools/comparaminstance.py +7 -9
- odxtools/comparamspec.py +16 -54
- odxtools/comparamsubset.py +22 -62
- odxtools/complexcomparam.py +5 -7
- odxtools/compumethods/compucodecompumethod.py +63 -0
- odxtools/compumethods/compuconst.py +31 -0
- odxtools/compumethods/compudefaultvalue.py +27 -0
- odxtools/compumethods/compuinternaltophys.py +56 -0
- odxtools/compumethods/compuinversevalue.py +7 -0
- odxtools/compumethods/compumethod.py +93 -12
- odxtools/compumethods/compuphystointernal.py +56 -0
- odxtools/compumethods/compurationalcoeffs.py +20 -9
- odxtools/compumethods/compuscale.py +30 -35
- odxtools/compumethods/createanycompumethod.py +28 -161
- odxtools/compumethods/identicalcompumethod.py +31 -6
- odxtools/compumethods/linearcompumethod.py +69 -189
- odxtools/compumethods/linearsegment.py +190 -0
- odxtools/compumethods/ratfunccompumethod.py +106 -0
- odxtools/compumethods/ratfuncsegment.py +87 -0
- odxtools/compumethods/scalelinearcompumethod.py +132 -26
- odxtools/compumethods/scaleratfunccompumethod.py +113 -0
- odxtools/compumethods/tabintpcompumethod.py +119 -99
- odxtools/compumethods/texttablecompumethod.py +107 -43
- odxtools/createanydiagcodedtype.py +10 -67
- odxtools/database.py +167 -87
- odxtools/dataobjectproperty.py +15 -25
- odxtools/decodestate.py +9 -15
- odxtools/description.py +47 -0
- odxtools/determinenumberofitems.py +4 -5
- odxtools/diagcodedtype.py +36 -106
- odxtools/diagcomm.py +24 -12
- odxtools/diagdatadictionaryspec.py +33 -34
- odxtools/diaglayercontainer.py +46 -54
- odxtools/diaglayers/basevariant.py +128 -0
- odxtools/diaglayers/basevariantraw.py +123 -0
- odxtools/diaglayers/diaglayer.py +432 -0
- odxtools/{diaglayerraw.py → diaglayers/diaglayerraw.py} +105 -120
- odxtools/diaglayers/ecushareddata.py +96 -0
- odxtools/diaglayers/ecushareddataraw.py +87 -0
- odxtools/diaglayers/ecuvariant.py +124 -0
- odxtools/diaglayers/ecuvariantraw.py +129 -0
- odxtools/diaglayers/functionalgroup.py +110 -0
- odxtools/diaglayers/functionalgroupraw.py +106 -0
- odxtools/{diaglayer.py → diaglayers/hierarchyelement.py} +209 -448
- odxtools/diaglayers/hierarchyelementraw.py +58 -0
- odxtools/diaglayers/protocol.py +64 -0
- odxtools/diaglayers/protocolraw.py +91 -0
- odxtools/diagnostictroublecode.py +8 -9
- odxtools/diagservice.py +56 -43
- odxtools/diagvariable.py +113 -0
- odxtools/docrevision.py +5 -7
- odxtools/dopbase.py +15 -17
- odxtools/dtcdop.py +168 -50
- odxtools/dynamicendmarkerfield.py +134 -0
- odxtools/dynamiclengthfield.py +41 -37
- odxtools/dyndefinedspec.py +177 -0
- odxtools/dynenddopref.py +38 -0
- odxtools/ecuvariantmatcher.py +6 -7
- odxtools/element.py +13 -15
- odxtools/encodestate.py +199 -22
- odxtools/endofpdufield.py +31 -18
- odxtools/environmentdata.py +8 -1
- odxtools/environmentdatadescription.py +198 -38
- odxtools/exceptions.py +11 -2
- odxtools/field.py +10 -10
- odxtools/functionalclass.py +3 -5
- odxtools/inputparam.py +3 -12
- odxtools/leadinglengthinfotype.py +37 -18
- odxtools/library.py +66 -0
- odxtools/loadfile.py +64 -0
- odxtools/matchingparameter.py +3 -3
- odxtools/message.py +0 -7
- odxtools/minmaxlengthtype.py +61 -33
- odxtools/modification.py +3 -5
- odxtools/multiplexer.py +128 -73
- odxtools/multiplexercase.py +13 -14
- odxtools/multiplexerdefaultcase.py +15 -12
- odxtools/multiplexerswitchkey.py +4 -5
- odxtools/nameditemlist.py +29 -5
- odxtools/negoutputparam.py +3 -5
- odxtools/odxcategory.py +83 -0
- odxtools/odxlink.py +60 -51
- odxtools/odxtypes.py +37 -5
- odxtools/outputparam.py +4 -15
- odxtools/parameterinfo.py +218 -67
- odxtools/parameters/codedconstparameter.py +16 -24
- odxtools/parameters/dynamicparameter.py +5 -4
- odxtools/parameters/lengthkeyparameter.py +60 -26
- odxtools/parameters/matchingrequestparameter.py +23 -11
- odxtools/parameters/nrcconstparameter.py +45 -46
- odxtools/parameters/parameter.py +54 -56
- odxtools/parameters/parameterwithdop.py +15 -25
- odxtools/parameters/physicalconstantparameter.py +15 -18
- odxtools/parameters/reservedparameter.py +6 -2
- odxtools/parameters/systemparameter.py +55 -11
- odxtools/parameters/tableentryparameter.py +3 -2
- odxtools/parameters/tablekeyparameter.py +103 -49
- odxtools/parameters/tablestructparameter.py +47 -48
- odxtools/parameters/valueparameter.py +16 -20
- odxtools/paramlengthinfotype.py +52 -32
- odxtools/parentref.py +16 -2
- odxtools/physicaldimension.py +3 -8
- odxtools/progcode.py +26 -11
- odxtools/protstack.py +3 -5
- odxtools/py.typed +0 -0
- odxtools/relateddoc.py +7 -9
- odxtools/request.py +120 -10
- odxtools/response.py +123 -23
- odxtools/scaleconstr.py +3 -3
- odxtools/servicebinner.py +1 -1
- odxtools/singleecujob.py +12 -10
- odxtools/snrefcontext.py +29 -0
- odxtools/specialdata.py +3 -5
- odxtools/specialdatagroup.py +7 -9
- odxtools/specialdatagroupcaption.py +3 -6
- odxtools/standardlengthtype.py +80 -14
- odxtools/state.py +3 -5
- odxtools/statechart.py +13 -19
- odxtools/statetransition.py +7 -17
- odxtools/staticfield.py +31 -25
- odxtools/subcomponent.py +288 -0
- odxtools/swvariable.py +21 -0
- odxtools/table.py +7 -8
- odxtools/tablerow.py +19 -11
- odxtools/teammember.py +3 -5
- odxtools/templates/comparam-spec.odx-c.xml.jinja2 +4 -24
- odxtools/templates/comparam-subset.odx-cs.xml.jinja2 +5 -26
- odxtools/templates/diag_layer_container.odx-d.xml.jinja2 +15 -31
- odxtools/templates/{index.xml.xml.jinja2 → index.xml.jinja2} +1 -1
- odxtools/templates/macros/printAudience.xml.jinja2 +1 -1
- odxtools/templates/macros/printBaseVariant.xml.jinja2 +53 -0
- odxtools/templates/macros/printCompanyData.xml.jinja2 +4 -7
- odxtools/templates/macros/printComparam.xml.jinja2 +6 -4
- odxtools/templates/macros/printComparamRef.xml.jinja2 +5 -12
- odxtools/templates/macros/printCompuMethod.xml.jinja2 +147 -0
- odxtools/templates/macros/printDOP.xml.jinja2 +27 -133
- odxtools/templates/macros/printDescription.xml.jinja2 +18 -0
- odxtools/templates/macros/printDiagComm.xml.jinja2 +1 -1
- odxtools/templates/macros/printDiagLayer.xml.jinja2 +222 -0
- odxtools/templates/macros/printDiagVariable.xml.jinja2 +66 -0
- odxtools/templates/macros/printDynDefinedSpec.xml.jinja2 +48 -0
- odxtools/templates/macros/printDynamicEndmarkerField.xml.jinja2 +16 -0
- odxtools/templates/macros/printDynamicLengthField.xml.jinja2 +1 -1
- odxtools/templates/macros/printEcuSharedData.xml.jinja2 +30 -0
- odxtools/templates/macros/printEcuVariant.xml.jinja2 +53 -0
- odxtools/templates/macros/printEcuVariantPattern.xml.jinja2 +1 -1
- odxtools/templates/macros/printElementId.xml.jinja2 +8 -3
- odxtools/templates/macros/printEndOfPdu.xml.jinja2 +1 -1
- odxtools/templates/macros/printEnvDataDesc.xml.jinja2 +1 -1
- odxtools/templates/macros/printFunctionalClass.xml.jinja2 +1 -1
- odxtools/templates/macros/printFunctionalGroup.xml.jinja2 +40 -0
- odxtools/templates/macros/printHierarchyElement.xml.jinja2 +24 -0
- odxtools/templates/macros/printLibrary.xml.jinja2 +21 -0
- odxtools/templates/macros/printMux.xml.jinja2 +4 -3
- odxtools/templates/macros/printOdxCategory.xml.jinja2 +28 -0
- odxtools/templates/macros/printParam.xml.jinja2 +11 -12
- odxtools/templates/macros/printProtStack.xml.jinja2 +1 -1
- odxtools/templates/macros/printProtocol.xml.jinja2 +30 -0
- odxtools/templates/macros/printRequest.xml.jinja2 +1 -1
- odxtools/templates/macros/printResponse.xml.jinja2 +1 -1
- odxtools/templates/macros/printService.xml.jinja2 +3 -2
- odxtools/templates/macros/printSingleEcuJob.xml.jinja2 +5 -26
- odxtools/templates/macros/printSpecialData.xml.jinja2 +1 -1
- odxtools/templates/macros/printState.xml.jinja2 +1 -1
- odxtools/templates/macros/printStateChart.xml.jinja2 +1 -1
- odxtools/templates/macros/printStateTransition.xml.jinja2 +1 -1
- odxtools/templates/macros/printStaticField.xml.jinja2 +1 -1
- odxtools/templates/macros/printStructure.xml.jinja2 +1 -1
- odxtools/templates/macros/printSubComponent.xml.jinja2 +104 -0
- odxtools/templates/macros/printTable.xml.jinja2 +4 -5
- odxtools/templates/macros/printUnitSpec.xml.jinja2 +3 -5
- odxtools/uds.py +2 -10
- odxtools/unit.py +4 -8
- odxtools/unitgroup.py +3 -5
- odxtools/unitspec.py +17 -17
- odxtools/utils.py +38 -20
- odxtools/variablegroup.py +32 -0
- odxtools/version.py +2 -2
- odxtools/{write_pdx_file.py → writepdxfile.py} +20 -10
- odxtools/xdoc.py +3 -5
- {odxtools-6.7.0.dist-info → odxtools-9.3.0.dist-info}/METADATA +20 -21
- odxtools-9.3.0.dist-info/RECORD +228 -0
- {odxtools-6.7.0.dist-info → odxtools-9.3.0.dist-info}/WHEEL +1 -1
- odxtools/createcompanydatas.py +0 -17
- odxtools/createsdgs.py +0 -19
- odxtools/load_file.py +0 -13
- odxtools/load_odx_d_file.py +0 -6
- odxtools/load_pdx_file.py +0 -8
- odxtools/templates/macros/printVariant.xml.jinja2 +0 -216
- odxtools-6.7.0.dist-info/RECORD +0 -182
- /odxtools/{diaglayertype.py → diaglayers/diaglayertype.py} +0 -0
- {odxtools-6.7.0.dist-info → odxtools-9.3.0.dist-info}/LICENSE +0 -0
- {odxtools-6.7.0.dist-info → odxtools-9.3.0.dist-info}/entry_points.txt +0 -0
- {odxtools-6.7.0.dist-info → odxtools-9.3.0.dist-info}/top_level.txt +0 -0
odxtools/cli/_print_utils.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
import re
|
3
3
|
import textwrap
|
4
|
-
from typing import
|
4
|
+
from typing import List, Optional, Tuple, Union
|
5
5
|
|
6
6
|
import markdownify
|
7
|
-
from
|
7
|
+
from rich import print as rich_print
|
8
|
+
from rich.padding import Padding as RichPadding
|
9
|
+
from rich.table import Table as RichTable
|
8
10
|
|
9
|
-
from ..
|
11
|
+
from ..description import Description
|
12
|
+
from ..diaglayers.diaglayer import DiagLayer
|
10
13
|
from ..diagservice import DiagService
|
11
14
|
from ..parameters.codedconstparameter import CodedConstParameter
|
12
15
|
from ..parameters.nrcconstparameter import NrcConstParameter
|
@@ -17,9 +20,9 @@ from ..parameters.valueparameter import ValueParameter
|
|
17
20
|
from ..singleecujob import SingleEcuJob
|
18
21
|
|
19
22
|
|
20
|
-
def format_desc(
|
23
|
+
def format_desc(description: Description, indent: int = 0) -> str:
|
21
24
|
# Collapse whitespaces
|
22
|
-
desc = re.sub(r"\s+", " ",
|
25
|
+
desc = re.sub(r"\s+", " ", str(description))
|
23
26
|
# Covert XHTML to Markdown
|
24
27
|
desc = markdownify.markdownify(desc)
|
25
28
|
# Collapse blank lines
|
@@ -35,148 +38,179 @@ def print_diagnostic_service(service: DiagService,
|
|
35
38
|
print_pre_condition_states: bool = False,
|
36
39
|
print_state_transitions: bool = False,
|
37
40
|
print_audiences: bool = False,
|
38
|
-
allow_unknown_bit_lengths: bool = False
|
39
|
-
print_fn: Callable[..., Any] = print) -> None:
|
41
|
+
allow_unknown_bit_lengths: bool = False) -> None:
|
40
42
|
|
41
|
-
|
43
|
+
rich_print(f" Service '{service.short_name}':")
|
42
44
|
|
43
45
|
if service.description:
|
44
46
|
desc = format_desc(service.description, indent=3)
|
45
|
-
|
47
|
+
rich_print(f" Description: " + desc)
|
46
48
|
|
47
49
|
if print_pre_condition_states and len(service.pre_condition_states) > 0:
|
48
50
|
pre_condition_states_short_names = [
|
49
51
|
pre_condition_state.short_name for pre_condition_state in service.pre_condition_states
|
50
52
|
]
|
51
|
-
|
53
|
+
rich_print(f" Pre-Condition States: {', '.join(pre_condition_states_short_names)}")
|
52
54
|
|
53
55
|
if print_state_transitions and len(service.state_transitions) > 0:
|
54
56
|
state_transitions = [
|
55
57
|
f"{state_transition.source_snref} -> {state_transition.target_snref}"
|
56
58
|
for state_transition in service.state_transitions
|
57
59
|
]
|
58
|
-
|
60
|
+
rich_print(f" State Transitions: {', '.join(state_transitions)}")
|
59
61
|
|
60
62
|
if print_audiences and service.audience:
|
61
63
|
enabled_audiences_short_names = [
|
62
64
|
enabled_audience.short_name for enabled_audience in service.audience.enabled_audiences
|
63
65
|
]
|
64
|
-
|
66
|
+
rich_print(f" Enabled Audiences: {', '.join(enabled_audiences_short_names)}")
|
65
67
|
|
66
68
|
if print_params:
|
67
|
-
print_service_parameters(
|
68
|
-
service, allow_unknown_bit_lengths=allow_unknown_bit_lengths, print_fn=print_fn)
|
69
|
+
print_service_parameters(service, allow_unknown_bit_lengths=allow_unknown_bit_lengths)
|
69
70
|
|
70
71
|
|
71
72
|
def print_service_parameters(service: DiagService,
|
72
|
-
|
73
|
-
|
74
|
-
# prints parameter details of request, positive response and
|
73
|
+
*,
|
74
|
+
allow_unknown_bit_lengths: bool = False) -> None:
|
75
|
+
# prints parameter details of request, positive response and
|
76
|
+
# negative response of diagnostic service
|
75
77
|
|
76
78
|
# Request
|
77
79
|
if service.request:
|
78
|
-
|
80
|
+
rich_print(f" Request '{service.request.short_name}':")
|
79
81
|
const_prefix = service.request.coded_const_prefix()
|
80
|
-
|
82
|
+
rich_print(
|
81
83
|
f" Identifying Prefix: 0x{const_prefix.hex().upper()} ({bytes(const_prefix)!r})")
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
print_fn(table_str)
|
87
|
-
print_fn()
|
84
|
+
rich_print(f" Parameters:")
|
85
|
+
param_table = extract_parameter_tabulation_data(service.request.parameters)
|
86
|
+
rich_print(RichPadding(param_table, pad=(0, 0, 0, 4)))
|
87
|
+
rich_print()
|
88
88
|
else:
|
89
|
-
|
89
|
+
rich_print(f" No Request!")
|
90
90
|
|
91
91
|
# Positive Responses
|
92
92
|
if not service.positive_responses:
|
93
|
-
|
93
|
+
rich_print(f" No positive responses")
|
94
94
|
|
95
95
|
for resp in service.positive_responses:
|
96
|
-
|
97
|
-
|
96
|
+
rich_print(f" Positive Response '{resp.short_name}':")
|
97
|
+
rich_print(f" Parameters:\n")
|
98
98
|
table = extract_parameter_tabulation_data(list(resp.parameters))
|
99
|
-
|
100
|
-
|
101
|
-
print_fn()
|
99
|
+
rich_print(RichPadding(table, pad=(0, 0, 0, 4)))
|
100
|
+
rich_print()
|
102
101
|
|
103
102
|
# Negative Response
|
104
103
|
if not service.negative_responses:
|
105
|
-
|
104
|
+
rich_print(f" No negative responses")
|
106
105
|
|
107
106
|
for resp in service.negative_responses:
|
108
|
-
|
109
|
-
|
107
|
+
rich_print(f" Negative Response '{resp.short_name}':")
|
108
|
+
rich_print(f" Parameters:\n")
|
110
109
|
table = extract_parameter_tabulation_data(list(resp.parameters))
|
111
|
-
|
112
|
-
|
113
|
-
print_fn()
|
110
|
+
rich_print(RichPadding(table, pad=(0, 0, 0, 4)))
|
111
|
+
rich_print()
|
114
112
|
|
115
|
-
|
113
|
+
rich_print("\n")
|
116
114
|
|
117
115
|
|
118
|
-
def extract_service_tabulation_data(services: List[DiagService]
|
119
|
-
|
120
|
-
|
116
|
+
def extract_service_tabulation_data(services: List[DiagService],
|
117
|
+
*,
|
118
|
+
additional_columns: Optional[List[Tuple[str, List[str]]]] = None
|
119
|
+
) -> RichTable:
|
120
|
+
"""Extracts data of diagnostic services into Dictionary which can
|
121
|
+
be printed by tabulate module
|
122
|
+
"""
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
# Create Rich table
|
125
|
+
table = RichTable(
|
126
|
+
title="", show_header=True, header_style="bold cyan", border_style="blue", show_lines=True)
|
127
|
+
|
128
|
+
name_column: List[str] = []
|
129
|
+
semantic_column: List[str] = []
|
130
|
+
request_column: List[str] = []
|
125
131
|
|
126
132
|
for service in services:
|
127
|
-
|
128
|
-
|
133
|
+
name_column.append(service.short_name)
|
134
|
+
semantic_column.append(service.semantic or "")
|
129
135
|
|
130
136
|
if service.request:
|
131
137
|
prefix = service.request.coded_const_prefix()
|
132
|
-
|
133
|
-
prefix) > 32 else
|
138
|
+
request_column.append(f"0x{str(prefix.hex().upper())[:32]}...") if len(
|
139
|
+
prefix) > 32 else request_column.append(f"0x{str(prefix.hex().upper())}")
|
134
140
|
else:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
141
|
+
request_column.append("")
|
142
|
+
|
143
|
+
table.add_column("Name", style="green")
|
144
|
+
table.add_column("Semantic", justify="left", style="white")
|
145
|
+
table.add_column("Request", justify="left", style="white")
|
146
|
+
if additional_columns is not None:
|
147
|
+
for ac_title, _ in additional_columns:
|
148
|
+
table.add_column(ac_title, justify="left", style="white")
|
149
|
+
|
150
|
+
rows = zip(name_column, semantic_column, request_column,
|
151
|
+
*[ac[1] for ac in additional_columns])
|
152
|
+
for row in rows:
|
153
|
+
table.add_row(*map(str, row))
|
154
|
+
|
155
|
+
return table
|
156
|
+
|
157
|
+
|
158
|
+
def extract_parameter_tabulation_data(parameters: List[Parameter]) -> RichTable:
|
159
|
+
# extracts data of parameters of diagnostic services into
|
160
|
+
# a RichTable object that can be printed
|
161
|
+
|
162
|
+
# Create Rich table
|
163
|
+
table = RichTable(
|
164
|
+
title="", show_header=True, header_style="bold cyan", border_style="blue", show_lines=True)
|
165
|
+
|
166
|
+
# Add columns with appropriate styling
|
167
|
+
table.add_column("Name", style="green")
|
168
|
+
table.add_column("Byte Position", justify="right", style="yellow")
|
169
|
+
table.add_column("Bit Length", justify="right", style="yellow")
|
170
|
+
table.add_column("Semantic", justify="left", style="white")
|
171
|
+
table.add_column("Parameter Type", justify="left", style="white")
|
172
|
+
table.add_column("Data Type", justify="left", style="white")
|
173
|
+
table.add_column("Value", justify="left", style="yellow")
|
174
|
+
table.add_column("Value Type", justify="left", style="white")
|
175
|
+
table.add_column("Linked DOP", justify="left", style="white")
|
176
|
+
|
177
|
+
name_column: List[str] = []
|
178
|
+
byte_column: List[str] = []
|
179
|
+
bit_length_column: List[str] = []
|
180
|
+
semantic_column: List[str] = []
|
181
|
+
param_type_column: List[str] = []
|
182
|
+
value_column: List[str] = []
|
183
|
+
value_type_column: List[str] = []
|
184
|
+
data_type_column: List[str] = []
|
185
|
+
dop_column: List[str] = []
|
153
186
|
|
154
187
|
for param in parameters:
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
188
|
+
name_column.append(param.short_name)
|
189
|
+
byte_column.append("" if param.byte_position is None else str(param.byte_position))
|
190
|
+
semantic_column.append(param.semantic or "")
|
191
|
+
param_type_column.append(param.parameter_type)
|
159
192
|
length = 0
|
160
193
|
if param.get_static_bit_length() is not None:
|
161
|
-
|
162
|
-
|
194
|
+
n = param.get_static_bit_length()
|
195
|
+
bit_length_column.append("" if n is None else str(n))
|
196
|
+
length = (n or 0) // 4
|
163
197
|
else:
|
164
|
-
|
198
|
+
bit_length_column.append("")
|
165
199
|
if isinstance(param, CodedConstParameter):
|
166
200
|
if isinstance(param.coded_value, int):
|
167
|
-
|
201
|
+
value_column.append(f"0x{param.coded_value:0{length}X}")
|
168
202
|
elif isinstance(param.coded_value, bytes) or isinstance(param.coded_value, bytearray):
|
169
|
-
|
203
|
+
value_column.append(f"0x{param.coded_value.hex().upper()}")
|
170
204
|
else:
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
205
|
+
value_column.append(f"{param.coded_value!r}")
|
206
|
+
data_type_column.append(param.diag_coded_type.base_data_type.name)
|
207
|
+
value_type_column.append('coded value')
|
208
|
+
dop_column.append("")
|
175
209
|
elif isinstance(param, NrcConstParameter):
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
210
|
+
data_type_column.append(param.diag_coded_type.base_data_type.name)
|
211
|
+
value_column.append(str(param.coded_values))
|
212
|
+
value_type_column.append('coded values')
|
213
|
+
dop_column.append("")
|
180
214
|
elif isinstance(param, (PhysicalConstantParameter, SystemParameter, ValueParameter)):
|
181
215
|
# this is a hack to make this routine work for parameters
|
182
216
|
# which reference DOPs of a type that a is not yet
|
@@ -185,71 +219,71 @@ def extract_parameter_tabulation_data(parameters: List[Parameter]) -> Dict[str,
|
|
185
219
|
param_dop = getattr(param, "_dop", None)
|
186
220
|
|
187
221
|
if param_dop is not None:
|
188
|
-
|
222
|
+
dop_column.append(param_dop.short_name)
|
189
223
|
|
190
224
|
if param_dop is not None and (phys_type := getattr(param, "physical_type",
|
191
225
|
None)) is not None:
|
192
|
-
|
226
|
+
data_type_column.append(phys_type.base_data_type.name)
|
193
227
|
else:
|
194
|
-
|
228
|
+
data_type_column.append("")
|
195
229
|
if isinstance(param, PhysicalConstantParameter):
|
196
230
|
if isinstance(param.physical_constant_value, bytes) or isinstance(
|
197
231
|
param.physical_constant_value, bytearray):
|
198
|
-
|
232
|
+
value_column.append(f"0x{param.physical_constant_value.hex().upper()}")
|
199
233
|
else:
|
200
|
-
|
201
|
-
|
234
|
+
value_column.append(f"{param.physical_constant_value!r}")
|
235
|
+
value_type_column.append('constant value')
|
202
236
|
elif isinstance(param, ValueParameter) and param.physical_default_value is not None:
|
203
237
|
if isinstance(param.physical_default_value, bytes) or isinstance(
|
204
238
|
param.physical_default_value, bytearray):
|
205
|
-
|
239
|
+
value_column.append(f"0x{param.physical_default_value.hex().upper()}")
|
206
240
|
else:
|
207
|
-
|
208
|
-
|
241
|
+
value_column.append(f"{param.physical_default_value!r}")
|
242
|
+
value_type_column.append('default value')
|
209
243
|
else:
|
210
|
-
|
211
|
-
|
244
|
+
value_column.append("")
|
245
|
+
value_type_column.append("")
|
212
246
|
else:
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
247
|
+
value_column.append("")
|
248
|
+
data_type_column.append("")
|
249
|
+
value_type_column.append("")
|
250
|
+
dop_column.append("")
|
251
|
+
|
252
|
+
# Add all rows at once by zipping dictionary values
|
253
|
+
rows = zip(name_column, byte_column, bit_length_column, semantic_column, param_type_column,
|
254
|
+
data_type_column, value_column, value_type_column, dop_column)
|
255
|
+
for row in rows:
|
256
|
+
table.add_row(*map(str, row))
|
257
|
+
|
258
|
+
return table
|
259
|
+
|
260
|
+
|
261
|
+
def print_dl_metrics(variants: List[DiagLayer]) -> None:
|
262
|
+
"""
|
263
|
+
Print diagnostic layer metrics using Rich tables.
|
264
|
+
Args:
|
265
|
+
variants: List of diagnostic layer variants to analyze
|
266
|
+
"""
|
267
|
+
# Create Rich table
|
268
|
+
table = RichTable(
|
269
|
+
title="", show_header=True, header_style="bold cyan", border_style="blue", show_lines=True)
|
270
|
+
|
271
|
+
# Add columns with appropriate styling
|
272
|
+
table.add_column("Name", style="green")
|
273
|
+
table.add_column("Variant Type", style="magenta")
|
274
|
+
table.add_column("Number of Services", justify="right", style="yellow")
|
275
|
+
table.add_column("Number of DOPs", justify="right", style="yellow")
|
276
|
+
table.add_column("Number of communication parameters", justify="right", style="yellow")
|
277
|
+
|
278
|
+
# Process each variant
|
238
279
|
for variant in variants:
|
239
280
|
assert isinstance(variant, DiagLayer)
|
240
281
|
all_services: List[Union[DiagService, SingleEcuJob]] = sorted(
|
241
282
|
variant.services, key=lambda x: x.short_name)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
table
|
249
|
-
'Name': name,
|
250
|
-
'Variant Type': type,
|
251
|
-
'Number of Services': num_services,
|
252
|
-
'Number of DOPs': num_dops,
|
253
|
-
'Number of communication parameters': num_comparams
|
254
|
-
}
|
255
|
-
print_fn(tabulate(table, headers='keys', tablefmt='presto'))
|
283
|
+
ddds = variant.diag_data_dictionary_spec
|
284
|
+
|
285
|
+
# Add row to table
|
286
|
+
table.add_row(variant.short_name, variant.variant_type.value, str(len(all_services)),
|
287
|
+
str(len(ddds.data_object_props)),
|
288
|
+
str(len(getattr(variant, "comparams_refs", []))))
|
289
|
+
rich_print(table)
|