Merge branch 'master' of https://github.com/rusefi/rusefi
This commit is contained in:
commit
f4e0f375fb
|
@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
* @see EngineSnifferPanel
|
* @see EngineSnifferPanel
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static final int CONSOLE_VERSION = 20181013;
|
public static final int CONSOLE_VERSION = 20181117;
|
||||||
public static final boolean SHOW_STIMULATOR = false;
|
public static final boolean SHOW_STIMULATOR = false;
|
||||||
private static final String TAB_INDEX = "main_tab";
|
private static final String TAB_INDEX = "main_tab";
|
||||||
protected static final String PORT_KEY = "port";
|
protected static final String PORT_KEY = "port";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi.ui.widgets;
|
package com.rusefi.ui.widgets;
|
||||||
|
|
||||||
import com.opensr5.Logger;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.FileLog;
|
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
import com.rusefi.io.CommandQueue;
|
import com.rusefi.io.CommandQueue;
|
||||||
|
@ -17,8 +16,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
* 10/21/2018
|
* 10/21/2018
|
||||||
*/
|
*/
|
||||||
public class EtbResearch {
|
public class EtbResearch {
|
||||||
private static final long SLEEP = 1000;
|
private static final int SECOND = 1000;
|
||||||
private final JButton button = new JButton("ETB R");
|
private static final long SLEEP = 3 * SECOND;
|
||||||
|
// how much do we want to change duty cycle on each iteration?
|
||||||
|
private static final double DUTY_CYCLE_STEP = 0.5;
|
||||||
|
private final JButton button = new JButton("ETB Research");
|
||||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
// close to zero but not really zero so that we can validate this value
|
// close to zero but not really zero so that we can validate this value
|
||||||
private final static double LOW_VALUE = 0.5;
|
private final static double LOW_VALUE = 0.5;
|
||||||
|
@ -27,37 +29,104 @@ public class EtbResearch {
|
||||||
|
|
||||||
State state;
|
State state;
|
||||||
private double currentValue;
|
private double currentValue;
|
||||||
|
/**
|
||||||
|
* here we record at which duty cycle ETB would start moving
|
||||||
|
*/
|
||||||
|
private double startedToOpenValue;
|
||||||
|
private double reached100Value;
|
||||||
|
private double startedToCloseValue;
|
||||||
|
private double backToZeroValue;
|
||||||
|
|
||||||
InvocationConfirmationListener goingUp = new InvocationConfirmationListener() {
|
private InvocationConfirmationListener goingDown = new InvocationConfirmationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCommandConfirmation() {
|
public void onCommandConfirmation() {
|
||||||
state = State.GOING_UP;
|
state = State.GOING_DOWN;
|
||||||
|
|
||||||
|
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
|
||||||
Thread.sleep(SLEEP);
|
sleep();
|
||||||
} catch (InterruptedException unexpected) {
|
|
||||||
unexpected.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||||
FileLog.MAIN.logLine("ETB duty " + currentValue + ": tps=" + tpsPosition);
|
MessagesCentral.getInstance().postMessage(getClass(), "ETB duty " + currentValue + ": tps=" + tpsPosition);
|
||||||
|
|
||||||
|
|
||||||
|
if (tpsPosition >= 100) {
|
||||||
|
currentValue -= DUTY_CYCLE_STEP;
|
||||||
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingDown);
|
||||||
|
} else if (tpsPosition > 0) {
|
||||||
|
|
||||||
|
if (startedToCloseValue == 0) {
|
||||||
|
// if that's the first we've moved let's remember duty cycle value
|
||||||
|
startedToCloseValue = currentValue;
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "Started to close at " + startedToCloseValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentValue -= DUTY_CYCLE_STEP;
|
||||||
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingDown);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
backToZeroValue = currentValue;
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "Back closed to close at " + backToZeroValue);
|
||||||
|
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "startedToCloseValue = " + startedToCloseValue + ", backToZeroValue = " + backToZeroValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private InvocationConfirmationListener goingUp = new InvocationConfirmationListener() {
|
||||||
|
@Override
|
||||||
|
public void onCommandConfirmation() {
|
||||||
|
state = State.GOING_UP;
|
||||||
|
|
||||||
|
executor.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sleep();
|
||||||
|
|
||||||
|
double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "ETB duty " + currentValue + ": tps=" + tpsPosition);
|
||||||
|
|
||||||
if (tpsPosition == 0) {
|
if (tpsPosition == 0) {
|
||||||
currentValue += 1.0;
|
// ETB has not moved yet, keep going up
|
||||||
|
currentValue += DUTY_CYCLE_STEP;
|
||||||
CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
|
||||||
|
} else if (tpsPosition < 100) {
|
||||||
|
|
||||||
|
if (startedToOpenValue == 0) {
|
||||||
|
// if that's the first we've moved let's remember duty cycle value
|
||||||
|
startedToOpenValue = currentValue;
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "Started to open at " + startedToOpenValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ETB has not reached 100%, keep going up
|
||||||
|
currentValue += DUTY_CYCLE_STEP;
|
||||||
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// looks like we have reached 100%, cool!
|
||||||
|
reached100Value = currentValue;
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||||
|
|
||||||
|
currentValue -= DUTY_CYCLE_STEP;
|
||||||
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InvocationConfirmationListener setDebugModeConfiguration = new InvocationConfirmationListener() {
|
// settings are confirmed, let's start going up from zero
|
||||||
|
private InvocationConfirmationListener setDebugModeConfiguration = new InvocationConfirmationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCommandConfirmation() {
|
public void onCommandConfirmation() {
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
|
@ -65,13 +134,23 @@ public class EtbResearch {
|
||||||
public void run() {
|
public void run() {
|
||||||
state = State.START;
|
state = State.START;
|
||||||
|
|
||||||
currentValue = LOW_VALUE;
|
MessagesCentral.getInstance().postMessage(getClass(), "Start!");
|
||||||
|
resetValues();
|
||||||
|
|
||||||
CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
|
CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void resetValues() {
|
||||||
|
currentValue = LOW_VALUE;
|
||||||
|
startedToOpenValue = 0;
|
||||||
|
reached100Value = 0;
|
||||||
|
startedToCloseValue = 0;
|
||||||
|
backToZeroValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public EtbResearch() {
|
public EtbResearch() {
|
||||||
button.addActionListener(new AbstractAction() {
|
button.addActionListener(new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,9 +176,26 @@ public class EtbResearch {
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum State {
|
private void sleep() {
|
||||||
|
try {
|
||||||
|
MessagesCentral.getInstance().postMessage(getClass(), "Sleeping " + SLEEP + "ms");
|
||||||
|
Thread.sleep(SLEEP);
|
||||||
|
} catch (InterruptedException unexpected) {
|
||||||
|
unexpected.printStackTrace();
|
||||||
|
throw new IllegalStateException(unexpected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum State {
|
||||||
|
/**
|
||||||
|
* To begin we need to adjust some settings
|
||||||
|
*/
|
||||||
DEBUG_MODE,
|
DEBUG_MODE,
|
||||||
|
/**
|
||||||
|
* Once settings change is confirmed we are here
|
||||||
|
*/
|
||||||
START,
|
START,
|
||||||
GOING_UP,
|
GOING_UP,
|
||||||
|
GOING_DOWN,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue