Skip to content

Commit

Permalink
Signals now reference the Frame they're in (#94)
Browse files Browse the repository at this point in the history
* Changelog update for release
  • Loading branch information
c4deszes authored Feb 26, 2022
1 parent 2c84e52 commit 06e9cd0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion ldfparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions ldfparser/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
if TYPE_CHECKING:
from .node import LinNode
from .encoding import LinSignalEncodingType
from .frame import LinUnconditionalFrame

class LinSignal:
"""
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06e9cd0

Please sign in to comment.