Skip to content

Commit

Permalink
handle LIN scale ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Jan 14, 2025
1 parent c49dacd commit 6b284f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ skip = ["pp*", "*_ppc64le", "*-musllinux*", "*_s390x"]

[tool.ruff]
target-version = "py39"
extend-exclude = ["./src/asammdf/gui/ui"]
extend-exclude = ["./src/asammdf/gui/ui", "./ext"]
force-exclude = true

[tool.ruff.lint]
Expand Down
20 changes: 18 additions & 2 deletions src/asammdf/blocks/bus_logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,24 @@ def get_conversion(signal: Signal) -> v4b.ChannelConversion | None:

a, b = float(signal.factor), float(signal.offset)

if signal.values:
conv = {}
conv = {}

scale_ranges = getattr(signal, "scale_ranges", None)
if scale_ranges:
for i, scale_info in enumerate(scale_ranges):
conv[f"upper_{i}"] = scale_info["max"]
conv[f"lower_{i}"] = scale_info["min"]
conv[f"text_{i}"] = from_dict({"a": scale_info["factor"], "b": scale_info["offset"]})

for i, (val, text) in enumerate(signal.values.items(), len(scale_ranges)):
conv[f"upper_{i}"] = val
conv[f"lower_{i}"] = val
conv[f"text_{i}"] = text

conv["default"] = from_dict({"a": a, "b": b})

elif signal.values:

for i, (val, text) in enumerate(signal.values.items()):
conv[f"upper_{i}"] = val
conv[f"lower_{i}"] = val
Expand Down

0 comments on commit 6b284f8

Please sign in to comment.