auto-sync

This commit is contained in:
rusEfi 2015-02-16 09:06:15 -06:00
parent 6806e6cf0a
commit d8846afac2
10 changed files with 154 additions and 31 deletions

View File

@ -0,0 +1,13 @@
package com.rusefi.config;
public class Field {
private final int offset;
public Field(int offset) {
this.offset = offset;
}
public int getOffset() {
return offset;
}
}

View File

@ -0,0 +1,5 @@
package com.rusefi.config;
public class Fields {
public static final Field ANALOGCHARTFREQUENCY = new Field(768);
}

View File

@ -0,0 +1,29 @@
package com.rusefi;
import com.irnems.core.EngineState;
import com.rusefi.io.LinkManager;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class AnalogChartCentral {
private static final String KEY = "analog_chart";
static List<AnalogChartListener> listeners = new CopyOnWriteArrayList<>();
static {
LinkManager.engineState.registerStringValueAction(KEY, new EngineState.ValueCallback<String>() {
@Override
public void onUpdate(String message) {
for (AnalogChartListener listener : listeners)
listener.onAnalogChart(message);
}
}
);
}
interface AnalogChartListener {
void onAnalogChart(String analogChart);
}
}

View File

@ -1,11 +1,11 @@
package com.rusefi;
import com.irnems.FileLog;
import com.irnems.core.EngineState;
import com.rusefi.io.LinkManager;
import com.rusefi.config.Fields;
import com.rusefi.ui.RpmModel;
import com.rusefi.ui.UiUtils;
import com.rusefi.ui.WavePanel;
import com.rusefi.ui.config.ConfigField;
import com.rusefi.ui.widgets.URLLabel;
import com.rusefi.ui.widgets.UpDownImage;
@ -20,11 +20,10 @@ import java.util.List;
* Date: 12/21/13
* Andrey Belomutskiy (c) 2012-2013
*/
public class AnalogChartPanel extends JPanel {
private static final String KEY = "analog_chart";
public class AnalogChartPanel {
private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Analog_Chart";
private final TreeMap<Double, Double> values = new TreeMap<Double, Double>();
private final TreeMap<Double, Double> values = new TreeMap<>();
private final AnalogChart analogChart = new AnalogChart();
private double minX;
@ -32,25 +31,24 @@ public class AnalogChartPanel extends JPanel {
private double minY;
private double maxY;
private final JPanel content = new JPanel(new BorderLayout());
private boolean paused = false;
public AnalogChartPanel() {
super(new BorderLayout());
LinkManager.engineState.registerStringValueAction(KEY, new EngineState.ValueCallback<String>() {
@Override
public void onUpdate(String message) {
unpackValues(values, message);
AnalogChartCentral.listeners.add(new AnalogChartCentral.AnalogChartListener() {
@Override
public void onAnalogChart(String message) {
unpackValues(values, message);
// MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
processValues();
UpDownImage.trueRepaint(analogChart);
processValues();
UpDownImage.trueRepaint(analogChart);
}
}
);
}
});
final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
@ -75,7 +73,6 @@ public class AnalogChartPanel extends JPanel {
upperPanel.add(new URLLabel(WavePanel.HELP_TEXT, HELP_URL));
pauseButton.addActionListener(new
ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -85,25 +82,36 @@ public class AnalogChartPanel extends JPanel {
}
);
add(upperPanel, BorderLayout.NORTH);
upperPanel.setBorder(BorderFactory.createLineBorder(Color.white));
content.add(upperPanel, BorderLayout.NORTH);
add(analogChart, BorderLayout.CENTER);
content.add(analogChart, BorderLayout.CENTER);
final JPanel lowerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
lowerPanel.setBorder(BorderFactory.createLineBorder(Color.white));
content.add(lowerPanel, BorderLayout.SOUTH);
lowerPanel.add(new ConfigField(Fields.ANALOGCHARTFREQUENCY).getContent());
}
private void processValues() {
List<Double> keys = new ArrayList<Double>(values.keySet());
List<Double> keys = new ArrayList<>(values.keySet());
minX = keys.get(0);
maxX = keys.get(keys.size() - 1);
FileLog.rlog("Analog chart from " + minX + " to " + maxX);
TreeSet<Double> sortedValues = new TreeSet<Double>();
TreeSet<Double> sortedValues = new TreeSet<>();
sortedValues.addAll(values.values());
List<Double> values = new ArrayList<Double>(sortedValues);
List<Double> values = new ArrayList<>(sortedValues);
minY = values.get(0);
maxY = values.get(values.size() - 1);
}
public JComponent getPanel() {
return content;
}
private class AnalogChart extends JComponent {
@Override
public void paint(Graphics g) {

View File

@ -0,0 +1,31 @@
package com.rusefi;
import com.irnems.core.MessagesCentral;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class AverageAnglePanel {
final JPanel panel = new JPanel(new BorderLayout());
AverageAngles aa = new AverageAngles();
public AverageAnglePanel() {
JButton reset = new JButton("reset");
reset.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
aa.clear();
}
});
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
@Override
public void onMessage(Class clazz, String message) {
}
});
}
}

View File

@ -23,7 +23,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see WavePanel
*/
public class Launcher extends FrameHelper {
public static final int CONSOLE_VERSION = 20150214;
public static final int CONSOLE_VERSION = 20150216;
public static final boolean SHOW_STIMULATOR = true;
public static final String TAB_INDEX = "main_tab";
private final String port;
@ -47,8 +47,8 @@ public class Launcher extends FrameHelper {
RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges"));
tabbedPane.addTab("Main", mainGauges.createRpmPanel());
tabbedPane.addTab("Gauges", new GaugesPanel().getContent());
tabbedPane.addTab("Digital Sniffer", wavePanel.getPanel());
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel());
tabbedPane.addTab("Engine Sniffer", wavePanel.getPanel());
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel().getPanel());
tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());

View File

@ -0,0 +1,15 @@
package com.rusefi.test;
import com.rusefi.AnalogChartPanel;
import com.rusefi.ui.FrameHelper;
/**
* 2/16/15
* (c) Andrey Belomutskiy
*/
public class AnalogChartPanelSandbox extends FrameHelper {
public static void main(String[] args) {
new EcuStimulatorSandbox().showFrame(new AnalogChartPanel().getPanel());
}
}

View File

@ -9,13 +9,8 @@ public class VoltageDividerTest extends TestCase {
@Test
public void testR1() {
assertEquals(2000.0, PotCommand.getR1InVoltageDivider3(1, 5, 10000));
assertEquals(2040.816326530612, PotCommand.getR1InVoltageDivider3(1, 4.9, 10000));
}
}

View File

@ -23,7 +23,7 @@ import java.util.*;
import java.util.List;
/**
* Digital Sniffer control consists of a set of {@link UpDownImage}
* Engine Sniffer control consists of a set of {@link UpDownImage}
* <p/>
* <p/>
* Date: 6/23/13

View File

@ -0,0 +1,27 @@
package com.rusefi.ui.config;
import com.rusefi.config.Field;
import javax.swing.*;
import java.awt.*;
public class ConfigField {
private final Field field;
private final JPanel content = new JPanel(new FlowLayout());
private final JLabel status = new JLabel("P");
private final JTextField view = new JTextField();
public ConfigField(Field field) {
this.field = field;
content.add(status);
status.setToolTipText("Pending...");
content.add(view);
}
public JPanel getContent() {
return content;
}
}