mirror of https://github.com/rusefi/rusefi-1.git
parent
b2ba9c1a0d
commit
4e7ddfb82e
|
@ -182,7 +182,7 @@ public class BinaryProtocol {
|
|||
|
||||
private void startPullThread(final DataListener textListener) {
|
||||
if (!linkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||
log.info("Current queue: " + linkManager.COMMUNICATION_QUEUE.size());
|
||||
log.info("Current queue size: " + linkManager.COMMUNICATION_QUEUE.size());
|
||||
}
|
||||
Runnable textPull = new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -1,21 +1,41 @@
|
|||
package com.rusefi.io;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.rusefi.Timeouts;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
/**
|
||||
* todo: open question if it's OK to use AWT timer in headless cases?
|
||||
*/
|
||||
public class ConnectionWatchdog {
|
||||
private final Timer reconnectTimer;
|
||||
private static final Logging log = getLogging(ConnectionWatchdog.class);
|
||||
|
||||
public ConnectionWatchdog(int timeoutMs, Runnable action) {
|
||||
private final Timer reconnectTimer;
|
||||
private static boolean isCreated;
|
||||
|
||||
private ConnectionWatchdog(int timeoutMs, Runnable action) {
|
||||
reconnectTimer = new Timer(timeoutMs, e -> {
|
||||
action.run();
|
||||
onDataArrived();
|
||||
});
|
||||
}
|
||||
|
||||
public void start() {
|
||||
public synchronized static void init(LinkManager linkManager) {
|
||||
if (isCreated)
|
||||
return; // only one instance is needed
|
||||
isCreated = true;
|
||||
new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> {
|
||||
linkManager.execute(() -> {
|
||||
log.info("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY);
|
||||
linkManager.restart();
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
void start() {
|
||||
HeartBeatListeners.INSTANCE.addListener(this::onDataArrived);
|
||||
onDataArrived();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20220222;
|
||||
public static final int CONSOLE_VERSION = 20220223;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -82,12 +82,7 @@ public class MainFrame {
|
|||
|
||||
@Override
|
||||
public void onConnectionEstablished() {
|
||||
new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> {
|
||||
linkManager.execute(() -> {
|
||||
log.info("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY);
|
||||
linkManager.restart();
|
||||
});
|
||||
}).start();
|
||||
ConnectionWatchdog.init(linkManager);
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
tabbedPane.settingsTab.showContent();
|
||||
|
|
|
@ -104,10 +104,7 @@ public class LightweightGUI {
|
|||
|
||||
linkManager.startAndConnect(autoDetectedPort, ConnectionStateListener.VOID);
|
||||
|
||||
new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> {
|
||||
log.info("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY);
|
||||
linkManager.restart();
|
||||
}).start();
|
||||
ConnectionWatchdog.init(linkManager);
|
||||
}
|
||||
|
||||
private static String detectPortUntilDetected() {
|
||||
|
|
Loading…
Reference in New Issue