nicer column names in PID modes

This commit is contained in:
rusefi 2018-10-08 22:14:43 -04:00
parent 2f63e9d899
commit bbdf6daf9a
2 changed files with 60 additions and 4 deletions

View File

@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20180924;
public static final int CONSOLE_VERSION = 20181007;
public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";

View File

@ -1,7 +1,13 @@
package com.rusefi;
import com.opensr5.ConfigurationImage;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.BinaryProtocolHolder;
import com.rusefi.config.Fields;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.io.ConnectionStatus;
import com.rusefi.ui.config.ConfigField;
import java.io.FileWriter;
import java.io.IOException;
@ -90,11 +96,18 @@ public class SensorLogger {
return;
isRunning = true;
startSensorLogFile();
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, new SensorCentral.SensorListener() {
@Override
public void onSensorUpdate(double value) {
if (ConnectionStatus.INSTANCE.getValue() != ConnectionStatus.Value.CONNECTED)
return;
if (logFile == null) {
/*
* we only start file header once we have first bunch of data
*/
startSensorLogFile();
}
writeSensorLogLine();
}
});
@ -130,9 +143,18 @@ public class SensorLogger {
logFile.write("\"rusEfi console" + Launcher.CONSOLE_VERSION + " firmware " + Launcher.firmwareVersion.get() + "\"\r\n");
logFile.write("Captured " + FileLog.getDate() + "\r\n");
int debugMode = -1;
BinaryProtocol bp = BinaryProtocolHolder.getInstance().get();
if (bp != null) {
ConfigurationImage ci = bp.getController();
if (ci != null) {
debugMode = ConfigField.getIntValue(ci, Fields.DEBUGMODE);
}
}
System.out.println("debug mode " + debugMode);
logFile.write("Time\t");
for (Sensor sensor : SENSORS) {
logFile.write(sensor.name() + "\t");
logFile.write(getSensorName(sensor, debugMode) + "\t");
}
logFile.write("\r\n");
@ -149,4 +171,38 @@ public class SensorLogger {
logFile = null;
}
}
private static String getSensorName(Sensor sensor, int debugMode) {
if (sensor == Sensor.debugFloatField2 && isPidDebugMode(debugMode)) {
return "PID: I-term";
}
if (sensor == Sensor.debugFloatField3 && isPidDebugMode(debugMode)) {
return "PID: prevError";
}
if (sensor == Sensor.debugFloatField4 && isPidDebugMode(debugMode)) {
return "PID: I setting";
}
if (sensor == Sensor.debugFloatField5 && isPidDebugMode(debugMode)) {
return "PID: D setting";
}
if (sensor == Sensor.debugFloatField6 && isPidDebugMode(debugMode)) {
return "PID: D-term";
}
if (sensor == Sensor.debugIntField1 && isPidDebugMode(debugMode)) {
return "PID: P setting";
}
if (sensor == Sensor.debugIntField2 && isPidDebugMode(debugMode)) {
return "PID: offset";
}
return sensor.getName();
}
private static boolean isPidDebugMode(int debugMode) {
// nasty implementation hard-coded debug_mode_e values
return debugMode == 0
|| debugMode == 3
|| debugMode == 7
|| debugMode == 11
|| debugMode == 17;
}
}