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

Refactor table classes #164

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
34 changes: 25 additions & 9 deletions examples/somersaultecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,51 +1026,67 @@ class SomersaultSID(IntEnum):
}

# tables
flip_quality_table_id = OdxLinkId("somersault.table.flip_quality", doc_frags)
flip_quality_table_ref = OdxLinkRef.from_id(flip_quality_table_id)
somersault_tables = {
"flip_quality":
Table(
odx_id=OdxLinkId("somersault.table.flip_quality", doc_frags),
odx_id=flip_quality_table_id,
short_name="flip_quality",
long_name="Flip Quality",
description="<p>The quality the flip (average, good or best)</p>",
semantic="QUALITY",
key_label="key",
admin_data=None,
struct_label="response",
key_dop_ref=OdxLinkRef.from_id(somersault_dops["num_flips"].odx_id),
table_rows=[
table_rows_raw=[
TableRow(
table_ref=flip_quality_table_ref,
odx_id=OdxLinkId("somersault.table.flip_quality.average", doc_frags),
short_name="average",
long_name="Average",
key=3,
structure_ref=OdxLinkRef.from_id(somersault_dops["num_flips"].odx_id),
description="<p>The quality of the flip is average</p>",
semantic="QUALITY-KEY",
key_raw="3",
structure_ref=OdxLinkRef.from_id(
somersault_positive_responses["forward_flips_grudgingly_done"].odx_id),
structure_snref=None,
dop_ref=None,
dop_snref=None,
sdgs=[],
),
TableRow(
table_ref=flip_quality_table_ref,
odx_id=OdxLinkId("somersault.table.flip_quality.good", doc_frags),
short_name="good",
long_name="Good",
description=None,
semantic=None,
key=5,
structure_ref=OdxLinkRef.from_id(somersault_dops["num_flips"].odx_id),
key_raw="5",
structure_ref=OdxLinkRef.from_id(
somersault_positive_responses["forward_flips_happily_done"].odx_id),
structure_snref=None,
dop_ref=None,
dop_snref=None,
sdgs=[],
),
TableRow(
table_ref=flip_quality_table_ref,
odx_id=OdxLinkId("somersault.table.flip_quality.best", doc_frags),
short_name="best",
long_name="Best",
description=None,
semantic=None,
key=10,
structure_ref=OdxLinkRef.from_id(somersault_dops["num_flips"].odx_id),
key_raw="10",
structure_ref=OdxLinkRef.from_id(
somersault_positive_responses["backward_flips_grudgingly_done"].odx_id),
structure_snref=None,
dop_ref=None,
dop_snref=None,
sdgs=[],
),
],
table_row_refs=[],
sdgs=[],
)
}
Expand Down
11 changes: 2 additions & 9 deletions odxtools/diaglayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None:
global_negative_responses = self._compute_available_global_neg_responses(odxlinks)
self._global_negative_responses = NamedItemList(short_name_as_id, global_negative_responses)

tables = self._compute_available_tables()
self._tables = NamedItemList(short_name_as_id, tables)

functional_classes = self._compute_available_functional_classes()
self._functional_classes = NamedItemList(short_name_as_id, functional_classes)

Expand Down Expand Up @@ -157,6 +154,7 @@ def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None:
############

dops = NamedItemList(short_name_as_id, self._compute_available_data_object_props())
tables = NamedItemList(short_name_as_id, self._compute_available_tables())
dtc_dops: NamedItemList[DtcDop]
structures: NamedItemList[BasicStructure]
end_of_pdu_fields: NamedItemList[EndOfPduField]
Expand Down Expand Up @@ -190,7 +188,7 @@ def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None:
dtc_dops=dtc_dops,
structures=structures,
end_of_pdu_fields=end_of_pdu_fields,
tables=NamedItemList(short_name_as_id, tables),
tables=tables,
env_data_descs=env_data_descs,
env_datas=env_datas,
muxs=muxs,
Expand Down Expand Up @@ -313,11 +311,6 @@ def global_negative_responses(self) -> NamedItemList[Response]:
"""All global negative responses applicable to this DiagLayer"""
return self._global_negative_responses

@property
def tables(self) -> NamedItemList[Table]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diaglayer.tables property is gone, how is the user supposed to access tables now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

via diag_layer.diag_data_dictionary_spec.tables. You have a point though, I should add a deprecated method which does that. (fixed: bdc56ee )

"""All tables applicable to this DiagLayer"""
return self._tables

@property
def functional_classes(self) -> NamedItemList[FunctionalClass]:
"""All functional classes applicable to this DiagLayer"""
Expand Down
3 changes: 2 additions & 1 deletion odxtools/parameters/tablekeyparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from .parameterbase import Parameter

if TYPE_CHECKING:
from ..table import Table, TableRow
from ..table import Table
from ..tablerow import TableRow
from .diaglayer import DiagLayer


Expand Down
Loading