refactoring & dead code
This commit is contained in:
parent
f71efcdf9f
commit
670ee877eb
|
@ -204,7 +204,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (requestOutputChannels())
|
if (requestOutputChannels())
|
||||||
ConnectionWatchdog.onDataArrived();
|
HeartBeatListeners.onDataArrived();
|
||||||
compositeLogic();
|
compositeLogic();
|
||||||
String text = requestPendingMessages();
|
String text = requestPendingMessages();
|
||||||
if (text != null)
|
if (text != null)
|
||||||
|
@ -336,6 +336,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeartBeatListeners.onDataArrived();
|
||||||
ConnectionStatusLogic.INSTANCE.markConnected();
|
ConnectionStatusLogic.INSTANCE.markConnected();
|
||||||
System.arraycopy(response, 1, image.getContent(), offset, requestSize);
|
System.arraycopy(response, 1, image.getContent(), offset, requestSize);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi.io;
|
package com.rusefi.io;
|
||||||
|
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.EngineTimeListener;
|
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.rusefi.io;
|
||||||
|
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
import com.rusefi.Timeouts;
|
import com.rusefi.Timeouts;
|
||||||
import com.rusefi.core.EngineTimeListener;
|
|
||||||
import com.rusefi.io.LinkManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -23,17 +21,11 @@ public class ConnectionWatchdog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start() {
|
public static void start() {
|
||||||
|
HeartBeatListeners.INSTANCE.addListener(ConnectionWatchdog::onDataArrived);
|
||||||
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
|
* 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
|
@Override
|
||||||
public void beforeLine(String fullLine) {
|
public void beforeLine(String fullLine) {
|
||||||
FileLog.MAIN.logLine(fullLine);
|
FileLog.MAIN.logLine(fullLine);
|
||||||
ConnectionWatchdog.onDataArrived();
|
HeartBeatListeners.onDataArrived();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/25/12
|
* Date: 12/25/12
|
||||||
|
@ -43,8 +42,6 @@ public class EngineState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<EngineTimeListener> timeListeners = new CopyOnWriteArrayList<>();
|
|
||||||
|
|
||||||
private final ResponseBuffer buffer;
|
private final ResponseBuffer buffer;
|
||||||
private final List<StringActionPair> actions = new ArrayList<>();
|
private final List<StringActionPair> actions = new ArrayList<>();
|
||||||
private final Set<String> keys = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
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