diff --git a/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java b/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java index 27e7a3f8..e72f8f38 100644 --- a/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java +++ b/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java @@ -3,23 +3,14 @@ package enginuity.logger.innovate.plugin; import enginuity.logger.ecu.external.ExternalDataItem; import static enginuity.util.ThreadUtil.runAsDaemon; -public final class InnovateControllerImpl implements InnovateController, DataListener { - private Lc1Convertor convertor = new Lc1ConvertorImpl(); - private byte[] bytes; +public final class InnovateControllerImpl implements InnovateController { + private Lc1DataItem dataItem = new Lc1DataItem(); public InnovateControllerImpl(InnovateConnection connection) { - runAsDaemon(new InnovateRunnerImpl(connection, this)); + runAsDaemon(new InnovateRunnerImpl(connection, dataItem)); } public synchronized ExternalDataItem getDataItem() { - if (bytes != null) { - return new Lc1DataItem(convertor.convert(bytes)); - } else { - return new Lc1DataItem(0.0); - } - } - - public synchronized void setBytes(byte[] bytes) { - this.bytes = bytes; + return dataItem; } } diff --git a/src/enginuity/logger/innovate/plugin/Lc1ConvertorImpl.java b/src/enginuity/logger/innovate/plugin/Lc1ConvertorImpl.java index 421f7602..6c78097a 100644 --- a/src/enginuity/logger/innovate/plugin/Lc1ConvertorImpl.java +++ b/src/enginuity/logger/innovate/plugin/Lc1ConvertorImpl.java @@ -22,7 +22,7 @@ public final class Lc1ConvertorImpl implements Lc1Convertor { } private double getAfr(byte[] bytes) { - return (getLambda(bytes) + 500) * getAF(bytes) / 10000; + return (getLambda(bytes) + 500) * getAF(bytes) / 10000.0; } private int getAF(byte[] bytes) { diff --git a/src/enginuity/logger/innovate/plugin/Lc1DataItem.java b/src/enginuity/logger/innovate/plugin/Lc1DataItem.java index b4bfa160..2c05139a 100644 --- a/src/enginuity/logger/innovate/plugin/Lc1DataItem.java +++ b/src/enginuity/logger/innovate/plugin/Lc1DataItem.java @@ -2,12 +2,9 @@ package enginuity.logger.innovate.plugin; import enginuity.logger.ecu.external.ExternalDataItem; -public final class Lc1DataItem implements ExternalDataItem { - private final double data; - - public Lc1DataItem(double data) { - this.data = data; - } +public final class Lc1DataItem implements ExternalDataItem, DataListener { + private Lc1Convertor convertor = new Lc1ConvertorImpl(); + private byte[] bytes; public String getName() { return "LC-1"; @@ -22,6 +19,14 @@ public final class Lc1DataItem implements ExternalDataItem { } public double getData() { - return data; + if (bytes != null) { + return convertor.convert(bytes); + } else { + return 0.0; + } + } + + public void setBytes(byte[] bytes) { + this.bytes = bytes; } } diff --git a/src/enginuity/logger/innovate/plugin/Lc1DataSource.java b/src/enginuity/logger/innovate/plugin/Lc1DataSource.java index 38d96153..b1c58afc 100644 --- a/src/enginuity/logger/innovate/plugin/Lc1DataSource.java +++ b/src/enginuity/logger/innovate/plugin/Lc1DataSource.java @@ -9,10 +9,12 @@ import java.util.List; public final class Lc1DataSource implements ExternalDataSource { private InnovateController controller; + private List dataItems; public Lc1DataSource() { Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), "COM6"); controller = new InnovateControllerImpl(connection); + dataItems = asList(controller.getDataItem()); } public String getName() { @@ -24,7 +26,7 @@ public final class Lc1DataSource implements ExternalDataSource { } public List getDataItems() { - return asList(controller.getDataItem()); + return dataItems; } public void setCommPortChoice(String commPort) {