Aded puck detection using Esera

This commit is contained in:
gac-S_Changer
2017-03-16 16:18:09 +01:00
parent 4d0b19d801
commit ff1bfbe15c
4 changed files with 188 additions and 100 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
package ch.psi.mxsc;
/**
*
*/
public class PuckState {
public final int id;
public boolean online;
public boolean mecSwitch;
public boolean indSwitch;
PuckState(int id) {
this.id = id;
}
BasePlate getBasePlate() {
if (MainPanel.getInstance() == null) {
return null;
}
return MainPanel.getInstance().basePlate;
}
void clear() {
online = false;
mecSwitch = false;
indSwitch = false;
BasePlate basePlate = getBasePlate();
if (basePlate != null) {
basePlate.getPucks()[id - 1].detection = Puck.Detection.Offline;
}
}
void set(boolean mecSwitch, boolean indSwitch) {
online = true;
this.mecSwitch = mecSwitch;
this.indSwitch = indSwitch;
BasePlate basePlate = getBasePlate();
if (basePlate != null) {
if (mecSwitch != indSwitch) {
basePlate.getPucks()[id - 1].detection = Puck.Detection.Error;
} else if (mecSwitch) {
basePlate.getPucks()[id - 1].detection = Puck.Detection.Present;
} else {
basePlate.getPucks()[id - 1].detection = Puck.Detection.Empty;
}
}
}
@Override
public String toString() {
return "Online = " + online + "\ns1 = " + mecSwitch + "\ns2 = " + indSwitch;
}
}