package ch.psi.mxsc; import static ch.psi.mxsc.Controller.NUMBER_OF_PUCKS; import ch.psi.pshell.device.Device; import ch.psi.pshell.device.DeviceListener; import ch.psi.pshell.utils.State; import java.util.List; /** * */ public class EseraDetection implements AutoCloseable{ final Device device; public EseraDetection(Device device){ this.device = device; if (device!=null){ device.addListener(listener); } } DeviceListener listener = new DeviceListener(){ @Override public void onStateChanged(Device device, State state, State former) { if (!state.isInitialized()){ Controller.getInstance().clearPuckStates(); } } @Override public void onValueChanged(Device device, Object value, Object former) { if ((value == null) || !(value instanceof List)){ Controller.getInstance().clearPuckStates(); } else { List l = (List)value; PuckState[] puckState = Controller.getInstance().getPuckStates(); for (int i=0; i