REO progress

This commit is contained in:
rusefi 2020-06-14 18:47:58 -04:00
parent 14ede84e8d
commit 91b80cabb7
11 changed files with 97 additions and 19 deletions

View File

@ -1449,7 +1449,7 @@ end_struct
#define GAUGE_NAME_CPU_TEMP "CPU Temperature"
#define GAUGE_NAME_ETB_TARGET "ETB position target"
#define GAUGE_NAME_ETB_ERROR "ETB position error"
#define GAUGE_NAME_ETB_DUTY "ETB duty cycle"
#define GAUGE_NAME_ETB_DUTY "ETB Duty"
#define GAUGE_NAME_ACCEL_X "Acceleration: X"
#define GAUGE_NAME_ACCEL_Y "Acceleration: Y"

View File

@ -1235,7 +1235,7 @@ gaugeCategory = Sensors - Raw
; Electronic throttle body
entry = etb1Error, "ETB Error", float, "%.3f"
entry = etb1DutyCycle, "ETB Duty", float, "%.3f"
entry = etb1DutyCycle, @@GAUGE_NAME_ETB_DUTY@@, float, "%.3f"
entry = etbTarget, "ETB Target", float, "%.3f"

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Sun Jun 14 18:37:49 EDT 2020
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Sun Jun 14 18:44:35 EDT 2020
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@ -541,7 +541,7 @@ public class Fields {
public static final String GAUGE_NAME_DWELL_DUTY = "dwell: coil duty cycle";
public static final String GAUGE_NAME_ECU_TEMPERATURE = "ECU temperature";
public static final String GAUGE_NAME_ENGINE_LOAD = "Engine Load";
public static final String GAUGE_NAME_ETB_DUTY = "ETB duty cycle";
public static final String GAUGE_NAME_ETB_DUTY = "ETB Duty";
public static final String GAUGE_NAME_ETB_ERROR = "ETB position error";
public static final String GAUGE_NAME_ETB_TARGET = "ETB position target";
public static final String GAUGE_NAME_FUEL_BARO_CORR = "fuel: Barometric pressure correction";

View File

@ -95,7 +95,7 @@ public enum Sensor {
engineMakeCodeNameCrc16("engine crc16", SensorCategory.STATUS, FieldType.INT16, 134, 0, 5),
// Errors
errorCodeCounter("error counter", SensorCategory.STATUS, FieldType.INT, 136, 0, 5),
totalTriggerErrorCounter(GAUGE_NAME_TRG_ERR, SensorCategory.STATUS, FieldType.INT, 136, 0, 5),
lastErrorCode("last error", SensorCategory.STATUS, FieldType.INT, 138, 0, 5),
// Debug

View File

@ -18,11 +18,13 @@ import java.util.stream.Collectors;
* </p>
* Andrey Belomutskiy, (c) 2013-2020
*/
public class BinarySensorLog extends SensorLog {
public class BinarySensorLog implements SensorLog {
private final Function<Sensor, Double> valueProvider;
private final Collection<Sensor> sensors;
private DataOutputStream stream;
private String fileName;
private int counter;
public BinarySensorLog() {
@ -49,10 +51,10 @@ public class BinarySensorLog extends SensorLog {
}
@Override
void writeSensorLogLine() {
public void writeSensorLogLine() {
if (stream == null) {
FileLog.createFolderIfNeeded();
String fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".mlg";
fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".mlg";
try {
stream = new DataOutputStream(new FileOutputStream(fileName));
@ -182,6 +184,10 @@ public class BinarySensorLog extends SensorLog {
}
}
public String getFileName() {
return fileName;
}
private void writeLine(DataOutputStream stream, String name, int length) throws IOException {
for (int i = 0; i < name.length(); i++) {
stream.write(name.charAt(i));

View File

@ -1,4 +1,68 @@
package com.rusefi.sensor_logs;
public class BinarySensorLogRestarter {
import com.rusefi.FileLog;
import com.rusefi.Timeouts;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.tools.online.Online;
import com.rusefi.ui.AuthTokenPanel;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class BinarySensorLogRestarter implements SensorLog {
private final static Executor UPLOAD_EXECUTOR = Executors.newSingleThreadExecutor();
private BinarySensorLog logger;
private long seenRunning;
@Override
public double getSecondsSinceFileStart() {
throw new UnsupportedOperationException();
}
@Override
public synchronized void writeSensorLogLine() {
double rpm = SensorCentral.getInstance().getValue(Sensor.RPM);
if (rpm > 200) {
seenRunning = System.currentTimeMillis();
}
if (rpm == 0 && seenRunning > 0 && (System.currentTimeMillis() - seenRunning) > 5 * Timeouts.SECOND) {
// restart logging 5 seconds after last positive RPM
close();
}
if (logger == null) {
logger = new BinarySensorLog();
}
logger.writeSensorLogLine();
}
@Override
public synchronized void close() {
if (logger != null) {
logger.close();
String fileName = logger.getFileName();
scheduleUpload(fileName);
}
logger = null;
seenRunning = 0;
}
private void scheduleUpload(String fileName) {
FileLog.MAIN.logLine("Will upload " + fileName);
UPLOAD_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
try {
Online.upload(new File(fileName), AuthTokenPanel.getAuthToken());
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}

View File

@ -12,7 +12,7 @@ public class BinarySensorLogSandbox {
Map<Sensor, Double> values = new HashMap<>();
Function<Sensor, Double> valueProvider = sensor -> {
Double result = values.get(sensor);
Double result = values.getOrDefault(sensor, 0.0);
Objects.requireNonNull(result, "value for sensor");
return result;
};
@ -21,6 +21,14 @@ public class BinarySensorLogSandbox {
Sensor.TIME_SECONDS,
Sensor.RPM,
Sensor.VSS,
Sensor.TPS,
Sensor.PPS,
Sensor.veValue,
Sensor.etbTarget,
Sensor.etb1DutyCycle,
Sensor.totalTriggerErrorCounter,
Sensor.AFR,
Sensor.TARGET_AFR,
Sensor.FIRMWARE_VERSION,
Sensor.CLT);

View File

@ -19,7 +19,7 @@ import java.io.Writer;
* </p>
* Andrey Belomutskiy, (c) 2013-2020
*/
public class PlainTextSensorLog extends SensorLog {
public class PlainTextSensorLog implements SensorLog {
private Writer logFile;
private long fileStartTime;
@ -80,7 +80,7 @@ public class PlainTextSensorLog extends SensorLog {
}
@Override
void writeSensorLogLine() {
public void writeSensorLogLine() {
startIfNeeded();
if (logFile == null)
return;

View File

@ -1,9 +1,9 @@
package com.rusefi.sensor_logs;
public abstract class SensorLog {
public abstract double getSecondsSinceFileStart();
public interface SensorLog {
double getSecondsSinceFileStart();
abstract void writeSensorLogLine();
void writeSensorLogLine();
public abstract void close();
void close();
}

View File

@ -73,14 +73,14 @@ public class SensorLogger {
Sensor.debugIntField4,
Sensor.debugIntField5,
Sensor.errorCodeCounter,
Sensor.totalTriggerErrorCounter,
Sensor.lastErrorCode,
Sensor.engineMakeCodeNameCrc16,
Sensor.tuneCrc16,
};
private static List<SensorLog> sensorLogs = Arrays.asList(new PlainTextSensorLog(), new BinarySensorLog());
private static List<SensorLog> sensorLogs = Arrays.asList(new PlainTextSensorLog(), new BinarySensorLogRestarter());
private static boolean isInitialized;

View File

@ -76,7 +76,7 @@ public class FormulasPane {
content.add(topButtonsPanel, BorderLayout.NORTH);
JPanel bottomPanel = new JPanel(new FlowLayout());
bottomPanel.add(new IntGaugeLabel("count", Sensor.errorCodeCounter));
bottomPanel.add(new IntGaugeLabel("count", Sensor.totalTriggerErrorCounter));
bottomPanel.add(new IntGaugeLabel("error", Sensor.lastErrorCode));
content.add(bottomPanel, BorderLayout.SOUTH);