diff --git a/src/canmatrix/formats/ldf.py b/src/canmatrix/formats/ldf.py index 44553f24..e3932196 100644 --- a/src/canmatrix/formats/ldf.py +++ b/src/canmatrix/formats/ldf.py @@ -2,9 +2,12 @@ import ldfparser import canmatrix +import ldfparser.encoding + def load(f, **options): # type: (typing.IO, **typing.Any) -> canmatrix.CanMatrix ldf = ldfparser.parseLDF(path=f.name) # using f.name is not nice, but works + db = canmatrix.CanMatrix() for lin_frame in ldf.frames: @@ -17,6 +20,17 @@ def load(f, **options): # type: (typing.IO, **typing.Any) -> canmatrix.CanMatri for mapping in lin_frame.signal_map: lin_signal = mapping[1] cm_signal = canmatrix.Signal() + if lin_signal.name in ldf.converters: + for converter in ldf.converters[lin_signal.name]._converters: + if isinstance(converter, ldfparser.encoding.LogicalValue): + cm_signal.add_values(converter.phy_value, converter.info) + if isinstance(converter, ldfparser.encoding.PhysicalValue): + cm_signal.offset = converter.offset + cm_signal.factor = converter.scale + cm_signal.unit = converter.unit + cm_signal.min = converter.phy_min + cm_signal.max = converter.phy_max + cm_signal.name = lin_signal.name cm_signal.size = lin_signal.width cm_signal.initial_value = lin_signal.init_value