Aded puck detection using Esera
This commit is contained in:
58
src/main/java/ch/psi/mxsc/PuckState.java
Normal file
58
src/main/java/ch/psi/mxsc/PuckState.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user