only: Make sure you are disconnected from TunerStudio

This commit is contained in:
rusefillc 2024-05-22 12:22:16 -04:00
parent cb4d0a62f4
commit 977cb15d5f
2 changed files with 21 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import java.net.URL;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
public interface rusEFIVersion { public interface rusEFIVersion {
int CONSOLE_VERSION = 20240511; int CONSOLE_VERSION = 20240522;
AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A"); AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
static long classBuildTimeMillis() { static long classBuildTimeMillis() {

View File

@ -69,6 +69,7 @@ public class StartupFrame {
public StartupFrame() { public StartupFrame() {
String title = "rusEFI console version " + Launcher.CONSOLE_VERSION; String title = "rusEFI console version " + Launcher.CONSOLE_VERSION;
log.info(title); log.info(title);
noPortsMessage.setForeground(Color.red);
frame = FrameHelper.createFrame(title).getFrame(); frame = FrameHelper.createFrame(title).getFrame();
frame.addWindowListener(new WindowAdapter() { frame.addWindowListener(new WindowAdapter() {
@Override @Override
@ -226,10 +227,18 @@ public class StartupFrame {
List<SerialPortScanner.PortResult> ports = currentHardware.getKnownPorts(); List<SerialPortScanner.PortResult> ports = currentHardware.getKnownPorts();
log.info("Rendering available ports: " + ports); log.info("Rendering available ports: " + ports);
connectPanel.setVisible(!ports.isEmpty()); connectPanel.setVisible(!ports.isEmpty());
noPortsMessage.setText(NO_PORTS_FOUND);
noPortsMessage.setVisible(ports.isEmpty());
applyPortSelectionToUIcontrol(ports);
boolean hasEcuOrBootloader = applyPortSelectionToUIcontrol(ports);
if (ports.isEmpty()) {
noPortsMessage.setText(NO_PORTS_FOUND);
} else {
noPortsMessage.setText("Make sure you are disconnected from TunerStudio");
}
noPortsMessage.setVisible(ports.isEmpty() || !hasEcuOrBootloader);
UiUtils.trueLayout(connectPanel); UiUtils.trueLayout(connectPanel);
} }
@ -282,10 +291,16 @@ public class StartupFrame {
SerialPortScanner.INSTANCE.stopTimer(); SerialPortScanner.INSTANCE.stopTimer();
} }
private void applyPortSelectionToUIcontrol(List<SerialPortScanner.PortResult> ports) { private boolean applyPortSelectionToUIcontrol(List<SerialPortScanner.PortResult> ports) {
comboPorts.removeAllItems(); comboPorts.removeAllItems();
boolean hasEcuOrBootloader = false;
for (final SerialPortScanner.PortResult port : ports) { for (final SerialPortScanner.PortResult port : ports) {
comboPorts.addItem(port); comboPorts.addItem(port);
if (port.type == SerialPortScanner.SerialPortType.Ecu ||
port.type == SerialPortScanner.SerialPortType.EcuWithOpenblt ||
port.type == SerialPortScanner.SerialPortType.OpenBlt) {
hasEcuOrBootloader = true;
}
} }
String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY); String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY);
if (!PersistentConfiguration.getBoolProperty(ALWAYS_AUTO_PORT)) { if (!PersistentConfiguration.getBoolProperty(ALWAYS_AUTO_PORT)) {
@ -293,6 +308,7 @@ public class StartupFrame {
} }
trueLayout(comboPorts); trueLayout(comboPorts);
return hasEcuOrBootloader;
} }
private static JComboBox<String> createSpeedCombo() { private static JComboBox<String> createSpeedCombo() {