auto-sync
This commit is contained in:
parent
ba8d743aa2
commit
973af9efe2
|
@ -74,6 +74,7 @@ public class EngineState {
|
|||
SensorStats.start(Sensor.VREF, Sensor.VREF_WIDTH);
|
||||
|
||||
SensorStats.startStandardDeviation(Sensor.DWELL0, Sensor.DWELL0_SD);
|
||||
SensorStats.startDelta(Sensor.INJECTOR_1_DWELL, Sensor.INJECTOR_2_DWELL, Sensor.INJ_1_2_DELTA);
|
||||
|
||||
registerStringValueAction("adcfast_co", NOTHING);
|
||||
registerStringValueAction("adcfast_max", NOTHING);
|
||||
|
|
|
@ -67,6 +67,11 @@ public enum Sensor {
|
|||
|
||||
ADC_FAST("ADC_FAST", "b", 4000),
|
||||
ADC_FAST_AVG("ADC_FAST_AVG", "b", 4000),
|
||||
INJECTOR_1_DWELL("inj #1"),
|
||||
INJECTOR_2_DWELL("inj #2"),
|
||||
|
||||
|
||||
INJ_1_2_DELTA("inj 1-2 delta"),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.irnems.core;
|
||||
|
||||
import com.rusefi.CyclicBuffer;
|
||||
import com.rusefi.waves.WaveReport;
|
||||
|
||||
/**
|
||||
* 7/26/13
|
||||
|
@ -41,15 +42,14 @@ public class SensorStats {
|
|||
* http://en.wikipedia.org/wiki/Standard_deviation
|
||||
*/
|
||||
public static void startStandardDeviation(Sensor source, final Sensor destination) {
|
||||
final CyclicBuffer sb = new CyclicBuffer(30);
|
||||
final CyclicBuffer cb = new CyclicBuffer(30);
|
||||
|
||||
SensorCentral.getInstance().addListener(source, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
sb.add(value);
|
||||
|
||||
if (sb.getSize() == sb.getMaxSize()) {
|
||||
double stdDev = sb.getStandardDeviation();
|
||||
cb.add(value);
|
||||
if (cb.getSize() == cb.getMaxSize()) {
|
||||
double stdDev = cb.getStandardDeviation();
|
||||
SensorCentral.getInstance().setValue(stdDev, destination);
|
||||
}
|
||||
}
|
||||
|
@ -57,4 +57,14 @@ public class SensorStats {
|
|||
);
|
||||
}
|
||||
|
||||
public static void startDelta(Sensor input1, final Sensor input2, final Sensor destination) {
|
||||
final CyclicBuffer cb = new CyclicBuffer(30);
|
||||
SensorCentral.getInstance().addListener(input1, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
double valueMs = 1.0 * (value - SensorCentral.getInstance().getValue(input2)) / WaveReport.SYS_TICKS_PER_MS;
|
||||
SensorCentral.getInstance().setValue(valueMs, destination);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.irnems.core.Sensor;
|
||||
import com.irnems.core.SensorCentral;
|
||||
import com.irnems.waves.TimeAxisTranslator;
|
||||
import com.rusefi.ui.WavePanel;
|
||||
import com.rusefi.waves.WaveReport;
|
||||
|
@ -10,6 +12,8 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* This is a renderer of an individual {@link WaveReport} - this makes a simple Logical Analyzer
|
||||
|
@ -17,6 +21,7 @@ import java.util.Date;
|
|||
* <p/>
|
||||
* Date: 6/23/13
|
||||
* (c) Andrey Belomutskiy
|
||||
*
|
||||
* @see WavePanel
|
||||
*/
|
||||
public class UpDownImage extends JPanel {
|
||||
|
@ -32,6 +37,13 @@ public class UpDownImage extends JPanel {
|
|||
private RevolutionLog time2rpm = RevolutionLog.parseRevolutions(null);
|
||||
private String pin = "";
|
||||
|
||||
private static final Map<String, Sensor> name2sensor = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
static {
|
||||
name2sensor.put("inj1", Sensor.INJECTOR_1_DWELL);
|
||||
name2sensor.put("inj2", Sensor.INJECTOR_2_DWELL);
|
||||
}
|
||||
|
||||
public UpDownImage(final String name) {
|
||||
this(WaveReport.MOCK, name);
|
||||
setToolTip();
|
||||
|
@ -49,10 +61,6 @@ public class UpDownImage extends JPanel {
|
|||
this.zoomProvider = zoomProvider;
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
trueRepaint(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This does not make any sense :( That's an attempt
|
||||
* to hack http://rusefi.com/forum/viewtopic.php?f=2&t=631&p=10083#p10081
|
||||
|
@ -117,9 +125,21 @@ public class UpDownImage extends JPanel {
|
|||
|
||||
public void setWaveReport(WaveReport wr, StringBuilder revolutions) {
|
||||
this.wr = wr;
|
||||
propagateDwellIntoSensor(wr);
|
||||
this.revolutions = revolutions;
|
||||
lastUpdateTime = System.currentTimeMillis();
|
||||
onUpdate();
|
||||
trueRepaint(this);
|
||||
}
|
||||
|
||||
private void propagateDwellIntoSensor(WaveReport wr) {
|
||||
Sensor sensor = name2sensor.get(name);
|
||||
if (sensor == null)
|
||||
return;
|
||||
|
||||
if (!wr.getList().isEmpty()) {
|
||||
WaveReport.UpDown last = wr.getList().get(wr.getList().size() - 1);
|
||||
SensorCentral.getInstance().setValue(last.getDuration(), sensor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -224,9 +244,6 @@ public class UpDownImage extends JPanel {
|
|||
|
||||
g.setColor(Color.green);
|
||||
g.drawString(toAngle, x1 + offset, (int) (1.0 * d.height));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setRevolutions(StringBuilder revolutions) {
|
||||
|
|
Loading…
Reference in New Issue