diff --git a/CHANGELOG.md b/CHANGELOG.md index 805ed1d..b20ec49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.14.0] - 2022-02-26 + ### Added - `LDF` objects can now be saved as `.ldf` files (experimental) - Encoding types now have references to the Signals it represents - `LDF` object now has functions to lookup encoding types +- `LinSignal` now reference the `LinUnconditionalFrame` they're in ### Changed diff --git a/ldfparser/parser.py b/ldfparser/parser.py index 64fdfeb..7abaa49 100644 --- a/ldfparser/parser.py +++ b/ldfparser/parser.py @@ -118,7 +118,11 @@ def _populate_ldf_frames(json: dict, ldf: LDF): elif 48 <= frame['frame_id'] <= 63: length = 8 - ldf._unconditional_frames[frame['name']] = LinUnconditionalFrame(frame['frame_id'], frame['name'], length, signals) + frame_obj = LinUnconditionalFrame(frame['frame_id'], frame['name'], length, signals) + ldf._unconditional_frames[frame['name']] = frame_obj + + for (_, signal) in signals.items(): + signal.frame = frame_obj def _populate_ldf_event_triggered_frames(json: dict, ldf: LDF): if "event_triggered_frames" not in json: diff --git a/ldfparser/signal.py b/ldfparser/signal.py index b011300..4f1e970 100644 --- a/ldfparser/signal.py +++ b/ldfparser/signal.py @@ -6,6 +6,7 @@ if TYPE_CHECKING: from .node import LinNode from .encoding import LinSignalEncodingType + from .frame import LinUnconditionalFrame class LinSignal: """ @@ -30,6 +31,7 @@ def __init__(self, name: str, width: int, init_value: Union[int, List[int]]): self.publisher: 'LinNode' = None self.subscribers: List['LinNode'] = [] self.encoding_type: 'LinSignalEncodingType' = None + self.frame: 'LinUnconditionalFrame' = None def __eq__(self, o: object) -> bool: if isinstance(o, LinSignal): diff --git a/tests/test_parser.py b/tests/test_parser.py index 27a6fbd..828cd5f 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -121,6 +121,7 @@ def test_no_signal_subscribers(): assert ldf.signal('DummySignal_0') is not None assert ldf.frame('DummyFrame') is not None + assert ldf.signal('DummySignal_0').frame.name == 'DummyFrame' @pytest.mark.unit