diff --git a/pyproject.toml b/pyproject.toml index c6b9c0a14..73ab06339 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/src/asammdf/blocks/bus_logging_utils.py b/src/asammdf/blocks/bus_logging_utils.py index 7cbb311b9..f422e753a 100644 --- a/src/asammdf/blocks/bus_logging_utils.py +++ b/src/asammdf/blocks/bus_logging_utils.py @@ -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