From f77684983453ad8306ca8746e6afc76f116844ad Mon Sep 17 00:00:00 2001 From: Dale Schultz Date: Tue, 27 Sep 2011 21:58:01 +0000 Subject: [PATCH] LM-2 MTS plug-in updates, plug-in may still be broken in this check-in. git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@346 38686702-15cf-42e4-a595-3071df8bf5ea --- .../innovate/generic/mts/io/MTSRunner.java | 166 +++++++----------- .../innovate/generic/mts/io/Test.java | 22 ++- templates/shortcutSpec-linux.xml.template | 10 +- templates/shortcutSpec-windows.xml.template | 14 +- 4 files changed, 94 insertions(+), 118 deletions(-) diff --git a/src/com/romraider/logger/external/innovate/generic/mts/io/MTSRunner.java b/src/com/romraider/logger/external/innovate/generic/mts/io/MTSRunner.java index 315c59d2..e4402d18 100644 --- a/src/com/romraider/logger/external/innovate/generic/mts/io/MTSRunner.java +++ b/src/com/romraider/logger/external/innovate/generic/mts/io/MTSRunner.java @@ -19,21 +19,19 @@ package com.romraider.logger.external.innovate.generic.mts.io; -import java.util.Map; - -import com.romraider.logger.external.core.DataListener; -import com.romraider.logger.external.core.Stoppable; -import com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2MtsDataItem; -import com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorType; -import com.romraider.logger.external.mrf.plugin.MrfDataItem; -import com.romraider.logger.external.mrf.plugin.MrfSensorType; - import static com.romraider.logger.external.innovate.generic.mts.io.MTSFactory.createMTS; import static com.romraider.util.ThreadUtil.sleep; import static java.lang.System.currentTimeMillis; -import org.apache.log4j.Logger; import static org.apache.log4j.Logger.getLogger; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.romraider.logger.external.core.Stoppable; +import com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2MtsDataItem; +import com.romraider.logger.external.innovate.lm2.mts.plugin.Lm2SensorType; + public final class MTSRunner implements Stoppable { private static final Logger LOGGER = getLogger(MTSRunner.class); private final Map dataItems; @@ -102,100 +100,68 @@ public final class MTSRunner implements Stoppable { LOGGER.info("MTS: found " + inputCount + " inputs."); if (inputCount > 0) { - // attempt to get data - mts.startData(); - - // for each input get some info about it - while (!stop) { - for (int i = 0; i < inputCount; i++) { - // report each input found -// mts.currentInput(i); -// LOGGER.info("MTS: InputNo:" + i + ", InputName:" + mts.inputName() + -// ", InputType:" + mts.inputType() + ", DeviceName:" + mts.inputDeviceName() + -// ", DeviceType:" + mts.inputDeviceType() + ", DeviceChannel:" + -// mts.inputDeviceChannel()); -// } - // select the input - mts.currentInput(i); - + for (int i = 0; i < inputCount; i++) { + // report each input found + mts.currentInput(i); + LOGGER.info(String.format( + "MTS: InputNo: %02d, InputName: %s, InputType: %d, DeviceName: %s, DeviceType: %d, DeviceChannel: %d, Units: %s, Multiplier: %f, MinValue: %f, MaxValue: %f, MinVolts: %f, MaxVolts: %f", + i, mts.inputName(), mts.inputType(), mts.inputDeviceName(), mts.inputDeviceType(), mts.inputDeviceChannel(), mts.inputUnit(), mts.inputAFRMultiplier(), mts.inputMinValue(), mts.inputMaxValue(), mts.inputMinVolt(), mts.inputMaxVolt())); + } // attempt to get data -// mts.startData(); - - // wait a moment for data acquisition to begin -// sleep(1000L); - - // start collecting data -// while (!stop) { - int type = mts.inputType(); - int function = mts.inputFunction(); - int sample = mts.inputSample(); - - LOGGER.trace("MTS: type = " + type + ", function = " + function + ", sample = " + sample); - - float data = 0f; + mts.startData(); - // Input Types - // 0 = Lambda - // 1 = AFR - // 2 = 5V - - // 5V channel - // Determine the range between min and max, - // calculate what percentage of that our sample represents, - // shift back to match our offset from 0.0 for min - if (type == 2) { - // MTS_FUNC_NOTLAMBDA - if (function == 9) { - float min = mts.inputMinValue(); - float max = mts.inputMaxValue(); - data = ((max - min) * ((float) sample / 1024f)) + min; - Lm2SensorType[] sensors = Lm2SensorType.values(); - for (Lm2SensorType sensorType : sensors) { - if (sensorType.getValue() == function && - sensorType.getChannel() == mts.inputDeviceChannel()) { - Lm2MtsDataItem dataItem = dataItems.get(sensorType); - dataItem.setData(data); - } - } - } - } + // for each input get the sample + while (!stop) { + for (int i = 0; i < inputCount; i++) { + mts.currentInput(i); + int type = mts.inputType(); + int function = mts.inputFunction(); + int sample = mts.inputSample(); + + LOGGER.trace("MTS: type = " + type + ", function = " + function + ", sample = " + sample); + + float data = 0f; - // AFR - // Take each sample step as .001 Lambda, - // add 0.5 (so our range is 0.5 to 1.523 for our 1024 steps), - // then multiply by the AFR multiplier - if (type == 0 || type == 1) { - // MTS_FUNC_LAMBDA - if (function == 0) { - //float multiplier = mts.inputAFRMultiplier(); - //data = ((float) sample / 1000f + 0.5f) * multiplier; - data = ((float) sample / 1000f + 0.5f); - Lm2SensorType[] sensors = Lm2SensorType.values(); - for (Lm2SensorType sensorType : sensors) { - if (sensorType.getValue() == function && - sensorType.getChannel() == mts.inputDeviceChannel()) { - Lm2MtsDataItem dataItem = dataItems.get(sensorType); - dataItem.setData(data); - } - } - } - // MTS_FUNC_O2 - if (function == 1) { - data = ((float) sample / 10f); - } - } + // Input Types + // 0 = Lambda + // 1 = AFR + // 2 = 5V - // Lambda - // Identical to AFR, except we do not multiply for AFR. -// if (type == 0) { -// // MTS_FUNC_LAMBDA -// if (function == 0) { -// data = (float) sample / 1000f + 0.5f; -// } -// } - } - sleep(10L); - } + // 5V channel + // Determine the range between min and max, + // calculate what percentage of that our sample represents, + // shift back to match our offset from 0.0 for min + if (type == 2) { + // MTS_FUNC_NOTLAMBDA + if (function == 9) { + float min = mts.inputMinValue(); + float max = mts.inputMaxValue(); + data = ((max - min) * ((float) sample / 1024f)) + min; + } + } + + // AFR + // Take each sample step as .001 Lambda, + // add 0.5 (so our range is 0.5 to 1.523 for our 1024 steps), + // then multiply by the AFR multiplier + if (type == 0 || type == 1) { + // MTS_FUNC_LAMBDA + if (function == 0) { + //float multiplier = mts.inputAFRMultiplier(); + //data = ((float) sample / 1000f + 0.5f) * multiplier; + data = ((float) sample / 1000f + 0.5f); + } + // MTS_FUNC_O2 + if (function == 1) { + data = ((float) sample / 10f); + } + } + Lm2SensorType sensor = Lm2SensorType.valueOf(function, mts.inputDeviceChannel()); + Lm2MtsDataItem dataItem = dataItems.get(sensor); + if (dataItem != null) dataItem.setData(data); + } + sleep(10L); + } } else { LOGGER.error("MTS: Error - no input channels found to log from!"); diff --git a/src/com/romraider/logger/external/innovate/generic/mts/io/Test.java b/src/com/romraider/logger/external/innovate/generic/mts/io/Test.java index 107c086c..951768fa 100644 --- a/src/com/romraider/logger/external/innovate/generic/mts/io/Test.java +++ b/src/com/romraider/logger/external/innovate/generic/mts/io/Test.java @@ -97,7 +97,7 @@ public class Test implements MTSEvents { printAvailableInputs(); // attempt to get data - mts.currentInput(0); +// mts.currentInput(0); mts.startData(); // notes: @@ -122,7 +122,8 @@ public class Test implements MTSEvents { // MTS_FUNC_INVALID 10 // retrieve 10 samples - getSamples(10); +// getSamples(10); + waitFor(20000); // dispose of the event handler instance connectionEventCookie.close(); @@ -147,10 +148,19 @@ public class Test implements MTSEvents { } public void newData() { - //int data = mts.inputSample(); - //float multiplier = mts.inputAFRMultiplier(); - //int sampleMeaning = mts.inputFunction(); - //System.out.printf("newData raised. data = %f%n", data * multiplier); + int i; + float data = 0f; +// for (i = 0; i < mts.inputCount(); i++) { + i=0; + mts.currentInput(i); + float min = mts.inputMinValue(); + float max = mts.inputMaxValue(); + data = mts.inputSample(); + data = ((max - min) * ((float) data / 1024f)) + min; + float multiplier = mts.inputAFRMultiplier(); + int sampleMeaning = mts.inputFunction(); + System.out.printf("newData raised for Input: %02d, Function: %d, Data: %f,\tMultiplier: %f%n", i, sampleMeaning, data, multiplier); +// } } /** diff --git a/templates/shortcutSpec-linux.xml.template b/templates/shortcutSpec-linux.xml.template index 6cd28562..f4a48b56 100644 --- a/templates/shortcutSpec-linux.xml.template +++ b/templates/shortcutSpec-linux.xml.template @@ -13,7 +13,7 @@ startup="no" target="$JAVA_HOME/bin/java" commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar"" - initialState="noShow" + initialState="normal" iconFile="$INSTALL_PATH/graphics/romraider-ico.ico" workingDirectory="$INSTALL_PATH" type="Application" @@ -31,7 +31,7 @@ startup="no" target="$JAVA_HOME/bin/java" commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar" -logger" - initialState="noShow" + initialState="normal" iconFile="$INSTALL_PATH/graphics/romraider-ico.ico" workingDirectory="$INSTALL_PATH" type="Application" @@ -50,7 +50,7 @@ target="" workingDirectory="" commandLine="" - initialState="noShow" + initialState="normal" iconFile="help" iconIndex="0" url="$INSTALL_PATH/license.txt" @@ -70,7 +70,7 @@ target="" workingDirectory="" commandLine="" - initialState="noShow" + initialState="normal" iconFile="help" iconIndex="0" url="$INSTALL_PATH/release_notes.txt" @@ -89,7 +89,7 @@ startup="no" target="$JAVA_HOME/bin/java" commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar"" - initialState="noShow" + initialState="normal" iconFile="trashcan_full" iconIndex="0" workingDirectory="" diff --git a/templates/shortcutSpec-windows.xml.template b/templates/shortcutSpec-windows.xml.template index ce870c67..e421db73 100644 --- a/templates/shortcutSpec-windows.xml.template +++ b/templates/shortcutSpec-windows.xml.template @@ -47,10 +47,10 @@ applications="no" startMenu="no" startup="no" - target="" - workingDirectory="" + target="$INSTALL_PATH/license.txt" + workingDirectory="$INSTALL_PATH" commandLine="" - initialState="noShow" + initialState="normal" iconFile="help" iconIndex="0" url="$INSTALL_PATH/license.txt" @@ -67,10 +67,10 @@ applications="no" startMenu="no" startup="no" - target="" - workingDirectory="" + target="$INSTALL_PATH/release_notes.txt" + workingDirectory="$INSTALL_PATH" commandLine="" - initialState="noShow" + initialState="normal" iconFile="help" iconIndex="0" url="$INSTALL_PATH/release_notes.txt" @@ -87,7 +87,7 @@ applications="no" startMenu="no" startup="no" - target="$JAVA_HOME/bin/java" + target="$JAVA_HOME/bin/javaw" commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar"" initialState="noShow" iconFile="trashcan_full"