REO progress
This commit is contained in:
parent
2af7886dea
commit
330d3414d2
|
@ -93,7 +93,7 @@ public enum FileLog {
|
|||
return new FileOutputStream(fileName, true);
|
||||
}
|
||||
|
||||
static void createFolderIfNeeded() {
|
||||
public static void createFolderIfNeeded() {
|
||||
File dir = new File(DIR);
|
||||
if (dir.exists())
|
||||
return;
|
||||
|
|
|
@ -3,6 +3,6 @@ package com.rusefi;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20200609;
|
||||
public static final int CONSOLE_VERSION = 20200614;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package com.rusefi.sensor_logs;
|
||||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.Launcher;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolHolder;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.ui.config.ConfigField;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class PlainTextSensorLog extends SensorLog {
|
||||
Writer logFile;
|
||||
|
||||
private long fileStartTime;
|
||||
|
||||
|
||||
public void startIfNeeded() {
|
||||
if (logFile == null) {
|
||||
/*
|
||||
* we only start file header once we have first bunch of data
|
||||
*/
|
||||
startSensorLogFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSensorLogFile() {
|
||||
FileLog.createFolderIfNeeded();
|
||||
String fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".msl";
|
||||
|
||||
fileStartTime = System.currentTimeMillis();
|
||||
try {
|
||||
logFile = new FileWriter(fileName);
|
||||
|
||||
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().getCurrentStreamState();
|
||||
if (bp != null) {
|
||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||
if (ci != null) {
|
||||
debugMode = ConfigField.getIntValue(ci, Fields.DEBUGMODE);
|
||||
}
|
||||
}
|
||||
System.out.println("debug mode " + debugMode);
|
||||
logFile.write("Time\t");
|
||||
for (Sensor sensor : SensorLogger.SENSORS) {
|
||||
logFile.write(SensorLogger.getSensorName(sensor, debugMode) + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
|
||||
logFile.write("Time\t");
|
||||
for (Sensor sensor : SensorLogger.SENSORS) {
|
||||
logFile.write(sensor.getUnits() + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
logFile.flush();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSecondsSinceFileStart() {
|
||||
long msSinceFileStart = System.currentTimeMillis() - fileStartTime;
|
||||
return msSinceFileStart / 1000.0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
void writeSensorLogLine() {
|
||||
startIfNeeded();
|
||||
if (logFile == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
logFile.write(getSecondsSinceFileStart() + "\t");
|
||||
for (Sensor sensor : SensorLogger.SENSORS) {
|
||||
logFile.write(SensorCentral.getInstance().getValue(sensor) + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
logFile.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logFile = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.rusefi.sensor_logs;
|
||||
|
||||
public abstract class SensorLog {
|
||||
public abstract double getSecondsSinceFileStart();
|
||||
|
||||
abstract void writeSensorLogLine();
|
||||
}
|
|
@ -1,27 +1,18 @@
|
|||
package com.rusefi;
|
||||
package com.rusefi.sensor_logs;
|
||||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolHolder;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.ConnectionStatusLogic;
|
||||
import com.rusefi.io.ConnectionStatusValue;
|
||||
import com.rusefi.ui.config.ConfigField;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 4/15/2016.
|
||||
*/
|
||||
public class SensorLogger {
|
||||
private static Writer logFile;
|
||||
private static SensorLog sensorLog = new PlainTextSensorLog();
|
||||
|
||||
private static Sensor[] SENSORS = {Sensor.RPM,
|
||||
protected static Sensor[] SENSORS = {Sensor.RPM,
|
||||
Sensor.INT_TEMP,
|
||||
|
||||
Sensor.engineMode,
|
||||
|
@ -87,7 +78,6 @@ public class SensorLogger {
|
|||
Sensor.engineMakeCodeNameCrc16,
|
||||
Sensor.tuneCrc16,
|
||||
};
|
||||
private static long fileStartTime;
|
||||
|
||||
private SensorLogger() {
|
||||
}
|
||||
|
@ -102,81 +92,16 @@ public class SensorLogger {
|
|||
public void onSensorUpdate(double value) {
|
||||
if (ConnectionStatusLogic.INSTANCE.getValue() != ConnectionStatusValue.CONNECTED)
|
||||
return;
|
||||
if (logFile == null) {
|
||||
/*
|
||||
* we only start file header once we have first bunch of data
|
||||
*/
|
||||
startSensorLogFile();
|
||||
}
|
||||
|
||||
writeSensorLogLine();
|
||||
sensorLog.writeSensorLogLine();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void writeSensorLogLine() {
|
||||
if (logFile == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
logFile.write(getSecondsSinceFileStart() + "\t");
|
||||
for (Sensor sensor : SENSORS) {
|
||||
logFile.write(SensorCentral.getInstance().getValue(sensor) + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
logFile.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static double getSecondsSinceFileStart() {
|
||||
long msSinceFileStart = System.currentTimeMillis() - fileStartTime;
|
||||
return msSinceFileStart / 1000.0;
|
||||
return sensorLog.getSecondsSinceFileStart();
|
||||
}
|
||||
|
||||
private static void startSensorLogFile() {
|
||||
FileLog.createFolderIfNeeded();
|
||||
String fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".msl";
|
||||
|
||||
fileStartTime = System.currentTimeMillis();
|
||||
try {
|
||||
logFile = new FileWriter(fileName);
|
||||
|
||||
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().getCurrentStreamState();
|
||||
if (bp != null) {
|
||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||
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(getSensorName(sensor, debugMode) + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
|
||||
logFile.write("Time\t");
|
||||
for (Sensor sensor : SENSORS) {
|
||||
logFile.write(sensor.getUnits() + "\t");
|
||||
}
|
||||
logFile.write("\r\n");
|
||||
logFile.flush();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getSensorName(Sensor sensor, int debugMode) {
|
||||
static String getSensorName(Sensor sensor, int debugMode) {
|
||||
if (sensor == Sensor.debugFloatField1 && isPidDebugMode(debugMode)) {
|
||||
return "PID: output";
|
||||
}
|
|
@ -12,7 +12,7 @@ import javax.swing.*;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.romraider.util.ThreadUtil.sleep;
|
||||
import static com.rusefi.SensorLogger.getSecondsSinceFileStart;
|
||||
import static com.rusefi.sensor_logs.SensorLogger.getSecondsSinceFileStart;
|
||||
import static com.rusefi.Timeouts.SECOND;
|
||||
import static com.rusefi.config.generated.Fields.CMD_ETB_DUTY;
|
||||
import static com.rusefi.etb.TestSequenceStep.count;
|
||||
|
|
Loading…
Reference in New Issue