mirror of https://github.com/rusefi/RomRaider.git
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
This commit is contained in:
parent
58106e629a
commit
f776849834
|
@ -19,21 +19,19 @@
|
||||||
|
|
||||||
package com.romraider.logger.external.innovate.generic.mts.io;
|
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.logger.external.innovate.generic.mts.io.MTSFactory.createMTS;
|
||||||
import static com.romraider.util.ThreadUtil.sleep;
|
import static com.romraider.util.ThreadUtil.sleep;
|
||||||
import static java.lang.System.currentTimeMillis;
|
import static java.lang.System.currentTimeMillis;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import static org.apache.log4j.Logger.getLogger;
|
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 {
|
public final class MTSRunner implements Stoppable {
|
||||||
private static final Logger LOGGER = getLogger(MTSRunner.class);
|
private static final Logger LOGGER = getLogger(MTSRunner.class);
|
||||||
private final Map<Lm2SensorType, Lm2MtsDataItem> dataItems;
|
private final Map<Lm2SensorType, Lm2MtsDataItem> dataItems;
|
||||||
|
@ -102,100 +100,68 @@ public final class MTSRunner implements Stoppable {
|
||||||
LOGGER.info("MTS: found " + inputCount + " inputs.");
|
LOGGER.info("MTS: found " + inputCount + " inputs.");
|
||||||
|
|
||||||
if (inputCount > 0) {
|
if (inputCount > 0) {
|
||||||
// attempt to get data
|
for (int i = 0; i < inputCount; i++) {
|
||||||
mts.startData();
|
// report each input found
|
||||||
|
mts.currentInput(i);
|
||||||
// for each input get some info about it
|
LOGGER.info(String.format(
|
||||||
while (!stop) {
|
"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",
|
||||||
for (int i = 0; i < inputCount; i++) {
|
i, mts.inputName(), mts.inputType(), mts.inputDeviceName(), mts.inputDeviceType(), mts.inputDeviceChannel(), mts.inputUnit(), mts.inputAFRMultiplier(), mts.inputMinValue(), mts.inputMaxValue(), mts.inputMinVolt(), mts.inputMaxVolt()));
|
||||||
// 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);
|
|
||||||
|
|
||||||
// attempt to get data
|
// attempt to get data
|
||||||
// mts.startData();
|
mts.startData();
|
||||||
|
|
||||||
// wait a moment for data acquisition to begin
|
// for each input get the sample
|
||||||
// sleep(1000L);
|
while (!stop) {
|
||||||
|
for (int i = 0; i < inputCount; i++) {
|
||||||
|
mts.currentInput(i);
|
||||||
|
int type = mts.inputType();
|
||||||
|
int function = mts.inputFunction();
|
||||||
|
int sample = mts.inputSample();
|
||||||
|
|
||||||
// start collecting data
|
LOGGER.trace("MTS: type = " + type + ", function = " + function + ", sample = " + sample);
|
||||||
// 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;
|
||||||
|
|
||||||
float data = 0f;
|
// Input Types
|
||||||
|
// 0 = Lambda
|
||||||
|
// 1 = AFR
|
||||||
|
// 2 = 5V
|
||||||
|
|
||||||
// Input Types
|
// 5V channel
|
||||||
// 0 = Lambda
|
// Determine the range between min and max,
|
||||||
// 1 = AFR
|
// calculate what percentage of that our sample represents,
|
||||||
// 2 = 5V
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 5V channel
|
// AFR
|
||||||
// Determine the range between min and max,
|
// Take each sample step as .001 Lambda,
|
||||||
// calculate what percentage of that our sample represents,
|
// add 0.5 (so our range is 0.5 to 1.523 for our 1024 steps),
|
||||||
// shift back to match our offset from 0.0 for min
|
// then multiply by the AFR multiplier
|
||||||
if (type == 2) {
|
if (type == 0 || type == 1) {
|
||||||
// MTS_FUNC_NOTLAMBDA
|
// MTS_FUNC_LAMBDA
|
||||||
if (function == 9) {
|
if (function == 0) {
|
||||||
float min = mts.inputMinValue();
|
//float multiplier = mts.inputAFRMultiplier();
|
||||||
float max = mts.inputMaxValue();
|
//data = ((float) sample / 1000f + 0.5f) * multiplier;
|
||||||
data = ((max - min) * ((float) sample / 1024f)) + min;
|
data = ((float) sample / 1000f + 0.5f);
|
||||||
Lm2SensorType[] sensors = Lm2SensorType.values();
|
}
|
||||||
for (Lm2SensorType sensorType : sensors) {
|
// MTS_FUNC_O2
|
||||||
if (sensorType.getValue() == function &&
|
if (function == 1) {
|
||||||
sensorType.getChannel() == mts.inputDeviceChannel()) {
|
data = ((float) sample / 10f);
|
||||||
Lm2MtsDataItem dataItem = dataItems.get(sensorType);
|
}
|
||||||
dataItem.setData(data);
|
}
|
||||||
}
|
Lm2SensorType sensor = Lm2SensorType.valueOf(function, mts.inputDeviceChannel());
|
||||||
}
|
Lm2MtsDataItem dataItem = dataItems.get(sensor);
|
||||||
}
|
if (dataItem != null) dataItem.setData(data);
|
||||||
}
|
}
|
||||||
|
sleep(10L);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOGGER.error("MTS: Error - no input channels found to log from!");
|
LOGGER.error("MTS: Error - no input channels found to log from!");
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class Test implements MTSEvents {
|
||||||
printAvailableInputs();
|
printAvailableInputs();
|
||||||
|
|
||||||
// attempt to get data
|
// attempt to get data
|
||||||
mts.currentInput(0);
|
// mts.currentInput(0);
|
||||||
mts.startData();
|
mts.startData();
|
||||||
|
|
||||||
// notes:
|
// notes:
|
||||||
|
@ -122,7 +122,8 @@ public class Test implements MTSEvents {
|
||||||
// MTS_FUNC_INVALID 10
|
// MTS_FUNC_INVALID 10
|
||||||
|
|
||||||
// retrieve 10 samples
|
// retrieve 10 samples
|
||||||
getSamples(10);
|
// getSamples(10);
|
||||||
|
waitFor(20000);
|
||||||
|
|
||||||
// dispose of the event handler instance
|
// dispose of the event handler instance
|
||||||
connectionEventCookie.close();
|
connectionEventCookie.close();
|
||||||
|
@ -147,10 +148,19 @@ public class Test implements MTSEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void newData() {
|
public void newData() {
|
||||||
//int data = mts.inputSample();
|
int i;
|
||||||
//float multiplier = mts.inputAFRMultiplier();
|
float data = 0f;
|
||||||
//int sampleMeaning = mts.inputFunction();
|
// for (i = 0; i < mts.inputCount(); i++) {
|
||||||
//System.out.printf("newData raised. data = %f%n", data * multiplier);
|
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);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
startup="no"
|
startup="no"
|
||||||
target="$JAVA_HOME/bin/java"
|
target="$JAVA_HOME/bin/java"
|
||||||
commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar""
|
commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="$INSTALL_PATH/graphics/romraider-ico.ico"
|
iconFile="$INSTALL_PATH/graphics/romraider-ico.ico"
|
||||||
workingDirectory="$INSTALL_PATH"
|
workingDirectory="$INSTALL_PATH"
|
||||||
type="Application"
|
type="Application"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
startup="no"
|
startup="no"
|
||||||
target="$JAVA_HOME/bin/java"
|
target="$JAVA_HOME/bin/java"
|
||||||
commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar" -logger"
|
commandLine="@jvm.args.linux@ -jar "$INSTALL_PATH/@name.package@.jar" -logger"
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="$INSTALL_PATH/graphics/romraider-ico.ico"
|
iconFile="$INSTALL_PATH/graphics/romraider-ico.ico"
|
||||||
workingDirectory="$INSTALL_PATH"
|
workingDirectory="$INSTALL_PATH"
|
||||||
type="Application"
|
type="Application"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
target=""
|
target=""
|
||||||
workingDirectory=""
|
workingDirectory=""
|
||||||
commandLine=""
|
commandLine=""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="help"
|
iconFile="help"
|
||||||
iconIndex="0"
|
iconIndex="0"
|
||||||
url="$INSTALL_PATH/license.txt"
|
url="$INSTALL_PATH/license.txt"
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
target=""
|
target=""
|
||||||
workingDirectory=""
|
workingDirectory=""
|
||||||
commandLine=""
|
commandLine=""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="help"
|
iconFile="help"
|
||||||
iconIndex="0"
|
iconIndex="0"
|
||||||
url="$INSTALL_PATH/release_notes.txt"
|
url="$INSTALL_PATH/release_notes.txt"
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
startup="no"
|
startup="no"
|
||||||
target="$JAVA_HOME/bin/java"
|
target="$JAVA_HOME/bin/java"
|
||||||
commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar""
|
commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="trashcan_full"
|
iconFile="trashcan_full"
|
||||||
iconIndex="0"
|
iconIndex="0"
|
||||||
workingDirectory=""
|
workingDirectory=""
|
||||||
|
|
|
@ -47,10 +47,10 @@
|
||||||
applications="no"
|
applications="no"
|
||||||
startMenu="no"
|
startMenu="no"
|
||||||
startup="no"
|
startup="no"
|
||||||
target=""
|
target="$INSTALL_PATH/license.txt"
|
||||||
workingDirectory=""
|
workingDirectory="$INSTALL_PATH"
|
||||||
commandLine=""
|
commandLine=""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="help"
|
iconFile="help"
|
||||||
iconIndex="0"
|
iconIndex="0"
|
||||||
url="$INSTALL_PATH/license.txt"
|
url="$INSTALL_PATH/license.txt"
|
||||||
|
@ -67,10 +67,10 @@
|
||||||
applications="no"
|
applications="no"
|
||||||
startMenu="no"
|
startMenu="no"
|
||||||
startup="no"
|
startup="no"
|
||||||
target=""
|
target="$INSTALL_PATH/release_notes.txt"
|
||||||
workingDirectory=""
|
workingDirectory="$INSTALL_PATH"
|
||||||
commandLine=""
|
commandLine=""
|
||||||
initialState="noShow"
|
initialState="normal"
|
||||||
iconFile="help"
|
iconFile="help"
|
||||||
iconIndex="0"
|
iconIndex="0"
|
||||||
url="$INSTALL_PATH/release_notes.txt"
|
url="$INSTALL_PATH/release_notes.txt"
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
applications="no"
|
applications="no"
|
||||||
startMenu="no"
|
startMenu="no"
|
||||||
startup="no"
|
startup="no"
|
||||||
target="$JAVA_HOME/bin/java"
|
target="$JAVA_HOME/bin/javaw"
|
||||||
commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar""
|
commandLine="-jar "$INSTALL_PATH/Uninstaller/uninstaller.jar""
|
||||||
initialState="noShow"
|
initialState="noShow"
|
||||||
iconFile="trashcan_full"
|
iconFile="trashcan_full"
|
||||||
|
|
Loading…
Reference in New Issue