mirror of https://github.com/rusefi/rusefi-1.git
refactoring: better dependency control
This commit is contained in:
parent
85e145c277
commit
227bab7a95
|
@ -103,8 +103,8 @@ public class AutoTest {
|
|||
assertRpmDoesNotJump(15000, 15, 30, FAIL);
|
||||
}
|
||||
|
||||
public void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback) {
|
||||
changeRpm(rpm);
|
||||
public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function<String, Object> callback) {
|
||||
IoUtil.changeRpm(CommandQueue.getInstance(), rpm);
|
||||
sleepSeconds(settleTime);
|
||||
AtomicReference<String> result = new AtomicReference<>();
|
||||
SensorCentral.SensorListener listener = new SensorCentral.SensorListener() {
|
||||
|
@ -145,7 +145,7 @@ public class AutoTest {
|
|||
private void testSachs() {
|
||||
setEngineType(29);
|
||||
String msg = "BMW";
|
||||
IoUtil.changeRpm(1200);
|
||||
changeRpm(1200);
|
||||
// todo: add more content
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,13 @@ public class AutoTest {
|
|||
sendCommand("chart 1");
|
||||
String msg = "BMW";
|
||||
EngineChart chart;
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
chart = nextChart1();
|
||||
double x = 173.988;
|
||||
// something is wrong here - it's a 6 cylinder here, why 4 cylinder cycle?
|
||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.0199666, x, x + 180, x + 360, x + 540);
|
||||
|
||||
IoUtil.changeRpm(1200);
|
||||
changeRpm(1200);
|
||||
chart = nextChart1();
|
||||
|
||||
x = 688.464;
|
||||
|
@ -173,7 +173,7 @@ public class AutoTest {
|
|||
}
|
||||
|
||||
void changeRpm(final int rpm) {
|
||||
IoUtil.changeRpm(rpm);
|
||||
IoUtil.changeRpm(CommandQueue.getInstance(), rpm);
|
||||
}
|
||||
|
||||
private void testMitsu() {
|
||||
|
@ -206,7 +206,7 @@ public class AutoTest {
|
|||
private void testMazda626() {
|
||||
setEngineType(28);
|
||||
String msg = "mazda 626 default cranking";
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
EngineChart chart;
|
||||
chart = nextChart1();
|
||||
|
||||
|
@ -227,9 +227,9 @@ public class AutoTest {
|
|||
sendCommand("disable cylinder_cleanup");
|
||||
EngineChart chart;
|
||||
String msg = "2003 Neon cranking ";
|
||||
IoUtil.changeRpm(200);
|
||||
IoUtil.changeRpm(250); // another approach to artificial delay
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
changeRpm(250); // another approach to artificial delay
|
||||
changeRpm(200);
|
||||
assertEquals("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT));
|
||||
|
||||
chart = nextChart();
|
||||
|
@ -249,9 +249,9 @@ public class AutoTest {
|
|||
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.01056666666666691, 0.02, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
|
||||
msg = "2003 Neon running";
|
||||
IoUtil.changeRpm(2000);
|
||||
IoUtil.changeRpm(2700);
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
changeRpm(2700);
|
||||
changeRpm(2000);
|
||||
chart = nextChart();
|
||||
x = 104.0;
|
||||
assertWave(true, msg, chart, EngineChart.SPARK_1, 0.13299999999999998, EngineReport.RATIO, EngineReport.RATIO, x + 180, x + 540);
|
||||
|
@ -288,9 +288,9 @@ public class AutoTest {
|
|||
setEngineType(14);
|
||||
EngineChart chart;
|
||||
sendCommand("set mock_vbatt_voltage 1.395");
|
||||
IoUtil.changeRpm(200);
|
||||
IoUtil.changeRpm(260);
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
changeRpm(260);
|
||||
changeRpm(200);
|
||||
String msg = "ProtegeLX cranking";
|
||||
chart = nextChart1();
|
||||
assertEquals("", 12, SensorCentral.getInstance().getValue(Sensor.VBATT), 0.1);
|
||||
|
@ -302,7 +302,7 @@ public class AutoTest {
|
|||
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.008566666666, x, x + 180, x + 360, x + 540);
|
||||
|
||||
msg = "ProtegeLX running";
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
chart = nextChart1();
|
||||
x = 112;
|
||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
||||
|
@ -319,7 +319,7 @@ public class AutoTest {
|
|||
/**
|
||||
* note that command order matters - RPM change resets wave chart
|
||||
*/
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
chart = nextChart1();
|
||||
|
||||
String msg = "1995 Neon";
|
||||
|
@ -338,8 +338,8 @@ public class AutoTest {
|
|||
// switching to Speed Density
|
||||
sendCommand("set mock_map_voltage 1");
|
||||
sendComplexCommand("set algorithm 3");
|
||||
IoUtil.changeRpm(2600);
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2600);
|
||||
changeRpm(2000);
|
||||
chart = nextChart1();
|
||||
x = -70;
|
||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_4, 0.493, x + 540);
|
||||
|
@ -352,7 +352,7 @@ public class AutoTest {
|
|||
private void testFordFiesta() {
|
||||
setEngineType(4);
|
||||
EngineChart chart;
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
chart = nextChart1();
|
||||
|
||||
String msg = "Fiesta";
|
||||
|
@ -366,7 +366,7 @@ public class AutoTest {
|
|||
private void testFord6() {
|
||||
setEngineType(7);
|
||||
EngineChart chart;
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
chart = nextChart1();
|
||||
|
||||
String msg = "ford 6";
|
||||
|
@ -389,7 +389,7 @@ public class AutoTest {
|
|||
EngineChart chart;
|
||||
// todo: interesting changeRpm(100);
|
||||
sendComplexCommand("set cranking_rpm 500");
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
|
||||
double x;
|
||||
chart = nextChart1();
|
||||
|
@ -398,12 +398,12 @@ public class AutoTest {
|
|||
assertWave("aspire default cranking ", chart, EngineChart.SPARK_1, 0.1944, x, x + 180, x + 360, x + 540);
|
||||
|
||||
|
||||
IoUtil.changeRpm(600);
|
||||
changeRpm(600);
|
||||
chart = nextChart1();
|
||||
x = 78;
|
||||
assertWave(true, "aspire default running ", chart, EngineChart.SPARK_1, 0.04, 0.1, 0.1, x, x + 180, x + 360, x + 540);
|
||||
|
||||
IoUtil.changeRpm(200);
|
||||
changeRpm(200);
|
||||
|
||||
sendCommand("set cranking_charge_angle 65");
|
||||
sendCommand("set cranking_timing_angle -31");
|
||||
|
@ -424,17 +424,17 @@ public class AutoTest {
|
|||
assertWave("aspire", chart, EngineChart.SPARK_1, 40.0 / 360, x, x + 180, x + 360, x + 540);
|
||||
sendCommand("set cranking_charge_angle 65");
|
||||
|
||||
IoUtil.changeRpm(600);
|
||||
changeRpm(600);
|
||||
sendComplexCommand("set cranking_rpm 700");
|
||||
chart = nextChart();
|
||||
x = 55;
|
||||
assertWave("cranking@600", chart, EngineChart.SPARK_1, 0.18, x, x + 180, x + 360, x + 540);
|
||||
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2000);
|
||||
sendCommand("set_whole_fuel_map 1.57");
|
||||
|
||||
IoUtil.changeRpm(2600);
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2600);
|
||||
changeRpm(2000);
|
||||
chart = nextChart();
|
||||
|
||||
msg = "aspire running";
|
||||
|
@ -485,8 +485,8 @@ public class AutoTest {
|
|||
// switching to Speed Density
|
||||
sendCommand("set mock_maf_voltage 2");
|
||||
sendComplexCommand("set algorithm 3");
|
||||
IoUtil.changeRpm(2400);
|
||||
IoUtil.changeRpm(2000);
|
||||
changeRpm(2400);
|
||||
changeRpm(2000);
|
||||
chart = nextChart();
|
||||
assertEquals("MAP", 69.12, SensorCentral.getInstance().getValue(Sensor.MAP));
|
||||
//assertEquals(1, SensorCentral.getInstance().getValue(Sensor.));
|
||||
|
@ -497,7 +497,7 @@ public class AutoTest {
|
|||
assertWave(false, msg + " fuel SD #4", chart, EngineChart.INJECTOR_4, 0.577, 0.1, 0.1, x + 540);
|
||||
|
||||
// above hard limit
|
||||
IoUtil.changeRpm(10000);
|
||||
changeRpm(10000);
|
||||
chart = nextChart();
|
||||
assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1);
|
||||
}
|
||||
|
|
|
@ -67,9 +67,9 @@ public class IoUtil {
|
|||
}
|
||||
}
|
||||
|
||||
static void changeRpm(final int rpm) {
|
||||
static void changeRpm(CommandQueue commandQueue, final int rpm) {
|
||||
FileLog.MAIN.logLine("AUTOTEST rpm EN " + rpm);
|
||||
sendCommand("rpm " + rpm, CommandQueue.getInstance());
|
||||
sendCommand("rpm " + rpm, commandQueue);
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
final CountDownLatch rpmLatch = new CountDownLatch(1);
|
||||
|
|
|
@ -85,8 +85,8 @@ public class ConsoleUI {
|
|||
linkManager.restart();
|
||||
}).start();
|
||||
|
||||
GaugesPanel.DetachedRepository.INSTANCE.init(getConfig().getRoot().getChild("detached"));
|
||||
GaugesPanel.DetachedRepository.INSTANCE.load();
|
||||
uiContext.DetachedRepositoryINSTANCE.init(getConfig().getRoot().getChild("detached"));
|
||||
uiContext.DetachedRepositoryINSTANCE.load();
|
||||
if (!linkManager.isLogViewer())
|
||||
tabbedPane.addTab("Gauges", new GaugesPanel(uiContext, getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent());
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class ConsoleUI {
|
|||
tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane());
|
||||
if (!linkManager.isLogViewer()) {
|
||||
tabbedPane.addTab("Formulas/Live Data", new FormulasPane(uiContext).getContent());
|
||||
tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent());
|
||||
tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane(uiContext).getContent());
|
||||
}
|
||||
|
||||
if (!linkManager.isLogViewer() && false) // todo: fix it & better name?
|
||||
|
|
|
@ -9,8 +9,6 @@ import com.rusefi.ui.etb.EtbCommandsPanel;
|
|||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.rusefi.config.generated.Fields.CMD_ETB_DUTY;
|
||||
|
||||
/**
|
||||
* Controls related to Electronic Throttle Body
|
||||
*
|
||||
|
@ -21,9 +19,9 @@ public class ETBPane {
|
|||
|
||||
public ETBPane(UIContext uiContext) {
|
||||
JPanel centerPanel = new JPanel(new GridLayout(3, 1));
|
||||
centerPanel.add(GaugesGridElement.create(Sensor.PPS));
|
||||
centerPanel.add(GaugesGridElement.create(Sensor.ETB_CONTROL_QUALITY));
|
||||
centerPanel.add(GaugesGridElement.create(Sensor.TPS));
|
||||
centerPanel.add(GaugesGridElement.create(uiContext, Sensor.PPS));
|
||||
centerPanel.add(GaugesGridElement.create(uiContext, Sensor.ETB_CONTROL_QUALITY));
|
||||
centerPanel.add(GaugesGridElement.create(uiContext, Sensor.TPS));
|
||||
|
||||
content.add(new EtbCommandsPanel(uiContext).getContent(), BorderLayout.WEST);
|
||||
content.add(centerPanel, BorderLayout.CENTER);
|
||||
|
|
|
@ -2,22 +2,25 @@ package com.rusefi.etb;
|
|||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.UIContext;
|
||||
|
||||
public class EtbTarget extends TestSequenceStep {
|
||||
private final UIContext uiContext;
|
||||
/**
|
||||
* 0-100 percent open
|
||||
*/
|
||||
private final double position;
|
||||
private final Runnable onEachStep;
|
||||
|
||||
public EtbTarget(long duration, double position, Runnable onEachStep, Condition condition) {
|
||||
public EtbTarget(UIContext uiContext, long duration, double position, Runnable onEachStep, Condition condition) {
|
||||
super(duration, condition);
|
||||
this.uiContext = uiContext;
|
||||
this.position = position;
|
||||
this.onEachStep = onEachStep;
|
||||
}
|
||||
|
||||
protected void doJob() {
|
||||
CommandQueue.getInstance().write("set " + Fields.MOCK_PPS_POSITION_COMMAND + " " + position);
|
||||
uiContext.getCommandQueue().write("set " + Fields.MOCK_PPS_POSITION_COMMAND + " " + position);
|
||||
if (onEachStep != null)
|
||||
onEachStep.run();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public abstract class TestSequenceStep {
|
|||
protected abstract void doJob();
|
||||
|
||||
public TestSequenceStep addNext(UIContext uiContext, long duration, double position, Runnable onEachStep, Condition condition) {
|
||||
return addNext(new EtbTarget(duration, position, onEachStep, condition));
|
||||
return addNext(new EtbTarget(uiContext, duration, position, onEachStep, condition));
|
||||
}
|
||||
|
||||
public TestSequenceStep addNext(TestSequenceStep step) {
|
||||
|
|
|
@ -39,12 +39,13 @@ public class FormulasPane {
|
|||
private final UIContext uiContext;
|
||||
private boolean isPaused;
|
||||
|
||||
private JPanel liveDocs = LiveDocPanel.createLiveDocumentationPanel();
|
||||
private JPanel liveDocs;
|
||||
|
||||
public FormulasPane(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
|
||||
JPanel vertical = new JPanel(new VerticalFlowLayout());
|
||||
liveDocs = LiveDocPanel.createLiveDocumentationPanel(uiContext);
|
||||
vertical.add(liveDocs);
|
||||
vertical.add(formulaProxy);
|
||||
|
||||
|
|
|
@ -123,8 +123,8 @@ public class FuelTunePane {
|
|||
GaugesGrid grid = new GaugesGrid(1, 3);
|
||||
rightPanel.add(grid.panel);
|
||||
|
||||
grid.panel.add(GaugesGridElement.read(config.getChild("1"), Sensor.RPM));
|
||||
grid.panel.add(GaugesGridElement.read(config.getChild("2"), Sensor.AFR));
|
||||
grid.panel.add(GaugesGridElement.read(uiContext, config.getChild("1"), Sensor.RPM));
|
||||
grid.panel.add(GaugesGridElement.read(uiContext, config.getChild("2"), Sensor.AFR));
|
||||
|
||||
JPanel middlePanel = new JPanel(new GridLayout(1, 2));
|
||||
middlePanel.add(veTable);
|
||||
|
|
|
@ -21,14 +21,16 @@ public class GaugesGridElement {
|
|||
private static final String IS_LIVE_GRAPH = "type";
|
||||
|
||||
private final JPanelWithListener wrapper = new JPanelWithListener(new BorderLayout());
|
||||
private final UIContext uiContext;
|
||||
private final Node config;
|
||||
|
||||
private GaugesGridElement(Node config) {
|
||||
private GaugesGridElement(UIContext uiContext, Node config) {
|
||||
this.uiContext = uiContext;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public static JComponent create(Sensor sensor) {
|
||||
return new GaugesGridElement(new Node()).createGauge(sensor);
|
||||
public static JComponent create(UIContext uiContext, Sensor sensor) {
|
||||
return new GaugesGridElement(uiContext, new Node()).createGauge(sensor);
|
||||
}
|
||||
|
||||
private JComponent createLiveBarElement(final Sensor defaultSensor) {
|
||||
|
@ -70,19 +72,19 @@ public class GaugesGridElement {
|
|||
});
|
||||
|
||||
wrapper.setLayout(new BorderLayout());
|
||||
SensorGauge.createGaugeBody(sensor, wrapper, gaugeChangeListener, switchToLiveGraph);
|
||||
SensorGauge.createGaugeBody(uiContext, sensor, wrapper, gaugeChangeListener, switchToLiveGraph);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public static JComponent read(final Node config, Sensor defaultSensor) {
|
||||
public static JComponent read(UIContext uiContext, final Node config, Sensor defaultSensor) {
|
||||
|
||||
if (config.getBoolProperty(IS_LIVE_GRAPH)) {
|
||||
return new GaugesGridElement(config).createLiveBarElement(defaultSensor);
|
||||
return new GaugesGridElement(uiContext, config).createLiveBarElement(defaultSensor);
|
||||
}
|
||||
|
||||
String gaugeName = config.getProperty(GAUGE_TYPE, defaultSensor.name());
|
||||
Sensor sensor = Sensor.lookup(gaugeName, defaultSensor);
|
||||
return new GaugesGridElement(config).createGauge(sensor);
|
||||
return new GaugesGridElement(uiContext, config).createGauge(sensor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ public class GaugesPanel {
|
|||
for (int i = 0; i < rows * columns; i++) {
|
||||
// sometimes grid is quite large so we shall be careful with default sensor index
|
||||
Sensor defaultSensor = DEFAULT_LAYOUT[Math.min(i, DEFAULT_LAYOUT.length - 1)];
|
||||
Component element = GaugesGridElement.read(config.getChild("element_" + i), defaultSensor);
|
||||
Component element = GaugesGridElement.read(uiContext, config.getChild("element_" + i), defaultSensor);
|
||||
|
||||
gauges.panel.add(element);
|
||||
}
|
||||
|
@ -272,14 +272,19 @@ public class GaugesPanel {
|
|||
return content;
|
||||
}
|
||||
|
||||
public enum DetachedRepository {
|
||||
INSTANCE;
|
||||
public static class DetachedRepository {
|
||||
|
||||
public static final String COUNT = "count";
|
||||
public static final String DETACHED = "detached";
|
||||
private final UIContext uiContext;
|
||||
private List<DetachedSensor> list = new ArrayList<>();
|
||||
private Node config;
|
||||
|
||||
public DetachedRepository(UIContext uiContext) {
|
||||
|
||||
this.uiContext = uiContext;
|
||||
}
|
||||
|
||||
public void add(DetachedSensor detachedSensor) {
|
||||
list.add(detachedSensor);
|
||||
saveConfig();
|
||||
|
@ -293,7 +298,7 @@ public class GaugesPanel {
|
|||
public void load() {
|
||||
int count = config.getIntProperty(COUNT, 0);
|
||||
for (int i = 0; i < count; i++) {
|
||||
DetachedSensor.create(config.getChild(DETACHED + i));
|
||||
DetachedSensor.create(uiContext, config.getChild(DETACHED + i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@ public class LogDownloader {
|
|||
listDirectory();
|
||||
}
|
||||
});
|
||||
private final UIContext uiContext;
|
||||
|
||||
public LogDownloader() {
|
||||
public LogDownloader(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
UiUtils.showLoadingMessage(content);
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
@ -80,7 +82,7 @@ public class LogDownloader {
|
|||
UIManager.getString("OptionPane.titleText"),
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (i == JOptionPane.YES_OPTION) {
|
||||
CommandQueue.getInstance().write("del " + name);
|
||||
uiContext.getCommandQueue().write("del " + name);
|
||||
timer.restart();
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +92,7 @@ public class LogDownloader {
|
|||
downloadFile.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommandQueue.getInstance().write("get_file 0 " + name);
|
||||
uiContext.getCommandQueue().write("get_file 0 " + name);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -10,15 +10,16 @@ import java.awt.*;
|
|||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
*/
|
||||
public class SensorsLiveDataPane {
|
||||
private JPanel liveDocs = LiveDocPanel.createSensorsLiveDataPanel();
|
||||
private JPanel liveDocs;
|
||||
/**
|
||||
* this is the panel we expose to the outside world
|
||||
*/
|
||||
private final JPanel content = new JPanel(new BorderLayout());
|
||||
|
||||
public SensorsLiveDataPane() {
|
||||
public SensorsLiveDataPane(UIContext uiContext) {
|
||||
JPanel vertical = new JPanel(new VerticalFlowLayout());
|
||||
|
||||
liveDocs = LiveDocPanel.createSensorsLiveDataPanel(uiContext);
|
||||
vertical.add(liveDocs);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(vertical, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
|
|
@ -8,6 +8,7 @@ public class UIContext {
|
|||
private final LinkManager linkManager = new LinkManager();
|
||||
|
||||
public SensorLogger sensorLogger = new SensorLogger(this);
|
||||
public GaugesPanel.DetachedRepository DetachedRepositoryINSTANCE = new GaugesPanel.DetachedRepository(this);
|
||||
|
||||
public LinkManager getLinkManager() {
|
||||
return linkManager;
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class BaseConfigField {
|
|||
protected void sendValue(Field field, String newValue) {
|
||||
String msg = field.setCommand() + " " + newValue;
|
||||
FileLog.MAIN.logLine("Sending " + msg);
|
||||
CommandQueue.getInstance().write(msg);
|
||||
uiContext.getCommandQueue().write(msg);
|
||||
status.setText("S");
|
||||
status.setToolTipText("Storing...");
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class MainFrame {
|
|||
Node root = getConfig().getRoot();
|
||||
root.setProperty("version", Launcher.CONSOLE_VERSION);
|
||||
root.setProperty(ConsoleUI.TAB_INDEX, tabbedPane.tabbedPane.getSelectedIndex());
|
||||
GaugesPanel.DetachedRepository.INSTANCE.saveConfig();
|
||||
consoleUI.uiContext.DetachedRepositoryINSTANCE.saveConfig();
|
||||
getConfig().save();
|
||||
BinaryProtocol bp = consoleUI.uiContext.getLinkManager().getCurrentStreamState();
|
||||
if (bp != null && !bp.isClosed)
|
||||
|
|
|
@ -20,7 +20,7 @@ public class TabbedPanel {
|
|||
|
||||
// public final RomEditorPane romEditorPane;
|
||||
public final SettingsTab settingsTab;
|
||||
public final LogDownloader logsManager = new LogDownloader();
|
||||
public final LogDownloader logsManager;
|
||||
public final FuelTunePane fuelTunePane;
|
||||
public final PaneSettings paneSettings = new PaneSettings(getConfig().getRoot().getChild("panes"));
|
||||
|
||||
|
@ -63,6 +63,7 @@ public class TabbedPanel {
|
|||
fuelTunePane = new FuelTunePane(uiContext, getConfig().getRoot().getChild("fueltune"));
|
||||
// romEditorPane = new RomEditorPane(uiContext);
|
||||
settingsTab = new SettingsTab(uiContext);
|
||||
logsManager = new LogDownloader(uiContext);
|
||||
}
|
||||
|
||||
public void addTab(String title, Component component) {
|
||||
|
|
|
@ -22,8 +22,10 @@ import static com.rusefi.config.generated.Fields.CMD_ETB_DUTY;
|
|||
*/
|
||||
public class EtbCommandsPanel {
|
||||
private final JPanel content = new JPanel(new VerticalFlowLayout());
|
||||
private final UIContext uiContext;
|
||||
|
||||
public EtbCommandsPanel(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
content.add(new DirectDrivePanel(uiContext).getContent());
|
||||
|
||||
JPanel testParameters = new JPanel(new VerticalFlowLayout());
|
||||
|
@ -65,14 +67,14 @@ public class EtbCommandsPanel {
|
|||
|
||||
content.add(createMagicSpotsPanel());
|
||||
content.add(UiUtils.wrap(new EtbMonteCarloSequence(uiContext).getButton()));
|
||||
content.add(UiUtils.wrap(new EtbReturnToNeutral().getContent()));
|
||||
content.add(UiUtils.wrap(new EtbReturnToNeutral(uiContext).getContent()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createMagicSpotsPanel() {
|
||||
JPanel spotsPane = new JPanel(new VerticalFlowLayout());
|
||||
spotsPane.setBorder(BorderFactory.createTitledBorder("Magic Spots"));
|
||||
MagicSpotsFinder magicSpotsFinder = new MagicSpotsFinder();
|
||||
MagicSpotsFinder magicSpotsFinder = new MagicSpotsFinder(uiContext);
|
||||
spotsPane.add(UiUtils.wrap(magicSpotsFinder.getButton()));
|
||||
spotsPane.add(magicSpotsFinder.getPoints());
|
||||
return spotsPane;
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.rusefi.core.SensorCentral;
|
|||
import com.rusefi.etb.EtbTarget;
|
||||
import com.rusefi.etb.StandardTestSequence;
|
||||
import com.rusefi.etb.TestSequenceStep;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.UIContext;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -72,7 +71,7 @@ public class EtbMonteCarloSequence {
|
|||
MessagesCentral.getInstance().postMessage(EtbMonteCarloSequence.class,
|
||||
uiContext.sensorLogger.getSecondsSinceFileStart() + " running " + stats);
|
||||
|
||||
TestSequenceStep firstStep = new EtbTarget(10 * SECOND, DEFAULT_POSITION, null, TestSequenceStep.Condition.YES);
|
||||
TestSequenceStep firstStep = new EtbTarget(uiContext, 10 * SECOND, DEFAULT_POSITION, null, TestSequenceStep.Condition.YES);
|
||||
TestSequenceStep.Condition condition = new TestSequenceStep.Condition() {
|
||||
@Override
|
||||
public boolean shouldRunTask() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.core.MessagesCentral;
|
|||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.UIContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -21,13 +22,15 @@ public class EtbReturnToNeutral {
|
|||
private static final int ACCEPTABLE_ERROR = 1;
|
||||
private static final int CYCLES_COUNT = 10;
|
||||
private static final String ZERO_DUTY_CYCLE_COMMAND = CMD_ETB_DUTY + " " + 0;
|
||||
private final UIContext uiContext;
|
||||
|
||||
private JButton button = new JButton("ETB Spring Test");
|
||||
|
||||
private final static float SHUT_OPEN = 70;
|
||||
private final static float SHUT_CLOSED = -70;
|
||||
|
||||
public EtbReturnToNeutral() {
|
||||
public EtbReturnToNeutral(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -51,7 +54,7 @@ public class EtbReturnToNeutral {
|
|||
|
||||
private void testSequence() throws InterruptedException {
|
||||
|
||||
CommandQueue.getInstance().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
uiContext.getCommandQueue().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
// longer pause in the beginning just in case
|
||||
Thread.sleep(2 * SECOND);
|
||||
assertPosition("First neutral position expected.", NEUTRAL_POSITION);
|
||||
|
@ -59,24 +62,24 @@ public class EtbReturnToNeutral {
|
|||
int errorCount = 0;
|
||||
|
||||
for (int i = 1; i <= CYCLES_COUNT; i++) {
|
||||
CommandQueue.getInstance().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
uiContext.getCommandQueue().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
Thread.sleep(SECOND);
|
||||
|
||||
boolean isError = assertPosition(i + ": Neutral position expected.", NEUTRAL_POSITION);
|
||||
if (isError)
|
||||
errorCount++;
|
||||
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + SHUT_OPEN);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + SHUT_OPEN);
|
||||
Thread.sleep((long) (0.5 * SECOND));
|
||||
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + SHUT_CLOSED);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + SHUT_CLOSED);
|
||||
Thread.sleep(SECOND);
|
||||
isError = assertPosition(i + ": Should be shot closed", 0);
|
||||
if (isError)
|
||||
errorCount++;
|
||||
}
|
||||
|
||||
CommandQueue.getInstance().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
uiContext.getCommandQueue().write(ZERO_DUTY_CYCLE_COMMAND);
|
||||
// CommandQueue.getInstance().write(DirectDrivePanel.CANCEL_DIRECT_DRIVE_COMMAND);
|
||||
MessagesCentral.getInstance().postMessage(getClass(), "Cycles = " + CYCLES_COUNT + ", errors = " + errorCount);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class EtbTestSequence {
|
|||
result.setText(String.format(state + " Result: %.3f", value));
|
||||
});
|
||||
|
||||
TestSequenceStep firstStep = new EtbTarget(10 * SECOND, 4, /*position*/onEachStep, TestSequenceStep.Condition.YES);
|
||||
TestSequenceStep firstStep = new EtbTarget(uiContext, 10 * SECOND, 4, /*position*/onEachStep, TestSequenceStep.Condition.YES);
|
||||
TestSequenceStep result = StandardTestSequence.addSequence(uiContext, firstStep, onEachStep, new TestSequenceStep.Condition() {
|
||||
@Override
|
||||
public boolean shouldRunTask() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.rusefi.core.Sensor;
|
|||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import org.putgemin.VerticalFlowLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -31,6 +32,7 @@ public class MagicSpotsFinder {
|
|||
private final JButton button = new JButton(MAGIC_SPOTS_FINDER);
|
||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
private final static double MEASURMENT_PRECISION = 0.5;
|
||||
private final UIContext uiContext;
|
||||
private double defaultTpsPosition;
|
||||
|
||||
// private boolean isStarted;
|
||||
|
@ -67,7 +69,7 @@ public class MagicSpotsFinder {
|
|||
|
||||
if (tpsPosition >= 100 - MEASURMENT_PRECISION) {
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
} else if (tpsPosition > defaultTpsPosition + MEASURMENT_PRECISION) {
|
||||
|
||||
if (startedToCloseValue == 0) {
|
||||
|
@ -78,7 +80,7 @@ public class MagicSpotsFinder {
|
|||
}
|
||||
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
} else {
|
||||
backToZeroValue = currentDutyCycle;
|
||||
backToZeroValueLabel.setText(String.format("Back Zero %.1f", backToZeroValue));
|
||||
|
@ -110,7 +112,7 @@ public class MagicSpotsFinder {
|
|||
if (tpsPosition < defaultTpsPosition + MEASURMENT_PRECISION) {
|
||||
// ETB has not moved yet, keep going up
|
||||
currentDutyCycle += DUTY_CYCLE_STEP;
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
} else if (tpsPosition < 100 - MEASURMENT_PRECISION) {
|
||||
|
||||
if (startedToOpenValue == 0) {
|
||||
|
@ -123,7 +125,7 @@ public class MagicSpotsFinder {
|
|||
|
||||
// ETB has not reached 100%, keep going up
|
||||
currentDutyCycle += DUTY_CYCLE_STEP;
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
|
||||
} else {
|
||||
// looks like we have reached 100%, cool!
|
||||
|
@ -132,7 +134,7 @@ public class MagicSpotsFinder {
|
|||
MessagesCentral.getInstance().postMessage(getClass(), "startedToOpenValue = " + startedToOpenValue + ", reached100Value = " + reached100Value);
|
||||
|
||||
currentDutyCycle -= DUTY_CYCLE_STEP;
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingDown);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +159,7 @@ public class MagicSpotsFinder {
|
|||
MessagesCentral.getInstance().postMessage(getClass(), "Start!");
|
||||
resetValues();
|
||||
|
||||
CommandQueue.getInstance().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
uiContext.getCommandQueue().write(CMD_ETB_DUTY + " " + currentDutyCycle, goingUp);
|
||||
sleep(INITIAL_SLEEP);
|
||||
defaultTpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
|
||||
}
|
||||
|
@ -173,7 +175,8 @@ public class MagicSpotsFinder {
|
|||
backToZeroValue = 0;
|
||||
}
|
||||
|
||||
public MagicSpotsFinder() {
|
||||
public MagicSpotsFinder(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
points.add(startedToOpenValueLabel);
|
||||
points.add(reached100ValueLabel);
|
||||
points.add(startedToCloseValueLabel);
|
||||
|
@ -193,7 +196,7 @@ public class MagicSpotsFinder {
|
|||
public void run() {
|
||||
// magic constant for DBG_ELECTRONIC_THROTTLE_EXTRA
|
||||
state = State.DEBUG_MODE;
|
||||
CommandQueue.getInstance().write("set debug_mode " + 29, setDebugModeConfiguration);
|
||||
uiContext.getCommandQueue().write("set debug_mode " + 29, setDebugModeConfiguration);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.rusefi.ldmp.*;
|
|||
import com.rusefi.ldmp.generated.*;
|
||||
import com.opensr5.ini.DialogModel;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import com.rusefi.ui.livedocs.controls.Toolbox;
|
||||
import com.rusefi.ui.widgets.DetachedSensor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
@ -34,15 +35,15 @@ public class LiveDocPanel {
|
|||
|
||||
|
||||
@NotNull
|
||||
public static JPanel createPanel(String title, Request[] content) {
|
||||
return createPanel(title, content, "", StateDictionary.NONE);
|
||||
public static JPanel createPanel(UIContext uiContext, String title, Request[] content) {
|
||||
return createPanel(uiContext, title, content, "", StateDictionary.NONE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static JPanel createPanel(String title, Request[] content, String settingsInstancePrefix, final int defaultContextId) {
|
||||
static JPanel createPanel(UIContext uiContext, String title, Request[] content, String settingsInstancePrefix, final int defaultContextId) {
|
||||
LiveDataContext defaultContext = new LiveDataContext(defaultContextId);
|
||||
|
||||
ActionPanel ap = createComponents(title, content, settingsInstancePrefix, defaultContext);
|
||||
ActionPanel ap = createComponents(uiContext, title, content, settingsInstancePrefix, defaultContext);
|
||||
JPanel panel = ap.getPanel();
|
||||
|
||||
LiveDocHolder holder = new LiveDocHolder(defaultContext, ap.getRefreshActions()) {
|
||||
|
@ -62,7 +63,7 @@ public class LiveDocPanel {
|
|||
return c.isVisible() && (parent == null || isRecursivelyVisible(parent));
|
||||
}
|
||||
|
||||
private static ActionPanel createComponents(String title, Request[] content, String settingsInstancePrefix, LiveDataContext defaultContext) {
|
||||
private static ActionPanel createComponents(UIContext uiContext, String title, Request[] content, String settingsInstancePrefix, LiveDataContext defaultContext) {
|
||||
ActionPanel result = new ActionPanel(title);
|
||||
|
||||
for (Request r : content) {
|
||||
|
@ -116,7 +117,7 @@ public class LiveDocPanel {
|
|||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !SwingUtilities.isRightMouseButton(e)) {
|
||||
final DetachedSensor ds = new DetachedSensor(sensor, MAGIC_DETACHED_GAUGE_SIZE);
|
||||
final DetachedSensor ds = new DetachedSensor(uiContext, sensor, MAGIC_DETACHED_GAUGE_SIZE);
|
||||
ds.show(e);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ public class LiveDocPanel {
|
|||
} else if (r instanceof IfRequest) {
|
||||
IfRequest request = (IfRequest) r;
|
||||
|
||||
IfConditionPanel panel = createIfRequestPanel(request, defaultContext);
|
||||
IfConditionPanel panel = createIfRequestPanel(uiContext, request, defaultContext);
|
||||
|
||||
result.actionsListAddAll(panel.getActionsList());
|
||||
|
||||
|
@ -170,7 +171,7 @@ public class LiveDocPanel {
|
|||
return "Configuration " + dialogField.getUiName() + " (" + configurationFieldName + ")";
|
||||
}
|
||||
|
||||
private static IfConditionPanel createIfRequestPanel(IfRequest request, LiveDataContext defaultContext) {
|
||||
private static IfConditionPanel createIfRequestPanel(UIContext uiContext, IfRequest request, LiveDataContext defaultContext) {
|
||||
Field conditionField = getField(defaultContext, request);
|
||||
|
||||
JPanel result = new JPanel(new VerticalFlowLayout());
|
||||
|
@ -179,8 +180,8 @@ public class LiveDocPanel {
|
|||
result.add(conditionLabel);
|
||||
|
||||
|
||||
ActionPanel trueAP = createComponents("", request.trueBlock.toArray(new Request[0]), "", defaultContext);
|
||||
ActionPanel falseAP = createComponents("", request.falseBlock.toArray(new Request[0]), "", defaultContext);
|
||||
ActionPanel trueAP = createComponents(uiContext, "", request.trueBlock.toArray(new Request[0]), "", defaultContext);
|
||||
ActionPanel falseAP = createComponents(uiContext, "", request.falseBlock.toArray(new Request[0]), "", defaultContext);
|
||||
|
||||
result.add(trueAP.getPanel());
|
||||
result.add(falseAP.getPanel());
|
||||
|
@ -215,14 +216,14 @@ public class LiveDocPanel {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public static JPanel createLiveDocumentationPanel() {
|
||||
public static JPanel createLiveDocumentationPanel(UIContext uiContext) {
|
||||
JPanel liveDocs = new JPanel(new MigLayout(LAYOUT));
|
||||
|
||||
liveDocs.add(createPanel("Fuel", FuelMathMeta.CONTENT), CONSTRAINTS);
|
||||
liveDocs.add(createPanel(uiContext,"Fuel", FuelMathMeta.CONTENT), CONSTRAINTS);
|
||||
|
||||
liveDocs.add(createPanel("tCharge", SpeedDensityMeta.CONTENT), CONSTRAINTS);
|
||||
liveDocs.add(createPanel(uiContext, "tCharge", SpeedDensityMeta.CONTENT), CONSTRAINTS);
|
||||
|
||||
liveDocs.add(createPanel("Idle", IdleThreadMeta.CONTENT), CONSTRAINTS);
|
||||
liveDocs.add(createPanel(uiContext, "Idle", IdleThreadMeta.CONTENT), CONSTRAINTS);
|
||||
|
||||
// todo: restore this functionality
|
||||
// liveDocs.add(createPanel("ETB", ElectronicThrottleMeta.CONTENT), CONSTRAINTS);
|
||||
|
@ -230,7 +231,7 @@ public class LiveDocPanel {
|
|||
return liveDocs;
|
||||
}
|
||||
|
||||
public static JPanel createSensorsLiveDataPanel() {
|
||||
public static JPanel createSensorsLiveDataPanel(UIContext uiContext) {
|
||||
JPanel liveDocs = new JPanel(new MigLayout(LAYOUT));
|
||||
|
||||
/*
|
||||
|
@ -239,7 +240,7 @@ public class LiveDocPanel {
|
|||
|
||||
*/
|
||||
|
||||
liveDocs.add(createPanel("Trigger", TriggerDecoderMeta.CONTENT), CONSTRAINTS);
|
||||
liveDocs.add(createPanel(uiContext, "Trigger", TriggerDecoderMeta.CONTENT), CONSTRAINTS);
|
||||
|
||||
return liveDocs;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.rusefi.ui.livedocs.test;
|
||||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.ui.livedocs.LiveDocPanel;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class LiveDocPanelTest {
|
||||
|
@ -17,11 +14,11 @@ public class LiveDocPanelTest {
|
|||
|
||||
@Test
|
||||
public void testValidDocumentationMetaInfo() {
|
||||
assertNotNull(LiveDocPanel.createLiveDocumentationPanel());
|
||||
assertNotNull(LiveDocPanel.createLiveDocumentationPanel(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSensorsMetaInfo() {
|
||||
assertNotNull(LiveDocPanel.createSensorsLiveDataPanel());
|
||||
assertNotNull(LiveDocPanel.createSensorsLiveDataPanel(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.rusefi.io.IMethodInvocation;
|
|||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.GaugesPanel;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
||||
|
@ -62,20 +63,23 @@ public class DetachedSensor {
|
|||
private final JFrame frame;
|
||||
private final JPanel mockControlPanel = new JPanel(new BorderLayout());
|
||||
private Sensor sensor;
|
||||
@org.jetbrains.annotations.NotNull
|
||||
private final UIContext uiContext;
|
||||
private int width;
|
||||
|
||||
public DetachedSensor(Sensor sensor, int width) {
|
||||
public DetachedSensor(UIContext uiContext, Sensor sensor, int width) {
|
||||
this.uiContext = uiContext;
|
||||
this.width = width;
|
||||
frame = new JFrame();
|
||||
frame.setAlwaysOnTop(true);
|
||||
onChange(sensor);
|
||||
|
||||
GaugesPanel.DetachedRepository.INSTANCE.add(this);
|
||||
uiContext.DetachedRepositoryINSTANCE.add(this);
|
||||
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
GaugesPanel.DetachedRepository.INSTANCE.remove(DetachedSensor.this);
|
||||
uiContext.DetachedRepositoryINSTANCE.remove(DetachedSensor.this);
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
|
@ -84,7 +88,7 @@ public class DetachedSensor {
|
|||
|
||||
void create() {
|
||||
SensorGauge.GaugeChangeListener listener = this::onChange;
|
||||
content.add(SensorGauge.createGauge(sensor, listener, null), BorderLayout.CENTER);
|
||||
content.add(SensorGauge.createGauge(uiContext, sensor, listener, null), BorderLayout.CENTER);
|
||||
content.add(mockControlPanel, BorderLayout.SOUTH);
|
||||
|
||||
frame.add(content);
|
||||
|
@ -173,12 +177,12 @@ public class DetachedSensor {
|
|||
child.setProperty(YPOS, frame.getLocation().y);
|
||||
}
|
||||
|
||||
public static void create(Node child) {
|
||||
public static void create(UIContext uiContext, Node child) {
|
||||
Sensor sensor = Sensor.lookup(child.getProperty(NAME, Sensor.RPM.name()), Sensor.RPM);
|
||||
int width = child.getIntProperty(WIDTH, 256);
|
||||
int xpos = child.getIntProperty(XPOS, 0);
|
||||
int ypos = child.getIntProperty(YPOS, 0);
|
||||
DetachedSensor ds = new DetachedSensor(sensor, width);
|
||||
DetachedSensor ds = new DetachedSensor(uiContext, sensor, width);
|
||||
ds.frame.setLocation(xpos, ypos);
|
||||
ds.frame.setVisible(true);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.core.Sensor;
|
|||
import com.rusefi.core.SensorCategory;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.ui.GaugesPanel;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import eu.hansolo.steelseries.gauges.Radial;
|
||||
import eu.hansolo.steelseries.tools.BackgroundColor;
|
||||
|
@ -27,10 +28,10 @@ public class SensorGauge {
|
|||
private static final String HINT_LINE_1 = "Double-click to detach";
|
||||
private static final String HINT_LINE_2 = "Right-click to change";
|
||||
|
||||
public static Component createGauge(Sensor sensor, GaugeChangeListener listener, JMenuItem extraMenuItem) {
|
||||
public static Component createGauge(UIContext uiContext, Sensor sensor, GaugeChangeListener listener, JMenuItem extraMenuItem) {
|
||||
JPanelWithListener wrapper = new JPanelWithListener(new BorderLayout());
|
||||
|
||||
createGaugeBody(sensor, wrapper, listener, extraMenuItem);
|
||||
createGaugeBody(uiContext, sensor, wrapper, listener, extraMenuItem);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ public class SensorGauge {
|
|||
void onSensorChange(Sensor sensor);
|
||||
}
|
||||
|
||||
public static void createGaugeBody(final Sensor sensor, final JPanelWithListener wrapper, final GaugeChangeListener listener,
|
||||
public static void createGaugeBody(UIContext uiContext, final Sensor sensor, final JPanelWithListener wrapper, final GaugeChangeListener listener,
|
||||
final JMenuItem extraMenuItem) {
|
||||
final Radial gauge = createRadial(sensor.getName(), sensor.getUnits(), sensor.getMaxValue(), sensor.getMinValue());
|
||||
|
||||
|
@ -68,9 +69,9 @@ public class SensorGauge {
|
|||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
showPopupMenu(e, wrapper, listener, extraMenuItem);
|
||||
showPopupMenu(uiContext, e, wrapper, listener, extraMenuItem);
|
||||
} else if (e.getClickCount() == 2) {
|
||||
handleDoubleClick(e, gauge, sensor);
|
||||
handleDoubleClick(uiContext, e, gauge, sensor);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -81,16 +82,16 @@ public class SensorGauge {
|
|||
UiUtils.trueLayout(wrapper.getParent());
|
||||
}
|
||||
|
||||
private static void showPopupMenu(MouseEvent e, JPanelWithListener wrapper, GaugeChangeListener listener,
|
||||
private static void showPopupMenu(UIContext uiContext, MouseEvent e, JPanelWithListener wrapper, GaugeChangeListener listener,
|
||||
JMenuItem extraMenuItem) {
|
||||
JPopupMenu pm = new JPopupMenu();
|
||||
fillGaugeMenuItems(pm, wrapper, listener, extraMenuItem);
|
||||
fillGaugeMenuItems(uiContext, pm, wrapper, listener, extraMenuItem);
|
||||
if (extraMenuItem != null)
|
||||
pm.add(extraMenuItem);
|
||||
pm.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
|
||||
private static void fillGaugeMenuItems(JPopupMenu popupMenu, final JPanelWithListener wrapper, final GaugeChangeListener listener, final JMenuItem extraMenuItem) {
|
||||
private static void fillGaugeMenuItems(UIContext uiContext, JPopupMenu popupMenu, final JPanelWithListener wrapper, final GaugeChangeListener listener, final JMenuItem extraMenuItem) {
|
||||
for (final SensorCategory sc : SensorCategory.values()) {
|
||||
JMenuItem cmi = new JMenu(sc.getName());
|
||||
popupMenu.add(cmi);
|
||||
|
@ -100,7 +101,7 @@ public class SensorGauge {
|
|||
mi.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
createGaugeBody(s, wrapper, listener, extraMenuItem);
|
||||
createGaugeBody(uiContext, s, wrapper, listener, extraMenuItem);
|
||||
listener.onSensorChange(s);
|
||||
}
|
||||
});
|
||||
|
@ -109,9 +110,9 @@ public class SensorGauge {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleDoubleClick(MouseEvent e, Radial gauge, Sensor sensor) {
|
||||
private static void handleDoubleClick(UIContext uiContext, MouseEvent e, Radial gauge, Sensor sensor) {
|
||||
int width = gauge.getSize().width;
|
||||
final DetachedSensor ds = new DetachedSensor(sensor, width);
|
||||
final DetachedSensor ds = new DetachedSensor(uiContext, sensor, width);
|
||||
|
||||
ds.show(e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue