Startup
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
#Thu Mar 16 17:34:07 CET 2017
|
#Fri Mar 17 11:09:48 CET 2017
|
||||||
colormap=Temperature
|
colormap=Temperature
|
||||||
colormapAutomatic=false
|
colormapAutomatic=false
|
||||||
colormapMax=0.0
|
colormapMax=NaN
|
||||||
colormapMin=0.0
|
colormapMin=NaN
|
||||||
flipHorizontally=false
|
flipHorizontally=false
|
||||||
flipVertically=false
|
flipVertically=false
|
||||||
grayscale=false
|
grayscale=false
|
||||||
imageHeight=1200
|
imageHeight=1040
|
||||||
imageWidth=1246
|
imageWidth=1392
|
||||||
invert=false
|
invert=false
|
||||||
rescaleFactor=1.0
|
rescaleFactor=1.0
|
||||||
rescaleOffset=0.0
|
rescaleOffset=0.0
|
||||||
@@ -19,9 +19,9 @@ rotation=0.0
|
|||||||
rotationCrop=false
|
rotationCrop=false
|
||||||
scale=1.0
|
scale=1.0
|
||||||
serverURL=localhost\:10000
|
serverURL=localhost\:10000
|
||||||
spatialCalOffsetX=16859.947265625
|
spatialCalOffsetX=-50.0
|
||||||
spatialCalOffsetY=16276.595703125
|
spatialCalOffsetY=-50.0
|
||||||
spatialCalScaleX=-26.761820720381525
|
spatialCalScaleX=-1.0
|
||||||
spatialCalScaleY=-26.595744663521685
|
spatialCalScaleY=-1.0
|
||||||
spatialCalUnits=mm
|
spatialCalUnits=mm
|
||||||
transpose=false
|
transpose=false
|
||||||
|
|||||||
+143
-152
@@ -82,12 +82,12 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ScreenPanel extends Panel {
|
public class ScreenPanel extends Panel {
|
||||||
|
|
||||||
final String CONFIG_FOLDER = "/afs/psi.ch/intranet/SF/Applications/config/camtool";
|
final String CONFIG_FOLDER = "/afs/psi.ch/intranet/SF/Applications/config/camtool_n";
|
||||||
final String CAMERA_DEVICE_NAME = "CurrentCamera";
|
final String CAMERA_DEVICE_NAME = "CurrentCamera";
|
||||||
boolean useCamtoolStats = true;
|
boolean useCamtoolStats = true;
|
||||||
|
|
||||||
String userOverlaysConfigFile;
|
String userOverlaysConfigFile;
|
||||||
ColormapSource camera;
|
ColormapSource camera;
|
||||||
String cameraName;
|
String cameraName;
|
||||||
String cameraConfigJson;
|
String cameraConfigJson;
|
||||||
@@ -124,7 +124,6 @@ public class ScreenPanel extends Panel {
|
|||||||
x_fit_gauss_function = getCamtoolDoubleArray("x_fit_gauss_function");
|
x_fit_gauss_function = getCamtoolDoubleArray("x_fit_gauss_function");
|
||||||
y_profile = getCamtoolDoubleArray("y_profile");
|
y_profile = getCamtoolDoubleArray("y_profile");
|
||||||
y_fit_gauss_function = getCamtoolDoubleArray("y_fit_gauss_function");
|
y_fit_gauss_function = getCamtoolDoubleArray("y_fit_gauss_function");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Data data;
|
Data data;
|
||||||
@@ -172,7 +171,7 @@ public class ScreenPanel extends Panel {
|
|||||||
|
|
||||||
if (App.hasArgument("usr_ov")) {
|
if (App.hasArgument("usr_ov")) {
|
||||||
try {
|
try {
|
||||||
userOverlaysConfigFile =App.getArgumentValue("usr_ov");
|
userOverlaysConfigFile = App.getArgumentValue("usr_ov");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -238,7 +237,7 @@ public class ScreenPanel extends Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
renderer.getPopupMenu().add(menuSaveStack);
|
renderer.getPopupMenu().add(menuSaveStack);
|
||||||
renderer.getPopupMenu().addSeparator();
|
renderer.getPopupMenu().addSeparator();
|
||||||
renderer.getPopupMenu().add(menuSetROI);
|
renderer.getPopupMenu().add(menuSetROI);
|
||||||
@@ -278,7 +277,7 @@ public class ScreenPanel extends Panel {
|
|||||||
imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_RIGHT);
|
imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_RIGHT);
|
||||||
if (MainFrame.isDark()) {
|
if (MainFrame.isDark()) {
|
||||||
textState.setEnabled(true);
|
textState.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -288,7 +287,7 @@ public class ScreenPanel extends Panel {
|
|||||||
boolean direct = App.getArgumentValue("ct").equals("0") || App.getArgumentValue("ct").equalsIgnoreCase("false");
|
boolean direct = App.getArgumentValue("ct").equals("0") || App.getArgumentValue("ct").equalsIgnoreCase("false");
|
||||||
buttonCamtool.setSelected(!direct);
|
buttonCamtool.setSelected(!direct);
|
||||||
buttonDirect.setSelected(direct);
|
buttonDirect.setSelected(direct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -324,8 +323,8 @@ public class ScreenPanel extends Panel {
|
|||||||
usingCamtool = buttonCamtool.isSelected();
|
usingCamtool = buttonCamtool.isSelected();
|
||||||
updateCameraList();
|
updateCameraList();
|
||||||
comboCameras.setEnabled(true);
|
comboCameras.setEnabled(true);
|
||||||
setComboCameraSelection(-1);
|
setComboCameraSelection(-1);
|
||||||
|
|
||||||
if (comboCameras.getModel().getSize() > 0) {
|
if (comboCameras.getModel().getSize() > 0) {
|
||||||
try {
|
try {
|
||||||
if (App.hasArgument("cam")) {
|
if (App.hasArgument("cam")) {
|
||||||
@@ -339,67 +338,68 @@ public class ScreenPanel extends Panel {
|
|||||||
}
|
}
|
||||||
startTimer(1000);
|
startTimer(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefaultComboBoxModel getCameraListFromFolder() {
|
||||||
DefaultComboBoxModel getCameraListFromFolder(){
|
|
||||||
File[] cameraConfigFiles = new File[0];
|
File[] cameraConfigFiles = new File[0];
|
||||||
cameraConfigFiles = IO.listFiles(CONFIG_FOLDER, new String[]{"json"});
|
cameraConfigFiles = IO.listFiles(CONFIG_FOLDER, new String[]{"json"});
|
||||||
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
|
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
for (File file : cameraConfigFiles) {
|
for (File file : cameraConfigFiles) {
|
||||||
String prefix = IO.getPrefix(file);
|
String prefix = IO.getPrefix(file);
|
||||||
if (!prefix.startsWith("#")) {
|
if (!prefix.startsWith("#") && !prefix.endsWith("_parameters")) {
|
||||||
model.addElement(prefix);
|
model.addElement(prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultComboBoxModel getCameraListFromCamtool() throws IOException, InterruptedException{
|
DefaultComboBoxModel getCameraListFromCamtool() throws IOException, InterruptedException {
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
Camtool camtool = new Camtool(CAMERA_DEVICE_NAME);
|
Camtool camtool = new Camtool(CAMERA_DEVICE_NAME);
|
||||||
try{
|
try {
|
||||||
camtool.initialize();
|
camtool.initialize();
|
||||||
List<String> cameras = camtool.getCameras();
|
List<String> cameras = camtool.getCameras();
|
||||||
Collections.sort(cameras);
|
Collections.sort(cameras);
|
||||||
for (String camera:cameras){
|
for (String camera : cameras) {
|
||||||
model.addElement(camera);
|
model.addElement(camera);
|
||||||
}
|
}
|
||||||
//model.addElement(Camtool.SIMULATION);
|
//model.addElement(Camtool.SIMULATION);
|
||||||
} finally{
|
} finally {
|
||||||
camtool.close();
|
camtool.close();
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean updatingCameraSelection;
|
boolean updatingCameraSelection;
|
||||||
void setComboCameraSelection(Object selection){
|
|
||||||
|
void setComboCameraSelection(Object selection) {
|
||||||
updatingCameraSelection = true;
|
updatingCameraSelection = true;
|
||||||
try{
|
try {
|
||||||
comboCameras.setSelectedItem(selection);
|
comboCameras.setSelectedItem(selection);
|
||||||
} finally{
|
} finally {
|
||||||
updatingCameraSelection = false;
|
updatingCameraSelection = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean usingCamtool;
|
boolean usingCamtool;
|
||||||
void updateCameraList(){
|
|
||||||
|
void updateCameraList() {
|
||||||
try {
|
try {
|
||||||
String selected = (String) comboCameras.getSelectedItem();
|
String selected = (String) comboCameras.getSelectedItem();
|
||||||
DefaultComboBoxModel model= usingCamtool ? getCameraListFromCamtool() : getCameraListFromFolder();
|
DefaultComboBoxModel model = usingCamtool ? getCameraListFromCamtool() : getCameraListFromFolder();
|
||||||
if (App.hasArgument("cam")) {
|
if (App.hasArgument("cam")) {
|
||||||
String cam = App.getArgumentValue("cam");
|
String cam = App.getArgumentValue("cam");
|
||||||
if (model.getIndexOf(cam) < 0) {
|
if (model.getIndexOf(cam) < 0) {
|
||||||
model.addElement(cam);
|
model.addElement(cam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
comboCameras.setModel(model);
|
comboCameras.setModel(model);
|
||||||
if (selected!=null){
|
if (selected != null) {
|
||||||
setComboCameraSelection(selected);
|
setComboCameraSelection(selected);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} finally{
|
} finally {
|
||||||
updateStop();
|
updateStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,96 +432,85 @@ public class ScreenPanel extends Panel {
|
|||||||
|
|
||||||
public static class CameraConfig {
|
public static class CameraConfig {
|
||||||
|
|
||||||
public HashMap kwargs;
|
public HashMap camera;
|
||||||
public ArrayList args;
|
|
||||||
public ArrayList links;
|
|
||||||
public String type;
|
|
||||||
public HashMap<String, Object> state;
|
|
||||||
public CameraConfig image_source;
|
|
||||||
public HashMap<String, CameraConfig> subcomponents;
|
|
||||||
|
|
||||||
public ArrayList<Integer> getCalibration() {
|
public HashMap getCalibration() {
|
||||||
return (ArrayList<Integer>) state.get("calibration");
|
return (HashMap) camera.get("calibration");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getCalibrationRefMarker() {
|
||||||
|
return (ArrayList<Integer>) getCalibration().get("reference_marker");
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCalOffsetX() {
|
public double getCalOffsetX() {
|
||||||
ArrayList<Integer> calibration = getCalibration();
|
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||||
double ret = -(calibration.get(0) + calibration.get(2)) / 2;
|
double ret = -(calibration.get(0) + calibration.get(2)) / 2;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCalOffsetY() {
|
public double getCalOffsetY() {
|
||||||
ArrayList<Integer> calibration = getCalibration();
|
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||||
double ret = -(calibration.get(1) + calibration.get(3)) / 2;
|
double ret = -(calibration.get(1) + calibration.get(3)) / 2;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getScaleX() {
|
public double getScaleX() {
|
||||||
ArrayList<Integer> calibration = getCalibration();
|
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||||
double width = Math.abs(calibration.get(2) - calibration.get(0));
|
double width = Math.abs(calibration.get(2) - calibration.get(0));
|
||||||
return getCalibrationWidth() / width;
|
return getCalibrationWidth() / width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getScaleY() {
|
public double getScaleY() {
|
||||||
ArrayList<Integer> calibration = getCalibration();
|
ArrayList<Integer> calibration = getCalibrationRefMarker();
|
||||||
double height = Math.abs(calibration.get(3) - calibration.get(1));
|
double height = Math.abs(calibration.get(3) - calibration.get(1));
|
||||||
return getCalibrationHeight() / height;
|
return getCalibrationHeight() / height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getCalibrationHeight() {
|
public Double getCalibrationHeight() {
|
||||||
return (Double) state.get("calibration_height");
|
return (Double) getCalibration().get("reference_marker_height");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getCalibrationWidth() {
|
public Double getCalibrationWidth() {
|
||||||
return (Double) state.get("calibration_width");
|
return (Double) getCalibration().get("reference_marker_width");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getCalibrationHorizontalAngle() {
|
public Double getCalibrationHorizontalAngle() {
|
||||||
return (Double) state.get("calibration_horizontal_angle");
|
return (Double) getCalibration().get("horizontal_camera_angle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getCalibrationVerticalAngle() {
|
public Double getCalibrationVerticalAngle() {
|
||||||
return (Double) state.get("calibration_vertical_angle");
|
return (Double) getCalibration().get("vertical_camera_angle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getMirrorX() {
|
public boolean getMirrorX() {
|
||||||
return (Boolean) state.get("mirror_x");
|
Boolean ret = (Boolean) camera.get("mirror_x");
|
||||||
|
return (ret == null) ? false : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getMirrorY() {
|
public boolean getMirrorY() {
|
||||||
return (Boolean) state.get("mirror_y");
|
Boolean ret = (Boolean) camera.get("mirror_y");
|
||||||
|
return (ret == null) ? false : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getRotate() {
|
public int getRotate() {
|
||||||
return (Integer) state.get("rotate");
|
Integer ret = (Integer) camera.get("rotate");
|
||||||
}
|
return (ret == null) ? 0 : ret;
|
||||||
|
|
||||||
public ArrayList<Integer> getOrigin() {
|
|
||||||
return (ArrayList<Integer>) state.get("origin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> getRoi() {
|
public ArrayList<Integer> getRoi() {
|
||||||
return (ArrayList<Integer>) state.get("roi");
|
return (ArrayList<Integer>) camera.get("roi");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getRoiEnable() {
|
public Boolean getRoiEnable() {
|
||||||
if ((state.get("roi_enable") == null) || (state.get("roi") == null)) {
|
if ((camera.get("roi_enable") == null) || (camera.get("roi") == null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (Boolean) state.get("roi_enable");
|
return (Boolean) camera.get("roi_enable");
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Double> getUnitSize() {
|
|
||||||
return (ArrayList<Double>) state.get("unit_size");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRun() {
|
|
||||||
return (Integer) state.get("run");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread devicesInitTask;
|
Thread devicesInitTask;
|
||||||
|
|
||||||
void setCamera(String cameraName) throws IOException, InterruptedException {
|
void setCamera(String cameraName) throws IOException, InterruptedException {
|
||||||
System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]");
|
System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]");
|
||||||
//renderer.removeOverlay(errorOverlay);
|
//renderer.removeOverlay(errorOverlay);
|
||||||
@@ -539,6 +528,7 @@ public class ScreenPanel extends Panel {
|
|||||||
camera = null;
|
camera = null;
|
||||||
}
|
}
|
||||||
renderer.setDevice(null);
|
renderer.setDevice(null);
|
||||||
|
|
||||||
renderer.setShowReticle(false);
|
renderer.setShowReticle(false);
|
||||||
renderer.removeOverlays(fitOv);
|
renderer.removeOverlays(fitOv);
|
||||||
renderer.removeOverlays(userOv);
|
renderer.removeOverlays(userOv);
|
||||||
@@ -548,8 +538,8 @@ public class ScreenPanel extends Panel {
|
|||||||
boolean changed = !String.valueOf(cameraName).equals(this.cameraName);
|
boolean changed = !String.valueOf(cameraName).equals(this.cameraName);
|
||||||
this.cameraName = cameraName;
|
this.cameraName = cameraName;
|
||||||
|
|
||||||
if (changed){
|
if (changed) {
|
||||||
if ( (devicesInitTask!=null) && (devicesInitTask.isAlive())){
|
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
|
||||||
devicesInitTask.interrupt();
|
devicesInitTask.interrupt();
|
||||||
}
|
}
|
||||||
if (screen != null) {
|
if (screen != null) {
|
||||||
@@ -559,12 +549,12 @@ public class ScreenPanel extends Panel {
|
|||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
filter.close();
|
filter.close();
|
||||||
filter = null;
|
filter = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cameraName==null){
|
if (cameraName == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Path configFile = Paths.get(CONFIG_FOLDER, cameraName + ".json");
|
Path configFile = Paths.get(CONFIG_FOLDER, cameraName + ".json");
|
||||||
cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
|
cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
|
||||||
@@ -582,8 +572,8 @@ public class ScreenPanel extends Panel {
|
|||||||
} else {
|
} else {
|
||||||
if ((cameraConfigJson == null) && (buttonDirect.isSelected())) {
|
if ((cameraConfigJson == null) && (buttonDirect.isSelected())) {
|
||||||
throw new Exception("Cannot open camera config file: " + configFile.toFile());
|
throw new Exception("Cannot open camera config file: " + configFile.toFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
camera = new PsiCamera(CAMERA_DEVICE_NAME, cameraName);
|
camera = new PsiCamera(CAMERA_DEVICE_NAME, cameraName);
|
||||||
config = (CameraConfig) JsonSerializer.decode(cameraConfigJson, CameraConfig.class);
|
config = (CameraConfig) JsonSerializer.decode(cameraConfigJson, CameraConfig.class);
|
||||||
camera.getConfig().flipHorizontally = config.getMirrorX();
|
camera.getConfig().flipHorizontally = config.getMirrorX();
|
||||||
@@ -655,14 +645,15 @@ public class ScreenPanel extends Panel {
|
|||||||
public void onImage(Object o, BufferedImage bi, Data data) {
|
public void onImage(Object o, BufferedImage bi, Data data) {
|
||||||
if (bi != null) {
|
if (bi != null) {
|
||||||
if (firstImage) {
|
if (firstImage) {
|
||||||
if ((renderer.getMode() == RendererMode.Zoom) || (renderer.getMode() == RendererMode.Fixed)) {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
if ((renderer.getMode() == RendererMode.Zoom) || (renderer.getMode() == RendererMode.Fixed)) {
|
||||||
centralizeRenderer();
|
centralizeRenderer();
|
||||||
}
|
}
|
||||||
});
|
checkReticle();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
firstImage = false;
|
firstImage = false;
|
||||||
}
|
}
|
||||||
renderer.setProfileSize(Math.min(bi.getWidth(), bi.getHeight()));
|
renderer.setProfileSize(Math.min(bi.getWidth(), bi.getHeight()));
|
||||||
@@ -690,7 +681,7 @@ public class ScreenPanel extends Panel {
|
|||||||
public void onError(Object o, Exception excptn) {
|
public void onError(Object o, Exception excptn) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
showException(ex);
|
showException(ex);
|
||||||
@@ -705,20 +696,20 @@ public class ScreenPanel extends Panel {
|
|||||||
renderer.addOverlay(errorOverlay);
|
renderer.addOverlay(errorOverlay);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
checkReticle();
|
//checkReticle();
|
||||||
onTimer();
|
onTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed){
|
if (changed) {
|
||||||
comboScreen.setModel(new DefaultComboBoxModel());
|
comboScreen.setModel(new DefaultComboBoxModel());
|
||||||
comboFilter.setModel(new DefaultComboBoxModel());
|
comboFilter.setModel(new DefaultComboBoxModel());
|
||||||
|
|
||||||
//Parallelizing initialization
|
//Parallelizing initialization
|
||||||
devicesInitTask = new Thread(() -> {
|
devicesInitTask = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
screen = new DiscretePositioner("CurrentScreen", cameraName + ":SET_SCREEN1_POS", cameraName + ":GET_SCREEN1_POS");
|
screen = new DiscretePositioner("CurrentScreen", cameraName + ":SET_SCREEN1_POS", cameraName + ":GET_SCREEN1_POS");
|
||||||
screen.setMonitored(true);
|
screen.setMonitored(true);
|
||||||
screen.initialize();
|
screen.initialize();
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
for (String pos : screen.getPositions()) {
|
for (String pos : screen.getPositions()) {
|
||||||
model.addElement(pos);
|
model.addElement(pos);
|
||||||
@@ -737,7 +728,7 @@ public class ScreenPanel extends Panel {
|
|||||||
try {
|
try {
|
||||||
filter = new DiscretePositioner("CurrentFilter", cameraName + ":SET_FILTER", cameraName + ":GET_FILTER");
|
filter = new DiscretePositioner("CurrentFilter", cameraName + ":SET_FILTER", cameraName + ":GET_FILTER");
|
||||||
filter.setMonitored(true);
|
filter.setMonitored(true);
|
||||||
filter.initialize();
|
filter.initialize();
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||||
for (String pos : filter.getPositions()) {
|
for (String pos : filter.getPositions()) {
|
||||||
model.addElement(pos);
|
model.addElement(pos);
|
||||||
@@ -748,12 +739,11 @@ public class ScreenPanel extends Panel {
|
|||||||
System.err.println(ex.getMessage());
|
System.err.println(ex.getMessage());
|
||||||
filter = null;
|
filter = null;
|
||||||
}
|
}
|
||||||
comboFilter.setEnabled(filter != null);
|
comboFilter.setEnabled(filter != null);
|
||||||
valueFilter.setDevice(filter);
|
valueFilter.setDevice(filter);
|
||||||
});
|
});
|
||||||
devicesInitTask.start();
|
devicesInitTask.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,37 +840,37 @@ public class ScreenPanel extends Panel {
|
|||||||
}
|
}
|
||||||
updatingColormap = false;
|
updatingColormap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean updatingCamtoolControls;
|
boolean updatingCamtoolControls;
|
||||||
void updateCamtoolControls(){
|
|
||||||
if ((camera!=null) && (camera instanceof Camtool)) {
|
void updateCamtoolControls() {
|
||||||
|
if ((camera != null) && (camera instanceof Camtool)) {
|
||||||
updatingCamtoolControls = true;
|
updatingCamtoolControls = true;
|
||||||
try{
|
try {
|
||||||
checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction());
|
checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction());
|
||||||
Double threshold = ((Camtool) camera).getThreshold();
|
Double threshold = ((Camtool) camera).getThreshold();
|
||||||
checkThreshold.setSelected(threshold != null);
|
checkThreshold.setSelected(threshold != null);
|
||||||
spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
|
spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
updatingCamtoolControls = false;
|
updatingCamtoolControls = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isCameraStopped(){
|
boolean isCameraStopped() {
|
||||||
if ((camera!=null) && (camera instanceof Camtool)) {
|
if ((camera != null) && (camera instanceof Camtool)) {
|
||||||
if (!((Camtool) camera).isPipelineStarted()){
|
if (!((Camtool) camera).isPipelineStarted()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((camera == null) || (camera.isClosed()) || !buttonStop.isEnabled());
|
return ((camera == null) || (camera.isClosed()) || !buttonStop.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateStop(){
|
void updateStop() {
|
||||||
buttonStop.setEnabled(comboCameras.getSelectedItem()!=null);
|
buttonStop.setEnabled(comboCameras.getSelectedItem() != null);
|
||||||
buttonStop.setText(isCameraStopped() ? "Start": "Stop");
|
buttonStop.setText(isCameraStopped() ? "Start" : "Stop");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1130,6 +1120,7 @@ public class ScreenPanel extends Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UserOverlay {
|
class UserOverlay {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
Overlay obj;
|
Overlay obj;
|
||||||
String[] channels;
|
String[] channels;
|
||||||
@@ -1139,7 +1130,7 @@ public class ScreenPanel extends Panel {
|
|||||||
void parseUserOverlays() {
|
void parseUserOverlays() {
|
||||||
Properties userOverlays = new Properties();
|
Properties userOverlays = new Properties();
|
||||||
userOverlayConfig = new ArrayList<>();
|
userOverlayConfig = new ArrayList<>();
|
||||||
if (userOverlaysConfigFile!=null){
|
if (userOverlaysConfigFile != null) {
|
||||||
try {
|
try {
|
||||||
try (FileInputStream in = new FileInputStream(getContext().getSetup().expandPath(userOverlaysConfigFile))) {
|
try (FileInputStream in = new FileInputStream(getContext().getSetup().expandPath(userOverlaysConfigFile))) {
|
||||||
userOverlays.load(in);
|
userOverlays.load(in);
|
||||||
@@ -2127,8 +2118,8 @@ public class ScreenPanel extends Panel {
|
|||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void comboCamerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCamerasActionPerformed
|
private void comboCamerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCamerasActionPerformed
|
||||||
try {
|
try {
|
||||||
if (!updatingCameraSelection){
|
if (!updatingCameraSelection) {
|
||||||
if (!comboCameras.isEnabled()) {
|
if (!comboCameras.isEnabled()) {
|
||||||
throw new Exception("Invalid state");
|
throw new Exception("Invalid state");
|
||||||
}
|
}
|
||||||
@@ -2139,7 +2130,7 @@ public class ScreenPanel extends Panel {
|
|||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (requestCameraListUpdate){
|
if (requestCameraListUpdate) {
|
||||||
requestCameraListUpdate = false;
|
requestCameraListUpdate = false;
|
||||||
try {
|
try {
|
||||||
updateCameraList();
|
updateCameraList();
|
||||||
@@ -2258,24 +2249,24 @@ public class ScreenPanel extends Panel {
|
|||||||
|
|
||||||
private void buttonGrabBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGrabBackgroundActionPerformed
|
private void buttonGrabBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGrabBackgroundActionPerformed
|
||||||
try {
|
try {
|
||||||
if ((camera!=null) && (camera instanceof Camtool)) {
|
if ((camera != null) && (camera instanceof Camtool)) {
|
||||||
if (SwingUtils.showOption(getTopLevel(), "Background", "Do you want to capture background now?", OptionType.YesNo) == OptionResult.Yes) {
|
if (SwingUtils.showOption(getTopLevel(), "Background", "Do you want to capture background now?", OptionType.YesNo) == OptionResult.Yes) {
|
||||||
boolean laserOn = getLaserState();
|
boolean laserOn = getLaserState();
|
||||||
boolean rendering = (!camera.isClosed());
|
boolean rendering = (!camera.isClosed());
|
||||||
if (rendering){
|
if (rendering) {
|
||||||
camera.close();
|
camera.close();
|
||||||
}
|
}
|
||||||
if (laserOn) {
|
if (laserOn) {
|
||||||
setLaserState(false);
|
setLaserState(false);
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
System.out.println("Grabbing background for: " + cameraName);
|
System.out.println("Grabbing background for: " + cameraName);
|
||||||
((Camtool) camera).grabBackground(cameraName, 5);
|
((Camtool) camera).grabBackground(cameraName, 5);
|
||||||
} finally {
|
} finally {
|
||||||
if (laserOn) {
|
if (laserOn) {
|
||||||
setLaserState(true);
|
setLaserState(true);
|
||||||
}
|
}
|
||||||
if (rendering){
|
if (rendering) {
|
||||||
comboCamerasActionPerformed(null);
|
comboCamerasActionPerformed(null);
|
||||||
}
|
}
|
||||||
updateStop();
|
updateStop();
|
||||||
@@ -2367,7 +2358,7 @@ public class ScreenPanel extends Panel {
|
|||||||
}//GEN-LAST:event_buttonZoom05ActionPerformed
|
}//GEN-LAST:event_buttonZoom05ActionPerformed
|
||||||
|
|
||||||
private void buttonCamtoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCamtoolActionPerformed
|
private void buttonCamtoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCamtoolActionPerformed
|
||||||
if (!usingCamtool){
|
if (!usingCamtool) {
|
||||||
usingCamtool = true;
|
usingCamtool = true;
|
||||||
requestCameraListUpdate = true;
|
requestCameraListUpdate = true;
|
||||||
}
|
}
|
||||||
@@ -2375,21 +2366,21 @@ public class ScreenPanel extends Panel {
|
|||||||
}//GEN-LAST:event_buttonCamtoolActionPerformed
|
}//GEN-LAST:event_buttonCamtoolActionPerformed
|
||||||
|
|
||||||
private void buttonDirectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDirectActionPerformed
|
private void buttonDirectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDirectActionPerformed
|
||||||
if (usingCamtool){
|
if (usingCamtool) {
|
||||||
usingCamtool = false;
|
usingCamtool = false;
|
||||||
requestCameraListUpdate = true;
|
requestCameraListUpdate = true;
|
||||||
}
|
}
|
||||||
comboCamerasActionPerformed(null);
|
comboCamerasActionPerformed(null);
|
||||||
}//GEN-LAST:event_buttonDirectActionPerformed
|
}//GEN-LAST:event_buttonDirectActionPerformed
|
||||||
|
|
||||||
private void comboScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboScreenActionPerformed
|
private void comboScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboScreenActionPerformed
|
||||||
|
|
||||||
comboScreen.setEnabled(false);
|
comboScreen.setEnabled(false);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ChannelInteger setpoint = null;
|
ChannelInteger setpoint = null;
|
||||||
try {
|
try {
|
||||||
int index = comboScreen.getSelectedIndex();
|
int index = comboScreen.getSelectedIndex();
|
||||||
setpoint = new ChannelInteger(null, cameraName + ":SET_SCREEN1_POS");
|
setpoint = new ChannelInteger(null, cameraName + ":SET_SCREEN1_POS");
|
||||||
setpoint.initialize();
|
setpoint.initialize();
|
||||||
@@ -2397,18 +2388,18 @@ public class ScreenPanel extends Panel {
|
|||||||
setpoint.write(index);
|
setpoint.write(index);
|
||||||
//Must be threaded to control the laser because of sleep in setLaserState
|
//Must be threaded to control the laser because of sleep in setLaserState
|
||||||
/*
|
/*
|
||||||
boolean laserOn = getLaserState();
|
boolean laserOn = getLaserState();
|
||||||
if (laserOn) {
|
if (laserOn) {
|
||||||
setLaserState(false);
|
setLaserState(false);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setpoint.write(index);
|
setpoint.write(index);
|
||||||
} finally {
|
} finally {
|
||||||
if (laserOn) {
|
if (laserOn) {
|
||||||
setLaserState(true);
|
setLaserState(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
screen.read();
|
screen.read();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -2417,7 +2408,7 @@ public class ScreenPanel extends Panel {
|
|||||||
comboScreen.setEnabled(true);
|
comboScreen.setEnabled(true);
|
||||||
if (setpoint != null) {
|
if (setpoint != null) {
|
||||||
setpoint.close();
|
setpoint.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@@ -2449,7 +2440,7 @@ public class ScreenPanel extends Panel {
|
|||||||
}//GEN-LAST:event_buttonZoom2ActionPerformed
|
}//GEN-LAST:event_buttonZoom2ActionPerformed
|
||||||
|
|
||||||
private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange
|
private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange
|
||||||
if (updatingCamtoolControls){
|
if (updatingCamtoolControls) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -2458,31 +2449,31 @@ public class ScreenPanel extends Panel {
|
|||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
updateCamtoolControls();
|
updateCamtoolControls();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_spinnerThresholdonChange
|
}//GEN-LAST:event_spinnerThresholdonChange
|
||||||
|
|
||||||
private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed
|
private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed
|
||||||
if (updatingCamtoolControls){
|
if (updatingCamtoolControls) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
|
if ((camera instanceof Camtool) && (((Camtool) camera).isPipelineStarted())) {
|
||||||
((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected());
|
((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
updateCamtoolControls();
|
updateCamtoolControls();
|
||||||
//There is a bug in camtool: it will flag bg extraction as on:
|
//There is a bug in camtool: it will flag bg extraction as on:
|
||||||
updatingCamtoolControls = true;
|
updatingCamtoolControls = true;
|
||||||
checkBackground.setSelected(false);
|
checkBackground.setSelected(false);
|
||||||
updatingCamtoolControls = false;
|
updatingCamtoolControls = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_checkBackgroundActionPerformed
|
}//GEN-LAST:event_checkBackgroundActionPerformed
|
||||||
|
|
||||||
private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed
|
private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed
|
||||||
if (updatingCamtoolControls){
|
if (updatingCamtoolControls) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -2490,24 +2481,24 @@ public class ScreenPanel extends Panel {
|
|||||||
spinnerThreshold.setEnabled(checkThreshold.isSelected());
|
spinnerThreshold.setEnabled(checkThreshold.isSelected());
|
||||||
((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null);
|
((Camtool) camera).setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
updateCamtoolControls();
|
updateCamtoolControls();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_checkThresholdActionPerformed
|
}//GEN-LAST:event_checkThresholdActionPerformed
|
||||||
|
|
||||||
private void buttonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopActionPerformed
|
private void buttonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopActionPerformed
|
||||||
try {
|
try {
|
||||||
if (buttonStop.getText().equals("Stop")){
|
if (buttonStop.getText().equals("Stop")) {
|
||||||
if ((camera!=null) && !camera.isClosed()){
|
if ((camera != null) && !camera.isClosed()) {
|
||||||
camera.close();
|
camera.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isCameraStopped()){
|
if (isCameraStopped()) {
|
||||||
comboCamerasActionPerformed(null);
|
comboCamerasActionPerformed(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
showException(ex);
|
showException(ex);
|
||||||
} finally {
|
} finally {
|
||||||
updateStop();
|
updateStop();
|
||||||
|
|||||||
Reference in New Issue
Block a user