auto-sync
This commit is contained in:
parent
9f382381a7
commit
06a80fb2a6
|
@ -58,7 +58,7 @@ EXTERN_ENGINE
|
|||
;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
|
||||
static LocalVersionHolder localVersion;
|
||||
static LocalVersionHolder triggerVersion;
|
||||
|
||||
extern engine_pins_s enginePins;
|
||||
static MainTriggerCallback mainTriggerCallbackInstance;
|
||||
|
@ -334,7 +334,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
|
|||
int revolutionIndex = engine->rpmCalculator.getRevolutionCounter() % 2;
|
||||
|
||||
if (eventIndex == 0) {
|
||||
if (localVersion.isOld())
|
||||
if (triggerVersion.isOld())
|
||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static int stopEmulationAtIndex = DO_NOT_STOP;
|
|||
static bool isEmulating = true;
|
||||
|
||||
static Logging *logger;
|
||||
static LocalVersionHolder localVersion;
|
||||
static LocalVersionHolder emulatorConfigVersion;
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
|
@ -89,8 +89,8 @@ void setTriggerEmulatorRPM(int rpm, Engine *engine) {
|
|||
}
|
||||
|
||||
static void updateTriggerShapeIfNeeded(PwmConfig *state) {
|
||||
if (localVersion.isOld()) {
|
||||
scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", localVersion.getVersion(),
|
||||
if (emulatorConfigVersion.isOld()) {
|
||||
scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", emulatorConfigVersion.getVersion(),
|
||||
getGlobalConfigurationVersion(), currentTimeMillis());
|
||||
|
||||
applyNonPersistentConfiguration(logger, engine);
|
||||
|
|
|
@ -11,7 +11,10 @@ int getGlobalConfigurationVersion(void);
|
|||
|
||||
//ctor
|
||||
LocalVersionHolder::LocalVersionHolder() {
|
||||
localVersion = 0;
|
||||
/**
|
||||
* we want local version to be 'old' on instantiation
|
||||
*/
|
||||
localVersion = -1;
|
||||
}
|
||||
|
||||
int LocalVersionHolder::getVersion() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import org.apache.commons.math3.stat.descriptive.moment.Mean;
|
||||
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -49,9 +50,10 @@ public class AverageAngles {
|
|||
}
|
||||
}
|
||||
|
||||
public void printReport() {
|
||||
public void printReport(PrintStream stream) {
|
||||
List<Double> angles = new ArrayList<>();
|
||||
|
||||
stream.println("index,average,stdev");
|
||||
|
||||
for (Map.Entry<Integer, List<Double>> e : angleData.entrySet()) {
|
||||
int k = e.getKey();
|
||||
|
@ -68,16 +70,15 @@ public class AverageAngles {
|
|||
|
||||
angles.add(mean);
|
||||
|
||||
System.out.println("i " + k + " average=" + mean + " dev=" + sdv);
|
||||
stream.println(k + "," + mean + "," + sdv);
|
||||
}
|
||||
if (angleData.isEmpty())
|
||||
return;
|
||||
Double lastValue = angles.get(angles.size() - 1);
|
||||
System.out.println("Last value = " + lastValue);
|
||||
stream.println("Last value = " + lastValue);
|
||||
double delta = 720 - lastValue;
|
||||
for (double v : angles) {
|
||||
System.out.println((delta + v));
|
||||
stream.println((delta + v));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class AverageAnglesUtil {
|
|||
System.out.println(line);
|
||||
}
|
||||
|
||||
aa.printReport();
|
||||
aa.printReport(System.out);
|
||||
|
||||
}
|
||||
}
|
|
@ -27,20 +27,10 @@ public class SensorCentral {
|
|||
private SensorCentral() {
|
||||
}
|
||||
|
||||
public double getValueOrNan(Sensor sensor) {
|
||||
Double value = values.get(sensor);
|
||||
if (value == null)
|
||||
return Double.NaN;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: migrate to getValueOrNan implementation?
|
||||
*/
|
||||
public double getValue(Sensor sensor) {
|
||||
Double value = values.get(sensor);
|
||||
if (value == null)
|
||||
throw new NullPointerException("No value for sensor: " + sensor);
|
||||
return Double.NaN;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SensorStats {
|
|||
SensorCentral.getInstance().addListener(input1, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
double valueMs = 1.0 * (value - SensorCentral.getInstance().getValueOrNan(input2)) / WaveReport.SYS_TICKS_PER_MS;
|
||||
double valueMs = 1.0 * (value - SensorCentral.getInstance().getValue(input2)) / WaveReport.SYS_TICKS_PER_MS;
|
||||
SensorCentral.getInstance().setValue(valueMs, destination);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
public class AnalogChartCentral {
|
||||
private static final String KEY = "analog_chart";
|
||||
|
||||
static List<AnalogChartListener> listeners = new CopyOnWriteArrayList<>();
|
||||
private static List<AnalogChartListener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
static {
|
||||
LinkManager.engineState.registerStringValueAction(KEY, new EngineState.ValueCallback<String>() {
|
||||
|
@ -22,6 +22,10 @@ public class AnalogChartCentral {
|
|||
);
|
||||
}
|
||||
|
||||
public static void addListener(AnalogChartListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
interface AnalogChartListener {
|
||||
void onAnalogChart(String analogChart);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class AnalogChartPanel {
|
|||
|
||||
public AnalogChartPanel() {
|
||||
|
||||
AnalogChartCentral.listeners.add(new AnalogChartCentral.AnalogChartListener() {
|
||||
AnalogChartCentral.addListener(new AnalogChartCentral.AnalogChartListener() {
|
||||
@Override
|
||||
public void onAnalogChart(String message) {
|
||||
unpackValues(values, message);
|
||||
|
@ -47,7 +47,6 @@ public class AnalogChartPanel {
|
|||
processValues();
|
||||
UiUtils.trueRepaint(canvas);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -67,17 +66,15 @@ public class AnalogChartPanel {
|
|||
JButton imageButton = new JButton(EngineSnifferPanel.SAVE_IMAGE);
|
||||
imageButton.setMnemonic('s');
|
||||
upperPanel.add(imageButton);
|
||||
imageButton.addActionListener(new
|
||||
imageButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int rpm = RpmModel.getInstance().getValue();
|
||||
String fileName = FileLog.getDate() + "rpm_" + rpm + "_sensor" + ".png";
|
||||
|
||||
ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int rpm = RpmModel.getInstance().getValue();
|
||||
String fileName = FileLog.getDate() + "rpm_" + rpm + "_analog" + ".png";
|
||||
|
||||
UiUtils.saveImageWithPrompt(fileName, upperPanel, canvas);
|
||||
}
|
||||
}
|
||||
UiUtils.saveImageWithPrompt(fileName, upperPanel, canvas);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
final JButton pauseButton = new JButton(PAUSE.getMessage());
|
||||
|
|
|
@ -1,31 +1,58 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static com.rusefi.ui.util.LocalizedMessages.RESET;
|
||||
|
||||
public class AverageAnglePanel {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
private final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
AverageAngles aa = new AverageAngles();
|
||||
private final AverageAngles aa = new AverageAngles();
|
||||
private final JTextArea text = new JTextArea();
|
||||
|
||||
public AverageAnglePanel() {
|
||||
JButton reset = new JButton("reset");
|
||||
JButton reset = new JButton(RESET.getMessage());
|
||||
reset.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
aa.clear();
|
||||
showResults();
|
||||
}
|
||||
});
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
panel.add(reset, BorderLayout.NORTH);
|
||||
panel.add(new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
|
||||
@Override
|
||||
public void onMessage(Class clazz, String message) {
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(400, 400);
|
||||
}
|
||||
});
|
||||
}, BorderLayout.CENTER);
|
||||
|
||||
AnalogChartCentral.addListener(new AnalogChartCentral.AnalogChartListener() {
|
||||
@Override
|
||||
public void onAnalogChart(String message) {
|
||||
int rpm = (int) SensorCentral.getInstance().getValue(Sensor.RPM);
|
||||
aa.add(rpm, message);
|
||||
showResults();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void showResults() {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
aa.printReport(new PrintStream(byteArrayOutputStream));
|
||||
text.setText(byteArrayOutputStream.toString());
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.AverageAnglePanel;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.OutputChannel;
|
||||
|
@ -96,6 +97,8 @@ public class Wizard {
|
|||
|
||||
panel.add(content, BorderLayout.CENTER);
|
||||
|
||||
panel.add(new AverageAnglePanel().getPanel(), BorderLayout.SOUTH);
|
||||
|
||||
button.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
|
@ -4,6 +4,7 @@ public enum LocalizedMessages {
|
|||
CLEAR("clear"),
|
||||
PAUSE("pause"),
|
||||
RESUME("resume"),
|
||||
RESET("reset"),
|
||||
;
|
||||
private final String message;
|
||||
|
||||
|
|
Loading…
Reference in New Issue