parent
5b7d6fc59e
commit
f1faf16a78
|
@ -6,6 +6,7 @@ import com.rusefi.IoUtil;
|
|||
import com.rusefi.TestingUtils;
|
||||
import com.rusefi.Timeouts;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.ISensorCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
|
@ -44,17 +45,18 @@ public class EcuTestHelper {
|
|||
sleepSeconds(settleTime);
|
||||
AtomicReference<String> result = new AtomicReference<>();
|
||||
long start = System.currentTimeMillis();
|
||||
SensorCentral.SensorListener listener = value -> {
|
||||
double actualRpm = SensorCentral.getInstance().getValue(Sensor.RPM);
|
||||
|
||||
ISensorCentral.ListenerToken listener = SensorCentral.getInstance().addListener(Sensor.RPM, actualRpm -> {
|
||||
if (!isCloseEnough(rpm, actualRpm)) {
|
||||
long seconds = (System.currentTimeMillis() - start) / 1000;
|
||||
result.set("Got " + actualRpm + " while trying to stay at " + rpm + " after " + seconds + " seconds");
|
||||
}
|
||||
};
|
||||
SensorCentral.getInstance().addListener(Sensor.RPM, listener);
|
||||
});
|
||||
|
||||
sleepSeconds(testDuration);
|
||||
callback.apply(result.get());
|
||||
SensorCentral.getInstance().removeListener(Sensor.RPM, listener);
|
||||
|
||||
listener.remove();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -131,7 +133,7 @@ public class EcuTestHelper {
|
|||
sleepSeconds(2);
|
||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
|
||||
// TODO: document the reason for this sleep?!
|
||||
sleepSeconds(3);
|
||||
sleepSeconds(1);
|
||||
sendCommand(getEnableCommand(Fields.CMD_PWM));
|
||||
sendCommand(getEnableCommand(Fields.CMD_SELF_STIMULATION));
|
||||
// // we need to skip one chart since it might have been produced with previous engine type
|
||||
|
|
|
@ -31,12 +31,7 @@ public class ConnectionStatusLogic {
|
|||
private List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private ConnectionStatusLogic() {
|
||||
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
markConnected();
|
||||
}
|
||||
});
|
||||
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, value -> markConnected());
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
|
|
@ -48,36 +48,30 @@ public class SensorStats {
|
|||
public static void startStandardDeviation(Sensor source, final Sensor destination) {
|
||||
final CyclicBuffer cb = new CyclicBuffer(30);
|
||||
|
||||
SensorCentral.getInstance().addListener(source, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
cb.add(value);
|
||||
if (cb.getSize() == cb.getMaxSize()) {
|
||||
double stdDev = DataBuffer.getStandardDeviation(cb.getValues());
|
||||
SensorCentral.getInstance().setValue(stdDev, destination);
|
||||
}
|
||||
SensorCentral.getInstance().addListener(source,
|
||||
value -> {
|
||||
cb.add(value);
|
||||
if (cb.getSize() == cb.getMaxSize()) {
|
||||
double stdDev = DataBuffer.getStandardDeviation(cb.getValues());
|
||||
SensorCentral.getInstance().setValue(stdDev, destination);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static void startDelta(Sensor input1, final Sensor input2, final Sensor destination) {
|
||||
SensorCentral.getInstance().addListener(input1, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
double valueMs = 1.0 * (value - SensorCentral.getInstance().getValue(input2)) / EngineReport.ENGINE_SNIFFER_TICKS_PER_MS;
|
||||
SensorCentral.getInstance().addListener(input1,
|
||||
value -> {
|
||||
double valueMs = (value - SensorCentral.getInstance().getValue(input2)) / EngineReport.ENGINE_SNIFFER_TICKS_PER_MS;
|
||||
SensorCentral.getInstance().setValue(valueMs, destination);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void startConversion(final Sensor source, final Sensor destination, final SensorConversion conversion) {
|
||||
SensorCentral.getInstance().addListener(source, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
SensorCentral.getInstance().addListener(source,
|
||||
value -> {
|
||||
double converted = conversion.convertValue(value);
|
||||
SensorCentral.getInstance().setValue(converted, destination);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,15 +96,13 @@ public class SensorLogger {
|
|||
return;
|
||||
}
|
||||
isInitialized = true;
|
||||
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS,
|
||||
value -> {
|
||||
if (ConnectionStatusLogic.INSTANCE.getValue() != ConnectionStatusValue.CONNECTED)
|
||||
return;
|
||||
for (SensorLog sensorLog : sensorLogs)
|
||||
sensorLog.writeSensorLogLine();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public double getSecondsSinceFileStart() {
|
||||
|
|
|
@ -285,9 +285,7 @@ public class FuelTunePane {
|
|||
|
||||
public void showContent() {
|
||||
final ISensorCentral sc = SensorCentral.getInstance();
|
||||
sc.addListener(Sensor.RPM, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
sc.addListener(Sensor.RPM, value -> {
|
||||
if (!collect.isSelected())
|
||||
return;
|
||||
int rpm = (int) value;
|
||||
|
@ -303,7 +301,7 @@ public class FuelTunePane {
|
|||
incomingDataPoints.add(newPoint);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
loadArray(veLoadBins, veLoadOffset);
|
||||
loadArray(veRpmBins, veRpmOffset);
|
||||
|
|
|
@ -27,12 +27,7 @@ public class RpmModel {
|
|||
}
|
||||
|
||||
private RpmModel() {
|
||||
SensorCentral.getInstance().addListener(Sensor.RPM, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
setValue((int) value);
|
||||
}
|
||||
});
|
||||
SensorCentral.getInstance().addListener(Sensor.RPM, value -> setValue((int) value));
|
||||
}
|
||||
|
||||
public void setValue(int rpm) {
|
||||
|
|
|
@ -45,13 +45,7 @@ public class LightweightGUI {
|
|||
|
||||
|
||||
JLabel firmwareVersion = new JLabel();
|
||||
SensorCentral.getInstance().addListener(Sensor.FIRMWARE_VERSION, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
firmwareVersion.setText(Integer.toString((int) value));
|
||||
}
|
||||
});
|
||||
|
||||
SensorCentral.getInstance().addListener(Sensor.FIRMWARE_VERSION, value -> firmwareVersion.setText(Integer.toString((int) value)));
|
||||
leftPanel.add(firmwareVersion);
|
||||
|
||||
content.add(topPanel, BorderLayout.NORTH);
|
||||
|
|
|
@ -123,12 +123,7 @@ public class LiveDocPanel {
|
|||
}
|
||||
});
|
||||
result.addControl(label);
|
||||
SensorCentral.getInstance().addListener(sensor, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
label.setText(niceToString(value, LIVE_DATA_PRECISION));
|
||||
}
|
||||
});
|
||||
SensorCentral.getInstance().addListener(sensor, value -> label.setText(niceToString(value, LIVE_DATA_PRECISION)));
|
||||
} else if (r instanceof IfRequest) {
|
||||
IfRequest request = (IfRequest) r;
|
||||
|
||||
|
|
|
@ -16,11 +16,7 @@ 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);
|
||||
}
|
||||
});
|
||||
|
||||
SensorCentral.getInstance().addListener(sensor, value -> setText(shortName + ": " + (int)value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,14 @@ public class SensorGauge {
|
|||
|
||||
gauge.setBackgroundColor(BackgroundColor.LIGHT_GRAY);
|
||||
|
||||
SensorCentral.getInstance().addListener(sensor, new SensorCentral.SensorListener() {
|
||||
public void onSensorUpdate(double value) {
|
||||
SensorCentral.getInstance().addListener(sensor,
|
||||
value -> {
|
||||
if (GaugesPanel.IS_PAUSED)
|
||||
return;
|
||||
gauge.setValue(sensor.translateValue(value));
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
gauge.setValue(sensor.translateValue(SensorCentral.getInstance().getValue(sensor)));
|
||||
gauge.setLcdDecimals(2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue