Hiding puck detection errors from users.
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
package ch.psi.mxsc;
|
||||
|
||||
import static ch.psi.mxsc.Controller.NUMBER_OF_PUCKS;
|
||||
import ch.psi.pshell.core.JsonSerializer;
|
||||
import ch.psi.pshell.device.DeviceBase;
|
||||
import ch.psi.pshell.device.ReadonlyAsyncRegisterBase;
|
||||
import ch.psi.pshell.device.ReadonlyRegisterBase;
|
||||
import ch.psi.utils.Chrono;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.Threading;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PuckDetection extends DeviceBase {
|
||||
|
||||
final String server;
|
||||
public volatile Chrono chrono;
|
||||
boolean debug;
|
||||
public static final int TIMEOUT = 10000;
|
||||
|
||||
public PuckDetection(String name, String server) {
|
||||
super(name);
|
||||
@@ -32,6 +33,16 @@ public class PuckDetection extends DeviceBase {
|
||||
|
||||
Thread thread;
|
||||
Thread watchDog;
|
||||
|
||||
class UpdateTimeReadable extends ReadonlyAsyncRegisterBase<Integer>{
|
||||
UpdateTimeReadable(){
|
||||
super("Raspberry Update Time");
|
||||
}
|
||||
void update(int value){
|
||||
setCache(value);
|
||||
}
|
||||
};
|
||||
public UpdateTimeReadable updateTime = new UpdateTimeReadable();
|
||||
|
||||
@Override
|
||||
protected void doInitialize() throws IOException, InterruptedException {
|
||||
@@ -53,7 +64,7 @@ public class PuckDetection extends DeviceBase {
|
||||
public void run() {
|
||||
try {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
if (chrono.isTimeout(3000)) {
|
||||
if (chrono.isTimeout(TIMEOUT)) {
|
||||
if (!isSimulated()) {
|
||||
setState(State.Offline);
|
||||
if (Controller.getInstance() != null) {
|
||||
@@ -115,6 +126,9 @@ public class PuckDetection extends DeviceBase {
|
||||
Controller.getInstance().updateView();
|
||||
}
|
||||
setState(State.Ready);
|
||||
if (chrono != null){
|
||||
updateTime.update(chrono.getEllapsed());
|
||||
}
|
||||
chrono = new Chrono();
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user