External covertors almost complete.

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@343 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
Dale Schultz 2011-09-26 04:09:48 +00:00
parent 0a45682dff
commit 17eb5ebd2c
51 changed files with 890 additions and 783 deletions

View File

@ -19,26 +19,31 @@
package com.romraider.logger.external.aem.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class AemDataItem implements ExternalDataItem, DataListener {
private EcuDataConvertor[] convertors;
private double data;
public AemDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
return "AEM UEGO AFR [9600]";
return "AEM UEGO Wideband [9600]";
}
public String getDescription() {
return "AEM UEGO AFR data";
return "AEM UEGO Wideband data";
}
// public String getUnits() {
// return "AFR";
// }
public double getData() {
return data;
}
@ -47,19 +52,7 @@ public final class AemDataItem implements ExternalDataItem, DataListener {
this.data = data;
}
// public String getFormat() {
// return "0.##";
// }
//
// public String getExpression() {
// return "x";
// }
public EcuDataConvertor[] getConvertors() {
String units = "AFR";
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,17 +19,28 @@
package com.romraider.logger.external.aem.plugin;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_146;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_147;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_155;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_172;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_34;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_64;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_90;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import java.util.List;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.aem.io.AemRunner;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import javax.swing.Action;
import java.util.List;
public final class AemDataSource implements ExternalDataSource {
private AemDataItem dataItem = new AemDataItem();
private AemDataItem dataItem = new AemDataItem(AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);
private AemRunner runner;
private String port;
@ -42,7 +53,7 @@ public final class AemDataSource implements ExternalDataSource {
}
public String getVersion() {
return "0.04";
return "0.05";
}
public List<? extends ExternalDataItem> getDataItems() {

View File

@ -0,0 +1,48 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.aem.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum AemSensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.0680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x", "0.00"), // gasoline
AFR_90 ("AFR Ethonal", "x*0.6122448979591837", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "x*0.9931972789115646", "0.00"), // diesel
AFR_64 ("AFR Methonal", "x*0.4353741496598639", "0.00"),// methanol
AFR_155 ("AFR LPG", "x*1.054421768707483", "0.00"), // LPG
AFR_172 ("AFR CNG", "x*1.170068027210884", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "x*2.312925170068027", "0.00"); // Hydrogen
private final String units;
private final String expression;
private final String format;
AemSensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -19,14 +19,23 @@
package com.romraider.logger.external.aem2.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class AemDataItem implements ExternalDataItem, DataListener {
private EcuDataConvertor[] convertors;
private double data;
public AemDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
return "AEM UEGO [19200 baud]";
}
@ -35,10 +44,6 @@ public final class AemDataItem implements ExternalDataItem, DataListener {
return "AEM UEGO Wideband data";
}
// public String getUnits() {
// return "Lambda";
// }
public double getData() {
return data;
}
@ -47,19 +52,7 @@ public final class AemDataItem implements ExternalDataItem, DataListener {
this.data = data;
}
// public String getFormat() {
// return "0.##";
// }
//
// public String getExpression() {
// return "x";
// }
public EcuDataConvertor[] getConvertors() {
String units = "Lambda";
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,17 +19,28 @@
package com.romraider.logger.external.aem2.plugin;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_146;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_147;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_155;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_172;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_34;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_64;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.AFR_90;
import static com.romraider.logger.external.aem.plugin.AemSensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import java.util.List;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.aem2.io.AemRunner;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import javax.swing.Action;
import java.util.List;
public final class AemDataSource implements ExternalDataSource {
private AemDataItem dataItem = new AemDataItem();
private AemDataItem dataItem = new AemDataItem(LAMBDA, AFR_147, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);
private AemRunner runner;
private String port;
@ -42,7 +53,7 @@ public final class AemDataSource implements ExternalDataSource {
}
public String getVersion() {
return "0.01";
return "0.02";
}
public List<? extends ExternalDataItem> getDataItems() {

View File

@ -0,0 +1,47 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.aem2.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum AemSensorConversions implements ExternalSensorConversions {
LAMBDA ("Lambda", "x", "0.00"),
AFR_147 ("AFR Gasoline", "x*14.7", "0.00"),// gasoline
AFR_90 ("AFR Ethonal", "x*9.0", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "x*14.6", "0.00"), // diesel
AFR_64 ("AFR Methonal", "x*6.4", "0.00"), // methanol
AFR_155 ("AFR LPG", "x*15.5", "0.00"), // LPG
AFR_172 ("AFR CNG", "x*17.2", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "x*34", "0.00"); // Hydrogen
private final String units;
private final String expression;
private final String format;
AemSensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -0,0 +1,25 @@
package com.romraider.logger.external.core;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
public class ExternalDataConvertorLoader {
public static EcuDataConvertor[] loadConvertors(
ExternalDataItem dataItem,
EcuDataConvertor[] convertors,
ExternalSensorConversions... convertorList)
{
int i = 0;
for (ExternalSensorConversions convertor : convertorList) {
convertors[i] = new ExternalDataConvertorImpl(
dataItem,
convertor.units(),
convertor.expression(),
convertor.format()
);
i++;
}
return convertors;
}
}

View File

@ -26,12 +26,6 @@ public interface ExternalDataItem {
String getDescription();
// String getUnits();
//
// String getFormat();
//
// String getExpression();
double getData();
EcuDataConvertor[] getConvertors();

View File

@ -0,0 +1,11 @@
package com.romraider.logger.external.core;
public interface ExternalSensorConversions {
String units();
String expression();
String format();
}

View File

@ -17,13 +17,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.zt2.plugin;
package com.romraider.logger.external.core;
public enum ZT2SensorType {
AFR,
RPM,
public enum ExternalSensorType {
EGT,
ENGINE_SPEED,
MAP,
THERMACOUPLE1,
THERMACOUPLE2,
THERMACOUPLE3,
TorVss,
TPS,
USR
USER1,
USER2,
USER3,
WIDEBAND,
}

View File

@ -19,29 +19,22 @@
package com.romraider.logger.external.fourteenpoint7.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
import com.romraider.logger.external.core.RawDataListener;
public final class NawDataItem implements ExternalDataItem, RawDataListener {
private final NawConvertor convertor = new NawConvertorImpl();
private final EcuDataConvertor[] convertors;
private EcuDataConvertor[] convertors;
private byte[] bytes;
public NawDataItem(NawSensorConversions... convertorList) {
public NawDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
int i = 0;
for (NawSensorConversions convertor :convertorList) {
convertors[i] = new ExternalDataConvertorImpl(
this,
convertor.units(),
convertor.expression(),
convertor.format()
);
i++;
}
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {

View File

@ -19,22 +19,25 @@
package com.romraider.logger.external.fourteenpoint7.plugin;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_146;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_147;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_155;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_172;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_34;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_64;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_90;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import java.util.List;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.fourteenpoint7.io.NawRunner;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.LAMBDA;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_147;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_90;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_146;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_64;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_155;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_172;
import static com.romraider.logger.external.fourteenpoint7.plugin.NawSensorConversions.AFR_34;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import javax.swing.Action;
import java.util.List;
public final class NawDataSource implements ExternalDataSource {
private NawDataItem dataItem = new NawDataItem(LAMBDA, AFR_147, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);

View File

@ -19,7 +19,9 @@
package com.romraider.logger.external.fourteenpoint7.plugin;
public enum NawSensorConversions {
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum NawSensorConversions implements ExternalSensorConversions {
LAMBDA ("Lambda", "x", "0.00"),
AFR_147 ("AFR Gasoline", "x*14.7", "0.00"),// gasoline
AFR_90 ("AFR Ethonal", "x*9.0", "0.00"), // ethanol

View File

@ -19,28 +19,21 @@
package com.romraider.logger.external.innovate.generic.serial.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class InnovateDataItem implements ExternalDataItem, DataListener {
private final EcuDataConvertor[] convertors;
private EcuDataConvertor[] convertors;
private double data;
public InnovateDataItem(InnovateSensorConversions... convertorList) {
public InnovateDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
int i = 0;
for (InnovateSensorConversions convertor :convertorList) {
convertors[i] = new ExternalDataConvertorImpl(
this,
convertor.units(),
convertor.expression(),
convertor.format()
);
i++;
}
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {

View File

@ -19,11 +19,6 @@
package com.romraider.logger.external.innovate.generic.serial.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.innovate.generic.serial.io.InnovateRunner;
import static com.romraider.logger.external.innovate.generic.serial.plugin.InnovateSensorConversions.AFR_146;
import static com.romraider.logger.external.innovate.generic.serial.plugin.InnovateSensorConversions.AFR_147;
import static com.romraider.logger.external.innovate.generic.serial.plugin.InnovateSensorConversions.AFR_155;
@ -34,9 +29,16 @@ import static com.romraider.logger.external.innovate.generic.serial.plugin.Innov
import static com.romraider.logger.external.innovate.generic.serial.plugin.InnovateSensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import javax.swing.Action;
import java.util.List;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.innovate.generic.serial.io.InnovateRunner;
public final class InnovateDataSource implements ExternalDataSource {
private InnovateDataItem dataItem = new InnovateDataItem(AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);
private InnovateRunner runner;

View File

@ -19,7 +19,9 @@
package com.romraider.logger.external.innovate.generic.serial.plugin;
public enum InnovateSensorConversions {
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum InnovateSensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.0680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x", "0.00"), // gasoline

View File

@ -19,20 +19,29 @@
package com.romraider.logger.external.innovate.lm2.mts.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class Lm2MtsDataItem implements ExternalDataItem, DataListener {
private EcuDataConvertor[] convertors;
private double data;
public Lm2MtsDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
return "Innovate LM-2 [mts]";
}
public String getDescription() {
return "Innovate LM-2 AFR data";
return "Innovate LM-2 Wideband data";
}
public double getData() {
@ -44,10 +53,6 @@ public final class Lm2MtsDataItem implements ExternalDataItem, DataListener {
}
public EcuDataConvertor[] getConvertors() {
String units = "AFR";
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,21 +19,33 @@
package com.romraider.logger.external.innovate.lm2.mts.plugin;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_146;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_147;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_155;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_172;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_34;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_64;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.AFR_90;
import static com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.lang.Integer.parseInt;
import static java.util.Arrays.asList;
import static org.apache.log4j.Logger.getLogger;
import java.util.List;
import javax.swing.Action;
import org.apache.log4j.Logger;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.innovate.generic.mts.io.MTSRunner;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.lang.Integer.parseInt;
import static java.util.Arrays.asList;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
import javax.swing.Action;
import java.util.List;
public final class Lm2MtsDataSource implements ExternalDataSource {
private static final Logger LOGGER = getLogger(Lm2MtsDataSource.class);
private final Lm2MtsDataItem dataItem = new Lm2MtsDataItem();
private final Lm2MtsDataItem dataItem = new Lm2MtsDataItem(AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);
private MTSRunner runner;
private int mtsPort = -1;

View File

@ -0,0 +1,48 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.innovate.lm2.mts.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum Lm2SensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.0680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x", "0.00"), // gasoline
AFR_90 ("AFR Ethonal", "x*0.6122448979591837", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "x*0.9931972789115646", "0.00"), // diesel
AFR_64 ("AFR Methonal", "x*0.4353741496598639", "0.00"),// methanol
AFR_155 ("AFR LPG", "x*1.054421768707483", "0.00"), // LPG
AFR_172 ("AFR CNG", "x*1.170068027210884", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "x*2.312925170068027", "0.00"); // Hydrogen
private final String units;
private final String expression;
private final String format;
Lm2SensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -19,29 +19,23 @@
package com.romraider.logger.external.mrf.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class MrfDataItem implements ExternalDataItem, DataListener {
private final EcuDataConvertor[] convertors;
private EcuDataConvertor[] convertors;
private final String name;
private double data;
public MrfDataItem(String name, MrfSensorConversions... convertorList) {
public MrfDataItem(String name, ExternalSensorConversions... convertorList) {
super();
this.name = name;
convertors = new EcuDataConvertor[convertorList.length];
int i = 0;
for (MrfSensorConversions convertor : convertorList) {
convertors[i] = new ExternalDataConvertorImpl(
this,
convertor.units(),
convertor.expression(),
convertor.format()
);
i++;
}
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {

View File

@ -19,17 +19,6 @@
package com.romraider.logger.external.mrf.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.mrf.io.MrfRunner;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.AFR;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.EGT;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.FUEL_PRESS;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.MANIFOLD_TEMP;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.MAP;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.OIL_PRESS;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.OIL_TEMP;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_146;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_147;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_155;
@ -37,20 +26,34 @@ import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_34;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_64;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.AFR_90;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.LAMBDA;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.DEG_F;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.DEG_C;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.PSI;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.BAR;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.DEG_C;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.DEG_F;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.KPA;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.LAMBDA;
import static com.romraider.logger.external.mrf.plugin.MrfSensorConversions.PSI;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.AFR;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.EGT;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.FUEL_PRESS;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.MANIFOLD_TEMP;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.MAP;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.OIL_PRESS;
import static com.romraider.logger.external.mrf.plugin.MrfSensorType.OIL_TEMP;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Collections.unmodifiableList;
import javax.swing.Action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.mrf.io.MrfRunner;
public final class MrfDataSource implements ExternalDataSource {
private final Map<MrfSensorType, MrfDataItem> dataItems = new HashMap<MrfSensorType, MrfDataItem>();
private MrfRunner runner;

View File

@ -19,7 +19,9 @@
package com.romraider.logger.external.mrf.plugin;
public enum MrfSensorConversions {
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum MrfSensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.0680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x", "0.00"), // gasoline

View File

@ -28,19 +28,19 @@ public enum MrfSensorType {
FUEL_PRESS(5),
MANIFOLD_TEMP(6);
private final int index;
private final int value;
private MrfSensorType(int index) {
this.index = index;
private MrfSensorType(int value) {
this.value = value;
}
public int getIndex() {
return index;
public int getValue() {
return value;
}
public static MrfSensorType valueOf(int index) {
public static MrfSensorType valueOf(int value) {
for (MrfSensorType type : values()) {
if (type.getIndex() == index) return type;
if (type.getValue() == value) return type;
}
return null;
}

View File

@ -25,11 +25,13 @@ import static com.romraider.logger.external.plx.io.PlxParserImpl.ParserState.EXP
import static com.romraider.logger.external.plx.io.PlxParserImpl.ParserState.EXPECTING_SECOND_HALF_OF_SENSOR_TYPE;
import static com.romraider.logger.external.plx.io.PlxParserImpl.ParserState.EXPECTING_SECOND_HALF_OF_VALUE;
import static com.romraider.logger.external.plx.io.PlxParserImpl.ParserState.EXPECTING_START;
import static com.romraider.logger.external.plx.io.PlxSensorType.valueOf;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.valueOf;
import static org.apache.log4j.Logger.getLogger;
import org.apache.log4j.Logger;
import com.romraider.logger.external.plx.plugin.PlxSensorType;
public final class PlxParserImpl implements PlxParser {
private static final Logger LOGGER = getLogger(PlxParserImpl.class);
@ -74,10 +76,9 @@ public final class PlxParserImpl implements PlxParser {
case EXPECTING_SECOND_HALF_OF_VALUE:
state = EXPECTING_FIRST_HALF_OF_SENSOR_TYPE;
int rawValue = (partialValue << 6) | b;
LOGGER.trace("PLX sensor:" + sensorType + " instance:" + instance + " value:" + rawValue );
return new PlxResponse(sensorType, rawValue);
LOGGER.info("PLX sensor: " + sensorType + " instance: " + instance + " value: " + rawValue );
return new PlxResponse(sensorType, instance, rawValue);
}
return null;
}

View File

@ -19,12 +19,16 @@
package com.romraider.logger.external.plx.io;
import com.romraider.logger.external.plx.plugin.PlxSensorType;
public final class PlxResponse {
public PlxSensorType sensor;
public int instance;
public int value;
public PlxResponse(PlxSensorType sensor, int value) {
public PlxResponse(PlxSensorType sensor, int instance, int value) {
this.sensor = sensor;
this.instance = instance;
this.value = value;
}
}

View File

@ -20,8 +20,12 @@
package com.romraider.logger.external.plx.io;
import com.romraider.logger.external.core.Stoppable;
import static com.romraider.logger.external.plx.io.PlxSensorType.UNKNOWN;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.UNKNOWN;
import com.romraider.logger.external.plx.plugin.PlxDataItem;
import com.romraider.logger.external.plx.plugin.PlxSensorType;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
import java.util.Map;
@ -45,12 +49,9 @@ public final class PlxRunner implements Stoppable {
PlxResponse response = parser.pushByte(b);
if (!isValid(response)) continue;
PlxDataItem item = dataItems.get(response.sensor);
if (item != null) {
if (item != null && (response.instance == item.getInstance())) {
item.setRaw(response.value);
}
else {
LOGGER.error("plx sensor ^ is not supported");
}
}
} catch (Throwable t) {
LOGGER.error("Error occurred", t);

View File

@ -1,53 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.plx.io;
public enum PlxSensorUnits {
WIDEBAND_AFR_LAMBDA(0),
WIDEBAND_AFR_GASOLINE147(1),
WIDEBAND_AFR_DIESEL146(2),
WIDEBAND_AFR_METHANOL64(3),
WIDEBAND_AFR_ETHANOL90(4),
WIDEBAND_AFR_LPG155(5),
WIDEBAND_AFR_CNG172(6),
EXHAUST_GAS_TEMPERATURE_CELSIUS(0),
EXHAUST_GAS_TEMPERATURE_FAHRENHEIT(1),
AIR_INTAKE_TEMPERATURE_CELSUIS(0),
AIR_INTAKE_TEMPERATURE_FAHRENHEIT(1),
KNOCK(0);
private final int value;
private PlxSensorUnits(int value) {
this.value = value;
}
public int v() {
return value;
}
public static PlxSensorUnits valueOf(int value) {
PlxSensorUnits[] types = values();
for (PlxSensorUnits type : types) {
if (type.v() == value) return type;
}
throw new IllegalArgumentException("Unknown PLX Sensor Units: " + value);
}
}

View File

@ -23,7 +23,25 @@ import com.romraider.io.serial.connection.SerialConnection;
import static com.romraider.util.ThreadUtil.sleep;
public final class TestPlxConnection implements SerialConnection {
private final byte[] data = {(byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x0f, 0x40};
// max byte value for address and data is 0x3F
private final byte[] data = {(byte) 0x80,
0x00, 0x00, 0x00, 0x00, 0x20, // AFR 0
0x00, 0x00, 0x01, 0x00, 0x05, // AFR 1
0x00, 0x01, 0x00, 0x3F, 0x3F, // EGT 0
0x00, 0x02, 0x00, 0x02, 0x30, // Fluid Temp 0
0x40,
(byte) 0x80,
0x00, 0x00, 0x00, 0x00, 0x10, // AFR 0
0x00, 0x00, 0x01, 0x00, 0x07, // AFR 1
0x00, 0x01, 0x00, 0x2F, 0x3F, // EGT 0
0x00, 0x02, 0x00, 0x01, 0x00, // Fluid Temp 0
0x40,
(byte) 0x80,
0x00, 0x00, 0x00, 0x00, 0x08, // AFR 0
0x00, 0x00, 0x01, 0x00, 0x09, // AFR 1
0x00, 0x01, 0x00, 0x1F, 0x3F, // EGT 0
0x00, 0x02, 0x00, 0x00, 0x3F, // Fluid Temp 0
0x40};
private int index;
private byte[] result = new byte[1];

View File

@ -1,27 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.plx.plugin;
import com.romraider.logger.external.plx.io.PlxSensorType;
import com.romraider.logger.external.plx.io.PlxSensorUnits;
public interface PlxConvertor {
double convert(int raw, PlxSensorType sensorType, PlxSensorUnits units);
}

View File

@ -1,184 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.plx.plugin;
import com.romraider.logger.external.plx.io.PlxSensorType;
import static com.romraider.logger.external.plx.io.PlxSensorType.EXHAUST_GAS_TEMPERATURE;
import static com.romraider.logger.external.plx.io.PlxSensorType.WIDEBAND_AFR;
import com.romraider.logger.external.plx.io.PlxSensorUnits;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.EXHAUST_GAS_TEMPERATURE_CELSIUS;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.EXHAUST_GAS_TEMPERATURE_FAHRENHEIT;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_CNG172;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_DIESEL146;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_ETHANOL90;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_GASOLINE147;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_LAMBDA;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_LPG155;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_METHANOL64;
public final class PlxConvertorImpl implements PlxConvertor {
public double convert(int raw, PlxSensorType sensorType, PlxSensorUnits units) {
if (sensorType == WIDEBAND_AFR) {
if (units == WIDEBAND_AFR_LAMBDA) return (raw / 3.75 + 68) / 100;
if (units == WIDEBAND_AFR_GASOLINE147) return (raw / 2.55 + 100) / 10;
if (units == WIDEBAND_AFR_DIESEL146) return (raw / 2.58 + 100) / 10;
if (units == WIDEBAND_AFR_METHANOL64) return (raw / 5.856 + 43.5) / 10;
if (units == WIDEBAND_AFR_ETHANOL90) return (raw / 4.167 + 61.7) / 10;
if (units == WIDEBAND_AFR_LPG155) return (raw / 2.417 + 105.6) / 10;
if (units == WIDEBAND_AFR_CNG172) return (raw / 2.18 + 117) / 10;
}
if (sensorType == EXHAUST_GAS_TEMPERATURE) {
if (units == EXHAUST_GAS_TEMPERATURE_CELSIUS) return raw;
if (units == EXHAUST_GAS_TEMPERATURE_FAHRENHEIT) return (raw / .555 + 32);
}
return 0.0;
/* To be supported in the future... maybe..
else if (sensorType == PlxSensorType.FLUID_TEMPERATURE)
{
if (units == 0) //Degrees Celsius Water
return raw;
else if (units == 1) //Degrees Fahrenheit Water
return (raw / .555 + 32);
else if (units == 2) //Degrees Celsius Oil
return raw;
else if (units == 3) //Degrees Fahrenheit Oil
return (raw / .555 + 32);
}
else if (sensorType == PlxSensorType.VACUUM) //Vac
{
if (units == 0) //in/Hg (inch Mercury)
return -(raw / 11.39 - 29.93);
else if (units == 1) //mm/Hg (millimeters Mercury)
return -(raw * 2.23 + 760.4);
}
else if (sensorType == PlxSensorType.BOOST) //Boost
{
if (units == 0) //0-30 PSI
return raw / 22.73;
else if (units == 1) //0-2 kg/cm^2
return raw / 329.47;
else if (units == 2) //0-15 PSI
return raw / 22.73;
else if (units == 3) //0-1 kg/cm^2
return raw / 329.47;
else if (units == 4) //0-60 PSI
return raw / 22.73;
else if (units == 5) //0-4 kg/cm^2
return raw / 329.47;
}
else if (sensorType == PlxSensorType.AIR_INTAKE_TEMPERATURE) //AIT
{
if (units == 0) //Celsius
return raw;
else if (units == 1) //Fahrenheit
return (raw / .555 + 32);
}
else if (sensorType == PlxSensorType.RPM) //RPM
{
return raw * 19.55; //RPM
}
else if (sensorType == PlxSensorType.VEHICLE_SPEED) //Speed
{
if (units == 0) //MPH
return raw / 6.39;
else if (units == 1) //KMH
return raw / 3.97;
}
else if (sensorType == PlxSensorType.THROTTLE_POSITION) //TPS
{
return raw; //Throttle Position %
}
else if (sensorType == PlxSensorType.ENGINE_LOAD) //Engine Load
{
return raw; //Engine Load %
}
else if (sensorType == PlxSensorType.FLUID_PRESSURE) //Fluid Pressure
{
if (units == 0) //PSI Fuel
return raw / 5.115;
else if (units == 1) //kg/cm^2 Fuel
return raw / 72.73;
else if (units == 2) //Bar Fuel
return raw / 74.22;
else if (units == 3) //PSI Oil
return raw / 5.115;
else if (units == 4) //kg/cm^2 Oil
return raw / 72.73;
else if (units == 5) //Bar Oil
return raw / 74.22;
}
else if (sensorType == PlxSensorType.TIMING) //Engine timing
{
return raw - 64; //Degree Timing
}
else if (sensorType == PlxSensorType.MANIFOLD_ABSOLUTE_PRESSURE) //MAP
{
if (units == 0) //kPa
return raw;
else if (units == 1) //inHg
return raw / 3.386;
}
else if (sensorType == PlxSensorType.MASS_AIR_FLOW) //MAF
{
if (units == 0) //g/s (grams per second)
return raw;
else if (units == 1) //lb/min (pounds per minute)
return raw / 7.54;
}
else if (sensorType == PlxSensorType.SHORT_TERM_FUEL_TRIM) //Short term fuel trim
{
return raw - 100; //Fuel trim %
}
else if (sensorType == PlxSensorType.LONG_TERM_FUEL_TRIM) //Long term fuel trim
{
return raw - 100; //Fuel trim %
}
else if (sensorType == PlxSensorType.NARROWBAND_AFR) //Narrowband O2 sensor
{
if (units == 0) //Percent
return raw;
else if (units == 1) //Volts
return raw / 78.43;
}
else if (sensorType == PlxSensorType.FUEL_LEVEL) //Fuel level
{
return raw; //Fuel Level %
}
else if (sensorType == PlxSensorType.VOLTAGE) //Volts
{
return raw / 51.15; //Volt Meter Volts
}
else if (sensorType == PlxSensorType.KNOCK) //Knock
{
return raw / 204.6; //Knock volts 0-5
}
else if (sensorType == PlxSensorType.DUTY_CYCLE) //Duty cycle
{
if (units == 0) //Positive Duty
return raw / 10.23;
else if (units == 1) //Negative Duty
return 100 - (raw / 10.23);
}
return 0.0;
*/
}
}

View File

@ -22,5 +22,8 @@ package com.romraider.logger.external.plx.plugin;
import com.romraider.logger.external.core.ExternalDataItem;
public interface PlxDataItem extends ExternalDataItem {
void setRaw(int raw);
void setRaw(int raw);
int getInstance();
}

View File

@ -19,24 +19,23 @@
package com.romraider.logger.external.plx.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.plx.io.PlxSensorType;
import com.romraider.logger.external.plx.io.PlxSensorUnits;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class PlxDataItemImpl implements PlxDataItem {
private final PlxConvertor convertor = new PlxConvertorImpl();
private final PlxSensorUnits sensorUnits;
private final PlxSensorType sensorType;
private final String units;
private EcuDataConvertor[] convertors;
private final String name;
private int instance;
private int raw;
public PlxDataItemImpl(String name, String units, PlxSensorType sensorType, PlxSensorUnits sensorUnits) {
this.sensorType = sensorType;
this.sensorUnits = sensorUnits;
this.units = units;
this.name = name;
public PlxDataItemImpl(String name, int instance, ExternalSensorConversions... convertorList) {
super();
this.name = name;
this.instance = instance;
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
@ -47,30 +46,19 @@ public final class PlxDataItemImpl implements PlxDataItem {
return "PLX " + name + " data";
}
// public String getUnits() {
// return units;
// }
public int getInstance() {
return instance;
}
public double getData() {
return convertor.convert(raw, sensorType, sensorUnits);
return raw;
}
public void setRaw(int raw) {
this.raw = raw;
}
// public String getFormat() {
// return "0.##";
// }
//
// public String getExpression() {
// return "x";
// }
public EcuDataConvertor[] getConvertors() {
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,32 +19,106 @@
package com.romraider.logger.external.plx.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.plx.io.PlxRunner;
import com.romraider.logger.external.plx.io.PlxSensorType;
import static com.romraider.logger.external.plx.io.PlxSensorType.WIDEBAND_AFR;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_GASOLINE147;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.WIDEBAND_AFR_LAMBDA;
import static com.romraider.logger.external.plx.io.PlxSensorType.EXHAUST_GAS_TEMPERATURE;
import static com.romraider.logger.external.plx.io.PlxSensorUnits.EXHAUST_GAS_TEMPERATURE_CELSIUS;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_146;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_147;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_155;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_172;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_34;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_64;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.AFR_90;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.BATTERY;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.BOOST_BAR;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.BOOST_KGCM2;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.BOOST_KPA;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.BOOST_PSI;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.DC_NEG;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.DC_POS;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.DEGREES;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.DEG_C;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.DEG_F;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.FLUID_BAR;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.FLUID_KGCM2;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.FLUID_KPA;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.FLUID_PSI;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.FUEL_TRIM;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.KNOCK_VDC;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.KPH;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.LAMBDA;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAF_GS;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAF_LB;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAP_BAR;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAP_KGCM2;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAP_KPA;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MAP_PSI;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.MPH;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.NB_P;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.NB_V;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.PERCENT;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.RPM;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.VACUUM_IN;
import static com.romraider.logger.external.plx.plugin.PlxSensorConversions.VACUUM_MM;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.AIR_INTAKE_TEMPERATURE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.BOOST;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.DUTY_CYCLE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.ENGINE_LOAD;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.ENGINE_SPEED;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.EXHAUST_GAS_TEMPERATURE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.FLUID_PRESSURE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.FLUID_TEMPERATURE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.FUEL_LEVEL;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.KNOCK;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.LONG_TERM_FUEL_TRIM;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.MANIFOLD_ABSOLUTE_PRESSURE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.MASS_AIR_FLOW;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.NARROWBAND_AFR;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.SHORT_TERM_FUEL_TRIM;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.THROTTLE_POSITION;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.TIMING;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.VACUUM;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.VEHICLE_SPEED;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.VOLTAGE;
import static com.romraider.logger.external.plx.plugin.PlxSensorType.WIDEBAND;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import javax.swing.Action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.plx.io.PlxRunner;
public final class PlxDataSource implements ExternalDataSource {
private final Map<PlxSensorType, PlxDataItem> dataItems = new HashMap<PlxSensorType, PlxDataItem>();
private PlxRunner runner;
private String port;
{
dataItems.put(WIDEBAND_AFR, new PlxDataItemImpl("Wideband AFR", "AFR", WIDEBAND_AFR, WIDEBAND_AFR_GASOLINE147));
// dataItems.put(WIDEBAND_AFR, new PlxDataItemImpl("Wideband Lambda", "Lambda", WIDEBAND_AFR, WIDEBAND_AFR_LAMBDA));
dataItems.put(EXHAUST_GAS_TEMPERATURE, new PlxDataItemImpl("EGT", "C", EXHAUST_GAS_TEMPERATURE, EXHAUST_GAS_TEMPERATURE_CELSIUS));
dataItems.put(WIDEBAND, new PlxDataItemImpl("O2 - Wideband", 0, AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34));
dataItems.put(EXHAUST_GAS_TEMPERATURE, new PlxDataItemImpl("EGT", 0, DEG_C, DEG_F));
dataItems.put(FLUID_TEMPERATURE, new PlxDataItemImpl("Oil/H20 Temperature", 0, DEG_C, DEG_F));
dataItems.put(VACUUM, new PlxDataItemImpl("Manifold Vaccum", 0, VACUUM_IN, VACUUM_MM));
dataItems.put(BOOST, new PlxDataItemImpl("Manifold Boost", 0, BOOST_PSI, BOOST_BAR, BOOST_KPA, BOOST_KGCM2));
dataItems.put(AIR_INTAKE_TEMPERATURE, new PlxDataItemImpl("Intake Air Temperature", 0, DEG_C, DEG_F));
dataItems.put(ENGINE_SPEED, new PlxDataItemImpl("Engine Speed", 0, RPM));
dataItems.put(VEHICLE_SPEED, new PlxDataItemImpl("Vehicle Speed", 0, MPH, KPH));
dataItems.put(THROTTLE_POSITION, new PlxDataItemImpl("Throttle Position", 0, PERCENT));
dataItems.put(ENGINE_LOAD, new PlxDataItemImpl("Engine Load", 0, PERCENT));
dataItems.put(FLUID_PRESSURE, new PlxDataItemImpl("Fuel/0il Pressure", 0, FLUID_PSI, FLUID_BAR, FLUID_KPA, FLUID_KGCM2));
dataItems.put(TIMING, new PlxDataItemImpl("Engine Timing", 0, DEGREES));
dataItems.put(MANIFOLD_ABSOLUTE_PRESSURE, new PlxDataItemImpl("Manifold Absolute Pressure", 0, MAP_PSI, MAP_BAR, MAP_KPA, MAP_KGCM2));
dataItems.put(MASS_AIR_FLOW, new PlxDataItemImpl("Mass Air Flow", 0, MAF_GS, MAF_LB));
dataItems.put(SHORT_TERM_FUEL_TRIM, new PlxDataItemImpl("Fuel Trim - Short Term", 0, FUEL_TRIM));
dataItems.put(LONG_TERM_FUEL_TRIM, new PlxDataItemImpl("Fuel Trim - Long Term", 0, FUEL_TRIM));
dataItems.put(NARROWBAND_AFR, new PlxDataItemImpl("O2 - Narrowband", 0, NB_P, NB_V));
dataItems.put(FUEL_LEVEL, new PlxDataItemImpl("Fuel Level", 0, PERCENT));
dataItems.put(VOLTAGE, new PlxDataItemImpl("Battery Voltage", 0, BATTERY));
dataItems.put(KNOCK, new PlxDataItemImpl("Knock", 0, KNOCK_VDC));
dataItems.put(DUTY_CYCLE, new PlxDataItemImpl("Duty Cycle", 0, DC_POS, DC_NEG));
}
public String getId() {
@ -56,7 +130,7 @@ public final class PlxDataSource implements ExternalDataSource {
}
public String getVersion() {
return "0.03";
return "0.04";
}
public List<? extends ExternalDataItem> getDataItems() {

View File

@ -0,0 +1,77 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.plx.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum PlxSensorConversions implements ExternalSensorConversions {
LAMBDA ("Lambda", "(x/3.75+68)/100", "0.00"),
AFR_147 ("AFR Gasoline", "(x/2.55+100)/10", "0.00"), // gasoline
AFR_90 ("AFR Ethonal", "(x/4.167+61.7)/10", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "(x/2.58+100)/10", "0.00"), // diesel
AFR_64 ("AFR Methonal", "(x/5.856+43.5)/10", "0.00"),// methanol
AFR_155 ("AFR LPG", "(x/2.417+105.6)/10", "0.00"), // LPG
AFR_172 ("AFR CNG", "(x/2.18+117)/10", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "(x/3.75+68)*0.34", "0.00"), // Hydrogen
DEG_C ("C", "x", "0.0"),
DEG_F ("F", "(x/.555+32)", "0.0"),
VACUUM_IN ("in/Hg", "-(x/11.39-29.93)", "0.00"),
VACUUM_MM ("mm/Hg", "-(x*2.23+760.4)", "0.00"),
BOOST_PSI ("psi", "x/22.73", "0.00"),
BOOST_BAR ("bar", "x*0.00303333", "0.00"), // converts from PSI to bar
BOOST_KPA ("kPa", "x*0.30333292", "0.0"), // converts from PSI to kpa
BOOST_KGCM2 ("kg/cm^2", "x/329.47", "0.00"),
RPM ("rpm", "x*19.55", "0"),
MPH ("mph", "x/6.39", "0.0"),
KPH ("kph", "x/3.97", "0.0"),
PERCENT ("%", "x", "0.0"),
FLUID_PSI ("psi", "x/5.115", "0.00"),
FLUID_BAR ("bar", "x/74.22", "0.00"),
FLUID_KPA ("kPa", "x*1.34794864", "0.00"), // converts from PSI to kpa
FLUID_KGCM2 ("kg/cm^2", "x/72.73", "0.00"),
DEGREES ("deg", "x-64", "0.00"),
MAP_PSI ("psi", "x*0.14503774", "0.00"), // converts from kPa
MAP_BAR ("bar", "x*0.01", "0.00"), // converts from kPa
MAP_KPA ("kPa", "x", "0.0"),
MAP_KGCM2 ("kg/cm^2", "x*0.01019716", "0.00"), // converts from kPa
MAF_GS ("g/sec", "x", "0.00"),
MAF_LB ("lb/min", "x/7.54", "0.00"),
FUEL_TRIM ("%", "x-100", "0.00"),
NB_P ("%", "x", "0.00"),
NB_V ("vdc", "x/78.43", "0.00"),
BATTERY ("vdc", "x/51.15", "0.00"),
KNOCK_VDC ("vdc", "x/204.6", "0.00"),
DC_POS ("+%", "x/10.23", "0.0"),
DC_NEG ("-%", "100-(x/10.23)", "0.0");
private final String units;
private final String expression;
private final String format;
PlxSensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -17,16 +17,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.plx.io;
package com.romraider.logger.external.plx.plugin;
public enum PlxSensorType {
WIDEBAND_AFR(0),
WIDEBAND(0),
EXHAUST_GAS_TEMPERATURE(1),
FLUID_TEMPERATURE(2),
VACUUM(3),
BOOST(4),
AIR_INTAKE_TEMPERATURE(5),
RPM(6),
ENGINE_SPEED(6),
VEHICLE_SPEED(7),
THROTTLE_POSITION(8),
ENGINE_LOAD(9),
@ -41,7 +41,7 @@ public enum PlxSensorType {
VOLTAGE(18),
KNOCK(19),
DUTY_CYCLE(20),
UNKNOWN(4032);
UNKNOWN(-1);
private final int value;
@ -54,8 +54,7 @@ public enum PlxSensorType {
}
public static PlxSensorType valueOf(int value) {
PlxSensorType[] types = values();
for (PlxSensorType type : types) {
for (PlxSensorType type : values()) {
if (type.v() == value) return type;
}
throw new IllegalArgumentException("Unknown PLX Sensor Type: " + value);

View File

@ -19,18 +19,18 @@
package com.romraider.logger.external.te.io;
import com.romraider.logger.external.core.ExternalSensorType;
import com.romraider.logger.external.core.Stoppable;
import com.romraider.logger.external.te.plugin.TEDataItem;
import com.romraider.logger.external.te.plugin.TESensorType;
import static com.romraider.logger.external.te.plugin.TESensorType.WBO2;
import static com.romraider.logger.external.te.plugin.TESensorType.USR1;
import static com.romraider.logger.external.te.plugin.TESensorType.USR2;
import static com.romraider.logger.external.te.plugin.TESensorType.USR3;
import static com.romraider.logger.external.te.plugin.TESensorType.TC1;
import static com.romraider.logger.external.te.plugin.TESensorType.TC2;
import static com.romraider.logger.external.te.plugin.TESensorType.TC3;
import static com.romraider.logger.external.te.plugin.TESensorType.TorVss;
import static com.romraider.logger.external.te.plugin.TESensorType.RPM;
import static com.romraider.logger.external.core.ExternalSensorType.WIDEBAND;
import static com.romraider.logger.external.core.ExternalSensorType.USER1;
import static com.romraider.logger.external.core.ExternalSensorType.USER2;
import static com.romraider.logger.external.core.ExternalSensorType.USER3;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE1;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE2;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE3;
import static com.romraider.logger.external.core.ExternalSensorType.TorVss;
import static com.romraider.logger.external.core.ExternalSensorType.ENGINE_SPEED;
import static com.romraider.util.ByteUtil.asUnsignedInt;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
@ -40,14 +40,14 @@ import java.util.Map;
public final class TERunner implements Stoppable {
private static final Logger LOGGER = getLogger(TERunner.class);
private final Map<TESensorType, TEDataItem> dataItems;
private final Map<ExternalSensorType, TEDataItem> dataItems;
private final TEConnection connection;
private boolean stop;
private byte byteSum;
private int sequenceNo;
private int lastSequenceNo = -1;
public TERunner(String port, Map<TESensorType, TEDataItem> dataItems) {
public TERunner(String port, Map<ExternalSensorType, TEDataItem> dataItems) {
this.connection = new TEConnectionImpl(port);
this.dataItems = dataItems;
}
@ -103,43 +103,43 @@ public final class TERunner implements Stoppable {
lastSequenceNo = sequenceNo;
}
else {
TEDataItem dataItem = dataItems.get(WBO2);
TEDataItem dataItem = dataItems.get(WIDEBAND);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(5));
int raw2 = asUnsignedInt(buffer.get(6));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(USR1);
dataItem = dataItems.get(USER1);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(9));
int raw2 = asUnsignedInt(buffer.get(10));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(USR2);
dataItem = dataItems.get(USER2);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(11));
int raw2 = asUnsignedInt(buffer.get(12));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(USR3);
dataItem = dataItems.get(USER3);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(13));
int raw2 = asUnsignedInt(buffer.get(14));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(TC1);
dataItem = dataItems.get(THERMACOUPLE1);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(15));
int raw2 = asUnsignedInt(buffer.get(16));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(TC2);
dataItem = dataItems.get(THERMACOUPLE2);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(17));
int raw2 = asUnsignedInt(buffer.get(18));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(TC3);
dataItem = dataItems.get(THERMACOUPLE3);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(19));
int raw2 = asUnsignedInt(buffer.get(20));
@ -151,7 +151,7 @@ public final class TERunner implements Stoppable {
int raw2 = asUnsignedInt(buffer.get(22));
dataItem.setRaw(raw1, raw2);
}
dataItem = dataItems.get(RPM);
dataItem = dataItems.get(ENGINE_SPEED);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(23));
int raw2 = asUnsignedInt(buffer.get(24));

View File

@ -20,27 +20,19 @@
package com.romraider.logger.external.te.plugin;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.ExternalSensorConversions;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
public final class TEDataItemImpl implements TEDataItem {
private final EcuDataConvertor[] convertors;
private EcuDataConvertor[] convertors;
private final String name;
private int[] raw;
public TEDataItemImpl(String name, TESensorConversions... convertorList) {
super();
public TEDataItemImpl(String name, ExternalSensorConversions... convertorList) {
super();
this.name = name;
convertors = new EcuDataConvertor[convertorList.length];
int i = 0;
for (TESensorConversions convertor :convertorList) {
convertors[i] = new ExternalDataConvertorImpl(
this,
convertor.units(),
convertor.expression(),
convertor.format()
);
i++;
}
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {

View File

@ -19,54 +19,58 @@
package com.romraider.logger.external.te.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.te.io.TERunner;
import static com.romraider.logger.external.te.plugin.TESensorType.WBO2;
import static com.romraider.logger.external.te.plugin.TESensorType.USR1;
import static com.romraider.logger.external.te.plugin.TESensorType.USR2;
import static com.romraider.logger.external.te.plugin.TESensorType.USR3;
import static com.romraider.logger.external.te.plugin.TESensorType.TC1;
import static com.romraider.logger.external.te.plugin.TESensorType.TC2;
import static com.romraider.logger.external.te.plugin.TESensorType.TC3;
import static com.romraider.logger.external.te.plugin.TESensorType.TorVss;
import static com.romraider.logger.external.te.plugin.TESensorType.RPM;
import static com.romraider.logger.external.te.plugin.TESensorConversions.LAMBDA;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_147;
import static com.romraider.logger.external.core.ExternalSensorType.ENGINE_SPEED;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE1;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE2;
import static com.romraider.logger.external.core.ExternalSensorType.THERMACOUPLE3;
import static com.romraider.logger.external.core.ExternalSensorType.TorVss;
import static com.romraider.logger.external.core.ExternalSensorType.USER1;
import static com.romraider.logger.external.core.ExternalSensorType.USER2;
import static com.romraider.logger.external.core.ExternalSensorType.USER3;
import static com.romraider.logger.external.core.ExternalSensorType.WIDEBAND;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_146;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_90;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_64;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_147;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_155;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_172;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_34;
import static com.romraider.logger.external.te.plugin.TESensorConversions.VDC;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_64;
import static com.romraider.logger.external.te.plugin.TESensorConversions.AFR_90;
import static com.romraider.logger.external.te.plugin.TESensorConversions.LAMBDA;
import static com.romraider.logger.external.te.plugin.TESensorConversions.RPM_4;
import static com.romraider.logger.external.te.plugin.TESensorConversions.TC;
import static com.romraider.logger.external.te.plugin.TESensorConversions.THERM;
import static com.romraider.logger.external.te.plugin.TESensorConversions.RPM_4;
import static com.romraider.logger.external.te.plugin.TESensorConversions.VDC;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Collections.unmodifiableList;
import javax.swing.Action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.core.ExternalSensorType;
import com.romraider.logger.external.te.io.TERunner;
public final class TEDataSource implements ExternalDataSource {
private final Map<TESensorType, TEDataItem> dataItems = new HashMap<TESensorType, TEDataItem>();
private final Map<ExternalSensorType, TEDataItem> dataItems = new HashMap<ExternalSensorType, TEDataItem>();
private TERunner runner;
private String port;
{
dataItems.put(WBO2, new TEDataItemImpl("Wideband", LAMBDA, AFR_147, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34));
dataItems.put(USR1, new TEDataItemImpl("User 1", VDC));
dataItems.put(USR2, new TEDataItemImpl("User 2", VDC));
dataItems.put(USR3, new TEDataItemImpl("User 3", VDC));
dataItems.put(TC1, new TEDataItemImpl("Thermocouple 1", TC));
dataItems.put(TC2, new TEDataItemImpl("Thermocouple 2", TC));
dataItems.put(TC3, new TEDataItemImpl("Thermocouple 3", TC));
dataItems.put(WIDEBAND, new TEDataItemImpl("Wideband", LAMBDA, AFR_147, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34));
dataItems.put(USER1, new TEDataItemImpl("User 1", VDC));
dataItems.put(USER2, new TEDataItemImpl("User 2", VDC));
dataItems.put(USER3, new TEDataItemImpl("User 3", VDC));
dataItems.put(THERMACOUPLE1, new TEDataItemImpl("Thermocouple 1", TC));
dataItems.put(THERMACOUPLE2, new TEDataItemImpl("Thermocouple 2", TC));
dataItems.put(THERMACOUPLE3, new TEDataItemImpl("Thermocouple 3", TC));
dataItems.put(TorVss, new TEDataItemImpl("Thermistor or Vss", THERM));
dataItems.put(RPM, new TEDataItemImpl("Engine Speed (4-cyl)", RPM_4));
dataItems.put(ENGINE_SPEED, new TEDataItemImpl("Engine Speed (4-cyl)", RPM_4));
}
public String getId() {

View File

@ -19,7 +19,9 @@
package com.romraider.logger.external.te.plugin;
public enum TESensorConversions {
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum TESensorConversions implements ExternalSensorConversions {
LAMBDA ("Lambda", "x/8192+0.5", "0.00"),
AFR_147 ("AFR Gasoline", "(x/8192+0.5)*14.7", "0.00"),// gasoline
AFR_90 ("AFR Ethonal", "(x/8192+0.5)*9.0", "0.00"), // ethanol

View File

@ -1,32 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.te.plugin;
public enum TESensorType {
WBO2,
USR1,
USR2,
USR3,
TC1,
TC2,
TC3,
TorVss,
RPM
}

View File

@ -20,14 +20,15 @@
package com.romraider.logger.external.txstuner.io;
import com.romraider.io.serial.connection.SerialConnection;
import com.romraider.io.serial.connection.SerialConnectionImpl;
import com.romraider.logger.external.txstuner.plugin.TxsTunerDataItem;
import com.romraider.logger.external.core.Stoppable;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import static org.apache.log4j.Logger.getLogger;
import static com.romraider.util.ParamChecker.isNullOrEmpty;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
import org.apache.log4j.Logger;
import com.romraider.io.serial.connection.SerialConnection;
import com.romraider.io.serial.connection.SerialConnectionImpl;
import com.romraider.logger.external.core.Stoppable;
import com.romraider.logger.external.txstuner.plugin.TxsTunerDataItem;
public final class TxsTunerRunner implements Stoppable {
private static final Logger LOGGER = getLogger(TxsTunerRunner.class);

View File

@ -19,27 +19,31 @@
package com.romraider.logger.external.txstuner.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.DataListener;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class TxsTunerDataItem implements ExternalDataItem, DataListener {
private double data;
private EcuDataConvertor[] convertors;
private double data;
public TxsTunerDataItem(ExternalSensorConversions... convertorList) {
super();
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
return "TXS Tuner AFR";
}
public String getDescription() {
return "TXS Tuner AFR data";
return "TXS Tuner Wideband data";
}
// public String getUnits() {
// return "AFR";
// }
public double getData() {
return data;
}
@ -48,19 +52,7 @@ public final class TxsTunerDataItem implements ExternalDataItem, DataListener {
this.data = data;
}
// public String getFormat() {
// return "0.##";
// }
//
// public String getExpression() {
// return "x";
// }
public EcuDataConvertor[] getConvertors() {
String units = "AFR";
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,18 +19,29 @@
package com.romraider.logger.external.txstuner.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.txstuner.io.TxsTunerRunner;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_146;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_147;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_155;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_172;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_34;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_64;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.AFR_90;
import static com.romraider.logger.external.txstuner.plugin.TxsTunerSensorConversions.LAMBDA;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Arrays.asList;
import javax.swing.Action;
import java.util.List;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.txstuner.io.TxsTunerRunner;
public class TxsTunerDataSource implements ExternalDataSource {
private TxsTunerDataItem dataItem = new TxsTunerDataItem();
private TxsTunerDataItem dataItem = new TxsTunerDataItem(AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34);
private TxsTunerRunner runner;
private String port;
@ -43,7 +54,7 @@ public class TxsTunerDataSource implements ExternalDataSource {
}
public String getVersion() {
return "0.01";
return "0.02";
}
public List<? extends ExternalDataItem> getDataItems() {

View File

@ -0,0 +1,48 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.txstuner.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum TxsTunerSensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.0680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x", "0.00"), // gasoline
AFR_90 ("AFR Ethonal", "x*0.6122448979591837", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "x*0.9931972789115646", "0.00"), // diesel
AFR_64 ("AFR Methonal", "x*0.4353741496598639", "0.00"),// methanol
AFR_155 ("AFR LPG", "x*1.054421768707483", "0.00"), // LPG
AFR_172 ("AFR CNG", "x*1.170068027210884", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "x*2.312925170068027", "0.00"); // Hydrogen
private final String units;
private final String expression;
private final String format;
TxsTunerSensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -19,38 +19,38 @@
package com.romraider.logger.external.zt2.io;
import com.romraider.logger.external.core.Stoppable;
import com.romraider.logger.external.zt2.plugin.ZT2DataItem;
import com.romraider.logger.external.zt2.plugin.ZT2SensorType;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.AFR;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.EGT;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.MAP;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.RPM;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.TPS;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.USR;
import static com.romraider.util.HexUtil.asHex;
import org.apache.log4j.Logger;
import static java.lang.System.currentTimeMillis;
import static com.romraider.logger.external.core.ExternalSensorType.EGT;
import static com.romraider.logger.external.core.ExternalSensorType.ENGINE_SPEED;
import static com.romraider.logger.external.core.ExternalSensorType.MAP;
import static com.romraider.logger.external.core.ExternalSensorType.TPS;
import static com.romraider.logger.external.core.ExternalSensorType.USER1;
import static com.romraider.logger.external.core.ExternalSensorType.WIDEBAND;
import static com.romraider.util.ByteUtil.asUnsignedInt;
import static org.apache.log4j.Logger.getLogger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.romraider.logger.external.core.ExternalSensorType;
import com.romraider.logger.external.core.Stoppable;
import com.romraider.logger.external.zt2.plugin.ZT2DataItem;
public final class ZT2Runner implements Stoppable {
private static final Logger LOGGER = getLogger(ZT2Runner.class);
private final Map<ZT2SensorType, ZT2DataItem> dataItems;
private final Map<ExternalSensorType, ZT2DataItem> dataItems;
private final ZT2Connection connection;
private boolean stop;
public ZT2Runner(String port, Map<ZT2SensorType, ZT2DataItem> dataItems) {
public ZT2Runner(String port, Map<ExternalSensorType, ZT2DataItem> dataItems) {
this.connection = new ZT2ConnectionImpl(port);
this.dataItems = dataItems;
}
public void run() {
try {
//Runtime rt = Runtime.getRuntime();
boolean packetStarted = false;
List<Byte> buffer = new ArrayList<Byte>(14);
while (!stop) {
@ -67,54 +67,53 @@ public final class ZT2Runner implements Stoppable {
} else if (packetStarted && buffer.size() <= 14) {
buffer.add(b);
ZT2DataItem dataItem = dataItems.get(WIDEBAND);
switch (buffer.size()) {
case 4:
ZT2DataItem afrDataItem = dataItems.get(AFR);
if (afrDataItem != null) {
int raw = convertAsUnsignedByteToInt(buffer.get(3));
afrDataItem.setRaw(raw);
if (dataItem != null) {
int raw = asUnsignedInt(buffer.get(3));
dataItem.setRaw(raw);
}
break;
case 6:
ZT2DataItem egtDataItem = dataItems.get(EGT);
if (egtDataItem != null) {
int raw1 = convertAsUnsignedByteToInt(buffer.get(4));
int raw2 = convertAsUnsignedByteToInt(buffer.get(5));
egtDataItem.setRaw(raw1, raw2);
dataItem = dataItems.get(EGT);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(4));
int raw2 = asUnsignedInt(buffer.get(5));
dataItem.setRaw(raw1, raw2);
}
break;
case 8:
ZT2DataItem rpmDataItem = dataItems.get(RPM);
if (rpmDataItem != null) {
int raw1 = convertAsUnsignedByteToInt(buffer.get(6));
int raw2 = convertAsUnsignedByteToInt(buffer.get(7));
rpmDataItem.setRaw(raw1, raw2);
dataItem = dataItems.get(ENGINE_SPEED);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(6));
int raw2 = asUnsignedInt(buffer.get(7));
dataItem.setRaw(raw1, raw2);
}
break;
case 10:
ZT2DataItem mapDataItem = dataItems.get(MAP);
if (mapDataItem != null) {
int raw1 = convertAsUnsignedByteToInt(buffer.get(8));
int raw2 = convertAsUnsignedByteToInt(buffer.get(9));
mapDataItem.setRaw(raw1, raw2);
dataItem = dataItems.get(MAP);
if (dataItem != null) {
int raw1 = asUnsignedInt(buffer.get(8));
int raw2 = asUnsignedInt(buffer.get(9));
dataItem.setRaw(raw1, raw2);
}
break;
case 11:
ZT2DataItem tpsDataItem = dataItems.get(TPS);
if (tpsDataItem != null) {
int raw = convertAsUnsignedByteToInt(buffer.get(10));
tpsDataItem.setRaw(raw);
dataItem = dataItems.get(TPS);
if (dataItem != null) {
int raw = asUnsignedInt(buffer.get(10));
dataItem.setRaw(raw);
}
break;
case 12:
ZT2DataItem usrDataItem = dataItems.get(USR);
if (usrDataItem != null) {
int raw = convertAsUnsignedByteToInt(buffer.get(11));
usrDataItem.setRaw(raw);
dataItem = dataItems.get(USER1);
if (dataItem != null) {
int raw = asUnsignedInt(buffer.get(11));
dataItem.setRaw(raw);
}
break;
case 14:
//LOGGER.info(currentTimeMillis() + ", Pkt: " + buffer + ", TMem: " + rt.totalMemory() + ", FMem: " + rt.freeMemory());
buffer.clear();
packetStarted = false;
break;
@ -125,7 +124,7 @@ public final class ZT2Runner implements Stoppable {
}
}
} catch (Throwable t) {
LOGGER.error("Error occurred", t);
LOGGER.error("ZT2 error occurred", t);
} finally {
connection.close();
}
@ -135,11 +134,4 @@ public final class ZT2Runner implements Stoppable {
stop = true;
connection.close();
}
private int convertAsUnsignedByteToInt(byte aByte) {
// A byte in java is signed, so -128 to 128
// unlike in other platforms where it's
// normally unsigned, so 0-255
return (int) aByte & 0xFF;
}
}

View File

@ -1,24 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.zt2.plugin;
public interface ZT2Converter {
double convert(ZT2SensorType sensorType, int... raw);
}

View File

@ -1,53 +0,0 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.zt2.plugin;
import static java.lang.Math.round;
public final class ZT2ConverterImpl implements ZT2Converter {
public double convert(ZT2SensorType sensorType, int... raw) {
switch (sensorType) {
case AFR:
// AFR / 10
return raw[0] / 10d;
case EGT:
// (EGT(low) + EGT(high)) * 256
return (raw[0] + raw[1]) * 256d;
case RPM:
// Cm = (Number of Cylinders in the Engine) / 2;
// round([(1000000/(RPM(low)+(RPM(high)*256)))*4.59]/Cm)
return round(((1000000d / (raw[0] + (raw[1] * 256d))) * 4.59d) / 2d);
case MAP:
// special handling on high byte - if 8th bit is 1 (means that it's negative)
if ((raw[1] & 128) == 128) {
// We are supposed to clear the 8 bit, calc, then restore the sign.
return 0 - ((raw[0] + (raw[1] & ~(1 << 7)) * 256d) / 10d);
} else {
return (raw[0] + raw[1] * 256d) / 10d;
}
case TPS:
return raw[0];
case USR:
return raw[0]; // input is between 0-5VDC, a conversion may be needed from hex to decimal
default:
throw new UnsupportedOperationException("Calculation for this particular ZTSensorType is not supported");
}
}
}

View File

@ -19,21 +19,21 @@
package com.romraider.logger.external.zt2.plugin;
import static com.romraider.logger.external.core.ExternalDataConvertorLoader.loadConvertors;
import com.romraider.logger.ecu.definition.EcuDataConvertor;
import com.romraider.logger.ecu.definition.ExternalDataConvertorImpl;
import com.romraider.logger.external.core.ExternalSensorConversions;
public final class ZT2DataItemImpl implements ZT2DataItem {
private final ZT2Converter converter = new ZT2ConverterImpl();
private final ZT2SensorType sensorType;
private final String units;
private EcuDataConvertor[] convertors;
private final String name;
private int[] raw;
public ZT2DataItemImpl(String name, String units, ZT2SensorType sensorType) {
super();
public ZT2DataItemImpl(String name, ExternalSensorConversions... convertorList) {
super();
this.name = name;
this.units = units;
this.sensorType = sensorType;
convertors = new EcuDataConvertor[convertorList.length];
convertors = loadConvertors(this, convertors, convertorList);
}
public String getName() {
@ -44,30 +44,26 @@ public final class ZT2DataItemImpl implements ZT2DataItem {
return "Zeitronix ZT-2 " + name + " data";
}
// public String getUnits() {
// return units;
// }
public double getData() {
return converter.convert(sensorType, raw);
if (name.equalsIgnoreCase("MAP") && ((raw[1] & 128) == 128)) {
// special handling on high byte - if 8th bit is 1 (means that it's negative)
// We are supposed to clear the 8 bit, calc, then restore the sign.
return 0 - (raw[0] + (raw[1] & ~(1 << 7)) * 256d);
}
else {
if (raw.length == 1)
return raw[0];
if (raw.length == 2)
return raw[0] + (raw[1] * 256d);
}
return 0;
}
public void setRaw(int... raw) {
this.raw = raw;
}
// public String getFormat() {
// return "0.##";
// }
//
// public String getExpression() {
// return "x";
// }
public EcuDataConvertor[] getConvertors() {
String expression = "x";
String format = "0.##";
EcuDataConvertor[] convertors = {new ExternalDataConvertorImpl(this, units, expression, format)};
return convertors;
}
}

View File

@ -19,36 +19,57 @@
package com.romraider.logger.external.zt2.plugin;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.zt2.io.ZT2Runner;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.AFR;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.EGT;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.MAP;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.RPM;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.TPS;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorType.USR;
import static com.romraider.logger.external.core.ExternalSensorType.EGT;
import static com.romraider.logger.external.core.ExternalSensorType.ENGINE_SPEED;
import static com.romraider.logger.external.core.ExternalSensorType.MAP;
import static com.romraider.logger.external.core.ExternalSensorType.TPS;
import static com.romraider.logger.external.core.ExternalSensorType.USER1;
import static com.romraider.logger.external.core.ExternalSensorType.WIDEBAND;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_146;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_147;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_155;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_172;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_34;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_64;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.AFR_90;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.BOOST_BAR;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.BOOST_KGCM2;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.BOOST_KPA;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.BOOST_PSI;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.DEG_C;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.DEG_F;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.LAMBDA;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.PERCENT;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.RPM;
import static com.romraider.logger.external.zt2.plugin.ZT2SensorConversions.VDC;
import static com.romraider.util.ThreadUtil.runAsDaemon;
import static java.util.Collections.unmodifiableList;
import javax.swing.Action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Action;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.external.core.ExternalDataItem;
import com.romraider.logger.external.core.ExternalDataSource;
import com.romraider.logger.external.core.ExternalSensorType;
import com.romraider.logger.external.zt2.io.ZT2Runner;
public final class ZT2DataSource implements ExternalDataSource {
private final Map<ZT2SensorType, ZT2DataItem> dataItems = new HashMap<ZT2SensorType, ZT2DataItem>();
private final Map<ExternalSensorType, ZT2DataItem> dataItems = new HashMap<ExternalSensorType, ZT2DataItem>();
private ZT2Runner runner;
private String port;
{
dataItems.put(AFR, new ZT2DataItemImpl("Wideband AFR", "AFR", AFR));
dataItems.put(TPS, new ZT2DataItemImpl("TPS", "Percent", TPS));
dataItems.put(RPM, new ZT2DataItemImpl("RPM", "RPM", RPM));
dataItems.put(MAP, new ZT2DataItemImpl("MAP", "Vacuum(inHg)/Boost(PSI)", MAP));
dataItems.put(EGT, new ZT2DataItemImpl("EGT", "Celsius", EGT));
dataItems.put(USR, new ZT2DataItemImpl("User Input", "Volts", USR));
dataItems.put(WIDEBAND, new ZT2DataItemImpl("Wideband O2", AFR_147, LAMBDA, AFR_90, AFR_146, AFR_64, AFR_155, AFR_172, AFR_34));
dataItems.put(TPS, new ZT2DataItemImpl("Throttle Poistion", PERCENT));
dataItems.put(ENGINE_SPEED, new ZT2DataItemImpl("Engine Speed", RPM));
dataItems.put(MAP, new ZT2DataItemImpl("MAP", BOOST_PSI, BOOST_BAR, BOOST_KPA, BOOST_KGCM2));
dataItems.put(EGT, new ZT2DataItemImpl("EGT", DEG_C, DEG_F));
dataItems.put(USER1, new ZT2DataItemImpl("User Input", VDC));
}
public String getId() {
@ -60,7 +81,7 @@ public final class ZT2DataSource implements ExternalDataSource {
}
public String getVersion() {
return "0.02";
return "0.03";
}
public List<? extends ExternalDataItem> getDataItems() {

View File

@ -0,0 +1,57 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2010 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.external.zt2.plugin;
import com.romraider.logger.external.core.ExternalSensorConversions;
public enum ZT2SensorConversions implements ExternalSensorConversions {
// AFR conversion assumes reported DATA value is Gas AFR
LAMBDA ("Lambda", "x*0.00680272108843537", "0.00"),
AFR_147 ("AFR Gasoline", "x*0.1", "0.00"), // gasoline
AFR_90 ("AFR Ethonal", "x*0.06122448979591837", "0.00"), // ethanol
AFR_146 ("AFR Diesel", "x*0.09931972789115646", "0.00"), // diesel
AFR_64 ("AFR Methonal", "x*0.04353741496598639", "0.00"),// methanol
AFR_155 ("AFR LPG", "x*0.1054421768707483", "0.00"), // LPG
AFR_172 ("AFR CNG", "x*0.1170068027210884", "0.00"), // CNG
AFR_34 ("AFR Hydrogen", "x*0.2312925170068027", "0.00"), // Hydrogen
PERCENT ("%", "x", "0.0"),
DEG_C ("C", "x", "0.0"),
DEG_F ("F", "(x/.555+32)", "0.0"),
BOOST_PSI ("psi", "x*0.1", "0.00"),
BOOST_BAR ("bar", "x*0.0068947573", "0.00"), // converts from PSI
BOOST_KPA ("kPa", "x*0.6894757282", "0.0"), // converts from PSI
BOOST_KGCM2 ("kg/cm^2", "x*0.0070306958", "0.00"), // converts from PSI
VDC ("vdc", "x", "0.00"),
RPM ("rpm", "round(((1000000/x)*4.59)/2)", "0");
private final String units;
private final String expression;
private final String format;
ZT2SensorConversions(String units, String expression, String format) {
this.units = units;
this.expression = expression;
this.format = format;
}
public String units() { return units; }
public String expression() { return expression; }
public String format() { return format; }
}

View File

@ -38,6 +38,7 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener
add(table);
setFrameIcon(null);
setBorder(createBevelBorder(0));
putClientProperty("JInternalFrame.isPalette", true);
setVisible(false);
setJMenuBar(new TableMenuBar(table));
toolBar = new TableToolBar(table, this);