new feature: start PCAN connector from UI
This commit is contained in:
parent
7035cc93e5
commit
1d7607b037
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20220722;
|
||||
public static final int CONSOLE_VERSION = 20220808;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -7,7 +7,11 @@ import com.rusefi.autoupdate.Autoupdate;
|
|||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.serial.BaudRateHolder;
|
||||
import com.rusefi.maintenance.*;
|
||||
import com.rusefi.maintenance.DriverInstall;
|
||||
import com.rusefi.maintenance.ExecHelper;
|
||||
import com.rusefi.maintenance.FirmwareFlasher;
|
||||
import com.rusefi.maintenance.ProgramSelector;
|
||||
import com.rusefi.ui.PcanConnectorUI;
|
||||
import com.rusefi.ui.util.HorizontalLine;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
@ -138,6 +142,7 @@ public class StartupFrame {
|
|||
JPanel topButtons = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
||||
topButtons.add(createShowDeviceManagerButton());
|
||||
topButtons.add(DriverInstall.createButton());
|
||||
topButtons.add(createPcanConnectorButton());
|
||||
realHardwarePanel.add(topButtons, "right, wrap");
|
||||
}
|
||||
realHardwarePanel.add(connectPanel, "right, wrap");
|
||||
|
@ -320,6 +325,13 @@ public class StartupFrame {
|
|||
};
|
||||
}
|
||||
|
||||
private Component createPcanConnectorButton() {
|
||||
JButton button = new JButton("PCAN");
|
||||
button.setToolTipText("PCAN connector for TS");
|
||||
button.addActionListener(e -> PcanConnectorUI.show());
|
||||
return button;
|
||||
}
|
||||
|
||||
private Component createShowDeviceManagerButton() {
|
||||
JButton showDeviceManager = new JButton(AutoupdateUtil.loadIcon("DeviceManager.png"));
|
||||
showDeviceManager.setMargin(new Insets(0, 0, 0, 0));
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.rusefi.NamedThreadFactory;
|
||||
import com.rusefi.io.stream.PCanIoStream;
|
||||
import com.rusefi.tools.CANConnectorStartup;
|
||||
import com.rusefi.ui.util.FrameHelper;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
public class PcanConnectorUI {
|
||||
private static final Logging log = getLogging(PcanConnectorUI.class);
|
||||
|
||||
public static void show() {
|
||||
FrameHelper frame = new FrameHelper(WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(new JLabel("Running PCAN connector for TS"), BorderLayout.NORTH);
|
||||
JTextArea logTextArea = new JTextArea();
|
||||
panel.add(logTextArea, BorderLayout.CENTER);
|
||||
|
||||
StatusConsumer statusConsumer = string -> SwingUtilities.invokeLater(() -> {
|
||||
log.info(string);
|
||||
logTextArea.append(string + "\r\n");
|
||||
UiUtils.trueLayout(logTextArea);
|
||||
});
|
||||
|
||||
new NamedThreadFactory("PCAN-connector").newThread(() -> {
|
||||
PCanIoStream stream = PCanIoStream.createStream(statusConsumer);
|
||||
try {
|
||||
if (stream != null)
|
||||
CANConnectorStartup.start(stream, statusConsumer);
|
||||
} catch (IOException e) {
|
||||
statusConsumer.append("Error " + e);
|
||||
}
|
||||
}).start();
|
||||
|
||||
frame.showFrame(panel);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue