Skip to content

Commit

Permalink
Fix some unserializable ReadIntoFactory implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
R1tschY committed Jun 7, 2024
1 parent 56e3960 commit f98b210
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ private static ValueReadFactory createChannelReaderFactory(
.resolve(ChannelConversionBlock.TYPE, input);
if (channelConversion.isPresent()) {
final var cc = channelConversion.get();
final var vals = cc.getVals();
switch (cc.getType()) {
case IDENTITY:
converted = rawValue;
break;
case LINEAR:
converted = (in, scope) -> new LinearConversion(cc, rawValue.build(in, scope));
converted = (in, scope) -> new LinearConversion(vals, rawValue.build(in, scope));
break;
case RATIONAL:
converted = (in, scope) -> new RationalConversion(cc, rawValue.build(in, scope));
converted = (in, scope) -> new RationalConversion(vals, rawValue.build(in, scope));
break;
case ALGEBRAIC:
case INTERPOLATED_VALUE_TABLE:
Expand Down Expand Up @@ -1055,7 +1056,7 @@ private static <B, R> Pair<List<ReadIntoFactory<B>>, List<Channel>> buildExtract
dataGroupBlock, channelGroupBlock, ch.getBlock(), input);
channels.add(ch);
channelReaders.add((in, scope) ->
new ReadIntoImpl<>(deserializeInto, channelReaderFactory.build(input, scope)));
new ReadIntoImpl<>(deserializeInto, channelReaderFactory.build(in, scope)));
}
} catch (NotImplementedFeatureException exception) {
log.warning("Ignoring channel '" + ch.getName() + "': " + exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package de.richardliebscher.mdf4.extract.read;

import de.richardliebscher.mdf4.blocks.ChannelConversionBlock;
import de.richardliebscher.mdf4.extract.de.UnsignedLong;
import de.richardliebscher.mdf4.extract.de.Visitor;
import java.io.IOException;
Expand All @@ -16,9 +15,9 @@ public class LinearConversion implements ValueRead {
private final double p2;
private final ValueRead inner;

public LinearConversion(ChannelConversionBlock cc, ValueRead valueRead) {
this.p1 = Double.longBitsToDouble(cc.getVals()[0]);
this.p2 = Double.longBitsToDouble(cc.getVals()[1]);
public LinearConversion(long[] ccVals, ValueRead valueRead) {
this.p1 = Double.longBitsToDouble(ccVals[0]);
this.p2 = Double.longBitsToDouble(ccVals[1]);
this.inner = valueRead;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package de.richardliebscher.mdf4.extract.read;

import de.richardliebscher.mdf4.blocks.ChannelConversionBlock;
import de.richardliebscher.mdf4.extract.de.UnsignedLong;
import de.richardliebscher.mdf4.extract.de.Visitor;
import java.io.IOException;
Expand All @@ -20,8 +19,7 @@ public class RationalConversion implements ValueRead {
private final double p6;
private final ValueRead inner;

public RationalConversion(ChannelConversionBlock cc, ValueRead valueRead) {
final var vals = cc.getVals();
public RationalConversion(long[] vals, ValueRead valueRead) {
this.p1 = Double.longBitsToDouble(vals[0]);
this.p2 = Double.longBitsToDouble(vals[1]);
this.p3 = Double.longBitsToDouble(vals[2]);
Expand Down

0 comments on commit f98b210

Please sign in to comment.