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