mirror of https://github.com/rusefi/rusefi-1.git
refactoring: better dependency control
This commit is contained in:
parent
ac1973a62d
commit
1a12d0cdeb
|
@ -61,6 +61,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
FileLog.MAIN.logLine(USE_PLAIN_PROTOCOL_PROPERTY + ": " + PLAIN_PROTOCOL);
|
||||
}
|
||||
|
||||
private final LinkManager linkManager;
|
||||
private final Logger logger;
|
||||
private final IoStream stream;
|
||||
private final IncomingDataBuffer incomingData;
|
||||
|
@ -110,7 +111,8 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
|
||||
private final Thread hook = new Thread(() -> closeComposites());
|
||||
|
||||
public BinaryProtocol(final Logger logger, IoStream stream) {
|
||||
public BinaryProtocol(LinkManager linkManager, final Logger logger, IoStream stream) {
|
||||
this.linkManager = linkManager;
|
||||
this.logger = logger;
|
||||
this.stream = stream;
|
||||
|
||||
|
@ -148,7 +150,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
CommunicationLoggingHolder.communicationLoggingListener.onPortHolderMessage(BinaryProtocol.class, "Sending [" + command + "]");
|
||||
}
|
||||
|
||||
Future f = LinkManager.submit(new Runnable() {
|
||||
Future f = linkManager.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendTextCommand(command);
|
||||
|
@ -191,16 +193,16 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
}
|
||||
|
||||
private void startTextPullThread(final DataListener listener) {
|
||||
if (!LinkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
System.out.println("Current queue: " + LinkManager.COMMUNICATION_QUEUE.size());
|
||||
if (!linkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
System.out.println("Current queue: " + linkManager.COMMUNICATION_QUEUE.size());
|
||||
}
|
||||
Runnable textPull = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!isClosed) {
|
||||
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
||||
if (LinkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
LinkManager.submit(new Runnable() {
|
||||
if (linkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
linkManager.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (requestOutputChannels())
|
||||
|
|
|
@ -41,11 +41,11 @@ public class LinkManager {
|
|||
return connected;
|
||||
}
|
||||
|
||||
public static void execute(Runnable runnable) {
|
||||
public void execute(Runnable runnable) {
|
||||
COMMUNICATION_EXECUTOR.execute(runnable);
|
||||
}
|
||||
|
||||
public static Future submit(Runnable runnable) {
|
||||
public Future submit(Runnable runnable) {
|
||||
return COMMUNICATION_EXECUTOR.submit(runnable);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class LinkManager {
|
|||
*
|
||||
* @see #COMMUNICATION_EXECUTOR
|
||||
*/
|
||||
public final static Executor TCP_READ_EXECUTOR = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
||||
public final Executor TCP_READ_EXECUTOR = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(@NotNull Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
|
@ -97,16 +97,15 @@ public class LinkManager {
|
|||
}
|
||||
});
|
||||
public static final String LOG_VIEWER = "log viewer";
|
||||
public static final LinkedBlockingQueue<Runnable> COMMUNICATION_QUEUE = new LinkedBlockingQueue<>();
|
||||
public final LinkedBlockingQueue<Runnable> COMMUNICATION_QUEUE = new LinkedBlockingQueue<>();
|
||||
/**
|
||||
* All request/responses to underlying controller are happening on this single-threaded executor in a FIFO manner
|
||||
* @see #TCP_READ_EXECUTOR
|
||||
*/
|
||||
public static final ExecutorService COMMUNICATION_EXECUTOR = new ThreadPoolExecutor(1, 1,
|
||||
public final ExecutorService COMMUNICATION_EXECUTOR = new ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
COMMUNICATION_QUEUE,
|
||||
new NamedThreadFactory("communication executor"));
|
||||
private static Thread COMMUNICATION_THREAD;
|
||||
|
||||
static {
|
||||
/*
|
||||
|
@ -154,20 +153,20 @@ public class LinkManager {
|
|||
connector.connectAndReadConfiguration(stateListener);
|
||||
}
|
||||
|
||||
public static void start(String port) {
|
||||
public void start(String port) {
|
||||
Objects.requireNonNull(port, "port");
|
||||
FileLog.MAIN.logLine("LinkManager: Starting " + port);
|
||||
if (isLogViewerMode(port)) {
|
||||
connector = LinkConnector.VOID;
|
||||
} else if (TcpConnector.isTcpPort(port)) {
|
||||
connector = new TcpConnector(port);
|
||||
connector = new TcpConnector(this, port);
|
||||
isSimulationMode = true;
|
||||
} else {
|
||||
connector = new SerialConnector(port);
|
||||
connector = new SerialConnector(this, port);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setConnector(LinkConnector connector) {
|
||||
public void setConnector(LinkConnector connector) {
|
||||
LinkManager.connector = connector;
|
||||
}
|
||||
|
||||
|
@ -176,7 +175,7 @@ public class LinkManager {
|
|||
return port.equals(LOG_VIEWER);
|
||||
}
|
||||
|
||||
public static boolean isLogViewer() {
|
||||
public boolean isLogViewer() {
|
||||
return connector == LinkConnector.VOID;
|
||||
}
|
||||
|
||||
|
@ -186,7 +185,7 @@ public class LinkManager {
|
|||
connector.send(command, fireEvent);
|
||||
}
|
||||
|
||||
public static void restart() {
|
||||
public void restart() {
|
||||
ConnectionStatusLogic.INSTANCE.setValue(ConnectionStatusValue.NOT_CONNECTED);
|
||||
connector.restart();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.awt.*;
|
|||
*/
|
||||
public class PortHolder {
|
||||
private static final DataListener dataListener = freshData -> LinkManager.engineState.processNewData(new String(freshData), LinkManager.ENCODER);
|
||||
private final LinkManager linkManager;
|
||||
|
||||
public ConnectionStateListener listener;
|
||||
private final Object portLock = new Object();
|
||||
|
@ -27,7 +28,8 @@ public class PortHolder {
|
|||
@Nullable
|
||||
private BinaryProtocol bp;
|
||||
|
||||
protected PortHolder() {
|
||||
protected PortHolder(LinkManager linkManager) {
|
||||
this.linkManager = linkManager;
|
||||
}
|
||||
|
||||
public String port;
|
||||
|
@ -40,7 +42,7 @@ public class PortHolder {
|
|||
|
||||
IoStream stream = SerialIoStreamJSerialComm.openPort(port);
|
||||
synchronized (portLock) {
|
||||
bp = new BinaryProtocol(FileLog.LOGGER, stream);
|
||||
bp = new BinaryProtocol(linkManager, FileLog.LOGGER, stream);
|
||||
portLock.notifyAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,12 @@ import com.rusefi.io.LinkManager;
|
|||
*/
|
||||
public class SerialConnector implements LinkConnector {
|
||||
|
||||
private final PortHolder portHolder = new PortHolder();
|
||||
private final PortHolder portHolder;
|
||||
private final LinkManager linkManager;
|
||||
|
||||
public SerialConnector(String serialPort) {
|
||||
public SerialConnector(LinkManager linkManager, String serialPort) {
|
||||
this.linkManager = linkManager;
|
||||
portHolder = new PortHolder(linkManager);
|
||||
portHolder.port = serialPort;
|
||||
}
|
||||
|
||||
|
@ -24,7 +27,7 @@ public class SerialConnector implements LinkConnector {
|
|||
FileLog.MAIN.logLine("SerialConnector: connecting");
|
||||
portHolder.listener = listener;
|
||||
FileLog.MAIN.logLine("scheduleOpening");
|
||||
LinkManager.execute(new Runnable() {
|
||||
linkManager.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||
|
@ -40,7 +43,7 @@ public class SerialConnector implements LinkConnector {
|
|||
|
||||
@Override
|
||||
public void restart() {
|
||||
LinkManager.execute(new Runnable() {
|
||||
linkManager.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesCentral.getInstance().postMessage(SerialConnector.this.getClass(), "Restarting serial IO");
|
||||
|
|
|
@ -101,7 +101,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
|||
throw new IllegalStateException("CRC mismatch");
|
||||
|
||||
|
||||
TcpIoStream stream = new TcpIoStream(clientSocket.getInputStream(), clientSocket.getOutputStream());
|
||||
TcpIoStream stream = new TcpIoStream(linkManager, clientSocket.getInputStream(), clientSocket.getOutputStream());
|
||||
if (command == COMMAND_HELLO) {
|
||||
stream.sendPacket((TS_OK + Fields.TS_SIGNATURE).getBytes(), FileLog.LOGGER);
|
||||
} else if (command == COMMAND_PROTOCOL) {
|
||||
|
|
|
@ -25,10 +25,12 @@ public class TcpConnector implements LinkConnector {
|
|||
public static final String LOCALHOST = "localhost";
|
||||
private final int port;
|
||||
private final String hostname;
|
||||
private final LinkManager linkManager;
|
||||
|
||||
private BinaryProtocol bp;
|
||||
|
||||
public TcpConnector(String port) {
|
||||
public TcpConnector(LinkManager linkManager, String port) {
|
||||
this.linkManager = linkManager;
|
||||
try {
|
||||
this.port = getTcpPort(port);
|
||||
this.hostname = getHostname(port);
|
||||
|
@ -122,7 +124,7 @@ public class TcpConnector implements LinkConnector {
|
|||
};
|
||||
// ioStream.setInputListener(listener1);
|
||||
|
||||
bp = new BinaryProtocol(FileLog.LOGGER, (IoStream) new TcpIoStream(stream, os));
|
||||
bp = new BinaryProtocol(linkManager, FileLog.LOGGER, new TcpIoStream(linkManager, stream, os));
|
||||
|
||||
boolean result = bp.connectAndReadConfiguration(listener1);
|
||||
if (result) {
|
||||
|
|
|
@ -17,9 +17,11 @@ import java.util.Arrays;
|
|||
public class TcpIoStream implements IoStream {
|
||||
private final InputStream input;
|
||||
private final OutputStream output;
|
||||
private final LinkManager linkManager;
|
||||
private boolean isClosed;
|
||||
|
||||
public TcpIoStream(InputStream input, OutputStream output) {
|
||||
public TcpIoStream(LinkManager linkManager, InputStream input, OutputStream output) {
|
||||
this.linkManager = linkManager;
|
||||
if (input == null)
|
||||
throw new NullPointerException("input");
|
||||
if (output == null)
|
||||
|
@ -46,7 +48,7 @@ public class TcpIoStream implements IoStream {
|
|||
|
||||
@Override
|
||||
public void setInputListener(final DataListener listener) {
|
||||
LinkManager.TCP_READ_EXECUTOR.execute(new Runnable() {
|
||||
linkManager.TCP_READ_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setName("TCP connector loop");
|
||||
|
|
|
@ -16,9 +16,10 @@ import java.io.ByteArrayOutputStream;
|
|||
|
||||
class BinaryProtocolServerSandbox {
|
||||
public static void main(String[] args) {
|
||||
TcpIoStream stream = new TcpIoStream(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream());
|
||||
BinaryProtocol bp = new BinaryProtocol(FileLog.LOGGER, (IoStream) stream);
|
||||
LinkManager.setConnector(new LinkConnector() {
|
||||
LinkManager linkManager = new LinkManager();
|
||||
TcpIoStream stream = new TcpIoStream(linkManager, new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream());
|
||||
BinaryProtocol bp = new BinaryProtocol(linkManager, FileLog.LOGGER, (IoStream) stream);
|
||||
linkManager.setConnector(new LinkConnector() {
|
||||
@Override
|
||||
public void connectAndReadConfiguration(ConnectionStateListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -41,6 +42,6 @@ class BinaryProtocolServerSandbox {
|
|||
});
|
||||
bp.setController(new ConfigurationImage(new byte[Fields.TOTAL_CONFIG_SIZE]));
|
||||
bp.currentOutputs = new byte[1 + Fields.TS_OUTPUT_SIZE];
|
||||
BinaryProtocolServer.start(new LinkManager());
|
||||
BinaryProtocolServer.start(linkManager);
|
||||
}
|
||||
}
|
|
@ -70,30 +70,31 @@ public class ConsoleUI {
|
|||
getConfig().getRoot().setProperty(PORT_KEY, port);
|
||||
getConfig().getRoot().setProperty(SPEED_KEY, BaudRateHolder.INSTANCE.baudRate);
|
||||
|
||||
uiContext.getLinkManager().start(port);
|
||||
LinkManager linkManager = uiContext.getLinkManager();
|
||||
linkManager.start(port);
|
||||
|
||||
engineSnifferPanel = new EngineSnifferPanel(uiContext, getConfig().getRoot().getChild("digital_sniffer"));
|
||||
if (!LinkManager.isLogViewerMode(port))
|
||||
engineSnifferPanel.setOutpinListener(LinkManager.engineState);
|
||||
|
||||
if (LinkManager.isLogViewerMode(port))
|
||||
tabbedPane.addTab("Log Viewer", new LogViewer(engineSnifferPanel));
|
||||
tabbedPane.addTab("Log Viewer", new LogViewer(uiContext, engineSnifferPanel));
|
||||
|
||||
new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> {
|
||||
FileLog.MAIN.logLine("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY);
|
||||
LinkManager.restart();
|
||||
linkManager.restart();
|
||||
}).start();
|
||||
|
||||
GaugesPanel.DetachedRepository.INSTANCE.init(getConfig().getRoot().getChild("detached"));
|
||||
GaugesPanel.DetachedRepository.INSTANCE.load();
|
||||
if (!LinkManager.isLogViewer())
|
||||
tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent());
|
||||
if (!linkManager.isLogViewer())
|
||||
tabbedPane.addTab("Gauges", new GaugesPanel(uiContext, getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent());
|
||||
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages"));
|
||||
if (!linkManager.isLogViewer()) {
|
||||
MessagesPane messagesPane = new MessagesPane(uiContext, getConfig().getRoot().getChild("messages"));
|
||||
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
||||
}
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!linkManager.isLogViewer()) {
|
||||
tabbedPane.addTab("Bench Test", new BenchTestPane(uiContext).getContent());
|
||||
if (tabbedPane.paneSettings.showEtbPane)
|
||||
tabbedPane.addTab("ETB", new ETBPane(uiContext).getContent());
|
||||
|
@ -102,7 +103,7 @@ public class ConsoleUI {
|
|||
|
||||
tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener());
|
||||
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!linkManager.isLogViewer()) {
|
||||
SensorSnifferPane sensorSniffer = new SensorSnifferPane(uiContext, getConfig().getRoot().getChild("sensor_sniffer"));
|
||||
tabbedPaneAdd("Sensor Sniffer", sensorSniffer.getPanel(), sensorSniffer.getTabSelectedListener());
|
||||
}
|
||||
|
@ -120,20 +121,20 @@ public class ConsoleUI {
|
|||
// tabbedPane.addTab("Table Editor", tabbedPane.romEditorPane);
|
||||
// tabbedPane.add("Wizards", new Wizard().createPane());
|
||||
|
||||
if (!LinkManager.isLogViewer())
|
||||
if (!linkManager.isLogViewer())
|
||||
tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane());
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!linkManager.isLogViewer()) {
|
||||
tabbedPane.addTab("Formulas/Live Data", new FormulasPane(uiContext).getContent());
|
||||
tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent());
|
||||
}
|
||||
|
||||
if (!LinkManager.isLogViewer() && false) // todo: fix it & better name?
|
||||
if (!linkManager.isLogViewer() && false) // todo: fix it & better name?
|
||||
tabbedPane.addTab("Logs Manager", tabbedPane.logsManager.getContent());
|
||||
if (tabbedPane.paneSettings.showFuelTunePane)
|
||||
tabbedPane.addTab("Fuel Tune", tabbedPane.fuelTunePane.getContent());
|
||||
|
||||
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!linkManager.isLogViewer()) {
|
||||
if (tabbedPane.paneSettings.showTriggerShapePane)
|
||||
tabbedPane.addTab("Trigger Shape", new AverageAnglePanel().getPanel());
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SensorSnifferPane {
|
|||
);
|
||||
|
||||
upperPanel.add(pauseButton);
|
||||
upperPanel.add(new RpmLabel(2).getContent());
|
||||
upperPanel.add(new RpmLabel(uiContext,2).getContent());
|
||||
|
||||
command = AnyCommand.createField(config, true, false);
|
||||
upperPanel.add(command.getContent());
|
||||
|
|
|
@ -84,7 +84,7 @@ public class UploadChanges {
|
|||
public static void scheduleUpload(UIContext uiContext, final ConfigurationImage newVersion, final Runnable afterUpload) {
|
||||
JFrame frame = wnd.getFrame();
|
||||
frame.setVisible(true);
|
||||
LinkManager.execute(new Runnable() {
|
||||
uiContext.getLinkManager().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
|
|
@ -6,6 +6,6 @@ import com.rusefi.ui.storage.PersistentConfiguration;
|
|||
|
||||
public class MsgPanelSandbox extends FrameHelper {
|
||||
public static void main(String[] args) {
|
||||
new FrameHelper().showFrame(new MessagesPane(PersistentConfiguration.getConfig().getRoot()).getContent());
|
||||
new FrameHelper().showFrame(new MessagesPane(null, PersistentConfiguration.getConfig().getRoot()).getContent());
|
||||
}
|
||||
}
|
|
@ -67,6 +67,7 @@ public class GaugesPanel {
|
|||
private final JPanel content = new JPanel(new BorderLayout());
|
||||
private final GaugesGrid gauges;
|
||||
private final Node config;
|
||||
private final UIContext uiContext;
|
||||
|
||||
private boolean showRpmPanel;
|
||||
private boolean showMessagesPanel;
|
||||
|
@ -77,7 +78,8 @@ public class GaugesPanel {
|
|||
private final JPanel messagesPanel = new JPanel(new BorderLayout());
|
||||
private final JSplitPane middleSplitPanel;
|
||||
|
||||
public GaugesPanel(final Node config, PaneSettings paneSettings) {
|
||||
public GaugesPanel(UIContext uiContext, final Node config, PaneSettings paneSettings) {
|
||||
this.uiContext = uiContext;
|
||||
gauges = new GaugesGrid(DEFAULT_ROWS, DEFAULT_COLUMNS);
|
||||
this.config = config;
|
||||
showRpmPanel = config.getBoolProperty(SHOW_RPM, true);
|
||||
|
@ -85,7 +87,7 @@ public class GaugesPanel {
|
|||
|
||||
prepareMessagesPanel();
|
||||
|
||||
lowerRpmPanel.add(new RpmLabel(15).getContent());
|
||||
lowerRpmPanel.add(new RpmLabel(uiContext,15).getContent());
|
||||
|
||||
int rows = config.getIntProperty(GAUGES_ROWS, DEFAULT_ROWS);
|
||||
int columns = config.getIntProperty(GAUGES_COLUMNS, DEFAULT_COLUMNS);
|
||||
|
@ -210,7 +212,7 @@ public class GaugesPanel {
|
|||
JPanel leftUpperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
||||
leftUpperPanel.add(createPauseButton());
|
||||
leftUpperPanel.add(createSaveImageButton());
|
||||
leftUpperPanel.add(new RpmLabel(2).getContent());
|
||||
leftUpperPanel.add(new RpmLabel(uiContext, 2).getContent());
|
||||
AnyCommand command = AnyCommand.createField(config, false, false);
|
||||
leftUpperPanel.add(command.getContent());
|
||||
return leftUpperPanel;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class MessagesPane {
|
|||
private final JButton fontButton = new JButton("Font");
|
||||
private final AnyCommand command;
|
||||
|
||||
public MessagesPane(final Node config) {
|
||||
public MessagesPane(UIContext uiContext, final Node config) {
|
||||
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
||||
|
||||
command = AnyCommand.createArea(config, config.getProperty(AnyCommand.KEY), true, false);
|
||||
|
@ -35,11 +35,11 @@ public class MessagesPane {
|
|||
|
||||
JPanel middlePanel = new JPanel(new BorderLayout());
|
||||
middlePanel.add(upperPanel.getMessagesScroll(), BorderLayout.CENTER);
|
||||
middlePanel.add(new RecentCommands().getContent(), BorderLayout.EAST);
|
||||
middlePanel.add(new RecentCommands(uiContext).getContent(), BorderLayout.EAST);
|
||||
|
||||
content.add(middlePanel, BorderLayout.CENTER);
|
||||
|
||||
upperPanel.getButtonPanel().add(new RpmLabel(2).getContent());
|
||||
upperPanel.getButtonPanel().add(new RpmLabel(uiContext, 2).getContent());
|
||||
topPanel.add(upperPanel.getButtonPanel());
|
||||
topPanel.add(fontButton);
|
||||
topPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL));
|
||||
|
@ -47,7 +47,7 @@ public class MessagesPane {
|
|||
|
||||
JPanel statsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
|
||||
statsPanel.add(new RpmLabel().getContent());
|
||||
statsPanel.add(new RpmLabel(uiContext).getContent());
|
||||
statsPanel.add(new IdleLabel());
|
||||
statsPanel.add(new WarningPanel().getPanel());
|
||||
|
||||
|
|
|
@ -91,8 +91,10 @@ public class RecentCommands {
|
|||
private final AtomicBoolean reentrant = new AtomicBoolean();
|
||||
|
||||
private final JScrollPane messagesScroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
private final UIContext uiContext;
|
||||
|
||||
public RecentCommands() {
|
||||
public RecentCommands(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {
|
||||
@Override
|
||||
public void onCommand(String command) {
|
||||
|
@ -165,7 +167,7 @@ public class RecentCommands {
|
|||
public void run() {
|
||||
content.removeAll();
|
||||
|
||||
if (LinkManager.isLogViewer())
|
||||
if (uiContext.getLinkManager().isLogViewer())
|
||||
content.add(createButton());
|
||||
|
||||
JButton reset = new JButton(AutoupdateUtil.loadIcon("/undo.jpg"));
|
||||
|
|
|
@ -21,12 +21,12 @@ public class RpmLabel {
|
|||
private final JLabel rpmValue = new JLabel();
|
||||
private final JLabel rpmCaption = new JLabel("RPM:");
|
||||
|
||||
public RpmLabel() {
|
||||
this(1);
|
||||
public RpmLabel(UIContext uiContext) {
|
||||
this(uiContext, 1);
|
||||
}
|
||||
|
||||
public RpmLabel(int size) {
|
||||
String initialLabel = LinkManager.isLogViewer() ? "LOG" : NO_CONNECTION;
|
||||
public RpmLabel(UIContext uiContext, int size) {
|
||||
String initialLabel = uiContext.getLinkManager().isLogViewer() ? "LOG" : NO_CONNECTION;
|
||||
rpmValue.setText(initialLabel);
|
||||
rpmValue.setForeground(Color.red);
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ public class EngineSnifferPanel {
|
|||
upperPanel.add(clearButton);
|
||||
upperPanel.add(saveImageButton);
|
||||
upperPanel.add(pauseButton);
|
||||
upperPanel.add(new RpmLabel(2).getContent());
|
||||
upperPanel.add(new RpmLabel(uiContext,2).getContent());
|
||||
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!uiContext.getLinkManager().isLogViewer()) {
|
||||
command = AnyCommand.createField(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true, true);
|
||||
upperPanel.add(command.getContent());
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ public class EngineSnifferPanel {
|
|||
displayChart(chart);
|
||||
}
|
||||
});
|
||||
if (LinkManager.isLogViewer())
|
||||
if (uiContext.getLinkManager().isLogViewer())
|
||||
upperPanel.add(scrollControl.getContent());
|
||||
|
||||
upperPanel.add(new URLLabel(HELP_TEXT, HELP_URL));
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
|
||||
if (!LinkManager.isLogViewer()) {
|
||||
if (!uiContext.getLinkManager().isLogViewer()) {
|
||||
JPanel lowerButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||
lowerButtons.add(new ConfigField(uiContext, Fields.GLOBALTRIGGERANGLEOFFSET, "Trigger Offset").getContent());
|
||||
lowerButtons.add(new BitConfigField(uiContext, Fields.VERBOSETRIGGERSYNCHDETAILS, "Verbose trigger Sync").getContent());
|
||||
|
|
|
@ -113,7 +113,7 @@ public class LightweightGUI {
|
|||
|
||||
new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> {
|
||||
FileLog.MAIN.logLine("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY);
|
||||
LinkManager.restart();
|
||||
linkManager.restart();
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.rusefi.core.EngineState;
|
|||
import com.rusefi.file.FileUtils;
|
||||
import com.rusefi.ui.ChartRepository;
|
||||
import com.rusefi.ui.LogDownloader;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import com.rusefi.ui.engine.EngineSnifferPanel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
@ -43,12 +44,14 @@ public class LogViewer extends JPanel {
|
|||
private final JLabel fileLabel = new JLabel();
|
||||
private final DefaultListModel<FileItem> fileListModel = new DefaultListModel<FileItem>();
|
||||
private final JList<FileItem> fileList = new JList<FileItem>(fileListModel);
|
||||
private final UIContext uiContext;
|
||||
private final EngineSnifferPanel engineSnifferPanel;
|
||||
private String currentFolder;
|
||||
private static JPanel descPanel = new JPanel();
|
||||
|
||||
public LogViewer(EngineSnifferPanel engineSnifferPanel) {
|
||||
public LogViewer(UIContext uiContext, EngineSnifferPanel engineSnifferPanel) {
|
||||
super(new BorderLayout());
|
||||
this.uiContext = uiContext;
|
||||
this.engineSnifferPanel = engineSnifferPanel;
|
||||
|
||||
setBackground(Color.green);
|
||||
|
@ -125,7 +128,7 @@ public class LogViewer extends JPanel {
|
|||
|
||||
int index = 0;
|
||||
|
||||
while (files.length > index && LinkManager.isLogViewer()) {
|
||||
while (files.length > index && uiContext.getLinkManager().isLogViewer()) {
|
||||
File file = files[index];
|
||||
if (file.getName().endsWith(FileLog.currentLogName)) {
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue