there is an unbelievably volume of dead code here

This commit is contained in:
Matthew Kennedy 2023-11-25 18:25:25 -08:00
parent 22f552c68c
commit 3d8fdcc089
9 changed files with 8 additions and 91 deletions

View File

@ -22,7 +22,6 @@ public class PortDetector {
private final static Logging log = Logging.getLogging(PortDetector.class); private final static Logging log = Logging.getLogging(PortDetector.class);
private static final NamedThreadFactory AUTO_DETECT_PORT = new NamedThreadFactory("ECU AutoDetectPort", true); private static final NamedThreadFactory AUTO_DETECT_PORT = new NamedThreadFactory("ECU AutoDetectPort", true);
public static final String AUTO = "auto";
/** /**
* Connect to all serial ports and find out which one respond first * Connect to all serial ports and find out which one respond first
@ -92,14 +91,4 @@ public class PortDetector {
// log.info("Returning " + result.get()); // log.info("Returning " + result.get());
return autoDetectResult; return autoDetectResult;
} }
@Nullable
public static SerialAutoChecker.AutoDetectResult autoDetectPort(JFrame parent) {
SerialAutoChecker.AutoDetectResult autoDetectedPort = autoDetectSerial();
if (autoDetectedPort.getSerialPort() == null) {
JOptionPane.showMessageDialog(parent, "Failed to locate rusEFI");
return null;
}
return autoDetectedPort;
}
} }

View File

@ -27,7 +27,6 @@ public enum FileLog {
@Nullable @Nullable
private OutputStream fileLog; // null if not opened yet or already closed private OutputStream fileLog; // null if not opened yet or already closed
public static boolean suspendLogging;
FileLog() { FileLog() {
} }
@ -93,8 +92,7 @@ public enum FileLog {
public synchronized void logLine(String fullLine) { public synchronized void logLine(String fullLine) {
String withDate = getDate() + Logger.END_OF_TIMESTAND_TAG + fullLine; String withDate = getDate() + Logger.END_OF_TIMESTAND_TAG + fullLine;
System.out.println(withDate); System.out.println(withDate);
if (suspendLogging)
return;
if (fileLog == null) if (fileLog == null)
return; return;
try { try {

View File

@ -17,7 +17,6 @@ import java.awt.event.ActionListener;
*/ */
abstract class CommandControl { abstract class CommandControl {
public static final String TEST = "Test"; public static final String TEST = "Test";
public static final String SET = "Set";
protected final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); protected final JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
private final UIContext uiContext; private final UIContext uiContext;

View File

@ -46,6 +46,8 @@ public class ConsoleUI {
public final UIContext uiContext = new UIContext(); public final UIContext uiContext = new UIContext();
public boolean showTriggerShapePane = false;
/** /**
* We can listen to tab activation event if we so desire * We can listen to tab activation event if we so desire
*/ */
@ -93,7 +95,8 @@ public class ConsoleUI {
// tabbedPane.addTab("ECU stimulation", stimulator.getPanel()); // tabbedPane.addTab("ECU stimulation", stimulator.getPanel());
// } // }
if (tabbedPane.paneSettings.showTriggerShapePane) // TODO: always false?
if (showTriggerShapePane)
tabbedPane.addTab("Trigger Shape", new AverageAnglePanel(uiContext).getPanel()); tabbedPane.addTab("Trigger Shape", new AverageAnglePanel(uiContext).getPanel());
int selectedIndex = getConfig().getRoot().getIntProperty(TAB_INDEX, DEFAULT_TAB_INDEX); int selectedIndex = getConfig().getRoot().getIntProperty(TAB_INDEX, DEFAULT_TAB_INDEX);

View File

@ -1,11 +0,0 @@
package com.rusefi;
import com.rusefi.core.preferences.storage.Node;
public class PaneSettings {
public boolean showTriggerShapePane;
public boolean showStimulatorPane;
public PaneSettings(Node config) {
}
}

View File

@ -28,7 +28,6 @@ public enum SerialPortScanner {
private final static Logging log = Logging.getLogging(SerialPortScanner.class); private final static Logging log = Logging.getLogging(SerialPortScanner.class);
public enum SerialPortType { public enum SerialPortType {
None(null, 100),
FomeEcu("FOME ECU", 20), FomeEcu("FOME ECU", 20),
FomeEcuWithOpenblt("FOME ECU w/ BL", 20), FomeEcuWithOpenblt("FOME ECU w/ BL", 20),
OpenBlt("OpenBLT Bootloader", 10), OpenBlt("OpenBLT Bootloader", 10),
@ -116,21 +115,12 @@ public enum SerialPortScanner {
String[] serialPorts = LinkManager.getCommPorts(); String[] serialPorts = LinkManager.getCommPorts();
int ecuCount = 0;
boolean hasAnyOpenblt = false;
for (String serialPort : serialPorts) { for (String serialPort : serialPorts) {
// First, check the port cache // First, check the port cache
if (portCache.containsKey(serialPort)) { if (portCache.containsKey(serialPort)) {
// We've already probed this port - don't re-probe it again // We've already probed this port - don't re-probe it again
PortResult cached = portCache.get(serialPort); PortResult cached = portCache.get(serialPort);
if (cached.isEcu()) {
ecuCount++;
} else if (cached.type == SerialPortType.OpenBlt) {
hasAnyOpenblt = true;
}
ports.add(cached); ports.add(cached);
} else { } else {
// This one isn't in the cache, probe it to determine what it is // This one isn't in the cache, probe it to determine what it is
@ -142,7 +132,6 @@ public enum SerialPortScanner {
log.info("Port " + serialPort + (isOpenblt ? " looks like" : " does not look like") + " an OpenBLT bootloader"); log.info("Port " + serialPort + (isOpenblt ? " looks like" : " does not look like") + " an OpenBLT bootloader");
if (isOpenblt) { if (isOpenblt) {
result = new PortResult(serialPort, SerialPortType.OpenBlt); result = new PortResult(serialPort, SerialPortType.OpenBlt);
hasAnyOpenblt = true;
} else { } else {
// See if this looks like an ECU // See if this looks like an ECU
String signature = getEcuSignature(serialPort); String signature = getEcuSignature(serialPort);
@ -152,7 +141,6 @@ public enum SerialPortScanner {
boolean ecuHasOpenblt = fomeEcuHasOpenblt(serialPort); boolean ecuHasOpenblt = fomeEcuHasOpenblt(serialPort);
log.info("FOME ECU at " + serialPort + (ecuHasOpenblt ? " has" : " does not have") + " an OpenBLT bootloader"); log.info("FOME ECU at " + serialPort + (ecuHasOpenblt ? " has" : " does not have") + " an OpenBLT bootloader");
result = new PortResult(serialPort, ecuHasOpenblt ? SerialPortType.FomeEcuWithOpenblt : SerialPortType.FomeEcu, signature); result = new PortResult(serialPort, ecuHasOpenblt ? SerialPortType.FomeEcuWithOpenblt : SerialPortType.FomeEcu, signature);
ecuCount++;
} else { } else {
// Dunno what this is, leave it in the list anyway // Dunno what this is, leave it in the list anyway
result = new PortResult(serialPort, SerialPortType.Unknown); result = new PortResult(serialPort, SerialPortType.Unknown);
@ -184,15 +172,12 @@ public enum SerialPortScanner {
}); });
} }
boolean hasAnyEcu = ecuCount > 0;
// Sort ports by their type to put your ECU at the top // Sort ports by their type to put your ECU at the top
ports.sort(Comparator.comparingInt(a -> a.type.sortOrder)); ports.sort(Comparator.comparingInt(a -> a.type.sortOrder));
if (includeSlowLookup) { if (includeSlowLookup) {
for (String tcpPort : TcpConnector.getAvailablePorts()) { for (String tcpPort : TcpConnector.getAvailablePorts()) {
ports.add(new PortResult(tcpPort, SerialPortType.FomeEcu)); ports.add(new PortResult(tcpPort, SerialPortType.FomeEcu));
hasAnyEcu = true;
} }
dfuConnected = DfuFlasher.detectSTM32BootloaderDriverState(UpdateOperationCallbacks.DUMMY); dfuConnected = DfuFlasher.detectSTM32BootloaderDriverState(UpdateOperationCallbacks.DUMMY);
@ -201,7 +186,7 @@ public enum SerialPortScanner {
} }
boolean isListUpdated; boolean isListUpdated;
AvailableHardware currentHardware = new AvailableHardware(ports, dfuConnected, hasAnyEcu, hasAnyOpenblt); AvailableHardware currentHardware = new AvailableHardware(ports, dfuConnected);
synchronized (lock) { synchronized (lock) {
isListUpdated = !currentHardware.equals(knownHardware); isListUpdated = !currentHardware.equals(knownHardware);
knownHardware = currentHardware; knownHardware = currentHardware;
@ -243,14 +228,10 @@ public enum SerialPortScanner {
public static class AvailableHardware { public static class AvailableHardware {
private final List<PortResult> ports; private final List<PortResult> ports;
public final boolean dfuFound; public final boolean dfuFound;
public final boolean hasAnyEcu;
public final boolean hasAnyOpenblt;
public <T> AvailableHardware(List<PortResult> ports, boolean dfuFound, boolean hasAnyEcu, boolean hasAnyOpenblt) { public <T> AvailableHardware(List<PortResult> ports, boolean dfuFound) {
this.ports = ports; this.ports = ports;
this.dfuFound = dfuFound; this.dfuFound = dfuFound;
this.hasAnyEcu = hasAnyEcu;
this.hasAnyOpenblt = hasAnyOpenblt;
} }
@NotNull @NotNull

View File

@ -1,39 +0,0 @@
package com.rusefi;
import javax.swing.*;
import java.awt.*;
public class ValueRangeControl {
private final JSpinner minSpinner;
private final JSpinner maxSpinner;
private final JPanel panel = new JPanel(new FlowLayout());
private final double increment;
public ValueRangeControl(String title, double min, double increment, double max) {
this.increment = increment;
minSpinner = new JSpinner(new SpinnerNumberModel(min, min, max, increment));
maxSpinner = new JSpinner(new SpinnerNumberModel(max, min, max, increment));
panel.add(new JLabel(title + " from"));
panel.add(minSpinner);
panel.add(new JLabel("to"));
panel.add(maxSpinner);
}
public double getFrom() {
return (double) minSpinner.getModel().getValue();
}
public double getTo() {
return (double) maxSpinner.getModel().getValue();
}
public double getStep() {
return increment;
}
public Component getContent() {
return panel;
}
}

View File

@ -258,7 +258,7 @@ public class ProgramSelector {
return content; return content;
} }
private SerialPortScanner.AvailableHardware currentHardware = new SerialPortScanner.AvailableHardware(new ArrayList<>(), false, false, false); private SerialPortScanner.AvailableHardware currentHardware = new SerialPortScanner.AvailableHardware(new ArrayList<>(), false);
private void selectedPortChanged(ItemEvent e) { private void selectedPortChanged(ItemEvent e) {
SerialPortScanner.PortResult pr = (SerialPortScanner.PortResult) e.getItem(); SerialPortScanner.PortResult pr = (SerialPortScanner.PortResult) e.getItem();

View File

@ -1,6 +1,5 @@
package com.rusefi.ui.console; package com.rusefi.ui.console;
import com.rusefi.PaneSettings;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.io.ConnectionStatusLogic; import com.rusefi.io.ConnectionStatusLogic;
@ -15,8 +14,6 @@ public class TabbedPanel {
// todo: the logic around 'criticalError' could be implemented nicer // todo: the logic around 'criticalError' could be implemented nicer
private String criticalError; private String criticalError;
public final PaneSettings paneSettings = new PaneSettings(getConfig().getRoot().getChild("panes"));
public final JTabbedPane tabbedPane = new JTabbedPane() { public final JTabbedPane tabbedPane = new JTabbedPane() {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {