Files
MXSC/src/main/java/ch/psi/mxsc/ControllerRT.java
2023-04-26 10:58:52 +02:00

64 lines
2.0 KiB
Java

package ch.psi.mxsc;
import static ch.psi.mxsc.Controller.NUMBER_OF_PUCKS;
import static ch.psi.mxsc.Controller.instance;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
import ch.psi.pshell.device.DeviceListener;
import ch.psi.pshell.device.GenericDevice;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class ControllerRT extends Controller{
ControllerRT(Panel mainFrame) {
//basePlate = new BasePlate();
basePlate.addListener(basePlateListener);
setPuckLoading(false);
for (PuckState ps : getPuckStates()){
ps.set(1, 0);
}
}
/*
@Override
public void onStateChange(State state, State former) {
if ((state == State.Ready)&&(former==State.Initializing)) {
PuckDetection puckDetection = this.getContext().getDevicePool().getByName("puckDetection", PuckDetection.class);
if (puckDetection!=null){
getMainFrame().removeDevice(puckDetection, true);
}
}
super.onStateChange(state, former);
}
*/
final DeviceListener basePlateListener = new DeviceAdapter() {
@Override
public void onValueChanged(Device device, Object value, Object former) {
if (value != null) {
String segment = ((Object[]) value)[0].toString();
Integer puck = (Integer) ((Object[]) value)[1];
Integer sample = (Integer) ((Object[]) value)[2];
mainFrame.onSelectionChanged(segment, puck, sample);
} else {
mainFrame.onSelectionChanged(null, null, null);
}
}
};
void onTimer() {
try {
refreshSamplesTable();
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.WARNING, null, ex);
}
}
}