error counter on formula pane

This commit is contained in:
rusefi 2017-08-05 17:34:58 -04:00
parent e748d50a39
commit f8d1f59250
6 changed files with 55 additions and 19 deletions

View File

@ -100,7 +100,7 @@ public enum Sensor {
// todo: unify with TIMING // todo: unify with TIMING
ignitionAdvance(SensorCategory.OPERATIONS, FieldType.FLOAT, 56, BackgroundColor.MUD, 30, 140), ignitionAdvance(SensorCategory.OPERATIONS, FieldType.FLOAT, 56, BackgroundColor.MUD, 30, 140),
DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.FLOAT, 60, BackgroundColor.MUD, 1, 10), DWELL(Fields.GAUGE_COIL_DWELL_TIME, SensorCategory.OPERATIONS, FieldType.FLOAT, 60, BackgroundColor.MUD, 1, 10),
actualLastInjection(SensorCategory.FUEL, FieldType.FLOAT, 64, BackgroundColor.MUD, 0, 30, "ms"), actualLastInjection(SensorCategory.FUEL, FieldType.FLOAT, /*offset */ 64, BackgroundColor.MUD, 0, 30, "ms"),
debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.OPERATIONS, FieldType.FLOAT, 68, BackgroundColor.MUD, 0, 5), debugFloatField1(GAUGE_NAME_DEBUG_F1, SensorCategory.OPERATIONS, FieldType.FLOAT, 68, BackgroundColor.MUD, 0, 5),
VSS(SensorCategory.OPERATIONS, FieldType.FLOAT, 76, BackgroundColor.BLUE), VSS(SensorCategory.OPERATIONS, FieldType.FLOAT, 76, BackgroundColor.BLUE),
FIRMWARE_VERSION(SensorCategory.OPERATIONS, FieldType.INT, 84, BackgroundColor.BLUE), FIRMWARE_VERSION(SensorCategory.OPERATIONS, FieldType.INT, 84, BackgroundColor.BLUE),
@ -128,7 +128,7 @@ public enum Sensor {
debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.OPERATIONS, FieldType.INT, 216, BackgroundColor.MUD, 0, 5), debugIntField2(GAUGE_NAME_DEBUG_I2, SensorCategory.OPERATIONS, FieldType.INT, 216, BackgroundColor.MUD, 0, 5),
debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.OPERATIONS, FieldType.INT, 220, BackgroundColor.MUD, 0, 5), debugIntField3(GAUGE_NAME_DEBUG_I3, SensorCategory.OPERATIONS, FieldType.INT, 220, BackgroundColor.MUD, 0, 5),
warningCounter(SensorCategory.OPERATIONS, FieldType.INT, 236, BackgroundColor.MUD, 0, 5), errorCodeCounter(SensorCategory.OPERATIONS, FieldType.INT, 236, BackgroundColor.MUD, 0, 5),
lastErrorCode(SensorCategory.OPERATIONS, FieldType.INT, 240, BackgroundColor.MUD, 0, 5), lastErrorCode(SensorCategory.OPERATIONS, FieldType.INT, 240, BackgroundColor.MUD, 0, 5),
RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000), RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000),

View File

@ -88,7 +88,7 @@ public class SensorCentral {
addDoubleSensor("tp", Sensor.TPS, es); addDoubleSensor("tp", Sensor.TPS, es);
addDoubleSensor("pps", Sensor.TPS, es); addDoubleSensor("pps", Sensor.TPS, es);
addDoubleSensor("error", Sensor.lastErrorCode, es); addDoubleSensor("error", Sensor.lastErrorCode, es);
addDoubleSensor("warn", Sensor.warningCounter, es); addDoubleSensor("warn", Sensor.errorCodeCounter, es);
addDoubleSensor("knck_c", Sensor.knockCount, es); addDoubleSensor("knck_c", Sensor.knockCount, es);
addDoubleSensor("knck_v", Sensor.KnockValue, es); addDoubleSensor("knck_v", Sensor.KnockValue, es);
addDoubleSensor("target", Sensor.TARGET_AFR, es); addDoubleSensor("target", Sensor.TARGET_AFR, es);

View File

@ -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 = 20170723; public static final int CONSOLE_VERSION = 20170805;
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";

View File

@ -71,7 +71,7 @@ public class SensorLogger {
Sensor.debugIntField2, Sensor.debugIntField2,
Sensor.debugIntField3, Sensor.debugIntField3,
Sensor.warningCounter, Sensor.errorCodeCounter,
Sensor.lastErrorCode, Sensor.lastErrorCode,
}; };

View File

@ -9,6 +9,7 @@ import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.ui.config.ConfigField; import com.rusefi.ui.config.ConfigField;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.IntGaugeLabel;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.scilab.forge.jlatexmath.TeXConstants; import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula; import org.scilab.forge.jlatexmath.TeXFormula;
@ -24,9 +25,12 @@ import java.awt.image.BufferedImage;
* (c) Andrey Belomutskiy 2013-2017 * (c) Andrey Belomutskiy 2013-2017
*/ */
public class FormulasPane { public class FormulasPane {
private static final String NL = "\r\n \\\\ ";
private static final String NL2 = NL + "\\ " + NL; // two new lines
private static final String NL3 = NL2 + "\\ " + NL; // two new lines
private final JPanel content = new JPanel(new BorderLayout()); private final JPanel content = new JPanel(new BorderLayout());
private final JPanel centerProxy = new JPanel(new BorderLayout()); private final JPanel centerProxy = new JPanel(new BorderLayout());
private final String newLine = "\r\n \\\\ ";
private boolean isPaused; private boolean isPaused;
public FormulasPane() { public FormulasPane() {
@ -57,6 +61,12 @@ public class FormulasPane {
top.add(pauseButton); top.add(pauseButton);
content.add(top, BorderLayout.NORTH); content.add(top, BorderLayout.NORTH);
JPanel bottomPanel = new JPanel(new FlowLayout());
bottomPanel.add(new IntGaugeLabel("count", Sensor.errorCodeCounter));
bottomPanel.add(new IntGaugeLabel("error", Sensor.lastErrorCode));
content.add(bottomPanel, BorderLayout.SOUTH);
updateFormula(); updateFormula();
new Timer(200, new ActionListener() { new Timer(200, new ActionListener() {
@Override @Override
@ -95,7 +105,7 @@ public class FormulasPane {
throw new IllegalStateException("Unexpected "+ algorithm); throw new IllegalStateException("Unexpected "+ algorithm);
engine_load_mode_e algo = values[algorithm]; engine_load_mode_e algo = values[algorithm];
String acceleration = getAccelerationVariables(ci); String acceleration = getAccelerationVariables(ci) + NL2;
String page; String page;
if (algo == engine_load_mode_e.LM_SPEED_DENSITY) { if (algo == engine_load_mode_e.LM_SPEED_DENSITY) {
@ -105,7 +115,7 @@ public class FormulasPane {
double maf = SensorCentral.getInstance().getValue(Sensor.MAF); double maf = SensorCentral.getInstance().getValue(Sensor.MAF);
String baseFuelStr = twoDecimals(Sensor.FUEL_BASE); String baseFuelStr = twoDecimals(Sensor.FUEL_BASE);
String baseFuel = "$Base_Fuel (ms) = lookup (" + String baseFuel = "$Table_Fuel (ms) = lookup (" +
"(RPM = " + rpm + ", " + "(RPM = " + rpm + ", " +
"MAF = " + maf + ") = " + "MAF = " + maf + ") = " +
baseFuelStr + "ms"; baseFuelStr + "ms";
@ -120,7 +130,7 @@ public class FormulasPane {
} }
TeXFormula formula = new TeXFormula("\r\n" + TeXFormula formula = new TeXFormula("\r\n" +
algo.title + newLine + newLine + newLine + page + ""); algo.title + NL3 + page + "");
TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20); TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
@ -158,9 +168,9 @@ public class FormulasPane {
String loadEnrichDelta = "$deltaLoad = max(currentLoad - previousLoad, length = " + elEnrichLength + String loadEnrichDelta = "$deltaLoad = max(currentLoad - previousLoad, length = " + elEnrichLength +
") = " + elDelta + "$"; ") = " + elDelta + "$";
return tpsEnrichDelta + newLine + return tpsEnrichDelta + NL +
tpsEnrich + newLine + tpsEnrich + NL +
loadEnrichDelta + newLine; loadEnrichDelta;
} }
@NotNull @NotNull
@ -194,7 +204,7 @@ public class FormulasPane {
"$"; "$";
String baseFuelStr = twoDecimals(Sensor.FUEL_BASE); String baseFuelStr = twoDecimals(Sensor.FUEL_BASE);
String baseFuel = "$Base_Fuel (ms) = \\frac{" + String baseFuel = "$SD_Fuel (ms) = \\frac{" +
"($Airmass = " + chargeAirMass + ")" + "($Airmass = " + chargeAirMass + ")" +
"}{" + "}{" +
"(TargetAFR (" + rpm_map + ") = " + TARGET_AFR + ")" + "(TargetAFR (" + rpm_map + ") = " + TARGET_AFR + ")" +
@ -209,15 +219,15 @@ public class FormulasPane {
String actualLastInjection = twoDecimals(Sensor.actualLastInjection); String actualLastInjection = twoDecimals(Sensor.actualLastInjection);
String injTime = "$Fuel (ms) = " + String injTime = "$Fuel (ms) = " +
"(Base_Fuel (" + baseFuelStr + "ms) + Tps_Accel_Corr = (" + tpsAccel + "ms))" + "(SD_Fuel (" + baseFuelStr + "ms) + Tps_Accel_Corr = (" + tpsAccel + "ms))" +
tempCorrections + getInjecctorLag() + tempCorrections + NL + getInjecctorLag() +
" = " + actualLastInjection + "ms_per_injection$"; " = " + actualLastInjection + "ms_per_injection$";
return acceleration + return acceleration +
tCharge + newLine + tCharge + NL3 +
mCharge + newLine + mCharge + NL2 +
baseFuel + newLine + baseFuel + NL2 +
injTime + newLine; injTime + NL;
} }
@NotNull @NotNull

View File

@ -0,0 +1,26 @@
package com.rusefi.ui.widgets;
import com.rusefi.config.FieldType;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import javax.swing.*;
/**
* Read-only text representation of an int {@link Sensor}
* <p>
* (c) Andrey Belomutskiy
* 8/5/2017
*/
public class IntGaugeLabel extends JLabel {
public IntGaugeLabel(final String shortName, Sensor sensor) {
if (sensor.getType() != FieldType.INT)
throw new IllegalArgumentException(sensor.name());
SensorCentral.getInstance().addListener(sensor, new SensorCentral.SensorListener() {
@Override
public void onSensorUpdate(double value) {
IntGaugeLabel.this.setText(shortName + ": " + (int)value);
}
});
}
}