steps towards Android
This commit is contained in:
parent
89ca7a23fb
commit
9e428cfe57
|
@ -12,5 +12,7 @@
|
|||
<orderEntry type="library" name="jSerialComm" level="project" />
|
||||
<orderEntry type="module" module-name="logging-api" exported="" />
|
||||
<orderEntry type="module" module-name="models" />
|
||||
<orderEntry type="library" exported="" name="annotations" level="project" />
|
||||
<orderEntry type="module" module-name="inifile" />
|
||||
</component>
|
||||
</module>
|
|
@ -231,7 +231,7 @@ public class ConsoleUI {
|
|||
new ConsoleUI(port);
|
||||
} else {
|
||||
for (String p : LinkManager.getCommPorts())
|
||||
MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, Launcher.class, "Available port: " + p);
|
||||
new StartupFrame().chooseSerialPort();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class EcuStimulator {
|
|||
putValue("engine_load", engineLoad) +
|
||||
putValue("advance", advance) +
|
||||
putValue("dwell", dwell);
|
||||
MessagesCentral.getInstance().postMessage(EcuStimulator.class, msg);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EcuStimulator.class, msg);
|
||||
|
||||
try {
|
||||
csv.write(msg + "\r\n");
|
||||
|
@ -232,7 +232,7 @@ public class EcuStimulator {
|
|||
}
|
||||
|
||||
private static void log(String message) {
|
||||
MessagesCentral.getInstance().postMessage(EcuStimulator.class, message);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EcuStimulator.class, message);
|
||||
FileLog.MAIN.logLine(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class TestSequenceStep {
|
|||
next.execute(executor);
|
||||
}
|
||||
} else {
|
||||
MessagesCentral.getInstance().postMessage(TestSequenceStep.class, "ETB test sequence done!");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, TestSequenceStep.class, "ETB test sequence done!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ public class RecentCommands {
|
|||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
MessagesCentral.getInstance().postMessage(AverageAnglesUtil.class, report);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AverageAnglesUtil.class, report);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.etb;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -61,14 +62,14 @@ public class EtbMonteCarloSequence {
|
|||
":pFactor:" + pFactor +
|
||||
":iFactor:" + iFactor +
|
||||
":dFactor:" + dFactor;
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class, stats);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class, stats);
|
||||
uiContext.getCommandQueue().write("etbreset");
|
||||
uiContext.getCommandQueue().write("set etb_o " + offset);
|
||||
uiContext.getCommandQueue().write("set etb_p " + pFactor);
|
||||
uiContext.getCommandQueue().write("set etb_i " + iFactor);
|
||||
uiContext.getCommandQueue().write("set etb_d " + dFactor);
|
||||
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class,
|
||||
uiContext.sensorLogger.getSecondsSinceFileStart() + " running " + stats);
|
||||
|
||||
TestSequenceStep firstStep = new EtbTarget(uiContext, 10 * SECOND, DEFAULT_POSITION, null, TestSequenceStep.Condition.YES);
|
||||
|
@ -78,7 +79,7 @@ public class EtbMonteCarloSequence {
|
|||
double currentValue = StandardTestSequence.metric.getStandardDeviation();
|
||||
boolean shouldRun = currentValue < bestResultSoFar;
|
||||
if (!shouldRun) {
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class,
|
||||
"Two much error accumulated, aborting! " + currentValue + " > " + bestResultSoFar);
|
||||
|
||||
}
|
||||
|
@ -92,7 +93,7 @@ public class EtbMonteCarloSequence {
|
|||
Runnable onEachStep = () -> SwingUtilities.invokeLater(() -> {
|
||||
String state = stepCounter.incrementAndGet() + "/" + totalSteps.get();
|
||||
double value = StandardTestSequence.metric.getStandardDeviation();
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,"Running " + state + ", current=" + value);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class,"Running " + state + ", current=" + value);
|
||||
});
|
||||
|
||||
TestSequenceStep last = StandardTestSequence.addSequence(uiContext, firstStep, onEachStep, condition);
|
||||
|
@ -108,18 +109,18 @@ public class EtbMonteCarloSequence {
|
|||
double cycleResult = SensorCentral.getInstance().getValue(Sensor.ETB_CONTROL_QUALITY);
|
||||
if (cycleResult < bestResultSoFar) {
|
||||
bestResultSoFar = cycleResult;
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class,
|
||||
uiContext.sensorLogger.getSecondsSinceFileStart() + ":" + stats + ":new_record:" + bestResultSoFar);
|
||||
}
|
||||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbMonteCarloSequence.class,
|
||||
uiContext.sensorLogger.getSecondsSinceFileStart() + ":" + stats + ":result:" + cycleResult);
|
||||
if (counter == TOTAL_CYCLES_COUNT) {
|
||||
stopETB();
|
||||
MessagesCentral.getInstance().postMessage(EtbTestSequence.class, "ETB MC sequence done!");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbTestSequence.class, "ETB MC sequence done!");
|
||||
return;
|
||||
}
|
||||
counter++;
|
||||
MessagesCentral.getInstance().postMessage(EtbTestSequence.class, "Starting " + counter + " of " + TOTAL_CYCLES_COUNT);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, EtbTestSequence.class, "Starting " + counter + " of " + TOTAL_CYCLES_COUNT);
|
||||
runRandomCycle();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.etb;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -81,7 +82,7 @@ public class EtbReturnToNeutral {
|
|||
|
||||
uiContext.getCommandQueue().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
// CommandQueue.getInstance().write(DirectDrivePanel.CANCEL_DIRECT_DRIVE_COMMAND);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Cycles = " + CYCLES_COUNT + ", errors = " + errorCount);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Cycles = " + CYCLES_COUNT + ", errors = " + errorCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,10 +90,10 @@ public class EtbReturnToNeutral {
|
|||
*/
|
||||
private boolean assertPosition(String msg, float expectedPosition) {
|
||||
double tps = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), msg + " TPS=" + tps);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), msg + " TPS=" + tps);
|
||||
boolean isError = Math.abs(tps - expectedPosition) > ACCEPTABLE_ERROR;
|
||||
if (isError)
|
||||
MessagesCentral.getInstance().postMessage(getClass(), msg + " NOT GREAT " + tps + " while expected " + expectedPosition);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), msg + " NOT GREAT " + tps + " while expected " + expectedPosition);
|
||||
return isError;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.etb;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -65,7 +66,7 @@ public class MagicSpotsFinder {
|
|||
sleep(SLEEP);
|
||||
|
||||
double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "ETB duty " + currentDutyCycle + ": tps=" + tpsPosition);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "ETB duty " + currentDutyCycle + ": tps=" + tpsPosition);
|
||||
|
||||
if (tpsPosition >= 100 - MEASURMENT_PRECISION) {
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
|
@ -76,7 +77,7 @@ public class MagicSpotsFinder {
|
|||
// if that's the first we've moved let's remember duty cycle value
|
||||
startedToCloseValue = currentDutyCycle;
|
||||
startedToCloseValueLabel.setText(String.format("Started Close %.1f", startedToCloseValue));
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Started to close at " + startedToCloseValue);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Started to close at " + startedToCloseValue);
|
||||
}
|
||||
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
|
@ -84,10 +85,10 @@ public class MagicSpotsFinder {
|
|||
} else {
|
||||
backToZeroValue = currentDutyCycle;
|
||||
backToZeroValueLabel.setText(String.format("Back Zero %.1f", backToZeroValue));
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Back closed to close at " + backToZeroValue);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Back closed to close at " + backToZeroValue);
|
||||
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "startedToCloseValue = " + startedToCloseValue + ", backToZeroValue = " + backToZeroValue);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "startedToCloseValue = " + startedToCloseValue + ", backToZeroValue = " + backToZeroValue);
|
||||
button.setEnabled(true);
|
||||
button.setText(MAGIC_SPOTS_FINDER);
|
||||
}
|
||||
|
@ -107,7 +108,7 @@ public class MagicSpotsFinder {
|
|||
sleep(SLEEP);
|
||||
|
||||
double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "ETB duty " + currentDutyCycle + ": tps=" + tpsPosition);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "ETB duty " + currentDutyCycle + ": tps=" + tpsPosition);
|
||||
|
||||
if (tpsPosition < defaultTpsPosition + MEASURMENT_PRECISION) {
|
||||
// ETB has not moved yet, keep going up
|
||||
|
@ -119,7 +120,7 @@ public class MagicSpotsFinder {
|
|||
// if that's the first we've moved let's remember duty cycle value
|
||||
startedToOpenValue = currentDutyCycle;
|
||||
startedToOpenValueLabel.setText(String.format("Start to open: %.1f", startedToOpenValue));
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Started to open at " + startedToOpenValue);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Started to open at " + startedToOpenValue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +132,7 @@ public class MagicSpotsFinder {
|
|||
// looks like we have reached 100%, cool!
|
||||
reached100Value = currentDutyCycle;
|
||||
reached100ValueLabel.setText(String.format("Reached 100: %.1f", reached100Value));
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
|
@ -156,7 +157,7 @@ public class MagicSpotsFinder {
|
|||
public void run() {
|
||||
state = State.START;
|
||||
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Start!");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Start!");
|
||||
resetValues();
|
||||
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
|
@ -209,7 +210,7 @@ public class MagicSpotsFinder {
|
|||
|
||||
private void sleep(long millis) {
|
||||
try {
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Sleeping " + millis + "ms");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, getClass(), "Sleeping " + millis + "ms");
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException unexpected) {
|
||||
unexpected.printStackTrace();
|
||||
|
|
|
@ -136,9 +136,9 @@ public class AnyCommand {
|
|||
String result = prepareEvalCommand(rawCommand);
|
||||
if (result.equals(rawCommand)) {
|
||||
// result was not translated
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Not valid expression");
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Please try eval \"2 + 2\"");
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "For RPN use rpn_eval \"2 2 +\"");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Not valid expression");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Please try eval \"2 + 2\"");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "For RPN use rpn_eval \"2 2 +\"");
|
||||
}
|
||||
return result;
|
||||
} else if (rawCommand.toLowerCase().startsWith("stim_check" + " ")) {
|
||||
|
@ -165,7 +165,7 @@ public class AnyCommand {
|
|||
private static void handleStimulationSelfCheck(String rawCommand, LinkManager linkManager) {
|
||||
String[] parts = rawCommand.split(" ", 4);
|
||||
if (parts.length != 4) {
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Invalid command length " + parts);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Invalid command length " + parts);
|
||||
return; // let's ignore invalid command
|
||||
}
|
||||
int rpm = Integer.parseInt(parts[1]);
|
||||
|
@ -174,14 +174,14 @@ public class AnyCommand {
|
|||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Will test with RPM " + rpm + ", settle time" + settleTime + "s and duration" + durationTime + "s");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Will test with RPM " + rpm + ", settle time" + settleTime + "s and duration" + durationTime + "s");
|
||||
Function<String, Object> callback = new Function<String, Object>() {
|
||||
@Override
|
||||
public Object apply(String status) {
|
||||
if (status == null) {
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, rpm + " worked!");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, rpm + " worked!");
|
||||
} else {
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, rpm + " failed " + status);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, rpm + " failed " + status);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -201,12 +201,12 @@ public class AnyCommand {
|
|||
private static void handleDecodeRpn(String rawCommand) {
|
||||
String[] parts = rawCommand.split(" ", 2);
|
||||
if (parts.length != 2) {
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Failed to parse, one argument expected");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Failed to parse, one argument expected");
|
||||
return;
|
||||
}
|
||||
String argument = unquote(parts[1]);
|
||||
String humanForm = InfixConverter.getHumanInfixFormOrError(argument);
|
||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Human form is \"" + humanForm + "\"");
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, AnyCommand.class, "Human form is \"" + humanForm + "\"");
|
||||
}
|
||||
|
||||
public static String prepareEvalCommand(String rawCommand) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -90,7 +91,7 @@ public class PotCommand {
|
|||
|
||||
public static int getPotResistance(double vout, double vRef) {
|
||||
double r = getR1InVoltageDivider3(vout, vRef, EcuStimulator.getInstance().getInputs().getEngineLoadR2Resistance());
|
||||
MessagesCentral.getInstance().postMessage(PotCommand.class, "VRef=" + vRef + ", needed resistance: " + r);
|
||||
MessagesCentral.getInstance().postMessage(FileLog.LOGGER, PotCommand.class, "VRef=" + vRef + ", needed resistance: " + r);
|
||||
// pot command accept resistance and does the conversion itself
|
||||
return (int) r;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue