refactoring & dead code
This commit is contained in:
parent
b05d318e77
commit
74d6791b31
|
@ -204,7 +204,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
@Override
|
||||
public void run() {
|
||||
if (requestOutputChannels())
|
||||
ConnectionWatchdog.onDataArrived();
|
||||
HeartBeatListeners.onDataArrived();
|
||||
compositeLogic();
|
||||
String text = requestPendingMessages();
|
||||
if (text != null)
|
||||
|
@ -336,6 +336,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
continue;
|
||||
}
|
||||
|
||||
HeartBeatListeners.onDataArrived();
|
||||
ConnectionStatusLogic.INSTANCE.markConnected();
|
||||
System.arraycopy(response, 1, image.getContent(), offset, requestSize);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.rusefi.io;
|
||||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.EngineTimeListener;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.rusefi.io;
|
|||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.Timeouts;
|
||||
import com.rusefi.core.EngineTimeListener;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -23,17 +21,11 @@ public class ConnectionWatchdog {
|
|||
}
|
||||
|
||||
public static void start() {
|
||||
HeartBeatListeners.INSTANCE.addListener(ConnectionWatchdog::onDataArrived);
|
||||
onDataArrived();
|
||||
|
||||
LinkManager.engineState.timeListeners.add(new EngineTimeListener() {
|
||||
@Override
|
||||
public void onTime(double time) {
|
||||
onDataArrived();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void onDataArrived() {
|
||||
private static void onDataArrived() {
|
||||
/**
|
||||
* this timer will reconnect
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.rusefi.io;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Singleton which allows listeners to be notified of controller data arrival.
|
||||
*/
|
||||
public enum HeartBeatListeners {
|
||||
INSTANCE;
|
||||
|
||||
private final CopyOnWriteArrayList<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
public synchronized void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
if (listeners.size() > 16)
|
||||
throw new IllegalStateException("Very unexpected " + listeners);
|
||||
}
|
||||
|
||||
public static void onDataArrived() {
|
||||
for (Listener listener : INSTANCE.listeners)
|
||||
listener.onDataArrival();
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onDataArrival();
|
||||
}
|
||||
}
|
|
@ -130,7 +130,7 @@ public class LinkManager {
|
|||
@Override
|
||||
public void beforeLine(String fullLine) {
|
||||
FileLog.MAIN.logLine(fullLine);
|
||||
ConnectionWatchdog.onDataArrived();
|
||||
HeartBeatListeners.onDataArrived();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Date: 12/25/12
|
||||
|
@ -43,8 +42,6 @@ public class EngineState {
|
|||
}
|
||||
}
|
||||
|
||||
public final List<EngineTimeListener> timeListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private final ResponseBuffer buffer;
|
||||
private final List<StringActionPair> actions = new ArrayList<>();
|
||||
private final Set<String> keys = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package com.rusefi.core;
|
||||
|
||||
/**
|
||||
* Date: 3/26/13
|
||||
* (c) Andrey Belomutskiy
|
||||
*/
|
||||
public interface EngineTimeListener {
|
||||
void onTime(double time);
|
||||
}
|
Loading…
Reference in New Issue