Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve table in TableKeyParameter #75

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions odxtools/parameters/tablekeyparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ def __init__(self,
semantic=semantic,
description=description
)
self.table_ref = None
self.table_snref = None
self.table_row_ref = None
self.table_row_snref = None
if table_ref:
self.table_ref = table_ref
self.table_row_snref = table_row_snref
self.table_row_ref = table_row_ref
elif table_snref:
self.table_ref = table_ref
self.table_snref = table_snref
self.table_row_snref = table_row_snref
elif table_row_ref:
self.table_row_ref = table_row_ref
Expand Down Expand Up @@ -59,3 +63,10 @@ def get_coded_value_as_bytes(self):
def decode_from_pdu(self, coded_message, default_byte_position=None):
raise NotImplementedError(
"Decoding a TableKeyParameter is not implemented yet.")

def resolve_references(self, parent_dl, id_lookup):
self.table = None
if self.table_snref:
self.table = parent_dl.local_diag_data_dictionary_spec.tables[self.table_snref]
elif self.table_ref:
self.table = id_lookup.get(self.table_ref)
4 changes: 4 additions & 0 deletions odxtools/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import Any, List, Dict, Iterable, Optional, OrderedDict, Union
import warnings

from odxtools.parameters.tablekeyparameter import TableKeyParameter

from .dataobjectproperty import DataObjectProperty, DopBase
from .decodestate import DecodeState, ParameterValuePair
from .encodestate import EncodeState
Expand Down Expand Up @@ -267,6 +269,8 @@ def _resolve_references(self, parent_dl, id_lookup):
for p in self.parameters:
if isinstance(p, ParameterWithDOP):
p.resolve_references(parent_dl, id_lookup)
if isinstance(p, TableKeyParameter):
p.resolve_references(parent_dl, id_lookup)

def __message_format_lines(self, allow_unknown_lengths=False):
# sort parameters
Expand Down