simulator: sensor mocking UI is broken fix #5473

This commit is contained in:
rusefillc 2023-07-31 18:21:54 -04:00
parent 0e6a5037aa
commit 31074fa972
8 changed files with 36 additions and 13 deletions

View File

@ -32,6 +32,9 @@ Release template (copy/paste this for new release):
- Latest jSerialComm 2.10.3
- Working disconnect button in Console #4862
### Fixed
- simulator: sensor mocking UI #5473
## July 2023 Release "Day 518"
### Added

View File

@ -0,0 +1,13 @@
package com.rusefi;
import com.rusefi.enums.SensorType;
public class SensorTypeHelper {
public static SensorType valueOfAnyCase(String name) {
for (SensorType type : SensorType.values()) {
if (type.name().equalsIgnoreCase(name))
return type;
}
throw new IllegalArgumentException("SensorType not found " + name);
}
}

View File

@ -2,7 +2,6 @@ package com.rusefi.core;
import com.rusefi.config.Field;
import com.rusefi.config.FieldType;
import com.rusefi.config.generated.EngineState;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.FuelComputer;
import com.rusefi.config.generated.TsOutputs;
@ -53,7 +52,7 @@ public enum Sensor implements BinaryLogEntry {
MAP(GAUGE_NAME_MAP, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, TsOutputs.MAPVALUE, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"),
BARO(GAUGE_NAME_BARO_PRESSURE, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, TsOutputs.BAROPRESSURE, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"),
Lambda(GAUGE_NAME_LAMBDA, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, TsOutputs.LAMBDAVALUE, 1.0 / PACK_MULT_LAMBDA, 0.65, 1.2, "lambda"),
Lambda1(GAUGE_NAME_LAMBDA, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, TsOutputs.LAMBDAVALUE, 1.0 / PACK_MULT_LAMBDA, 0.65, 1.2, "lambda"),
VBATT(GAUGE_NAME_VBAT, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, TsOutputs.VBATT, 1.0 / PACK_MULT_VOLTAGE, 4, 18, "Volts"),
// oilPressure(GAUGE_NAME_OIL_PRESSURE, SensorCategory.SENSOR_INPUTS, FieldType.INT16, 40, 1.0 / PACK_MULT_PRESSURE, 0, 5, "X"),

View File

@ -6,7 +6,7 @@ import java.net.URL;
import java.util.concurrent.atomic.AtomicReference;
public class rusEFIVersion {
public static final int CONSOLE_VERSION = 20230728;
public static final int CONSOLE_VERSION = 20230731;
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
public static long classBuildTimeMillis() {

View File

@ -30,7 +30,7 @@ public class BinarySensorLogSandbox {
Sensor.etbTarget,
Sensor.etb1DutyCycle,
Sensor.totalTriggerErrorCounter,
Sensor.Lambda,
Sensor.Lambda1,
// Sensor.TARGET_AFR,
Sensor.FIRMWARE_VERSION,
Sensor.CLT));

View File

@ -26,7 +26,7 @@ public class SensorLogger {
Sensor.MAF,
Sensor.MAP,
Sensor.instantMAP,
Sensor.Lambda,
Sensor.Lambda1,
Sensor.PPS,
Sensor.ETB_CONTROL_QUALITY,

View File

@ -41,7 +41,7 @@ public class GaugesPanel {
Sensor.etbTarget,
Sensor.lastErrorCode,
Sensor.Lambda,
Sensor.Lambda1,
Sensor.VBATT,
Sensor.vehicleSpeedKph,

View File

@ -1,6 +1,8 @@
package com.rusefi.ui.widgets;
import com.rusefi.SensorTypeHelper;
import com.rusefi.core.Sensor;
import com.rusefi.enums.SensorType;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.IMethodInvocation;
import com.rusefi.io.InvocationConfirmationListener;
@ -8,6 +10,7 @@ import com.rusefi.io.LinkManager;
import com.rusefi.ui.UIContext;
import com.rusefi.core.preferences.storage.Node;
import com.rusefi.ui.util.UiUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -21,6 +24,8 @@ import java.util.Collection;
import java.util.Hashtable;
import java.util.concurrent.atomic.AtomicReference;
import static com.rusefi.config.generated.Fields.CMD_SET_SENSOR_MOCK;
/**
* Andrey Belomutskiy, (c) 2013-2020
* 11/2/14
@ -31,7 +36,7 @@ public class DetachedSensor {
private static final Collection<Sensor> MOCKABLE = Arrays.asList(
Sensor.CLT,
Sensor.Lambda,
Sensor.Lambda1,
Sensor.IAT,
Sensor.MAF,
Sensor.MAP,
@ -59,7 +64,7 @@ public class DetachedSensor {
private final JFrame frame;
private final JPanel mockControlPanel = new JPanel(new BorderLayout());
private Sensor sensor;
@org.jetbrains.annotations.NotNull
@NotNull
private final UIContext uiContext;
private final int width;
@ -105,7 +110,7 @@ public class DetachedSensor {
mockControlPanel.removeAll();
boolean isMockable = isMockable();
if (isMockable) {
Component mockComponent = createMockVoltageSlider(uiContext.getCommandQueue(), sensor);
Component mockComponent = createMockValueSlider(uiContext.getCommandQueue(), sensor);
mockControlPanel.add(mockComponent);
}
UiUtils.trueLayout(content);
@ -118,8 +123,11 @@ public class DetachedSensor {
return MOCKABLE.contains(sensor) && LinkManager.isSimulationMode;
}
public static Component createMockVoltageSlider(CommandQueue commandQueue, final Sensor sensor) {
final JSlider slider = new JSlider(0, _5_VOLTS_WITH_DECIMAL);
public static Component createMockValueSlider(CommandQueue commandQueue, final Sensor sensor) {
SensorType sensorType = SensorTypeHelper.valueOfAnyCase(sensor.getName());
int maxValue = 200;
final JSlider slider = new JSlider(0, maxValue);
slider.setLabelTable(SLIDER_LABELS);
slider.setPaintLabels(true);
slider.setPaintTicks(true);
@ -131,7 +139,7 @@ public class DetachedSensor {
IMethodInvocation commandSender = new IMethodInvocation() {
@Override
public String getCommand() {
return "set mock_" + sensor.name().toLowerCase() + "_voltage " + pendingValue.get();
return CMD_SET_SENSOR_MOCK + " " + sensorType.ordinal() + " " + pendingValue.get();
}
@Override
@ -152,7 +160,7 @@ public class DetachedSensor {
slider.addChangeListener(e -> {
double value = slider.getValue() / 10.0;
double value = slider.getValue();
pendingValue.set(value);
/*