rusEFI console start-up speed fix #2964
This commit is contained in:
parent
fabe51e9c5
commit
12638ae723
|
@ -32,7 +32,10 @@ All notable user-facing or behavior-altering changes will be documented in this
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Injector nonlinearity (small pulse) correction - so far just polynomial, but table modes coming soon.
|
- Injector nonlinearity (small pulse) correction - so far just polynomial, but table modes coming soon.
|
||||||
- 1-4-3-6-2-5 firing order for VAG v6
|
- 1-4-3-6-2-5 firing order for VAG v6
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- rusEFI console start-up speed #2964
|
||||||
|
|
||||||
## June 2021 Release "National Logistics Day"
|
## June 2021 Release "National Logistics Day"
|
||||||
|
|
||||||
|
|
|
@ -62,16 +62,17 @@ public class TcpConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<String> getAvailablePorts() {
|
public static Collection<String> getAvailablePorts() {
|
||||||
return isTcpPortOpened() ? Collections.singletonList("" + DEFAULT_PORT) : Collections.<String>emptyList();
|
return isTcpPortOpened() ? Collections.singletonList("" + DEFAULT_PORT) : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTcpPortOpened() {
|
public static boolean isTcpPortOpened() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
Socket s = new Socket(LOCALHOST, DEFAULT_PORT);
|
Socket s = new Socket(LOCALHOST, DEFAULT_PORT);
|
||||||
s.close();
|
s.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println(new Date() + ": Connection refused in getAvailablePorts(): simulator not running");
|
System.out.println(new Date() + ": Connection refused in getAvailablePorts(): simulator not running in " + (System.currentTimeMillis() - now) + "ms");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
|
import com.rusefi.ui.util.UiUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,13 +28,14 @@ public enum SerialPortScanner {
|
||||||
/**
|
/**
|
||||||
* Find all available serial ports and checks if simulator local TCP port is available
|
* Find all available serial ports and checks if simulator local TCP port is available
|
||||||
*/
|
*/
|
||||||
void findAllAvailablePorts() {
|
void findAllAvailablePorts(boolean includeSlowTcpLookup) {
|
||||||
List<String> ports = new ArrayList<>();
|
List<String> ports = new ArrayList<>();
|
||||||
String[] serialPorts = LinkManager.getCommPorts();
|
String[] serialPorts = LinkManager.getCommPorts();
|
||||||
if (serialPorts.length > 0 && serialPorts.length < 15)
|
if (serialPorts.length > 0 && serialPorts.length < 15)
|
||||||
ports.add(AUTO_SERIAL);
|
ports.add(AUTO_SERIAL);
|
||||||
ports.addAll(Arrays.asList(serialPorts));
|
ports.addAll(Arrays.asList(serialPorts));
|
||||||
ports.addAll(TcpConnector.getAvailablePorts());
|
if (includeSlowTcpLookup)
|
||||||
|
ports.addAll(TcpConnector.getAvailablePorts());
|
||||||
|
|
||||||
boolean isListUpdated;
|
boolean isListUpdated;
|
||||||
synchronized (knownPorts) {
|
synchronized (knownPorts) {
|
||||||
|
@ -56,7 +59,7 @@ public enum SerialPortScanner {
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
Thread portsScanner = new Thread(() -> {
|
Thread portsScanner = new Thread(() -> {
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
findAllAvailablePorts();
|
findAllAvailablePorts(true);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -23,8 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
import static com.rusefi.ui.util.UiUtils.getAllComponents;
|
import static com.rusefi.ui.util.UiUtils.*;
|
||||||
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
|
||||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,26 +150,11 @@ public class StartupFrame {
|
||||||
realHardwarePanel.add(new EraseChip().getButton(), "right, wrap");
|
realHardwarePanel.add(new EraseChip().getButton(), "right, wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(() -> {
|
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(this::applyKnownPorts));
|
||||||
List<String> ports = SerialPortScanner.INSTANCE.getKnownPorts();
|
|
||||||
if (!currentlyDisplayedPorts.equals(ports) || isFirstTimeApplyingPorts) {
|
|
||||||
FileLog.MAIN.logLine("Available ports " + ports);
|
|
||||||
isFirstTimeApplyingPorts = false;
|
|
||||||
connectPanel.setVisible(!ports.isEmpty());
|
|
||||||
noPortsMessage.setVisible(ports.isEmpty());
|
|
||||||
// panel.add(comboSpeeds); // todo: finish speed selector UI component
|
|
||||||
// horizontalLine.setVisible(!ports.isEmpty());
|
|
||||||
|
|
||||||
applyPortSelectionToUIcontrol(ports);
|
|
||||||
currentlyDisplayedPorts = ports;
|
|
||||||
UiUtils.trueLayout(connectPanel);
|
|
||||||
frame.pack();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
// todo: invoke this NOT on AWT thread?
|
// todo: invoke this NOT on AWT thread?
|
||||||
SerialPortScanner.INSTANCE.findAllAvailablePorts();
|
SerialPortScanner.INSTANCE.findAllAvailablePorts(false);
|
||||||
|
applyKnownPorts();
|
||||||
|
|
||||||
final JButton buttonLogViewer = new JButton();
|
final JButton buttonLogViewer = new JButton();
|
||||||
buttonLogViewer.setText("Start " + LinkManager.LOG_VIEWER);
|
buttonLogViewer.setText("Start " + LinkManager.LOG_VIEWER);
|
||||||
|
@ -211,6 +195,23 @@ public class StartupFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyKnownPorts() {
|
||||||
|
List<String> ports = SerialPortScanner.INSTANCE.getKnownPorts();
|
||||||
|
if (!currentlyDisplayedPorts.equals(ports) || isFirstTimeApplyingPorts) {
|
||||||
|
FileLog.MAIN.logLine("Rendering available ports: " + ports);
|
||||||
|
isFirstTimeApplyingPorts = false;
|
||||||
|
connectPanel.setVisible(!ports.isEmpty());
|
||||||
|
noPortsMessage.setVisible(ports.isEmpty());
|
||||||
|
// panel.add(comboSpeeds); // todo: finish speed selector UI component
|
||||||
|
// horizontalLine.setVisible(!ports.isEmpty());
|
||||||
|
|
||||||
|
applyPortSelectionToUIcontrol(ports);
|
||||||
|
currentlyDisplayedPorts = ports;
|
||||||
|
UiUtils.trueLayout(connectPanel);
|
||||||
|
frame.pack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setFrameIcon(Frame frame) {
|
public static void setFrameIcon(Frame frame) {
|
||||||
ImageIcon icon = AutoupdateUtil.loadIcon(LOGO);
|
ImageIcon icon = AutoupdateUtil.loadIcon(LOGO);
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
|
@ -301,6 +302,7 @@ public class StartupFrame {
|
||||||
comboPorts.addItem(port);
|
comboPorts.addItem(port);
|
||||||
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
|
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
|
||||||
comboPorts.setSelectedItem(defaultPort);
|
comboPorts.setSelectedItem(defaultPort);
|
||||||
|
trueLayout(comboPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JComboBox<String> createSpeedCombo() {
|
private static JComboBox<String> createSpeedCombo() {
|
||||||
|
|
Loading…
Reference in New Issue