This commit is contained in:
@@ -9,6 +9,7 @@ import ch.psi.pshell.core.DevicePool;
|
||||
import ch.psi.pshell.core.DevicePoolListener;
|
||||
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.device.ReadbackDevice;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
@@ -89,6 +90,7 @@ public class Controller {
|
||||
}
|
||||
this.mainFrame = (MainPanel) mainFrame;
|
||||
instance = this;
|
||||
clearPuckStates();
|
||||
}
|
||||
|
||||
//public Panel getMainFrame() {
|
||||
@@ -97,7 +99,7 @@ public class Controller {
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
getMainFrame().repaint();
|
||||
getMainFrame().refresh();
|
||||
}
|
||||
|
||||
void onInitialize(int runCount) {
|
||||
@@ -106,7 +108,7 @@ public class Controller {
|
||||
getMainFrame().removeDevice(former);
|
||||
}
|
||||
getMainFrame().addDevice(basePlate);
|
||||
clearPuckStates();
|
||||
|
||||
|
||||
if (puckSensorAccess == PuckSensorAccess.Esera) {
|
||||
getMainFrame().getContext().getDevicePool().addListener(new DevicePoolListener() {
|
||||
@@ -133,17 +135,38 @@ public class Controller {
|
||||
detection = new EseraDetection((Device) getMainFrame().getDevice(PUCK_ESERA_DEVICE));
|
||||
}
|
||||
}
|
||||
|
||||
Controller.getInstance().getDevicePool().addListener(new DevicePoolListener() {
|
||||
@Override
|
||||
public void onDeviceAdded(GenericDevice dev) {
|
||||
updateDevices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceRemoved(GenericDevice dev) {
|
||||
}
|
||||
});
|
||||
updateDevices();
|
||||
|
||||
}
|
||||
|
||||
final DeviceListener hexiposiListener = new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateView();
|
||||
}
|
||||
};
|
||||
|
||||
void updateDevices(){
|
||||
if (hexiposi!=null){
|
||||
hexiposi.removeListener(hexiposiListener);
|
||||
}
|
||||
hexiposi = (Device) getMainFrame().getDevice("hexiposi");
|
||||
if (hexiposi != null) {
|
||||
hexiposi.addListener(new DeviceAdapter() {
|
||||
@Override
|
||||
public void onValueChanged(Device device, Object value, Object former) {
|
||||
updateView();
|
||||
}
|
||||
});
|
||||
hexiposi.addListener(hexiposiListener);
|
||||
} else {
|
||||
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, "No hexiposi detected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final PuckState[] puckState;
|
||||
@@ -186,7 +209,11 @@ public class Controller {
|
||||
}
|
||||
|
||||
public String getHexiposiPosition() {
|
||||
return (String) ((ReadbackDevice) hexiposi).getReadback().take();
|
||||
try {
|
||||
return (String) ((ReadbackDevice) hexiposi).getReadback().take();
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isLedRoomTemp() {
|
||||
@@ -245,7 +272,6 @@ public class Controller {
|
||||
public void clearImageDetection() throws Context.ContextStateException, ScriptException, IOException, InterruptedException {
|
||||
Map<String, List<String>> map = (Map<String, List<String>>) getMainFrame().eval("clear_detection(None)");
|
||||
setImageDetection(map);
|
||||
updateView();
|
||||
}
|
||||
|
||||
void setImageDetection(Map<String, List<String>> map) {
|
||||
@@ -257,6 +283,7 @@ public class Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
updateView();
|
||||
}
|
||||
|
||||
void setSinglePuckType(Puck.PuckType puckType) {
|
||||
|
||||
Reference in New Issue
Block a user