rusEFI console start-up speed fix #2964
This commit is contained in:
parent
fabe51e9c5
commit
12638ae723
|
@ -34,6 +34,9 @@ All notable user-facing or behavior-altering changes will be documented in this
|
|||
- 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
|
||||
|
||||
### Fixed
|
||||
- rusEFI console start-up speed #2964
|
||||
|
||||
## June 2021 Release "National Logistics Day"
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -62,16 +62,17 @@ public class TcpConnector {
|
|||
}
|
||||
|
||||
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() {
|
||||
long now = System.currentTimeMillis();
|
||||
try {
|
||||
Socket s = new Socket(LOCALHOST, DEFAULT_PORT);
|
||||
s.close();
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.rusefi;
|
|||
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.tcp.TcpConnector;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -26,12 +28,13 @@ public enum SerialPortScanner {
|
|||
/**
|
||||
* 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<>();
|
||||
String[] serialPorts = LinkManager.getCommPorts();
|
||||
if (serialPorts.length > 0 && serialPorts.length < 15)
|
||||
ports.add(AUTO_SERIAL);
|
||||
ports.addAll(Arrays.asList(serialPorts));
|
||||
if (includeSlowTcpLookup)
|
||||
ports.addAll(TcpConnector.getAvailablePorts());
|
||||
|
||||
boolean isListUpdated;
|
||||
|
@ -56,7 +59,7 @@ public enum SerialPortScanner {
|
|||
public void startTimer() {
|
||||
Thread portsScanner = new Thread(() -> {
|
||||
while (isRunning) {
|
||||
findAllAvailablePorts();
|
||||
findAllAvailablePorts(true);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
@ -23,8 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
import static com.rusefi.ui.util.UiUtils.getAllComponents;
|
||||
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
||||
import static com.rusefi.ui.util.UiUtils.*;
|
||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||
|
||||
/**
|
||||
|
@ -151,26 +150,11 @@ public class StartupFrame {
|
|||
realHardwarePanel.add(new EraseChip().getButton(), "right, wrap");
|
||||
}
|
||||
|
||||
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(() -> {
|
||||
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();
|
||||
}
|
||||
}));
|
||||
|
||||
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(this::applyKnownPorts));
|
||||
|
||||
// todo: invoke this NOT on AWT thread?
|
||||
SerialPortScanner.INSTANCE.findAllAvailablePorts();
|
||||
SerialPortScanner.INSTANCE.findAllAvailablePorts(false);
|
||||
applyKnownPorts();
|
||||
|
||||
final JButton buttonLogViewer = new JButton();
|
||||
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) {
|
||||
ImageIcon icon = AutoupdateUtil.loadIcon(LOGO);
|
||||
if (icon != null)
|
||||
|
@ -301,6 +302,7 @@ public class StartupFrame {
|
|||
comboPorts.addItem(port);
|
||||
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
|
||||
comboPorts.setSelectedItem(defaultPort);
|
||||
trueLayout(comboPorts);
|
||||
}
|
||||
|
||||
private static JComboBox<String> createSpeedCombo() {
|
||||
|
|
Loading…
Reference in New Issue