Skip to content

Commit

Permalink
store multiple scalings per signal (LDF-import)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroecker committed Dec 18, 2024
1 parent 7fde135 commit 8faab40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/canmatrix/canmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Signal(object):

cycle_time = attr.ib(default=0) # type: int
initial_value = attr.ib(converter=float_factory, default=float_factory(0.0)) # type: canmatrix.types.PhysicalValue

scale_ranges = attr.ib(factory=list)
min = attr.ib(
converter=lambda value, float_factory=float_factory: (
float_factory(value)
Expand Down
6 changes: 6 additions & 0 deletions src/canmatrix/formats/ldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def load(f, **options): # type: (typing.IO, **typing.Any) -> canmatrix.CanMatri
if isinstance(converter, ldfparser.encoding.LogicalValue):
cm_signal.add_values(converter.phy_value, converter.info)
if isinstance(converter, ldfparser.encoding.PhysicalValue):
cm_signal.scale_ranges.append({
"min" : converter.phy_min,
"max" : converter.phy_max,
"factor" : converter.scale,
"offset" : converter.offset,
"unit" : converter.unit})
cm_signal.offset = converter.offset
cm_signal.factor = converter.scale
cm_signal.unit = converter.unit
Expand Down

0 comments on commit 8faab40

Please sign in to comment.