auto-sync
This commit is contained in:
parent
465d54dcbe
commit
4899fa4e0b
|
@ -0,0 +1,38 @@
|
||||||
|
package com.rusefi.ui;
|
||||||
|
|
||||||
|
import com.rusefi.core.EngineTimeListener;
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
public class ConnectionWatchdog {
|
||||||
|
/**
|
||||||
|
* 10 seconds
|
||||||
|
*/
|
||||||
|
private static final int RESTART_DELAY = 10000;
|
||||||
|
|
||||||
|
private ConnectionWatchdog() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void start() {
|
||||||
|
final Timer reconnectTimer = new Timer(RESTART_DELAY, new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LinkManager.restart();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
reconnectTimer.restart();
|
||||||
|
|
||||||
|
LinkManager.engineState.timeListeners.add(new EngineTimeListener() {
|
||||||
|
@Override
|
||||||
|
public void onTime(double time) {
|
||||||
|
/**
|
||||||
|
* this timer will reconnect
|
||||||
|
*/
|
||||||
|
reconnectTimer.restart();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +1,13 @@
|
||||||
package com.rusefi.ui;
|
package com.rusefi.ui;
|
||||||
|
|
||||||
import com.rusefi.core.EngineTimeListener;
|
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.ui.storage.Node;
|
import com.rusefi.ui.storage.Node;
|
||||||
import com.rusefi.ui.widgets.*;
|
import com.rusefi.ui.widgets.*;
|
||||||
import com.rusefi.io.LinkManager;
|
|
||||||
import com.rusefi.ui.widgets.SensorGauge;
|
import com.rusefi.ui.widgets.SensorGauge;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 1/7/13
|
* Date: 1/7/13
|
||||||
|
@ -43,7 +39,7 @@ public class RpmPanel {
|
||||||
gauges.add(SensorGauge.createGauge(Sensor.MAF));
|
gauges.add(SensorGauge.createGauge(Sensor.MAF));
|
||||||
gauges.add(SensorGauge.createGauge(Sensor.TPS));
|
gauges.add(SensorGauge.createGauge(Sensor.TPS));
|
||||||
|
|
||||||
startConnectionWatchDog();
|
ConnectionWatchdog.start();
|
||||||
|
|
||||||
JPanel smallMessagePanel = new JPanel(new BorderLayout());
|
JPanel smallMessagePanel = new JPanel(new BorderLayout());
|
||||||
MessagesPanel mp = new MessagesPanel(config);
|
MessagesPanel mp = new MessagesPanel(config);
|
||||||
|
@ -66,30 +62,6 @@ public class RpmPanel {
|
||||||
return rpmPanel;
|
return rpmPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startConnectionWatchDog() {
|
|
||||||
final Timer reconnectTimer = new Timer(10000, new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
LinkManager.restart();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
reconnectTimer.restart();
|
|
||||||
|
|
||||||
LinkManager.engineState.timeListeners.add(new EngineTimeListener() {
|
|
||||||
@Override
|
|
||||||
public void onTime(double time) {
|
|
||||||
/**
|
|
||||||
* this timer will reconnect
|
|
||||||
*/
|
|
||||||
postponeReconnecting(reconnectTimer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postponeReconnecting(Timer timer2) {
|
|
||||||
timer2.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel createControls() {
|
private JPanel createControls() {
|
||||||
JPanel controls = new JPanel(new MigLayout());
|
JPanel controls = new JPanel(new MigLayout());
|
||||||
controls.setBorder(BorderFactory.createLineBorder(Color.red));
|
controls.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
|
|
Loading…
Reference in New Issue