engine type preset panel
This commit is contained in:
parent
cff8fa70b8
commit
fda21ae2aa
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
|
@ -1,17 +1,15 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.io.CommandQueue;
|
|
||||||
import com.rusefi.ui.MessagesView;
|
import com.rusefi.ui.MessagesView;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
import com.rusefi.ui.widgets.EtbResearch;
|
import com.rusefi.ui.widgets.EtbResearch;
|
||||||
import com.rusefi.ui.widgets.EtbTestSequence;
|
import com.rusefi.ui.widgets.EtbTestSequence;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.putgemin.VerticalFlowLayout;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
import static com.rusefi.CommandControl.TEST;
|
||||||
|
|
||||||
public class BenchTestPane {
|
public class BenchTestPane {
|
||||||
private final JPanel content = new JPanel(new GridLayout(2, 4));
|
private final JPanel content = new JPanel(new GridLayout(2, 4));
|
||||||
|
@ -32,7 +30,7 @@ public class BenchTestPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createMILTest() {
|
private Component createMILTest() {
|
||||||
BenchTestPanel panel = new BenchTestPanel("MIL", "check_engine.jpg") {
|
CommandControl panel = new CommandControl("MIL", "check_engine.jpg", TEST) {
|
||||||
@NotNull
|
@NotNull
|
||||||
protected String getCommand() {
|
protected String getCommand() {
|
||||||
return "milbench";
|
return "milbench";
|
||||||
|
@ -42,7 +40,7 @@ public class BenchTestPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createIdleTest() {
|
private Component createIdleTest() {
|
||||||
BenchTestPanel panel = new BenchTestPanel("Idle Valve", "idle_valve.png") {
|
CommandControl panel = new CommandControl("Idle Valve", "idle_valve.png", TEST) {
|
||||||
@NotNull
|
@NotNull
|
||||||
protected String getCommand() {
|
protected String getCommand() {
|
||||||
return "idlebench";
|
return "idlebench";
|
||||||
|
@ -52,38 +50,23 @@ public class BenchTestPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createDizzyTest() {
|
private Component createDizzyTest() {
|
||||||
BenchTestPanel panel = new BenchTestPanel("Dizzy", "dizzy.jpg") {
|
CommandControl panel = new FixedCommandControl("Dizzy", "dizzy.jpg", TEST, "dizzybench");
|
||||||
@NotNull
|
|
||||||
protected String getCommand() {
|
|
||||||
return "dizzybench";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createFanTest() {
|
private Component createFanTest() {
|
||||||
BenchTestPanel panel = new BenchTestPanel("Radiator Fan", "radiator_fan.jpg") {
|
CommandControl panel = new FixedCommandControl("Radiator Fan", "radiator_fan.jpg", TEST, "fanbench");
|
||||||
@NotNull
|
|
||||||
protected String getCommand() {
|
|
||||||
return "fanbench";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createFuelPumpTest() {
|
private Component createFuelPumpTest() {
|
||||||
BenchTestPanel panel = new BenchTestPanel("Fuel Pump", "fuel_pump.jpg") {
|
CommandControl panel = new FixedCommandControl("Fuel Pump", "fuel_pump.jpg", TEST, "fuelpumpbench");
|
||||||
@NotNull
|
|
||||||
protected String getCommand() {
|
|
||||||
return "fuelpumpbench";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return panel.getContent();
|
return panel.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component createSparkTest() {
|
private Component createSparkTest() {
|
||||||
final JComboBox<Integer> indexes = createIndexCombo();
|
final JComboBox<Integer> indexes = createIndexCombo();
|
||||||
BenchTestPanel panel = new BenchTestPanel("Spark #", "spark.jpg", indexes) {
|
CommandControl panel = new CommandControl("Spark #", "spark.jpg", TEST, indexes) {
|
||||||
@Override
|
@Override
|
||||||
protected String getCommand() {
|
protected String getCommand() {
|
||||||
return "sparkbench2 1000 " + indexes.getSelectedItem() + " 5 333 3";
|
return "sparkbench2 1000 " + indexes.getSelectedItem() + " 5 333 3";
|
||||||
|
@ -94,7 +77,7 @@ public class BenchTestPane {
|
||||||
|
|
||||||
private Component createInjectorTest() {
|
private Component createInjectorTest() {
|
||||||
final JComboBox<Integer> indexes = createIndexCombo();
|
final JComboBox<Integer> indexes = createIndexCombo();
|
||||||
BenchTestPanel panel = new BenchTestPanel("Injector #", "injector.png", indexes) {
|
CommandControl panel = new CommandControl("Injector #", "injector.png", TEST, indexes) {
|
||||||
@Override
|
@Override
|
||||||
protected String getCommand() {
|
protected String getCommand() {
|
||||||
return "fuelbench2 1000 " + indexes.getSelectedItem() + " 5 333 3";
|
return "fuelbench2 1000 " + indexes.getSelectedItem() + " 5 333 3";
|
||||||
|
@ -116,37 +99,4 @@ public class BenchTestPane {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class BenchTestPanel {
|
|
||||||
final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
|
||||||
final JButton test = new JButton("Test");
|
|
||||||
|
|
||||||
public BenchTestPanel(String text, String iconFileName, JComponent... components) {
|
|
||||||
ImageIcon icon = UiUtils.loadIcon(iconFileName);
|
|
||||||
JPanel rightVerticalPanel = new JPanel(new VerticalFlowLayout());
|
|
||||||
rightVerticalPanel.add(new JLabel(text));
|
|
||||||
for (JComponent component : components)
|
|
||||||
rightVerticalPanel.add(component);
|
|
||||||
rightVerticalPanel.add(test);
|
|
||||||
|
|
||||||
panel.add(new JLabel(icon));
|
|
||||||
panel.add(rightVerticalPanel);
|
|
||||||
|
|
||||||
int GAP = 3;
|
|
||||||
|
|
||||||
panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP)));
|
|
||||||
|
|
||||||
test.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
CommandQueue.getInstance().write(getCommand());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract String getCommand();
|
|
||||||
|
|
||||||
public Component getContent() {
|
|
||||||
return UiUtils.wrap(panel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.io.CommandQueue;
|
||||||
|
import com.rusefi.ui.util.UiUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.putgemin.VerticalFlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Andrey Belomutskiy 2013-2019
|
||||||
|
*/
|
||||||
|
abstract class CommandControl {
|
||||||
|
public static final String TEST = "Test";
|
||||||
|
public static final String SET = "Set";
|
||||||
|
protected final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||||
|
final JButton test;
|
||||||
|
|
||||||
|
public CommandControl(String labelText, String iconFileName, String buttonText, JComponent... components) {
|
||||||
|
ImageIcon icon = UiUtils.loadIcon(iconFileName);
|
||||||
|
JPanel rightVerticalPanel = new JPanel(new VerticalFlowLayout());
|
||||||
|
rightVerticalPanel.add(new JLabel(labelText));
|
||||||
|
for (JComponent component : components)
|
||||||
|
rightVerticalPanel.add(component);
|
||||||
|
test = new JButton(buttonText);
|
||||||
|
rightVerticalPanel.add(test);
|
||||||
|
|
||||||
|
panel.add(new JLabel(icon));
|
||||||
|
panel.add(rightVerticalPanel);
|
||||||
|
|
||||||
|
int GAP = 3;
|
||||||
|
|
||||||
|
panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP)));
|
||||||
|
|
||||||
|
test.addActionListener(createButtonListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected ActionListener createButtonListener() {
|
||||||
|
return e -> CommandQueue.getInstance().write(getCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract String getCommand();
|
||||||
|
|
||||||
|
public Component getContent() {
|
||||||
|
return UiUtils.wrap(panel);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
public class FixedCommandControl extends CommandControl {
|
||||||
|
private final String command;
|
||||||
|
|
||||||
|
public FixedCommandControl(String labelText, String iconFileName, String buttonText, String command) {
|
||||||
|
super(labelText, iconFileName, buttonText);
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getCommand() {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,13 +39,13 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* 12/25/12
|
* 12/25/12
|
||||||
* (c) Andrey Belomutskiy 2013-2018
|
* (c) Andrey Belomutskiy 2013-2019
|
||||||
*
|
*
|
||||||
* @see StartupFrame
|
* @see StartupFrame
|
||||||
* @see EngineSnifferPanel
|
* @see EngineSnifferPanel
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static final int CONSOLE_VERSION = 20181117;
|
public static final int CONSOLE_VERSION = 20190112;
|
||||||
public static final boolean SHOW_STIMULATOR = false;
|
public static final boolean SHOW_STIMULATOR = false;
|
||||||
private static final String TAB_INDEX = "main_tab";
|
private static final String TAB_INDEX = "main_tab";
|
||||||
protected static final String PORT_KEY = "port";
|
protected static final String PORT_KEY = "port";
|
||||||
|
@ -151,8 +151,14 @@ public class Launcher {
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges")).getContent());
|
tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges")).getContent());
|
||||||
|
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer()) {
|
||||||
tabbedPane.addTab("Formulas", new FormulasPane().getContent());
|
MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages"));
|
||||||
|
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
||||||
|
}
|
||||||
|
if (!LinkManager.isLogViewer()) {
|
||||||
|
tabbedPane.add("Bench Test", new BenchTestPane().getContent());
|
||||||
|
tabbedPane.add("Presets", new PresetsPans().getContent());
|
||||||
|
}
|
||||||
|
|
||||||
tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener());
|
tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener());
|
||||||
|
|
||||||
|
@ -170,10 +176,6 @@ public class Launcher {
|
||||||
tabbedPane.add("ECU stimulation", stimulator.getPanel());
|
tabbedPane.add("ECU stimulation", stimulator.getPanel());
|
||||||
}
|
}
|
||||||
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
||||||
if (!LinkManager.isLogViewer()) {
|
|
||||||
MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages"));
|
|
||||||
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
|
||||||
}
|
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Table Editor", tableEditor);
|
tabbedPane.addTab("Table Editor", tableEditor);
|
||||||
// tabbedPane.add("Wizards", new Wizard().createPane());
|
// tabbedPane.add("Wizards", new Wizard().createPane());
|
||||||
|
@ -181,7 +183,7 @@ public class Launcher {
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.add("Settings", settingsTab.createPane());
|
tabbedPane.add("Settings", settingsTab.createPane());
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.add("Bench Test", new BenchTestPane().getContent());
|
tabbedPane.addTab("Formulas", new FormulasPane().getContent());
|
||||||
if (!LinkManager.isLogViewer() && false) // todo: fix it & better name?
|
if (!LinkManager.isLogViewer() && false) // todo: fix it & better name?
|
||||||
tabbedPane.add("Logs Manager", logsManager.getContent());
|
tabbedPane.add("Logs Manager", logsManager.getContent());
|
||||||
fuelTunePane = new FuelTunePane(getConfig().getRoot().getChild("fueltune"));
|
fuelTunePane = new FuelTunePane(getConfig().getRoot().getChild("fueltune"));
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.io.CommandQueue;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Andrey Belomutskiy 2013-2019
|
||||||
|
*/
|
||||||
|
public class PresetsPans {
|
||||||
|
// see rusefi_enums.h
|
||||||
|
private static final int MIATA_NA_1_6 = 41;
|
||||||
|
private static final int MAZDA_MIATA_2003 = 47;
|
||||||
|
|
||||||
|
private JPanel content = new JPanel(new GridLayout(2, 4));
|
||||||
|
|
||||||
|
public PresetsPans() {
|
||||||
|
content.add(new SetEngineTypeCommandControl("Miata NA6", "engines/miata_na.png", MIATA_NA_1_6).getContent());
|
||||||
|
content.add(new SetEngineTypeCommandControl("Miata NB2", "engines/miata_nb.png", MAZDA_MIATA_2003).getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SetEngineTypeCommandControl extends FixedCommandControl {
|
||||||
|
private final String labelTest;
|
||||||
|
|
||||||
|
public SetEngineTypeCommandControl(String labelTest, String imageFileName, int engineType) {
|
||||||
|
super(labelTest, imageFileName, CommandControl.SET, "set engine_type " + engineType);
|
||||||
|
this.labelTest = labelTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected ActionListener createButtonListener() {
|
||||||
|
return e -> {
|
||||||
|
int dialogResult = JOptionPane.showConfirmDialog(panel, "Do you really want to reset all settings to " + labelTest,
|
||||||
|
"Warning", JOptionPane.YES_NO_OPTION);
|
||||||
|
if (dialogResult != JOptionPane.YES_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CommandQueue.getInstance().write(getCommand());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,7 +77,9 @@ public class LogDownloader {
|
||||||
removeFile.addActionListener(new ActionListener() {
|
removeFile.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int i = JOptionPane.showConfirmDialog(Launcher.getFrame(), "Do you really want to delete " + name + "?");
|
int i = JOptionPane.showConfirmDialog(Launcher.getFrame(), ("Do you really want to delete " + name + "?"),
|
||||||
|
UIManager.getString("OptionPane.titleText"),
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
if (i == JOptionPane.YES_OPTION) {
|
if (i == JOptionPane.YES_OPTION) {
|
||||||
CommandQueue.getInstance().write("del " + name);
|
CommandQueue.getInstance().write("del " + name);
|
||||||
timer.restart();
|
timer.restart();
|
||||||
|
|
Loading…
Reference in New Issue