mirror of https://github.com/rusefi/rusefi-1.git
refactoring: better dependency control
This commit is contained in:
parent
3f558b1e91
commit
2a92b21c49
|
@ -86,7 +86,8 @@ public class ECUEditorToolBar extends JToolBar {
|
||||||
Rom lastSelectedRom = ECUEditorManager.getECUEditor().getLastSelectedRom();
|
Rom lastSelectedRom = ECUEditorManager.getECUEditor().getLastSelectedRom();
|
||||||
byte[] newVersion = ConfigurationImage.extractContent(lastSelectedRom.saveFile());
|
byte[] newVersion = ConfigurationImage.extractContent(lastSelectedRom.saveFile());
|
||||||
System.out.println("new version size: " + newVersion.length);
|
System.out.println("new version size: " + newVersion.length);
|
||||||
UploadChanges.scheduleUpload(new ConfigurationImage(newVersion));
|
throw new UnsupportedOperationException("disabled");
|
||||||
|
//UploadChanges.scheduleUpload(new ConfigurationImage(newVersion));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
downloadImage.addActionListener(new ActionListener() {
|
downloadImage.addActionListener(new ActionListener() {
|
||||||
|
|
|
@ -44,9 +44,11 @@ public class ConsoleUI {
|
||||||
|
|
||||||
static Frame staticFrame;
|
static Frame staticFrame;
|
||||||
|
|
||||||
private final TabbedPanel tabbedPane = new TabbedPanel();
|
private final TabbedPanel tabbedPane;
|
||||||
|
|
||||||
private final MainFrame mainFrame = new MainFrame(this, tabbedPane);
|
private final MainFrame mainFrame;
|
||||||
|
|
||||||
|
private final UIContext uiContext = new UIContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We can listen to tab activation event if we so desire
|
* We can listen to tab activation event if we so desire
|
||||||
|
@ -58,7 +60,9 @@ public class ConsoleUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsoleUI(String port) {
|
public ConsoleUI(String port) {
|
||||||
|
tabbedPane = new TabbedPanel(uiContext);
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
mainFrame = new MainFrame(this, tabbedPane);
|
||||||
ConsoleUI.staticFrame = mainFrame.getFrame().getFrame();
|
ConsoleUI.staticFrame = mainFrame.getFrame().getFrame();
|
||||||
FileLog.MAIN.logLine("Console " + CONSOLE_VERSION);
|
FileLog.MAIN.logLine("Console " + CONSOLE_VERSION);
|
||||||
|
|
||||||
|
@ -113,14 +117,14 @@ public class ConsoleUI {
|
||||||
tabbedPane.addTab("ECU stimulation", stimulator.getPanel());
|
tabbedPane.addTab("ECU stimulation", stimulator.getPanel());
|
||||||
}
|
}
|
||||||
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
||||||
if (!LinkManager.isLogViewer())
|
// if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Table Editor", tabbedPane.tableEditor);
|
// tabbedPane.addTab("Table Editor", tabbedPane.romEditorPane);
|
||||||
// tabbedPane.add("Wizards", new Wizard().createPane());
|
// tabbedPane.add("Wizards", new Wizard().createPane());
|
||||||
|
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane());
|
tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane());
|
||||||
if (!LinkManager.isLogViewer()) {
|
if (!LinkManager.isLogViewer()) {
|
||||||
tabbedPane.addTab("Formulas/Live Data", new FormulasPane().getContent());
|
tabbedPane.addTab("Formulas/Live Data", new FormulasPane(uiContext).getContent());
|
||||||
tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent());
|
tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocolCmd;
|
import com.rusefi.binaryprotocol.BinaryProtocolCmd;
|
||||||
import com.opensr5.io.ConfigurationImageFile;
|
import com.opensr5.io.ConfigurationImageFile;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
import com.rusefi.ui.UIContext;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -13,10 +14,13 @@ import java.awt.*;
|
||||||
|
|
||||||
import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor;
|
import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor;
|
||||||
|
|
||||||
public class TableEditorPane extends JPanel {
|
public class RomEditorPane extends JPanel {
|
||||||
|
|
||||||
public TableEditorPane() {
|
private final UIContext uiContext;
|
||||||
|
|
||||||
|
public RomEditorPane(UIContext uiContext) {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
|
this.uiContext = uiContext;
|
||||||
UiUtils.showLoadingMessage(this);
|
UiUtils.showLoadingMessage(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,13 @@ import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor;
|
||||||
public class RomRaiderWrapper {
|
public class RomRaiderWrapper {
|
||||||
public static final String DEFINITION_FILE = "rusefi.xml";
|
public static final String DEFINITION_FILE = "rusefi.xml";
|
||||||
|
|
||||||
|
/*
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
startRomRaider();
|
startRomRaider();
|
||||||
|
|
||||||
ECUExec.openRom(ECUEditorManager.getECUEditor(), "rusefi_configuration.bin");
|
ECUExec.openRom(ECUEditorManager.getECUEditor(), "rusefi_configuration.bin");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public static ECUEditor startRomRaider() {
|
public static ECUEditor startRomRaider() {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.ui.RecentCommands;
|
import com.rusefi.ui.RecentCommands;
|
||||||
import com.rusefi.ui.StatusWindow;
|
import com.rusefi.ui.StatusWindow;
|
||||||
|
import com.rusefi.ui.UIContext;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -76,18 +77,18 @@ public class UploadChanges {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scheduleUpload(final ConfigurationImage newVersion) {
|
public static void scheduleUpload(UIContext uiContext, final ConfigurationImage newVersion) {
|
||||||
scheduleUpload(newVersion, null);
|
scheduleUpload(uiContext, newVersion, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scheduleUpload(final ConfigurationImage newVersion, final Runnable afterUpload) {
|
public static void scheduleUpload(UIContext uiContext, final ConfigurationImage newVersion, final Runnable afterUpload) {
|
||||||
JFrame frame = wnd.getFrame();
|
JFrame frame = wnd.getFrame();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
LinkManager.execute(new Runnable() {
|
LinkManager.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
LinkManager.getCurrentStreamState().uploadChanges(newVersion, logger);
|
uiContext.getLinkManager().getCurrentStreamState().uploadChanges(newVersion, logger);
|
||||||
if (afterUpload != null)
|
if (afterUpload != null)
|
||||||
afterUpload.run();
|
afterUpload.run();
|
||||||
} catch (InterruptedException | EOFException e) {
|
} catch (InterruptedException | EOFException e) {
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package com.rusefi.binaryprotocol;
|
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
|
||||||
import com.opensr5.Logger;
|
|
||||||
import com.opensr5.io.ConfigurationImageFile;
|
|
||||||
import com.romraider.editor.ecu.ECUEditor;
|
|
||||||
import com.rusefi.RomRaiderWrapper;
|
|
||||||
import com.rusefi.UploadChanges;
|
|
||||||
import com.rusefi.config.generated.Fields;
|
|
||||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
|
||||||
* 6/21/2017
|
|
||||||
*/
|
|
||||||
public class BinaryProtocolCmdSandbox {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
if (args.length != 1) {
|
|
||||||
System.out.println("Exactly one parameter expected: port");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String port = args[0];
|
|
||||||
|
|
||||||
Logger logger = UploadChanges.logger;
|
|
||||||
|
|
||||||
//SerialPort serialPort;
|
|
||||||
// serialPort = new SerialPort(port);
|
|
||||||
// boolean opened = serialPort.openPort();
|
|
||||||
// if (!opened) {
|
|
||||||
// logger.error("failed to open " + port);
|
|
||||||
// }
|
|
||||||
BinaryProtocol bp = new BinaryProtocol(logger, SerialIoStreamJSerialComm.openPort(port));
|
|
||||||
|
|
||||||
//SerialIoStreamJSSC.setupPort(serialPort, 38400);
|
|
||||||
logger.info("Binary looks good!");
|
|
||||||
|
|
||||||
bp.readImage(Fields.TOTAL_CONFIG_SIZE);
|
|
||||||
//
|
|
||||||
// image.saveToFile("rusefi_configuration.bin");
|
|
||||||
//
|
|
||||||
doShowImage(bp.getControllerConfiguration());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void doShowImage(ConfigurationImage image) throws Exception {
|
|
||||||
if (!BinaryProtocolCmd.checkForDefinitionFile())
|
|
||||||
return;
|
|
||||||
RomRaiderWrapper.startRomRaider();
|
|
||||||
ECUEditor.openImage(ConfigurationImageFile.getFileContent(image));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,7 +6,6 @@ import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
import com.rusefi.io.LinkManager;
|
|
||||||
import com.rusefi.ui.config.ConfigField;
|
import com.rusefi.ui.config.ConfigField;
|
||||||
import com.rusefi.ui.livedocs.LiveDocPanel;
|
import com.rusefi.ui.livedocs.LiveDocPanel;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
|
@ -37,11 +36,13 @@ public class FormulasPane {
|
||||||
*/
|
*/
|
||||||
private final JPanel content = new JPanel(new BorderLayout());
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
private final JPanel formulaProxy = new JPanel(new BorderLayout());
|
private final JPanel formulaProxy = new JPanel(new BorderLayout());
|
||||||
|
private final UIContext uiContext;
|
||||||
private boolean isPaused;
|
private boolean isPaused;
|
||||||
|
|
||||||
private JPanel liveDocs = LiveDocPanel.createLiveDocumentationPanel();
|
private JPanel liveDocs = LiveDocPanel.createLiveDocumentationPanel();
|
||||||
|
|
||||||
public FormulasPane() {
|
public FormulasPane(UIContext uiContext) {
|
||||||
|
this.uiContext = uiContext;
|
||||||
|
|
||||||
JPanel vertical = new JPanel(new VerticalFlowLayout());
|
JPanel vertical = new JPanel(new VerticalFlowLayout());
|
||||||
vertical.add(liveDocs);
|
vertical.add(liveDocs);
|
||||||
|
@ -107,7 +108,7 @@ public class FormulasPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFormula() {
|
private void updateFormula() {
|
||||||
BinaryProtocol bp = LinkManager.getCurrentStreamState();
|
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||||
if (bp == null)
|
if (bp == null)
|
||||||
return;
|
return;
|
||||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||||
|
|
|
@ -51,10 +51,12 @@ public class FuelTunePane {
|
||||||
private final JButton upload = new JButton("Upload");
|
private final JButton upload = new JButton("Upload");
|
||||||
private final JCheckBox collect = new JCheckBox("enable");
|
private final JCheckBox collect = new JCheckBox("enable");
|
||||||
private final JButton clean = new JButton("clear");
|
private final JButton clean = new JButton("clear");
|
||||||
|
private final UIContext uiContext;
|
||||||
private byte[] newVeMap;
|
private byte[] newVeMap;
|
||||||
private DataOutputStream dos;
|
private DataOutputStream dos;
|
||||||
|
|
||||||
public FuelTunePane(Node config) {
|
public FuelTunePane(UIContext uiContext, Node config) {
|
||||||
|
this.uiContext = uiContext;
|
||||||
final JLabel incomingBufferSize = new JLabel();
|
final JLabel incomingBufferSize = new JLabel();
|
||||||
|
|
||||||
JButton runLogic = new JButton("one iteration");
|
JButton runLogic = new JButton("one iteration");
|
||||||
|
@ -136,7 +138,7 @@ public class FuelTunePane {
|
||||||
|
|
||||||
private void uploadCurrentResult() {
|
private void uploadCurrentResult() {
|
||||||
byte[] newVeMap = FuelTunePane.this.newVeMap;
|
byte[] newVeMap = FuelTunePane.this.newVeMap;
|
||||||
BinaryProtocol bp = LinkManager.getCurrentStreamState();
|
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||||
if (newVeMap == null || bp == null)
|
if (newVeMap == null || bp == null)
|
||||||
return;
|
return;
|
||||||
ConfigurationImage ci = bp.getControllerConfiguration().clone();
|
ConfigurationImage ci = bp.getControllerConfiguration().clone();
|
||||||
|
@ -154,7 +156,7 @@ public class FuelTunePane {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
UploadChanges.scheduleUpload(ci, afterBurn);
|
UploadChanges.scheduleUpload(uiContext, ci, afterBurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doClean() {
|
private void doClean() {
|
||||||
|
@ -313,7 +315,7 @@ public class FuelTunePane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] reloadVeTable() {
|
private byte[] reloadVeTable() {
|
||||||
BinaryProtocol bp = LinkManager.getCurrentStreamState();
|
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||||
|
|
||||||
byte[] content = bp.getControllerConfiguration().getContent();
|
byte[] content = bp.getControllerConfiguration().getContent();
|
||||||
loadData(veTable.getXAxis(), content, veRpmOffset);
|
loadData(veTable.getXAxis(), content, veRpmOffset);
|
||||||
|
@ -329,7 +331,7 @@ public class FuelTunePane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadArray(double[] array, int offset) {
|
private void loadArray(double[] array, int offset) {
|
||||||
BinaryProtocol bp = LinkManager.getCurrentStreamState();
|
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||||
if (bp == null) {
|
if (bp == null) {
|
||||||
FileLog.MAIN.logLine("bp not ready");
|
FileLog.MAIN.logLine("bp not ready");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.rusefi.ui;
|
||||||
|
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
|
|
||||||
|
public class UIContext {
|
||||||
|
private final LinkManager linkManager = new LinkManager();
|
||||||
|
|
||||||
|
public LinkManager getLinkManager() {
|
||||||
|
return linkManager;
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ public class MainFrame {
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionEstablished() {
|
public void onConnectionEstablished() {
|
||||||
FileLog.MAIN.logLine("onConnectionEstablished");
|
FileLog.MAIN.logLine("onConnectionEstablished");
|
||||||
tabbedPane.tableEditor.showContent();
|
// tabbedPane.romEditorPane.showContent();
|
||||||
tabbedPane.settingsTab.showContent();
|
tabbedPane.settingsTab.showContent();
|
||||||
tabbedPane.logsManager.showContent();
|
tabbedPane.logsManager.showContent();
|
||||||
tabbedPane.fuelTunePane.showContent();
|
tabbedPane.fuelTunePane.showContent();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.rusefi.ui.console;
|
package com.rusefi.ui.console;
|
||||||
|
|
||||||
import com.rusefi.PaneSettings;
|
import com.rusefi.PaneSettings;
|
||||||
import com.rusefi.TableEditorPane;
|
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.ConnectionStatusLogic;
|
import com.rusefi.io.ConnectionStatusLogic;
|
||||||
import com.rusefi.ui.FuelTunePane;
|
import com.rusefi.ui.FuelTunePane;
|
||||||
import com.rusefi.ui.LogDownloader;
|
import com.rusefi.ui.LogDownloader;
|
||||||
|
import com.rusefi.ui.UIContext;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -18,10 +18,10 @@ public class TabbedPanel {
|
||||||
private String criticalError;
|
private String criticalError;
|
||||||
|
|
||||||
|
|
||||||
public final TableEditorPane tableEditor = new TableEditorPane();
|
// public final RomEditorPane romEditorPane;
|
||||||
public final SettingsTab settingsTab = new SettingsTab();
|
public final SettingsTab settingsTab;
|
||||||
public final LogDownloader logsManager = new LogDownloader();
|
public final LogDownloader logsManager = new LogDownloader();
|
||||||
public final FuelTunePane fuelTunePane = new FuelTunePane(getConfig().getRoot().getChild("fueltune"));
|
public final FuelTunePane fuelTunePane;
|
||||||
public final PaneSettings paneSettings = new PaneSettings(getConfig().getRoot().getChild("panes"));
|
public final PaneSettings paneSettings = new PaneSettings(getConfig().getRoot().getChild("panes"));
|
||||||
|
|
||||||
public final JTabbedPane tabbedPane = new JTabbedPane() {
|
public final JTabbedPane tabbedPane = new JTabbedPane() {
|
||||||
|
@ -55,11 +55,14 @@ public class TabbedPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public TabbedPanel() {
|
public TabbedPanel(UIContext uiContext) {
|
||||||
MessagesCentral.getInstance().addListener((clazz, message) -> {
|
MessagesCentral.getInstance().addListener((clazz, message) -> {
|
||||||
if (message.startsWith(Fields.CRITICAL_PREFIX))
|
if (message.startsWith(Fields.CRITICAL_PREFIX))
|
||||||
criticalError = message;
|
criticalError = message;
|
||||||
});
|
});
|
||||||
|
fuelTunePane = new FuelTunePane(uiContext, getConfig().getRoot().getChild("fueltune"));
|
||||||
|
// romEditorPane = new RomEditorPane(uiContext);
|
||||||
|
settingsTab = new SettingsTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTab(String title, Component component) {
|
public void addTab(String title, Component component) {
|
||||||
|
|
Loading…
Reference in New Issue