Startup Frame should scan for available hardware #4633
maybe startup improvement or just code simplification
This commit is contained in:
parent
db1d849b45
commit
c7685a1e42
|
@ -19,7 +19,7 @@ public enum SerialPortScanner {
|
||||||
|
|
||||||
private volatile boolean isRunning = true;
|
private volatile boolean isRunning = true;
|
||||||
|
|
||||||
private static final boolean SHOW_PCAN = Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
private static final boolean SHOW_PCAN = false;// todo: reimplement with wmic Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
||||||
private static final boolean SHOW_SOCKETCAN = isLinux();
|
private static final boolean SHOW_SOCKETCAN = isLinux();
|
||||||
|
|
||||||
static final String AUTO_SERIAL = "Auto Serial";
|
static final String AUTO_SERIAL = "Auto Serial";
|
||||||
|
@ -31,7 +31,7 @@ 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(boolean includeSlowTcpLookup) {
|
private 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)
|
if (serialPorts.length > 0)
|
||||||
|
@ -65,8 +65,10 @@ public enum SerialPortScanner {
|
||||||
|
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
Thread portsScanner = new Thread(() -> {
|
Thread portsScanner = new Thread(() -> {
|
||||||
|
boolean isFirstTime = true;
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
findAllAvailablePorts(true);
|
findAllAvailablePorts(!isFirstTime);
|
||||||
|
isFirstTime = false;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class StartupFrame {
|
||||||
* closing the application.
|
* closing the application.
|
||||||
*/
|
*/
|
||||||
private boolean isProceeding;
|
private boolean isProceeding;
|
||||||
private final JLabel noPortsMessage = new JLabel("No ports found!");
|
private final JLabel noPortsMessage = new JLabel("<html>No ports found!<br>Confirm blue LED is blinking</html>");
|
||||||
|
|
||||||
public StartupFrame() {
|
public StartupFrame() {
|
||||||
// AudioPlayback.start();
|
// AudioPlayback.start();
|
||||||
|
@ -172,10 +172,6 @@ public class StartupFrame {
|
||||||
|
|
||||||
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(this::applyKnownPorts));
|
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(this::applyKnownPorts));
|
||||||
|
|
||||||
// todo: invoke this NOT on AWT thread?
|
|
||||||
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);
|
||||||
buttonLogViewer.addActionListener(new ActionListener() {
|
buttonLogViewer.addActionListener(new ActionListener() {
|
||||||
|
|
Loading…
Reference in New Issue