mirror of https://github.com/FOME-Tech/fome-fw.git
auto-sync
This commit is contained in:
parent
01c0e7912f
commit
3ca20dbbdf
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.rusefi.config;
|
||||||
|
|
||||||
|
public class Fields {
|
||||||
|
public static final Field ANALOGCHARTFREQUENCY = new Field(768);
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.irnems.FileLog;
|
import com.irnems.FileLog;
|
||||||
import com.irnems.core.EngineState;
|
import com.rusefi.config.Fields;
|
||||||
import com.rusefi.io.LinkManager;
|
|
||||||
import com.rusefi.ui.RpmModel;
|
import com.rusefi.ui.RpmModel;
|
||||||
import com.rusefi.ui.UiUtils;
|
import com.rusefi.ui.UiUtils;
|
||||||
import com.rusefi.ui.WavePanel;
|
import com.rusefi.ui.WavePanel;
|
||||||
|
import com.rusefi.ui.config.ConfigField;
|
||||||
import com.rusefi.ui.widgets.URLLabel;
|
import com.rusefi.ui.widgets.URLLabel;
|
||||||
import com.rusefi.ui.widgets.UpDownImage;
|
import com.rusefi.ui.widgets.UpDownImage;
|
||||||
|
|
||||||
|
@ -20,11 +20,10 @@ import java.util.List;
|
||||||
* Date: 12/21/13
|
* Date: 12/21/13
|
||||||
* Andrey Belomutskiy (c) 2012-2013
|
* Andrey Belomutskiy (c) 2012-2013
|
||||||
*/
|
*/
|
||||||
public class AnalogChartPanel extends JPanel {
|
public class AnalogChartPanel {
|
||||||
private static final String KEY = "analog_chart";
|
|
||||||
private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Analog_Chart";
|
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 final AnalogChart analogChart = new AnalogChart();
|
||||||
|
|
||||||
private double minX;
|
private double minX;
|
||||||
|
@ -32,25 +31,24 @@ public class AnalogChartPanel extends JPanel {
|
||||||
private double minY;
|
private double minY;
|
||||||
private double maxY;
|
private double maxY;
|
||||||
|
|
||||||
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
private boolean paused = false;
|
private boolean paused = false;
|
||||||
|
|
||||||
public AnalogChartPanel() {
|
public AnalogChartPanel() {
|
||||||
super(new BorderLayout());
|
|
||||||
|
|
||||||
LinkManager.engineState.registerStringValueAction(KEY, new EngineState.ValueCallback<String>() {
|
AnalogChartCentral.listeners.add(new AnalogChartCentral.AnalogChartListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(String message) {
|
public void onAnalogChart(String message) {
|
||||||
|
unpackValues(values, message);
|
||||||
unpackValues(values, message);
|
|
||||||
|
|
||||||
// MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
|
// MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
|
||||||
|
|
||||||
processValues();
|
processValues();
|
||||||
UpDownImage.trueRepaint(analogChart);
|
UpDownImage.trueRepaint(analogChart);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
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));
|
upperPanel.add(new URLLabel(WavePanel.HELP_TEXT, HELP_URL));
|
||||||
pauseButton.addActionListener(new
|
pauseButton.addActionListener(new
|
||||||
|
|
||||||
ActionListener() {
|
ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
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() {
|
private void processValues() {
|
||||||
List<Double> keys = new ArrayList<Double>(values.keySet());
|
List<Double> keys = new ArrayList<>(values.keySet());
|
||||||
minX = keys.get(0);
|
minX = keys.get(0);
|
||||||
maxX = keys.get(keys.size() - 1);
|
maxX = keys.get(keys.size() - 1);
|
||||||
FileLog.rlog("Analog chart from " + minX + " to " + maxX);
|
FileLog.rlog("Analog chart from " + minX + " to " + maxX);
|
||||||
|
|
||||||
TreeSet<Double> sortedValues = new TreeSet<Double>();
|
TreeSet<Double> sortedValues = new TreeSet<>();
|
||||||
sortedValues.addAll(values.values());
|
sortedValues.addAll(values.values());
|
||||||
List<Double> values = new ArrayList<Double>(sortedValues);
|
List<Double> values = new ArrayList<>(sortedValues);
|
||||||
|
|
||||||
minY = values.get(0);
|
minY = values.get(0);
|
||||||
maxY = values.get(values.size() - 1);
|
maxY = values.get(values.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JComponent getPanel() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
private class AnalogChart extends JComponent {
|
private class AnalogChart extends JComponent {
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
* @see WavePanel
|
* @see WavePanel
|
||||||
*/
|
*/
|
||||||
public class Launcher extends FrameHelper {
|
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 boolean SHOW_STIMULATOR = true;
|
||||||
public static final String TAB_INDEX = "main_tab";
|
public static final String TAB_INDEX = "main_tab";
|
||||||
private final String port;
|
private final String port;
|
||||||
|
@ -47,8 +47,8 @@ public class Launcher extends FrameHelper {
|
||||||
RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges"));
|
RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges"));
|
||||||
tabbedPane.addTab("Main", mainGauges.createRpmPanel());
|
tabbedPane.addTab("Main", mainGauges.createRpmPanel());
|
||||||
tabbedPane.addTab("Gauges", new GaugesPanel().getContent());
|
tabbedPane.addTab("Gauges", new GaugesPanel().getContent());
|
||||||
tabbedPane.addTab("Digital Sniffer", wavePanel.getPanel());
|
tabbedPane.addTab("Engine Sniffer", wavePanel.getPanel());
|
||||||
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel());
|
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel().getPanel());
|
||||||
|
|
||||||
tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
|
tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,13 +9,8 @@ public class VoltageDividerTest extends TestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testR1() {
|
public void testR1() {
|
||||||
|
|
||||||
assertEquals(2000.0, PotCommand.getR1InVoltageDivider3(1, 5, 10000));
|
assertEquals(2000.0, PotCommand.getR1InVoltageDivider3(1, 5, 10000));
|
||||||
|
|
||||||
|
|
||||||
assertEquals(2040.816326530612, PotCommand.getR1InVoltageDivider3(1, 4.9, 10000));
|
assertEquals(2040.816326530612, PotCommand.getR1InVoltageDivider3(1, 4.9, 10000));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@ import java.util.*;
|
||||||
import java.util.List;
|
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/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* Date: 6/23/13
|
* Date: 6/23/13
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue