diff --git a/config/config.properties b/config/config.properties
index 5bd1d96..a6f7753 100755
--- a/config/config.properties
+++ b/config/config.properties
@@ -1,4 +1,4 @@
-#Wed Sep 06 11:10:30 CEST 2017
+#Mon Oct 23 10:33:19 CEST 2017
autoSaveScanData=true
createSessionFiles=false
dataLayout=default
@@ -17,6 +17,7 @@ logDaysToLive=-1
logLevel=Fine
logLevelConsole=Off
logPath={logs}/{date}_{time}
+notificationLevel=null
scanDataRelease=false
scanStreamerPort=-1
scanStreamingPort=-1
diff --git a/devices/Beam phase.properties b/devices/Beam phase.properties
index 26af9c2..94dc4ad 100644
--- a/devices/Beam phase.properties
+++ b/devices/Beam phase.properties
@@ -1,9 +1,9 @@
-#Thu Oct 19 11:15:53 CEST 2017
+#Tue Oct 31 08:29:24 CET 2017
maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
-rotation=true
+rotation=false
scale=1.0
unit=deg
diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index 46b9fc5..2a1aa9f 100644
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,17 +1,19 @@
-#Thu Oct 19 11:30:30 CEST 2017
+#Thu Nov 02 08:45:36 CET 2017
+\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
+\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
colormap=Flame
-colormapAutomatic=true
-colormapMax=32950.0
-colormapMin=73.0
+colormapAutomatic=false
+colormapMax=45.0
+colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=2148
-imageWidth=2272
+imageHeight=-1
+imageWidth=-1
invert=false
-regionStartX=129
-regionStartY=7
+regionStartX=0
+regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -22,9 +24,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
-spatialCalOffsetX=-338.45430435361357
-spatialCalOffsetY=-323.5054840514664
-spatialCalScaleX=-7.617446735341062
-spatialCalScaleY=-7.774538616246088
+spatialCalOffsetX=-796.492903878568
+spatialCalOffsetY=-947.4732834064881
+spatialCalScaleX=-8.699279822948917
+spatialCalScaleY=-8.747949755590955
spatialCalUnits=mm
transpose=false
diff --git a/devices/cam1.properties b/devices/cam1.properties
index 5304241..0303c5e 100644
--- a/devices/cam1.properties
+++ b/devices/cam1.properties
@@ -1,4 +1,4 @@
-#Wed Sep 20 16:11:40 CEST 2017
+#Thu Oct 26 19:06:08 CEST 2017
colormap=Temperature
colormapAutomatic=true
colormapMax=30000.0
diff --git a/devices/cam2.properties b/devices/cam2.properties
index e4c055b..8ca6428 100644
--- a/devices/cam2.properties
+++ b/devices/cam2.properties
@@ -1,4 +1,4 @@
-#Wed Sep 20 10:01:09 CEST 2017
+#Thu Nov 02 08:42:13 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
@@ -6,13 +6,13 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=1024
-imageWidth=1280
+imageHeight=-1
+imageWidth=-1
invert=false
offsetX=0.0
offsetY=0.0
-regionStartX=1
-regionStartY=1
+regionStartX=0
+regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
diff --git a/devices/cam3.properties b/devices/cam3.properties
index dbe34c7..852d33b 100644
--- a/devices/cam3.properties
+++ b/devices/cam3.properties
@@ -1,4 +1,4 @@
-#Wed Sep 20 10:01:09 CEST 2017
+#Thu Nov 02 08:42:13 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
@@ -6,11 +6,11 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=1024
-imageWidth=1280
+imageHeight=-1
+imageWidth=-1
invert=false
-regionStartX=1
-regionStartY=1
+regionStartX=0
+regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
diff --git a/devices/cam_server.properties b/devices/cam_server.properties
index 0d47335..58aa04f 100644
--- a/devices/cam_server.properties
+++ b/devices/cam_server.properties
@@ -1,4 +1,4 @@
-#Mon Oct 02 18:51:27 CEST 2017
+#Thu Nov 02 08:46:19 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
-spatialCalOffsetX=-861.4939970777481
-spatialCalOffsetY=-820.4883730911062
-spatialCalScaleX=-18.90359092620482
-spatialCalScaleY=-19.37984500632817
+spatialCalOffsetX=-796.492903878568
+spatialCalOffsetY=-947.4732834064881
+spatialCalScaleX=-8.699279822948917
+spatialCalScaleY=-8.747949755590955
spatialCalUnits=mm
transpose=false
diff --git a/plugins/CameraCalibrationDialog.form b/plugins/CameraCalibrationDialog.form
index 1070cd2..4ac7ff9 100644
--- a/plugins/CameraCalibrationDialog.form
+++ b/plugins/CameraCalibrationDialog.form
@@ -57,7 +57,7 @@
-
+
@@ -120,7 +120,9 @@
-
+
+
+
@@ -160,7 +162,10 @@
-
+
+
+
+
@@ -303,6 +308,11 @@
+
+
+
+
+
diff --git a/plugins/CameraCalibrationDialog.java b/plugins/CameraCalibrationDialog.java
index 0fe62ca..2a93151 100644
--- a/plugins/CameraCalibrationDialog.java
+++ b/plugins/CameraCalibrationDialog.java
@@ -82,6 +82,7 @@ public class CameraCalibrationDialog extends StandardDialog {
checkMirrorX.setSelected((config.get("mirror_x") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_x"));
checkMirrorY.setSelected((config.get("mirror_y") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_y"));
comboRotation.setSelectedIndex((config.get("rotate") == null) ? 0 :(Integer) (config.get("rotate")));
+ ckCalibrationEnabled.setSelected(calibration!=null);
if (calibration!=null){
spinnerRefWidth.setValue(((Number)calibration.get("reference_marker_width")).doubleValue());
spinnerRefHeight.setValue(((Number)calibration.get("reference_marker_height")).doubleValue());
@@ -221,6 +222,7 @@ public class CameraCalibrationDialog extends StandardDialog {
spinnerLeft = new javax.swing.JSpinner();
spinnerRight = new javax.swing.JSpinner();
buttonFetch = new javax.swing.JButton();
+ ckCalibrationEnabled = new javax.swing.JCheckBox();
jPanel2 = new javax.swing.JPanel();
checkMirrorX = new javax.swing.JCheckBox();
checkMirrorY = new javax.swing.JCheckBox();
@@ -330,6 +332,8 @@ public class CameraCalibrationDialog extends StandardDialog {
}
});
+ ckCalibrationEnabled.setText("Enabled");
+
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@@ -370,7 +374,9 @@ public class CameraCalibrationDialog extends StandardDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAngleHor, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
+ .addGap(9, 9, 9)
+ .addComponent(ckCalibrationEnabled)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonFetch)))
.addContainerGap())
);
@@ -405,7 +411,9 @@ public class CameraCalibrationDialog extends StandardDialog {
.addComponent(spinnerAngleVer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
- .addComponent(buttonFetch)
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonFetch)
+ .addComponent(ckCalibrationEnabled))
.addContainerGap())
);
@@ -590,7 +598,7 @@ public class CameraCalibrationDialog extends StandardDialog {
.addComponent(buttonOk)
.addComponent(buttonCancel)
.addComponent(buttonApply))
- .addContainerGap(16, Short.MAX_VALUE))
+ .addContainerGap())
);
}// //GEN-END:initComponents
@@ -642,24 +650,33 @@ public class CameraCalibrationDialog extends StandardDialog {
int x2 = Math.max(left, right);
int y1 = Math.min(top, bottom);
int y2 = Math.max(top, bottom);
- if ((x1!=-1) && (x2!=-1) && (y1!=-1) && (y2!=-1)){
- System.out.println("Updating " + cameraName + " configuration");
- HashMap calibration = new HashMap();
+ System.out.println("Updating " + cameraName + " configuration");
+ HashMap calibration = null;
+ if (ckCalibrationEnabled.isSelected()){
+ calibration = new HashMap();
calibration.put("reference_marker", Arrays.asList(new Integer[]{x1, y1, x2, y2}));
calibration.put("reference_marker_width", width);
calibration.put("reference_marker_height", height);
calibration.put("angle_horizontal", angleHor);
- calibration.put("angle_vertical", angleVer);
-
- Map config = server.getConfig(cameraName);
- config.put("camera_calibration", calibration);
- config.put("mirror_x", checkMirrorX.isSelected());
- config.put("mirror_y", checkMirrorY.isSelected());
- config.put("rotate", comboRotation.getSelectedIndex());
- server.setConfig(cameraName, config);
-
- System.out.println("New config: " + config);
- SwingUtils.showMessage(this, "Success", "Updated " + cameraName + " configuration");
+ calibration.put("angle_vertical", angleVer);
+ }
+
+ Map config = server.getConfig(cameraName);
+ config.put("camera_calibration", calibration);
+ config.put("mirror_x", checkMirrorX.isSelected());
+ config.put("mirror_y", checkMirrorY.isSelected());
+ config.put("rotate", comboRotation.getSelectedIndex());
+ server.setConfig(cameraName, config);
+
+ System.out.println("New config: " + config);
+ boolean reticle = renderer.getShowReticle();
+ if (reticle){
+ renderer.setShowReticle(false);
+ }
+ SwingUtils.showMessage(this, "Success", "Updated " + cameraName + " configuration");
+
+ if (reticle){
+ renderer.setShowReticle(true);
}
} catch (Exception ex) {
SwingUtils.showException(this, ex);
@@ -674,6 +691,7 @@ public class CameraCalibrationDialog extends StandardDialog {
private javax.swing.JButton buttonOk;
private javax.swing.JCheckBox checkMirrorX;
private javax.swing.JCheckBox checkMirrorY;
+ private javax.swing.JCheckBox ckCalibrationEnabled;
private javax.swing.JComboBox comboRotation;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form
index 3974d55..9751fdb 100644
--- a/plugins/ScreenPanel.form
+++ b/plugins/ScreenPanel.form
@@ -814,7 +814,7 @@
-
+
@@ -825,37 +825,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -874,6 +881,8 @@
+
+
@@ -892,9 +901,6 @@
-
-
-
@@ -919,10 +925,7 @@
-
-
-
-
+
@@ -935,7 +938,7 @@
-
+
@@ -952,6 +955,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java
index 6c6b303..f85b0fe 100644
--- a/plugins/ScreenPanel.java
+++ b/plugins/ScreenPanel.java
@@ -79,11 +79,13 @@ import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
@@ -93,6 +95,7 @@ import javax.swing.event.PopupMenuListener;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.math3.analysis.function.Gaussian;
import org.apache.commons.math3.fitting.GaussianCurveFitter;
+import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoint;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
@@ -106,7 +109,7 @@ public class ScreenPanel extends Panel {
String userOverlaysConfigFile;
ColormapSource camera;
PipelineServer server;
- String cameraName;
+ String cameraName;
int polling = 1000;
Overlay marker = null;
JDialog histogramDialog;
@@ -117,10 +120,11 @@ public class ScreenPanel extends Panel {
Overlay[] userOv;
Overlay[] fitOv;
Overlay[] profileOv;
- Overlay errorOverlay;
+ Overlay errorOverlay;
boolean requestCameraListUpdate;
boolean goodRegion;
- String serverUrl;
+ boolean slicing;
+ String serverUrl;
String instanceName;
Double getServerDouble(String name) {
@@ -130,53 +134,65 @@ public class ScreenPanel extends Panel {
double[] getServerDoubleArray(String name) {
return (double[]) Convert.toDouble(server.getValue(name));
}
-
+
Double getServerDouble(String name, StreamValue cache) {
return (Double) Convert.toDouble(cache.__getitem__(name));
}
double[] getServerDoubleArray(String name, StreamValue cache) {
return (double[]) Convert.toDouble(cache.__getitem__(name));
- }
-
-
+ }
+
class ImageData {
- ImageData(){
- if (server!= null) {
+
+ ImageData() {
+ if (server != null) {
StreamValue cache = server.getStream().take();
-
- String prefix = goodRegion ? "gr_" : "";
+
+ String prefix = goodRegion ? "gr_" : "";
x_fit_mean = getServerDouble(prefix + "x_fit_mean", cache);
y_fit_mean = getServerDouble(prefix + "y_fit_mean", cache);
x_fit_standard_deviation = getServerDouble(prefix + "x_fit_standard_deviation", cache);
y_fit_standard_deviation = getServerDouble(prefix + "y_fit_standard_deviation", cache);
- x_fit_gauss_function = getServerDoubleArray(prefix +"x_fit_gauss_function", cache);
- y_fit_gauss_function = getServerDoubleArray(prefix +"y_fit_gauss_function", cache);
+ x_fit_gauss_function = getServerDoubleArray(prefix + "x_fit_gauss_function", cache);
+ y_fit_gauss_function = getServerDoubleArray(prefix + "y_fit_gauss_function", cache);
x_profile = getServerDoubleArray("x_profile", cache);
y_profile = getServerDoubleArray("y_profile", cache);
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
x_rms = getServerDouble("x_rms", cache);
- y_rms = getServerDouble("y_rms", cache);
- if (goodRegion){
+ y_rms = getServerDouble("y_rms", cache);
+ if (goodRegion) {
double[] gX2 = new double[x_profile.length];
Arrays.fill(gX2, Double.NaN);
- try{
+ try {
double x = getServerDoubleArray("gr_x_axis", cache)[0];
- System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x): x), x_fit_gauss_function.length);
- } catch (Exception ex){
+ System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x), x_fit_gauss_function.length);
+ } catch (Exception ex) {
}
- x_fit_gauss_function = gX2;
+ x_fit_gauss_function = gX2;
double[] gY2 = new double[y_profile.length];
Arrays.fill(gY2, Double.NaN);
- try{
+ try {
double y = getServerDoubleArray("gr_y_axis", cache)[0];
- System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y): y), y_fit_gauss_function.length);
- } catch (Exception ex){
+ System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y), y_fit_gauss_function.length);
+ } catch (Exception ex) {
}
y_fit_gauss_function = gY2;
- }
- }
+ if (slicing) {
+ try {
+ int slices = getServerDouble("slice_amount").intValue();
+ sliceCenters = new PointDouble[slices];
+ for (int i = 0; i < slices; i++) {
+ double x = getServerDouble("slice_" + i + "_center_x");
+ double y = getServerDouble("slice_" + i + "_center_y");
+ sliceCenters[i] = new PointDouble(x, y);
+ }
+ } catch (Exception ex) {
+ }
+ }
+ }
+ }
}
public Double x_fit_mean;
public Double y_fit_mean;
@@ -189,11 +205,11 @@ public class ScreenPanel extends Panel {
public double[] x_profile;
public double[] x_fit_gauss_function;
public double[] y_profile;
- public double[] y_fit_gauss_function;
-
+ public double[] y_fit_gauss_function;
+ PointDouble[] sliceCenters;
}
- class Frame extends ImageData{
+ class Frame extends ImageData {
Frame(Data data) {
this.data = data;
@@ -210,8 +226,12 @@ public class ScreenPanel extends Panel {
initComponents();
spinnerThreshold.setVisible(false);
btFixColormapRange.setVisible(false);
- spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false);
- spinnerGrScale.setVisible(false); labelGrScale.setVisible(false);
+ setGoodRegionOptionsVisible(false);
+ setSlicingOptionsVisible(false);
+ JComponent editor = spinnerSlOrientation.getEditor();
+ if (editor instanceof JSpinner.DefaultEditor) {
+ ((JSpinner.DefaultEditor)editor).getTextField().setHorizontalAlignment(JTextField.RIGHT);
+ }
//spinnerMin.setVisible(false); labelMin.setVisible(false);
//spinnerMax.setVisible(false); labelMax.setVisible(false);
renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin"));
@@ -247,19 +267,19 @@ public class ScreenPanel extends Panel {
} catch (Exception ex) {
ex.printStackTrace();
}
- }
-
+ }
+
if (App.hasArgument("srv_url")) {
serverUrl = App.getArgumentValue("srv_url");
}
-
+
if (App.hasArgument("calc")) {
useServerStats = false;
}
-
+
renderer.setProfileNormalized(true);
renderer.setShowProfileLimits(false);
-
+
JMenuItem menuCalibrate = new JMenuItem("Calibrate...");
menuCalibrate.addActionListener((ActionEvent e) -> {
try {
@@ -268,7 +288,7 @@ public class ScreenPanel extends Panel {
ex.printStackTrace();
showException(ex);
}
- });
+ });
JMenuItem menuShowStreamData = new JMenuItem("Show Stream Data");
menuShowStreamData.addActionListener((ActionEvent e) -> {
@@ -277,7 +297,7 @@ public class ScreenPanel extends Panel {
} catch (Exception ex) {
showException(ex);
}
- });
+ });
JMenuItem menuSaveStack = new JMenuItem("Save Stack");
menuSaveStack.addActionListener((ActionEvent e) -> {
@@ -308,7 +328,7 @@ public class ScreenPanel extends Panel {
}
} catch (Exception ex) {
} finally {
- renderer.removeListener(this);
+ renderer.removeListener(this);
}
}
@@ -331,7 +351,7 @@ public class ScreenPanel extends Panel {
server.resetRoi();
} catch (IOException ex) {
showException(ex);
- }
+ }
}
});
@@ -348,7 +368,7 @@ public class ScreenPanel extends Panel {
menuSetROI.setEnabled(server != null);
menuShowStreamData.setVisible(server != null);
menuCalibrate.setVisible(server != null);
- menuCalibrate.setEnabled((calibrationDialolg==null) || (!calibrationDialolg.isShowing()) );
+ menuCalibrate.setEnabled((calibrationDialolg == null) || (!calibrationDialolg.isShowing()));
}
@Override
@@ -389,14 +409,12 @@ public class ScreenPanel extends Panel {
boolean direct = App.getArgumentValue("ct").equals("0") || App.getArgumentValue("ct").equalsIgnoreCase("false");
buttonServer.setSelected(!direct);
buttonDirect.setSelected(direct);
- }
+ }
}
-
-
@Override
public void onStop() {
- try{
+ try {
if (camera != null) {
camera.close();
camera = null;
@@ -404,7 +422,7 @@ public class ScreenPanel extends Panel {
}
} catch (Exception ex) {
ex.printStackTrace();
- }
+ }
super.onStop();
}
@@ -448,10 +466,10 @@ public class ScreenPanel extends Panel {
startTimer(1000);
}
- DefaultComboBoxModel getCameraList(boolean fromServer) throws Exception {
+ DefaultComboBoxModel getCameraList(boolean fromServer) throws Exception {
DefaultComboBoxModel model = new DefaultComboBoxModel();
- if (fromServer){
- try (PipelineServer srv = newServer()){
+ if (fromServer) {
+ try (PipelineServer srv = newServer()) {
srv.initialize();
List cameras = srv.getCameras();
Collections.sort(cameras);
@@ -459,23 +477,23 @@ public class ScreenPanel extends Panel {
model.addElement(camera);
}
}
-
+
} else {
ArrayList cameras = (ArrayList) getContext().getClassByName("SfCamera").getMethod("getCameras", new Class[]{}).invoke(null);
- for (String cam:cameras) {
+ for (String cam : cameras) {
model.addElement(cam);
}
}
return model;
}
-
- PipelineServer newServer() throws IOException{
- if (serverUrl!=null){
+
+ PipelineServer newServer() throws IOException {
+ if (serverUrl != null) {
System.out.println("Connecting to server: " + serverUrl);
- server = new PipelineServer(CAMERA_DEVICE_NAME, serverUrl);
+ server = new PipelineServer(CAMERA_DEVICE_NAME, serverUrl);
} else {
- System.out.println("Connecting to server");
- server = new PipelineServer(CAMERA_DEVICE_NAME);
+ System.out.println("Connecting to server");
+ server = new PipelineServer(CAMERA_DEVICE_NAME);
}
return server;
}
@@ -515,26 +533,25 @@ public class ScreenPanel extends Panel {
}
final Object lockOverlays = new Object();
-
+
void manageFit(BufferedImage bi, Data data) {
Overlay[][] fo = ((bi == null) || ((!showFit && !showProfile))) ? null : getFitOverlays(data);
- synchronized(lockOverlays){
- fo = (fo==null) ? new Overlay[][]{null, null} : fo;
+ synchronized (lockOverlays) {
+ fo = (fo == null) ? new Overlay[][]{null, null} : fo;
renderer.updateOverlays(fo[0], profileOv);
profileOv = fo[0];
renderer.updateOverlays(fo[1], fitOv);
fitOv = fo[1];
- }
+ }
}
void manageUserOverlays(BufferedImage bi, Data data) {
Overlay[] fo = (bi == null) ? null : getUserOverlays(data);
- synchronized(lockOverlays){
+ synchronized (lockOverlays) {
renderer.updateOverlays(fo, userOv);
userOv = fo;
}
}
-
@Override
public void onStateChange(State state, State former) {
@@ -552,21 +569,21 @@ public class ScreenPanel extends Panel {
Thread devicesInitTask;
- void setCamera(String cameraName) throws IOException, InterruptedException {
+ void setCamera(String cameraName) throws IOException, InterruptedException {
System.out.println("Initializing");
parseUserOverlays();
errorOverlay = null;
-
- if (dataTableDialog!=null){
- dataTableDialog.dispose();
- dataTableDialog = null;
- }
- dataTableModel = null;
-
- if (calibrationDialolg!=null){
+
+ if (dataTableDialog != null) {
+ dataTableDialog.dispose();
+ dataTableDialog = null;
+ }
+ dataTableModel = null;
+
+ if (calibrationDialolg != null) {
calibrationDialolg.dispose();
calibrationDialolg = null;
- }
+ }
boolean was_server = false;
if (camera != null) {
@@ -581,23 +598,23 @@ public class ScreenPanel extends Panel {
renderer.setShowReticle(false);
renderer.removeOverlays(fitOv);
- renderer.removeOverlays(profileOv);
+ renderer.removeOverlays(profileOv);
renderer.removeOverlays(userOv);
renderer.clear();
renderer.resetZoom();
boolean changed = !String.valueOf(cameraName).equals(this.cameraName);
this.cameraName = cameraName;
-
+
if (changed || buttonDirect.isSelected()) {
spinnerThreshold.setVisible(false);
- spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false);
- spinnerGrScale.setVisible(false); labelGrScale.setVisible(false);
checkThreshold.setEnabled(false);
- checkGoodRegion.setEnabled(false);
+ checkGoodRegion.setEnabled(false);
+ setGoodRegionOptionsVisible(false);
+ setSlicingOptionsVisible(false);
}
if (changed) {
- checkBackground.setEnabled(false);
+ checkBackground.setEnabled(false);
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
devicesInitTask.interrupt();
}
@@ -613,17 +630,16 @@ public class ScreenPanel extends Panel {
if (cameraName == null) {
return;
}
-
+
System.out.println("Setting camera: " + cameraName + " [" + (buttonServer.isSelected() ? "server" : "direct") + "]");
-
+
synchronized (imageBuffer) {
currentFrame = null;
imageBuffer.clear();
}
-
try {
- if (buttonServer.isSelected()) {
+ if (buttonServer.isSelected()) {
camera = newServer();
camera.getConfig().flipHorizontally = false;
camera.getConfig().flipVertically = false;
@@ -634,30 +650,30 @@ public class ScreenPanel extends Panel {
camera.getConfig().roiHeight = -1;
} else {
//camera = new SfCamera(CAMERA_DEVICE_NAME, cameraName);
- camera = (ColormapSource) getContext().getClassByName("SfCamera").getConstructor(new Class[]{String.class, String.class}).newInstance(new Object[]{CAMERA_DEVICE_NAME, cameraName});
+ camera = (ColormapSource) getContext().getClassByName("SfCamera").getConstructor(new Class[]{String.class, String.class}).newInstance(new Object[]{CAMERA_DEVICE_NAME, cameraName});
}
camera.initialize();
camera.assertInitialized();
System.out.println("Camera initialization OK");
- if (server != null) {
+ if (server != null) {
//server.start(cameraName, false);
- String pipelineName = cameraName+"_sp";
- instanceName = cameraName+"_sp1";
- if (!server.getPipelines().contains(pipelineName)){
+ String pipelineName = cameraName + "_sp";
+ instanceName = cameraName + "_sp1";
+ if (!server.getPipelines().contains(pipelineName)) {
System.out.println("Creating pipeline: " + pipelineName);
- HashMap config = new HashMap<>();
+ HashMap config = new HashMap<>();
config.put("camera_name", cameraName);
//server.createFromConfig(config, pipelineName);
server.savePipelineConfig(pipelineName, config);
- }
- server.start(pipelineName, instanceName);
-
+ }
+ server.start(pipelineName, instanceName);
+
updateServerControls();
checkThreshold.setEnabled(true);
- checkGoodRegion.setEnabled(true);
- } else {
+ checkGoodRegion.setEnabled(true);
+ } else {
checkThreshold.setSelected(false);
- checkGoodRegion.setSelected(false);
+ checkGoodRegion.setSelected(false);
if (polling <= 0) {
camera.setMonitored(true);
} else {
@@ -667,7 +683,7 @@ public class ScreenPanel extends Panel {
}
buttonReticle.setEnabled(camera.getConfig().isCalibrated());
- camera.getConfig().save();
+ camera.getConfig().save();
renderer.setDevice(camera);
renderer.setAutoScroll(true);
renderer.setMarker(marker);
@@ -677,7 +693,7 @@ public class ScreenPanel extends Panel {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
if (bi != null) {
- if ((imageSize== null) || imageSize.width!=bi.getWidth() || imageSize.height!=bi.getHeight()) {
+ if ((imageSize == null) || imageSize.width != bi.getWidth() || imageSize.height != bi.getHeight()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -687,7 +703,7 @@ public class ScreenPanel extends Panel {
checkReticle();
}
});
- imageSize = new Dimension (bi.getWidth(), bi.getHeight());
+ imageSize = new Dimension(bi.getWidth(), bi.getHeight());
}
renderer.setProfileSize(Math.min(bi.getWidth(), bi.getHeight()));
}
@@ -695,7 +711,7 @@ public class ScreenPanel extends Panel {
if (!renderer.isPaused()) {
if (data != null) {
synchronized (imageBuffer) {
- currentFrame =new Frame(data);
+ currentFrame = new Frame(data);
if (imageBufferLenght >= 1) {
imageBuffer.add(currentFrame);
if (imageBuffer.size() > imageBufferLenght) {
@@ -734,7 +750,7 @@ public class ScreenPanel extends Panel {
onTimer();
}
onChangeColormap(null);
- checkBackground.setEnabled(true);
+ checkBackground.setEnabled(true);
if (changed) {
comboScreen.setModel(new DefaultComboBoxModel());
comboFilter.setModel(new DefaultComboBoxModel());
@@ -742,7 +758,7 @@ public class ScreenPanel extends Panel {
//Parallelizing initialization
devicesInitTask = new Thread(() -> {
try {
- if (cameraName.contains("DSRM")){
+ if (cameraName.contains("DSRM")) {
screen = new DiscretePositioner("CurrentScreen", cameraName + ":POSITION_SP", cameraName + ":POSITION");
} else {
screen = new DiscretePositioner("CurrentScreen", cameraName + ":SET_SCREEN1_POS", cameraName + ":GET_SCREEN1_POS");
@@ -852,7 +868,7 @@ public class ScreenPanel extends Panel {
buttonFullRange.setSelected(true);
} else if (config.colormapAutomatic) {
buttonAutomatic.setSelected(true);
- } else {
+ } else {
buttonManual.setSelected(true);
}
btFixColormapRange.setVisible(buttonAutomatic.isSelected());
@@ -863,10 +879,10 @@ public class ScreenPanel extends Panel {
spinnerMax.setEnabled(buttonManual.isSelected());
//spinnerMin.setValue(Double.isNaN(config.colormapMin) ? 0 : Math.min(Math.max((int) config.colormapMin, 0), 65535));
//spinnerMax.setValue(Double.isNaN(config.colormapMax) ? 0 : Math.min(Math.max((int) config.colormapMax, 0), 65535));
- if (!Double.isNaN(config.colormapMin) ){
+ if (!Double.isNaN(config.colormapMin)) {
spinnerMin.setValue(Math.min(Math.max((int) config.colormapMin, 0), 65535));
}
- if (!Double.isNaN(config.colormapMax) ){
+ if (!Double.isNaN(config.colormapMax)) {
spinnerMax.setValue(Math.min(Math.max((int) config.colormapMax, 0), 65535));
}
}
@@ -881,27 +897,53 @@ public class ScreenPanel extends Panel {
void updateServerControls() {
if (server != null) {
updatingServerControls = true;
- try {
+ try {
checkBackground.setSelected(server.getBackgroundSubtraction());
Double threshold = (server.getThreshold());
checkThreshold.setSelected(threshold != null);
- spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
+ spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
Map gr = (server.getGoodRegion());
checkGoodRegion.setSelected(gr != null);
- if (gr != null){
- spinnerGrThreshold.setValue(((Number)gr.get("threshold")).doubleValue());
- spinnerGrScale.setValue(((Number)gr.get("gfscale")).doubleValue());
- }
+ if (gr != null) {
+ spinnerGrThreshold.setValue(((Number) gr.get("threshold")).doubleValue());
+ spinnerGrScale.setValue(((Number) gr.get("gfscale")).doubleValue());
+ }
+ Map slicing = (server.getSlicing());
+ checkSlicing.setSelected(slicing != null);
+ if (slicing != null) {
+ spinnerSlNumber.setValue(((Number) slicing.get("number_of_slices")).intValue());
+ spinnerSlScale.setValue(((Number) slicing.get("scale")).doubleValue());
+ spinnerSlOrientation.setValue((String) slicing.get("orientation"));
+ }
} catch (Exception ex) {
+ ex.printStackTrace();
}
goodRegion = checkGoodRegion.isSelected();
- spinnerThreshold.setVisible(checkThreshold.isSelected());
- spinnerGrThreshold.setVisible(goodRegion); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible());
- spinnerGrScale.setVisible(goodRegion); labelGrScale.setVisible(spinnerGrScale.isVisible());
+ spinnerThreshold.setVisible(checkThreshold.isSelected());
+ setGoodRegionOptionsVisible(goodRegion);
+ slicing = goodRegion && checkSlicing.isSelected();
+ setSlicingOptionsVisible(slicing);
updatingServerControls = false;
}
}
+ void setGoodRegionOptionsVisible(boolean visible) {
+ spinnerGrThreshold.setVisible(visible);
+ labelGrThreshold.setVisible(visible);
+ spinnerGrScale.setVisible(visible);
+ labelGrScale.setVisible(visible);
+ panelSlicing.setVisible(visible);
+ }
+
+ void setSlicingOptionsVisible(boolean visible) {
+ spinnerSlNumber.setVisible(visible);
+ labelSlNumber.setVisible(visible);
+ spinnerSlScale.setVisible(visible);
+ labelSlScale.setVisible(visible);
+ spinnerSlOrientation.setVisible(visible);
+ labelSlOrientation.setVisible(visible);
+ }
+
boolean isCameraStopped() {
if (server != null) {
if (!server.isStarted()) {
@@ -946,7 +988,7 @@ public class ScreenPanel extends Panel {
if ((renderer.getMarker() == null) && buttonMarker.isSelected()) {
buttonMarker.setSelected(false);
}
- if (!renderer.isPaused() && (dataTableDialog!=null) && (dataTableDialog.isShowing())){
+ if (!renderer.isPaused() && (dataTableDialog != null) && (dataTableDialog.isShowing())) {
updateStreamData();
}
updateZoom();
@@ -958,26 +1000,26 @@ public class ScreenPanel extends Panel {
Pen penFit = new Pen(new Color(192, 105, 0), 0);
Pen penCross = new Pen(new Color(192, 105, 0), 0);
-
-
- Frame getCurrentFrame(){
+ Pen penSlices = new Pen(Color.CYAN.darker(), 1);
+
+ Frame getCurrentFrame() {
if ((imageBufferLenght > 1) && (renderer.isPaused())) {
int index = ((int) pauseSelection.getValue()) - 1;
synchronized (imageBuffer) {
return (index < imageBuffer.size()) ? imageBuffer.get(index) : null;
}
- }
- return currentFrame;
+ }
+ return currentFrame;
}
-
- Frame getFrame(Data data){
+
+ Frame getFrame(Data data) {
synchronized (imageBuffer) {
for (Frame f : imageBuffer) {
if (f.data == data) {
- return f;
+ return f;
}
}
- }
+ }
return null;
}
@@ -991,21 +1033,31 @@ public class ScreenPanel extends Panel {
double[] pX = null, pY = null, gX = null, gY = null;
int height = data.getHeight();
int width = data.getWidth();
+ PointDouble[] sliceCenters = null;
//Double xCom=null, yCom=null;
if (data != null) {
int profileSize = renderer.getProfileSize();
if ((useServerStats) && (server != null)) {
try {
-
+
ImageData id = getFrame(data);
- if (id==null){
+ if (id == null) {
return null;
}
- xMean = id.x_fit_mean; xSigma = id.x_fit_standard_deviation;yMean = id.y_fit_mean;ySigma = id.y_fit_standard_deviation;
- gX = id.x_fit_gauss_function; gY = id.y_fit_gauss_function;
- pX = id.x_profile; pY = id.y_profile;
- xCom = id.x_center_of_mass; xRms = id.x_rms; yCom = id.y_center_of_mass; yRms = id.y_rms;
-
+ xMean = id.x_fit_mean;
+ xSigma = id.x_fit_standard_deviation;
+ yMean = id.y_fit_mean;
+ ySigma = id.y_fit_standard_deviation;
+ gX = id.x_fit_gauss_function;
+ gY = id.y_fit_gauss_function;
+ pX = id.x_profile;
+ pY = id.y_profile;
+ xCom = id.x_center_of_mass;
+ xRms = id.x_rms;
+ yCom = id.y_center_of_mass;
+ yRms = id.y_rms;
+ sliceCenters = id.sliceCenters;
+
profileSize /= 4;
if (pX != null) {
int[] x = Arr.indexesInt(pX.length);
@@ -1018,18 +1070,18 @@ public class ScreenPanel extends Panel {
double rangePlot = max - min;
for (int i = 0; i < x.length; i++) {
- if (gX != null) {
- y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize));
+ if (gX != null) {
+ y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize));
}
p[i] = (int) (height - 1 - (((pX[i] - minPlot) / rangePlot) * profileSize));
}
-
- if (goodRegion){
+
+ if (goodRegion) {
for (int i = 0; i < x.length; i++) {
- y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i];
- }
- }
-
+ y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i];
+ }
+ }
+
vgaussian = new Overlays.Polyline(penFit, x, y);
vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
}
@@ -1047,14 +1099,14 @@ public class ScreenPanel extends Panel {
for (int i = 0; i < x.length; i++) {
if (gY != null) {
- x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize);
+ x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize);
}
p[i] = (int) (((pY[i] - minPlot) / rangePlot) * profileSize);
}
-
- if (goodRegion){
+
+ if (goodRegion) {
for (int i = 0; i < x.length; i++) {
- x[i] = (Double.isNaN(gY[i])) ? -1 :x[i];
+ x[i] = (Double.isNaN(gY[i])) ? -1 : x[i];
}
}
hgaussian = new Overlays.Polyline(penFit, x, y);
@@ -1074,12 +1126,12 @@ public class ScreenPanel extends Panel {
return null;
}
if (renderer.getCalibration() != null) {
- try {
+ try {
double[] sum = data.integrateVertically(true);
- double[] saux = new double[sum.length];
+ double[] saux = new double[sum.length];
int[] p = new int[sum.length];
double[] x_egu = renderer.getCalibration().getAxisX(sum.length);
- double[] comRms = getComRms(sum, x_egu);
+ double[] comRms = getComRms(sum, x_egu);
xCom = comRms[0];
xRms = comRms[1];
int[] x = Arr.indexesInt(sum.length);
@@ -1088,7 +1140,7 @@ public class ScreenPanel extends Panel {
for (int i = 0; i < sum.length; i++) {
saux[i] = sum[i] - min;
}
- if (showFit){
+ if (showFit) {
double[] gaussian = fitGaussian(saux, x);
if (gaussian != null) {
if ((gaussian[2] < sum.length * 0.45)
@@ -1100,15 +1152,15 @@ public class ScreenPanel extends Panel {
double[] fit = getFitFunction(gaussian, x);
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
- y[i] = (int) (height - 1 - ((((fit[i] + min) / height - minPlot) / rangePlot) * profileSize));
- }
- vgaussian = new Overlays.Polyline(penFit, x, y);
+ y[i] = (int) (height - 1 - ((((fit[i] + min) / height - minPlot) / rangePlot) * profileSize));
+ }
+ vgaussian = new Overlays.Polyline(penFit, x, y);
}
}
}
- if (showProfile){
+ if (showProfile) {
for (int i = 0; i < x.length; i++) {
- p[i] = (int) (height - 1 - (((sum[i] / height- minPlot) / rangePlot) * profileSize));
+ p[i] = (int) (height - 1 - (((sum[i] / height - minPlot) / rangePlot) * profileSize));
}
vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
}
@@ -1121,7 +1173,7 @@ public class ScreenPanel extends Panel {
double[] saux = new double[sum.length];
int[] p = new int[sum.length];
double[] y_egu = renderer.getCalibration().getAxisY(sum.length);
- double[] comRms = getComRms(sum, y_egu);
+ double[] comRms = getComRms(sum, y_egu);
yCom = comRms[0];
yRms = comRms[1];
int[] x = Arr.indexesInt(sum.length);
@@ -1131,7 +1183,7 @@ public class ScreenPanel extends Panel {
saux[i] = sum[i] - min;
}
- if (showFit){
+ if (showFit) {
double[] gaussian = fitGaussian(saux, x);
if (gaussian != null) {
//Only aknowledge beam fully inside the image and peak over 3% of min
@@ -1145,15 +1197,15 @@ public class ScreenPanel extends Panel {
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
- y[i] = (int) ((((fit[i] + min) / width - minPlot) / rangePlot) * profileSize);
+ y[i] = (int) ((((fit[i] + min) / width - minPlot) / rangePlot) * profileSize);
}
- hgaussian = new Overlays.Polyline(penFit, y, x);
- }
+ hgaussian = new Overlays.Polyline(penFit, y, x);
+ }
}
- }
- if (showProfile){
+ }
+ if (showProfile) {
for (int i = 0; i < x.length; i++) {
- p[i] = (int) (((sum[i] / width - minPlot) / rangePlot) * profileSize);
+ p[i] = (int) (((sum[i] / width - minPlot) / rangePlot) * profileSize);
}
hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, x);
}
@@ -1174,27 +1226,29 @@ public class ScreenPanel extends Panel {
yMean = data.getY((int) Math.round(yMean));
}
}
- }
+ }
final String units = (renderer.getCalibration() != null) ? "\u00B5m" : "px";
final String fmt = "%7.1f" + units;
Overlays.Text textCom = null;
- Overlay[] pOv=null, fOv=null;
+ Overlay[] pOv = null, fOv = null;
+ Font fontInfoText = new Font(Font.MONOSPACED, 0, 14);
Point textPosition = new Point(12, 20);
- if (showProfile){
+ if (showProfile) {
if ((xCom != null) && (yCom != null)) {
- String text = String.format("com x: m=" + fmt + " \u03C3=" + fmt + "\ncom y: m=" + fmt + " \u03C3=" + fmt,xCom, xRms,yCom, yRms);
- textCom = new Overlays.Text(renderer.getPenProfile(), text, new Font(Font.MONOSPACED, 0, 14), textPosition);
+ String text = String.format("com x: m=" + fmt + " \u03C3=" + fmt + "\ncom y: m=" + fmt + " \u03C3=" + fmt, xCom, xRms, yCom, yRms);
+ textCom = new Overlays.Text(renderer.getPenProfile(), text, fontInfoText, textPosition);
textCom.setFixed(true);
textCom.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
- }
+ }
pOv = new Overlay[]{hprofile, vprofile, textCom};
+ textPosition = new Point(textPosition.x, textPosition.y + 34);
}
- if (showFit){
+ if (showFit) {
Overlays.Crosshairs cross = null;
Overlays.Text textFit = null;
if ((xMean != null) && (yMean != null)) {
- String text = String.format("fit x: m=" + fmt + " \u03C3=" + fmt + "\nfit y: m=" + fmt + " \u03C3=" + fmt,xMean, xSigma, yMean, ySigma);
- textFit = new Overlays.Text(penFit, text, new Font(Font.MONOSPACED, 0, 14), showProfile ? new Point(12, 54) : textPosition );
+ String text = String.format("fit x: m=" + fmt + " \u03C3=" + fmt + "\nfit y: m=" + fmt + " \u03C3=" + fmt, xMean, xSigma, yMean, ySigma);
+ textFit = new Overlays.Text(penFit, text, fontInfoText, textPosition);
textFit.setFixed(true);
textFit.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
Point center = new Point(xMean.intValue(), yMean.intValue());
@@ -1205,21 +1259,46 @@ public class ScreenPanel extends Panel {
}
cross = new Overlays.Crosshairs(penCross, center, new Dimension(Math.abs(2 * xSigma.intValue()), 2 * Math.abs(ySigma.intValue())));
}
- fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit};
-
- if (goodRegion){
- try{
- double[] x = getServerDoubleArray("gr_x_axis"); double[] y = getServerDoubleArray("gr_y_axis");
- double x1 = x[0]; double x2 = x[x.length-1]; double y1 = y[0]; double y2 = y[y.length-1];
+ textPosition = new Point(textPosition.x, textPosition.y + 34);
+ fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit};
+
+ if (goodRegion) {
+ try {
+ double[] x = getServerDoubleArray("gr_x_axis");
+ double[] y = getServerDoubleArray("gr_y_axis");
+ double x1 = x[0];
+ double x2 = x[x.length - 1];
+ double y1 = y[0];
+ double y2 = y[y.length - 1];
Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted));
goodRegionOv.setCalibration(renderer.getCalibration());
goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1));
- goodRegionOv.setAbsoluteSize(new DimensionDouble(x2-x1, y2-y1));
+ goodRegionOv.setAbsoluteSize(new DimensionDouble(x2 - x1, y2 - y1));
fOv = Arr.append(fOv, goodRegionOv);
- } catch (Exception ex){
- }
- }
-
+
+ if (slicing) {
+ if (sliceCenters != null) {
+ for (PointDouble sliceCenter : sliceCenters) {
+ Overlays.Crosshairs center = new Overlays.Crosshairs(penSlices);
+ center.setCalibration(renderer.getCalibration());
+ center.setAbsolutePosition(sliceCenter);
+ center.setSize(new Dimension(10, 10));
+ fOv = Arr.append(fOv, center);
+ }
+ if (sliceCenters.length > 1) {
+ double[] fit = fitPolynomial(sliceCenters, 1);
+ double angle = Math.toDegrees(Math.atan(fit[1]));
+ Overlays.Text text = new Overlays.Text(penSlices, String.format("slice: \u03B8= %5.1fdeg", angle), fontInfoText, textPosition);
+ text.setFixed(true);
+ text.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_LEFT);
+ fOv = Arr.append(fOv, text);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ }
+ }
+
}
return new Overlay[][]{pOv, fOv};
}
@@ -1318,7 +1397,7 @@ public class ScreenPanel extends Panel {
if (ov instanceof Overlays.Polyline) {
double[] x = (uo.channels[0].equals("null")) ? null : getServerDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : getServerDoubleArray(uo.channels[1]);
- if ((x != null) || (y !=null)) {
+ if ((x != null) || (y != null)) {
if (x == null) {
x = (renderer.getCalibration() == null) ? Arr.indexesDouble(y.length) : renderer.getCalibration().getAxisX(y.length);
}
@@ -1329,13 +1408,15 @@ public class ScreenPanel extends Panel {
valid = true;
}
} else {
- Double x = getServerDouble(uo.channels[0]); Double y = getServerDouble(uo.channels[1]);
- if ((x != null) && (y !=null)) {
- PointDouble position = new PointDouble(x,y);
+ Double x = getServerDouble(uo.channels[0]);
+ Double y = getServerDouble(uo.channels[1]);
+ if ((x != null) && (y != null)) {
+ PointDouble position = new PointDouble(x, y);
ov.setAbsolutePosition(position);
if (!(ov instanceof Overlays.Crosshairs)) {
- Double x2 = getServerDouble(uo.channels[2]); Double y2 = getServerDouble(uo.channels[3]);
- if ((x != null) && (y !=null)) {
+ Double x2 = getServerDouble(uo.channels[2]);
+ Double y2 = getServerDouble(uo.channels[3]);
+ if ((x != null) && (y != null)) {
DimensionDouble size = new DimensionDouble(x2 - position.x, y2 - position.y);
ov.setAbsoluteSize(size);
valid = true;
@@ -1345,7 +1426,7 @@ public class ScreenPanel extends Panel {
}
}
}
- if (valid){
+ if (valid) {
ret.add(ov);
}
} catch (Exception ex) {
@@ -1361,21 +1442,21 @@ public class ScreenPanel extends Panel {
double xmd = 0;
double xmd2 = 0;
double total = 0;
- for (int i=0; i< arr.length; i++) {
- double v = (arr[i] * x[i]);
+ for (int i = 0; i < arr.length; i++) {
+ double v = (arr[i] * x[i]);
xmd += v;
xmd2 += (v * x[i]);
total += arr[i];
}
if (total > 0) {
- double com = xmd / total;
- double com2 = xmd2 / total;
+ double com = xmd / total;
+ double com2 = xmd2 / total;
double rms = Math.sqrt(Math.abs(com2 - com * com));
- return new double[] {com, rms};
+ return new double[]{com, rms};
}
}
return new double[]{Double.NaN, Double.NaN};
- }
+ }
double[] fitGaussianScript(int[] y, int[] x) {
ScriptManager sm = Context.getInstance().getScriptManager();
@@ -1412,6 +1493,31 @@ public class ScreenPanel extends Panel {
}
+ double[] fitPolynomial(PointDouble[] points, int order) {
+ double[] y = new double[points.length];
+ double[] x = new double[points.length];
+ for (int i = 0; i < points.length; i++) {
+ x[i] = points[i].x;
+ y[i] = points[i].y;
+ }
+ return fitPolynomial(y, x, order);
+ }
+
+ double[] fitPolynomial(double[] y, double[] x, int order) {
+ try {
+ ArrayProperties pY = ArrayProperties.get(y);
+ PolynomialCurveFitter fitter = PolynomialCurveFitter.create(order).withMaxIterations(1000);
+ ArrayList values = new ArrayList<>();
+ for (int i = 0; i < y.length; i++) {
+ values.add(new WeightedObservedPoint(1.0, x[i], y[i]));
+ }
+ return fitter.fit(values);
+ } catch (Exception ex) {
+ return null;
+ }
+
+ }
+
double[] getFitFunction(double[] pars, int[] x) {
double[] fit = new double[x.length];
Gaussian g = new Gaussian(pars[0], pars[1], pars[2]);
@@ -1438,7 +1544,7 @@ public class ScreenPanel extends Panel {
}
void setLaserState(boolean value) throws Exception {
- System.out.println( "Setting laser state: " + value);
+ System.out.println("Setting laser state: " + value);
Epics.putq("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", value ? 0 : 1);
Epics.putq("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1);
Thread.sleep(3000);
@@ -1449,7 +1555,7 @@ public class ScreenPanel extends Panel {
}
void elog(String logbook, String title, String message, String[] attachments) throws Exception {
- String domain = "";
+ String domain = "";
String category = "Info";
String entry = "";
StringBuffer cmd = new StringBuffer();
@@ -1515,58 +1621,59 @@ public class ScreenPanel extends Panel {
}
}
}
-
- void writeFrameMetadata(String path, Frame frame) throws Exception{
+
+ void writeFrameMetadata(String path, Frame frame) throws Exception {
getContext().getDataManager().setAttribute("/", "Camera", String.valueOf(cameraName));
getContext().getDataManager().setAttribute("/", "Screen", String.valueOf(valueScreen.getLabel().getText()));
- getContext().getDataManager().setAttribute("/", "Filter", String.valueOf(valueFilter.getLabel().getText()));
+ getContext().getDataManager().setAttribute("/", "Filter", String.valueOf(valueFilter.getLabel().getText()));
Calibration cal = renderer.getCalibration();
- getContext().getDataManager().setAttribute("/", "Calibration", cal == null ? new double[]{1,1,0,0} :
- new double[]{cal.getScaleX(), cal.getScaleY(), cal.getOffsetX(), cal.getOffsetY()});
+ getContext().getDataManager().setAttribute("/", "Calibration", cal == null ? new double[]{1, 1, 0, 0}
+ : new double[]{cal.getScaleX(), cal.getScaleY(), cal.getOffsetX(), cal.getOffsetY()});
getContext().getDataManager().setAttribute(path, "Timestamp", Chrono.getTimeStr(frame.data.getTimestamp(), "HH:mm:ss.SSS"));
- if (server != null){
- try{
- getContext().getDataManager().setAttribute("/", "ROI", server.getRoi());
- } catch (Exception ex){
- getContext().getDataManager().setAttribute("/", "ROI", new int[]{0,0,-1,-1});
+ if (server != null) {
+ try {
+ getContext().getDataManager().setAttribute("/", "ROI", server.getRoi());
+ } catch (Exception ex) {
+ getContext().getDataManager().setAttribute("/", "ROI", new int[]{0, 0, -1, -1});
}
- if (frame!=null){
- for (Field f:ImageData.class.getFields()){
+ if (frame != null) {
+ for (Field f : ImageData.class.getFields()) {
Object value = f.get(frame);
getContext().getDataManager().setAttribute(path, f.getName(), (value == null) ? Double.NaN : value);
- }
- }
- for (String name : new String[]{"x_axis", "y_axis", "gr_x_axis", "gr_y_axis"}){
+ }
+ }
+ getContext().getDataManager().setAttribute("/", "GoodRegion", goodRegion);
+ getContext().getDataManager().setAttribute("/", "Slicing", slicing);
+ for (String name : new String[]{"x_axis", "y_axis", "gr_x_axis", "gr_y_axis"}) {
double[] val = getServerDoubleArray(name);
- getContext().getDataManager().setAttribute("/", "GoodRegion", goodRegion);
- if (val!=null){
+ if (val != null) {
getContext().getDataManager().setAttribute("/", name, val);
}
- }
- }
+ }
+ }
}
- void saveSnapshot() throws Exception {
+ void saveSnapshot() throws Exception {
getContext().setExecutionPars("snapshot");
String path = "/data";
String snapshotFile = null;
synchronized (imageBuffer) {
Frame id = getCurrentFrame();
- if (id==null){
+ if (id == null) {
throw new Exception("No current image");
}
Object data = id.data.getMatrix();
- getContext().getDataManager().setDataset(path, data, id.data.isUnsigned());
+ getContext().getDataManager().setDataset(path, data, id.data.isUnsigned());
writeFrameMetadata(path, id);
- getContext().getDataManager().closeOutput();
+ getContext().getDataManager().closeOutput();
//Enforce the same timestamp to data & image files.
//snapshotFile = getContext().getSetup().expandPath("{images}/{date}_{time}_snapshot.png", getContext().getExecutionPars().getStart());
snapshotFile = getContext().getExecutionPars().getPath() + ".png";
//renderer.saveSnapshot(snapshotFile, "png", true);
ImageBuffer.saveImage(SwingUtils.createImage(renderer), snapshotFile, "png");
-
+
}
-
+
JPanel panel = new JPanel();
GridBagLayout layout = new GridBagLayout();
layout.columnWidths = new int[]{0, 180}; //Minimum width
@@ -1580,7 +1687,7 @@ public class ScreenPanel extends Panel {
panel.add(new JLabel("Data file:"), c);
c.gridy = 1;
panel.add(new JLabel("Logbook:"), c);
- c.gridy = 2;
+ c.gridy = 2;
panel.add(new JLabel("Comment:"), c);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 1;
@@ -1589,21 +1696,25 @@ public class ScreenPanel extends Panel {
panel.add(comboLogbook, c);
c.gridy = 0;
panel.add(new JLabel(getContext().getExecutionPars().getPath()), c);
-
- if (SwingUtils.showOption(getTopLevel(), "Success", panel, OptionType.OkCancel) == OptionResult.Yes){
+
+ if (SwingUtils.showOption(getTopLevel(), "Success", panel, OptionType.OkCancel) == OptionResult.Yes) {
StringBuilder message = new StringBuilder();
message.append("Camera: ").append(cameraName).append(" (").
- append((server!=null) ? "server" : "direct").append(")").append("\n");
+ append((server != null) ? "server" : "direct").append(")").append("\n");
message.append("Screen: ").append(String.valueOf(valueScreen.getLabel().getText())).append("\n");
message.append("Filter: ").append(String.valueOf(valueFilter.getLabel().getText())).append("\n");
message.append("Data file: ").append(getContext().getExecutionPars().getPath()).append("\n");
- message.append("Comment: ").append(textComment.getText()).append("\n");
- if ((fitOv != null) && (fitOv.length > 5)) {
- Overlays.Text text = (Overlays.Text) fitOv[5];
- message.append(text.getText()).append("\n");
- }
- elog((String) comboLogbook.getSelectedItem(), "ScreenPanel Snapshot", message.toString(), new String[]{snapshotFile});
- }
+ message.append("Comment: ").append(textComment.getText()).append("\n");
+ if ((fitOv != null) /*&& (fitOv.length > 5)*/) {
+ for (int i=0; i ids = (value==null) ? new ArrayList<>(): new ArrayList(value.getIdentifiers());
- if (ids.size()+2 != dataTableModel.getRowCount()){
- dataTableModel.setNumRows(0);
- try {
- dataTableModel.addRow(new Object[]{"Locator", server.getUrl() + "/" + ((value==null) ? instanceName : server.getCurrentInstance())});
- } catch (Exception ex) {
+ List ids = (value == null) ? new ArrayList<>() : new ArrayList(value.getIdentifiers());
+ if (ids.size() + 2 != dataTableModel.getRowCount()) {
+ dataTableModel.setNumRows(0);
+ try {
+ dataTableModel.addRow(new Object[]{"Locator", server.getUrl() + "/" + ((value == null) ? instanceName : server.getCurrentInstance())});
+ } catch (Exception ex) {
dataTableModel.addRow(new Object[]{"Locator", ex.getMessage()});
}
- try {
+ try {
dataTableModel.addRow(new Object[]{"Stream", server.getStreamAddress()});
- } catch (Exception ex) {
+ } catch (Exception ex) {
dataTableModel.addRow(new Object[]{"Stream", ex.getMessage()});
}
- Collections.sort(ids);
- for (String id : ids){
+ Collections.sort(ids);
+ for (String id : ids) {
dataTableModel.addRow(new Object[]{id, ""});
- }
- }
- for (int i = 2 ; i< dataTableModel.getRowCount(); i++){
+ }
+ }
+ for (int i = 2; i < dataTableModel.getRowCount(); i++) {
String id = String.valueOf(dataTableModel.getValueAt(i, 0));
Object obj = server.getValue(id);
- if (obj!=null){
- if (obj.getClass().isArray()){
+ if (obj != null) {
+ if (obj.getClass().isArray()) {
obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
- } else if (obj instanceof Double){
+ } else if (obj instanceof Double) {
obj = Convert.roundDouble((Double) obj, 1);
- } else if (obj instanceof Float){
+ } else if (obj instanceof Float) {
obj = Convert.roundDouble((Float) obj, 1);
}
- }
+ }
dataTableModel.setValueAt(String.valueOf(obj), i, 1);
}
}
}
-
+
////////
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
@@ -1803,6 +1918,14 @@ public class ScreenPanel extends Panel {
spinnerGrThreshold = new javax.swing.JSpinner();
labelGrThreshold = new javax.swing.JLabel();
labelGrScale = new javax.swing.JLabel();
+ panelSlicing = new javax.swing.JPanel();
+ checkSlicing = new javax.swing.JCheckBox();
+ labelSlScale = new javax.swing.JLabel();
+ spinnerSlScale = new javax.swing.JSpinner();
+ labelSlNumber = new javax.swing.JLabel();
+ spinnerSlNumber = new javax.swing.JSpinner();
+ labelSlOrientation = new javax.swing.JLabel();
+ spinnerSlOrientation = new javax.swing.JSpinner();
setPreferredSize(new java.awt.Dimension(873, 600));
@@ -2322,7 +2445,7 @@ public class ScreenPanel extends Panel {
pauseSelection.setDecimals(0);
- panelScreen2.setBorder(javax.swing.BorderFactory.createTitledBorder("Image"));
+ panelScreen2.setBorder(javax.swing.BorderFactory.createTitledBorder("Pipeline"));
checkThreshold.setText("Threshold");
checkThreshold.addActionListener(new java.awt.event.ActionListener() {
@@ -2332,7 +2455,6 @@ public class ScreenPanel extends Panel {
});
spinnerThreshold.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 99999.0d, 1.0d));
- spinnerThreshold.setPreferredSize(new java.awt.Dimension(77, 20));
spinnerThreshold.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerThresholdonChange(evt);
@@ -2353,8 +2475,7 @@ public class ScreenPanel extends Panel {
}
});
- spinnerGrScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 100.0d, 1.0d));
- spinnerGrScale.setPreferredSize(new java.awt.Dimension(77, 20));
+ spinnerGrScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 99999.0d, 1.0d));
spinnerGrScale.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerGrThresholdonChange(evt);
@@ -2362,7 +2483,7 @@ public class ScreenPanel extends Panel {
});
spinnerGrThreshold.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.04d, 1.0d, 0.1d));
- spinnerGrThreshold.setPreferredSize(new java.awt.Dimension(77, 20));
+ spinnerGrThreshold.setPreferredSize(new java.awt.Dimension(92, 20));
spinnerGrThreshold.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerGrThresholdonChange(evt);
@@ -2373,6 +2494,90 @@ public class ScreenPanel extends Panel {
labelGrScale.setText("Scale:");
+ checkSlicing.setText("Slicing");
+ checkSlicing.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ checkSlicingActionPerformed(evt);
+ }
+ });
+
+ labelSlScale.setText("Scale:");
+
+ spinnerSlScale.setModel(new javax.swing.SpinnerNumberModel(3.0d, 0.01d, 99999.0d, 1.0d));
+ spinnerSlScale.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spinnerSlicingChange(evt);
+ }
+ });
+
+ labelSlNumber.setText("Slices:");
+
+ spinnerSlNumber.setModel(new javax.swing.SpinnerNumberModel(2, 0, 1000, 1));
+ spinnerSlNumber.setPreferredSize(new java.awt.Dimension(92, 20));
+ spinnerSlNumber.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spinnerSlicingChange(evt);
+ }
+ });
+
+ labelSlOrientation.setText("Orientation:");
+
+ spinnerSlOrientation.setModel(new javax.swing.SpinnerListModel(new String[] {"vertical", "horizontal"}));
+ spinnerSlOrientation.setPreferredSize(new java.awt.Dimension(92, 20));
+ spinnerSlOrientation.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ spinnerSlicingChange(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelSlicingLayout = new javax.swing.GroupLayout(panelSlicing);
+ panelSlicing.setLayout(panelSlicingLayout);
+ panelSlicingLayout.setHorizontalGroup(
+ panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSlicingLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSlicingLayout.createSequentialGroup()
+ .addComponent(checkSlicing)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelSlicingLayout.createSequentialGroup()
+ .addComponent(labelSlNumber)
+ .addGap(2, 2, 2)
+ .addComponent(spinnerSlNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelSlicingLayout.createSequentialGroup()
+ .addComponent(labelSlScale)
+ .addGap(2, 2, 2)
+ .addComponent(spinnerSlScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelSlicingLayout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(labelSlOrientation)
+ .addGap(2, 2, 2)
+ .addComponent(spinnerSlOrientation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+
+ panelSlicingLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerSlNumber, spinnerSlOrientation, spinnerSlScale});
+
+ panelSlicingLayout.setVerticalGroup(
+ panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSlicingLayout.createSequentialGroup()
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(checkSlicing)
+ .addGroup(panelSlicingLayout.createSequentialGroup()
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerSlNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(labelSlNumber))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerSlScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(labelSlScale))))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelSlicingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerSlOrientation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(labelSlOrientation)))
+ );
+
javax.swing.GroupLayout panelScreen2Layout = new javax.swing.GroupLayout(panelScreen2);
panelScreen2.setLayout(panelScreen2Layout);
panelScreen2Layout.setHorizontalGroup(
@@ -2380,33 +2585,37 @@ public class ScreenPanel extends Panel {
.addGroup(panelScreen2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
- .addComponent(checkGoodRegion)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(labelGrScale)
- .addGap(2, 2, 2)
- .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
- .addComponent(labelGrThreshold)
- .addGap(2, 2, 2)
- .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(panelScreen2Layout.createSequentialGroup()
- .addComponent(checkBackground)
- .addGap(0, 0, Short.MAX_VALUE))
.addGroup(panelScreen2Layout.createSequentialGroup()
.addComponent(checkThreshold)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
+ .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
+ .addComponent(checkGoodRegion)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(labelGrScale))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(labelGrThreshold)))
+ .addGap(2, 2, 2)))
+ .addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerGrScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
+ .addComponent(panelSlicing, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(panelScreen2Layout.createSequentialGroup()
+ .addGap(6, 6, 6)
+ .addComponent(checkBackground)
+ .addGap(106, 106, 106))
);
panelScreen2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerGrScale, spinnerGrThreshold, spinnerThreshold});
panelScreen2Layout.setVerticalGroup(
panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreen2Layout.createSequentialGroup()
- .addGap(4, 4, 4)
+ .addGroup(panelScreen2Layout.createSequentialGroup()
+ .addContainerGap()
.addComponent(checkBackground)
.addGap(2, 2, 2)
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -2421,6 +2630,8 @@ public class ScreenPanel extends Panel {
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerGrThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelGrThreshold))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(panelSlicing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@@ -2523,17 +2734,17 @@ public class ScreenPanel extends Panel {
try {
if (camera != null) {
String cameraConfigJson = null;
- if (usingServer){
- String cameraServerUrl = server.getUrl().substring(0, server.getUrl().length()-1) + "8";
- try (CameraServer srv = new CameraServer("CamServer", cameraServerUrl)){
+ if (usingServer) {
+ String cameraServerUrl = server.getUrl().substring(0, server.getUrl().length() - 1) + "8";
+ try (CameraServer srv = new CameraServer("CamServer", cameraServerUrl)) {
srv.initialize();
//TODO: replace into encodeMultiline
- cameraConfigJson = JsonSerializer.encode(srv.getConfig(cameraName), true);
+ cameraConfigJson = JsonSerializer.encode(srv.getConfig(cameraName), true);
}
-
+
} else {
String configFolder = (String) getContext().getClassByName("SfCamera").getMethod("getConfigFolder", new Class[]{}).invoke(null);
- Path configFile = Paths.get(configFolder, cameraName + ".json");
+ Path configFile = Paths.get(configFolder, cameraName + ".json");
cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
}
TextEditor editor = new TextEditor();
@@ -2601,7 +2812,7 @@ public class ScreenPanel extends Panel {
renderer.setProfile(Renderer.Profile.None);
} else {
renderer.removeOverlays(fitOv);
- fitOv = null;
+ fitOv = null;
}
} catch (Exception ex) {
showException(ex);
@@ -2632,13 +2843,13 @@ public class ScreenPanel extends Panel {
boolean laserOn = getLaserState();
if (laserOn) {
setLaserState(false);
- }
+ }
try {
System.out.println("Grabbing background for: " + cameraName);
- if (server!=null){
- server.captureBackground(5);
+ if (server != null) {
+ server.captureBackground(5);
} else {
- camera.captureBackground(5, 0);
+ camera.captureBackground(5, 0);
}
} finally {
if (laserOn) {
@@ -2680,14 +2891,17 @@ public class ScreenPanel extends Panel {
private void onChangeColormap(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onChangeColormap
try {
- if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) {
+ if ((camera != null) && (camera instanceof ColormapSource) && !updatingColormap) {
ColormapSource source = (ColormapSource) camera;
Color colorReticule = new Color(16, 16, 16);
Color colorMarker = new Color(128, 128, 128);
- source.getConfig().colormap = (Colormap)comboColormap.getSelectedItem();
- switch (source.getConfig().colormap){
+ source.getConfig().colormap = (Colormap) comboColormap.getSelectedItem();
+ switch (source.getConfig().colormap) {
case Grayscale:
case Inverted:
+ case Red:
+ case Green:
+ case Blue:
colorReticule = new Color(0, 192, 0);
colorMarker = new Color(64, 255, 64);
break;
@@ -2700,25 +2914,25 @@ public class ScreenPanel extends Panel {
renderer.setPenReticle(new Pen(colorReticule));
renderer.setPenProfile(new Pen(colorReticule, 0));
renderer.setPenMarker(new Pen(colorMarker, 2));
- renderer.setShowReticle(false);
+ renderer.setShowReticle(false);
checkReticle();
source.getConfig().colormapAutomatic = buttonAutomatic.isSelected();
source.getConfig().colormapMin = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMin.getValue();
source.getConfig().colormapMax = buttonFullRange.isSelected() ? Double.NaN : (Integer) spinnerMax.getValue();
- try{
+ try {
source.getConfig().save();
- } catch (Exception ex){
+ } catch (Exception ex) {
Logger.getLogger(ScreenPanel.class.getName()).log(Level.WARNING, null, ex);
}
- source.refresh();
+ source.refresh();
if (buttonPause.isSelected()) {
updatePause();
}
updateColormap();
}
- } catch (Exception ex) {
+ } catch (Exception ex) {
showException(ex);
- }
+ }
}//GEN-LAST:event_onChangeColormap
private void onChangeColormapRange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_onChangeColormapRange
@@ -2762,7 +2976,7 @@ public class ScreenPanel extends Panel {
ChannelInteger setpoint = null;
try {
int index = comboScreen.getSelectedIndex();
- if (cameraName.contains("DSRM")){
+ if (cameraName.contains("DSRM")) {
setpoint = new ChannelInteger(null, cameraName + ":POSITION_SP");
} else {
setpoint = new ChannelInteger(null, cameraName + ":SET_SCREEN1_POS");
@@ -2826,7 +3040,7 @@ public class ScreenPanel extends Panel {
private void spinnerThresholdonChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerThresholdonChange
if (!updatingServerControls) {
try {
- if ((server!=null) && (server.isStarted())) {
+ if ((server != null) && (server.isStarted())) {
server.setThreshold((Double) spinnerThreshold.getValue());
}
} catch (Exception ex) {
@@ -2837,7 +3051,7 @@ public class ScreenPanel extends Panel {
}//GEN-LAST:event_spinnerThresholdonChange
private void checkBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBackgroundActionPerformed
- if (server!=null){
+ if (server != null) {
if (!updatingServerControls) {
try {
if (server.isStarted()) {
@@ -2860,7 +3074,7 @@ public class ScreenPanel extends Panel {
private void checkThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkThresholdActionPerformed
if (!updatingServerControls) {
try {
- if ((server!=null) && (server.isStarted())) {
+ if ((server != null) && (server.isStarted())) {
spinnerThreshold.setVisible(checkThreshold.isSelected());
server.setThreshold(checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null);
}
@@ -2906,21 +3120,20 @@ public class ScreenPanel extends Panel {
private void checkGoodRegionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkGoodRegionActionPerformed
if (!updatingServerControls) {
try {
- if ((server!=null) && (server.isStarted())) {
- spinnerGrScale.setVisible(checkGoodRegion.isSelected()); labelGrScale.setVisible(spinnerGrScale.isVisible());
- spinnerGrThreshold.setVisible(checkGoodRegion.isSelected()); labelGrThreshold.setVisible(spinnerGrThreshold.isVisible());
- if (checkGoodRegion.isSelected()){
- server.setGoodRegion( ((Number)spinnerGrThreshold.getValue()).doubleValue(), ((Number)spinnerGrScale.getValue()).doubleValue() );
+ if ((server != null) && (server.isStarted())) {
+ goodRegion = checkGoodRegion.isSelected();
+ setGoodRegionOptionsVisible(goodRegion);
+ if (goodRegion) {
+ server.setGoodRegion(((Number) spinnerGrThreshold.getValue()).doubleValue(), ((Number) spinnerGrScale.getValue()).doubleValue());
} else {
server.setGoodRegion(null);
- }
- goodRegion = checkGoodRegion.isSelected();
+ }
}
} catch (Exception ex) {
showException(ex);
ex.printStackTrace();
updateServerControls();
- }
+ }
}
}//GEN-LAST:event_checkGoodRegionActionPerformed
@@ -2928,7 +3141,7 @@ public class ScreenPanel extends Panel {
if (!updatingServerControls) {
try {
if ((server != null) && (server.isStarted())) {
- server.setGoodRegion( (Double)spinnerGrThreshold.getValue(), (Double)spinnerGrScale.getValue() );
+ server.setGoodRegion((Double) spinnerGrThreshold.getValue(), (Double) spinnerGrScale.getValue());
}
} catch (Exception ex) {
showException(ex);
@@ -2938,19 +3151,52 @@ public class ScreenPanel extends Panel {
}//GEN-LAST:event_spinnerGrThresholdonChange
private void btFixColormapRangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFixColormapRangeActionPerformed
+ try {
+ updatingColormap = true;
+ ArrayProperties properties = currentFrame.data.getProperties();
+ spinnerMax.setValue(properties.max.intValue());
+ spinnerMin.setValue(properties.min.intValue());
+ buttonManual.setSelected(true);
+ } catch (Exception ex) {
+ showException(ex);
+ } finally {
+ updatingColormap = false;
+ onChangeColormap(null);
+ }
+ }//GEN-LAST:event_btFixColormapRangeActionPerformed
+
+ private void checkSlicingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkSlicingActionPerformed
+ if (!updatingServerControls) {
try {
- updatingColormap = true;
- ArrayProperties properties = currentFrame.data.getProperties();
- spinnerMax.setValue(properties.max.intValue());
- spinnerMin.setValue(properties.min.intValue());
- buttonManual.setSelected(true);
+ if ((server != null) && (server.isStarted())) {
+ slicing = checkSlicing.isSelected();
+ setSlicingOptionsVisible(slicing);
+ if (slicing) {
+ server.setSlicing((Integer) spinnerSlNumber.getValue(), (Double) spinnerSlScale.getValue(), spinnerSlOrientation.getValue().toString());
+ } else {
+ server.setSlicing(null);
+ }
+ }
} catch (Exception ex) {
showException(ex);
- } finally{
- updatingColormap = false;
- onChangeColormap(null);
+ ex.printStackTrace();
+ updateServerControls();
}
- }//GEN-LAST:event_btFixColormapRangeActionPerformed
+ }
+ }//GEN-LAST:event_checkSlicingActionPerformed
+
+ private void spinnerSlicingChange(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerSlicingChange
+ if (!updatingServerControls) {
+ try {
+ if ((server != null) && (server.isStarted())) {
+ server.setSlicing((Integer) spinnerSlNumber.getValue(), (Double) spinnerSlScale.getValue(), spinnerSlOrientation.getValue().toString());
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ updateServerControls();
+ }
+ }
+ }//GEN-LAST:event_spinnerSlicingChange
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btFixColormapRange;
@@ -2982,6 +3228,7 @@ public class ScreenPanel extends Panel {
private javax.swing.JCheckBox checkBackground;
private javax.swing.JCheckBox checkGoodRegion;
private javax.swing.JCheckBox checkHistogram;
+ private javax.swing.JCheckBox checkSlicing;
private javax.swing.JCheckBox checkThreshold;
private javax.swing.JComboBox comboCameras;
private javax.swing.JComboBox comboColormap;
@@ -3003,15 +3250,22 @@ public class ScreenPanel extends Panel {
private javax.swing.JLabel labelGrThreshold;
private javax.swing.JLabel labelMax;
private javax.swing.JLabel labelMin;
+ private javax.swing.JLabel labelSlNumber;
+ private javax.swing.JLabel labelSlOrientation;
+ private javax.swing.JLabel labelSlScale;
private javax.swing.JPanel panelScreen;
private javax.swing.JPanel panelScreen1;
private javax.swing.JPanel panelScreen2;
+ private javax.swing.JPanel panelSlicing;
private ch.psi.pshell.swing.ValueSelection pauseSelection;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JSpinner spinnerGrScale;
private javax.swing.JSpinner spinnerGrThreshold;
private javax.swing.JSpinner spinnerMax;
private javax.swing.JSpinner spinnerMin;
+ private javax.swing.JSpinner spinnerSlNumber;
+ private javax.swing.JSpinner spinnerSlOrientation;
+ private javax.swing.JSpinner spinnerSlScale;
private javax.swing.JSpinner spinnerThreshold;
private javax.swing.JTextField textState;
private ch.psi.pshell.swing.DeviceValuePanel valueFilter;
diff --git a/script/Alignment/Gun_solenoid_alignment.py b/script/Alignment/Gun_solenoid_alignment.py
index cec20c0..209c64e 100755
--- a/script/Alignment/Gun_solenoid_alignment.py
+++ b/script/Alignment/Gun_solenoid_alignment.py
@@ -14,7 +14,12 @@ do_elog = True
dry_run = False
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
camera_name = "SINEG01-DSCR190"
+bpm_name = "SINEG01-DBPM340"
use_good_region=False
+magnets = ["SINEG01-MCRX120","SINEG01-MCRY120",
+ "SINEG01-MQUA140","SINEG01-MQUA150",
+ "SINEG01-MCRX160","SINEG01-MCRY160",
+ "SINEG01-MCRX180","SINEG01-MCRY180"]
if not is_panel:
source = "server" # "server", "camtool", "bpm" or "direct"
@@ -55,7 +60,11 @@ print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_
setup_camera_scan()
-#switch_off_magnets()
+if not dry_run:
+ #magnet_values = []
+ #for magnet in magnets:
+ # magnet_values.append(caget (magnet + ":I-SET"))
+ switch_off_magnets( magnets )
# add here gun phase setting see wiki page
diff --git a/script/Alignment/Laser_gun_alignment.py b/script/Alignment/Laser_gun_alignment.py
index b3bf26f..1bcfe9d 100755
--- a/script/Alignment/Laser_gun_alignment.py
+++ b/script/Alignment/Laser_gun_alignment.py
@@ -5,7 +5,8 @@
# Procedure:
# switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement
- # change the current of the gun soleoid
+ # cycle the gun soleoid
+ # increase gun phase by 60 deg - RF focussing
# look at the centroid position (BPM or screen) downstream of the gun.
import datetime
@@ -14,17 +15,22 @@ do_elog = True
dry_run = False
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
camera_name = "SINEG01-DSCR190"
+bpm_name = "SINEG01-DBPM340"
use_good_region=False
+magnets = ["SINEG01-MCRX120","SINEG01-MCRY120",
+ "SINEG01-MQUA140","SINEG01-MQUA150",
+ "SINEG01-MCRX160","SINEG01-MCRY160",
+ "SINEG01-MCRX180","SINEG01-MCRY180"]
if not is_panel:
source = "server" # "server", "camtool", "bpm" or "direct"
- phi1= 95.0
- phi2 = 100.0
+ phi1= 105.0
+ phi2 = 115.0
dphi = 1.0
- settling_time = 0.1
+ settling_time = 0.15
plot_image = False
- number_images = 5
+ number_images = 2
use_background = True
multiple_background = False
number_backgrounds = 5
@@ -55,8 +61,12 @@ print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images
setup_camera_scan()
-
-#switch_off_magnets()
+
+if not dry_run:
+ #magnet_values = []
+ #for magnet in magnets:
+ # magnet_values.append(caget (magnet + ":I-SET"))
+ switch_off_magnets( magnets )
# add here gun phase setting see wiki page
@@ -107,9 +117,9 @@ set_attribute(path, "Plot index", centroid_plot_index)
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
log_msg = "Data file: " + get_exec_pars().path
- log_msg = log_msg + "\nI1: " + str(I1)
- log_msg = log_msg + "\nI2: " + str(I2)
- log_msg = log_msg + "\ndI: " + str(dI)
+ log_msg = log_msg + "\nphi1: " + str(phi1)
+ log_msg = log_msg + "\nphi2: " + str(phi2)
+ log_msg = log_msg + "\ndphi: " + str(dphi)
log_msg = log_msg + "\nSettling time: " + str(settling_time)
log_msg = log_msg + "\nImages: " + str(number_images)
log_msg = log_msg + "\nBackground: enabled=" + str(use_background) + " multiple=" + str(multiple_background) + " number=" + str(number_backgrounds)
diff --git a/script/RFscan/GunEnergyScan.py b/script/RFscan/GunEnergyScan.py
index 69ce802..f8592b2 100644
--- a/script/RFscan/GunEnergyScan.py
+++ b/script/RFscan/GunEnergyScan.py
@@ -89,7 +89,7 @@ def after_sample(record, scan):
#The scan loop
try:
phase.write(start)
- time.sleep(1.0)
+ time.sleep(2.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py
index d8fc992..73e887e 100644
--- a/script/RFscan/phase_scan_caqtdm.py
+++ b/script/RFscan/phase_scan_caqtdm.py
@@ -93,7 +93,9 @@ finally:
V.close()
P.close()
x.close()
-phase_offset = 90.0 - ph_crest # should take into account chicane delays which will be stored in :GET-VSUM-PHASE-OFFSET-CORR
+#phase_corr = caget(station + "-RSYS:GET-VSUM-PHASE-OFFSET-CORR")
+#phase_offset = 90.0 - ph_crest - phase_corr
+phase_offset = 90.0 - ph_crest
amplitude_scale = fit_amplitude / Ampl
power_scale = Power / fit_amplitude**2 if fit_amplitude != 0 else 0.0
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
@@ -108,4 +110,4 @@ if do_elog:
log_msg = log_msg + "Amplitude scale: %0.3f" % amplitude_scale + " MV \n"
log_msg = log_msg + "Power scale: %0.3f" % power_scale + " MW/MV^2"
attachments = get_plot_snapshots()
- elog(title, log_msg, attachments)
\ No newline at end of file
+ elog(title, log_msg, attachments)
diff --git a/script/local.py b/script/local.py
index 73b84b1..14d2f2e 100755
--- a/script/local.py
+++ b/script/local.py
@@ -34,7 +34,7 @@ def is_laser_on():
def ccr(magnet):
while caget(magnet+ ":I-COMP") > 0:
sleep(0.5)
-
+
def switch_off_magnets(magnets = None):
if magnets is None:
magnets = [ "SINEG01-MCRX120","SINEG01-MCRY120",
@@ -374,12 +374,12 @@ def check_camtool():
# Camera scans
###################################################################################################
-# mode = "server", "camtool", "bpm" or "direct"
+# source = "server", "camtool", "bpm" or "direct"
def setup_camera_scan():
- global mode, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run, laser_was_on
+ global source, camera_name, bpm_name, number_images, use_background, multiple_background, number_backgrounds, dry_run, laser_was_on
laser_was_on = is_laser_on()
multiple_background = multiple_background and use_background
- if mode == "server":
+ if source == "server":
cam_server.start(camera_name)
if use_background:
if not dry_run:
@@ -390,7 +390,7 @@ def setup_camera_scan():
else:
cam_server.setBackgroundSubtraction(False)
- elif mode == "camtool":
+ elif source == "camtool":
#kill_camtool()
check_camtool()
if use_background:
@@ -403,7 +403,7 @@ def setup_camera_scan():
else:
if source == "bpm":
run("Devices/BpmStats")
- add_device(BpmStats("image_stats", camera_name), True)
+ add_device(BpmStats("image_stats", bpm_name), True)
multiple_background = False
use_background = False
else:
@@ -422,13 +422,15 @@ def setup_camera_scan():
laser_on()
def before_sample_camera_scan():
- global mode, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
- if mode == "server":
+ global source, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
+ if source == "server":
if multiple_background:
bg = cam_server.captureBackground(number_backgrounds)
wait_cam_server_background(bg)
+ if not dry_run:
+ laser_on()
wait_cam_server_message(number_images)
- elif mode == "camtool":
+ elif source == "camtool":
if multiple_background:
camtool.stop()
camtool.grabBackground(camera_name, number_backgrounds)
@@ -448,12 +450,12 @@ def after_sample_camera_scan():
laser_off()
def get_camera_scan_sensors():
- global mode, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
- if mode == "server":
+ global source, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
+ if source == "server":
sensors = get_cam_server_stats(number_images, good_region=use_good_region)
if plot_image:
sensors.append(cam_server.getDataMatrix())
- elif mode == "camtool":
+ elif source == "camtool":
sensors = get_camtool_stats(number_images, good_region=use_good_region)
if plot_image:
sensors.append(camtool.getDataMatrix())
@@ -464,10 +466,10 @@ def get_camera_scan_sensors():
return sensors
def end_camera_scan():
- global mode, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run, laser_was_on
- #if mode == "server": cam_server.stop()
- #elif mode == "camtool": camtool.stop()
- #elif mode == "camtool": camtool.stop()
+ global source, camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run, laser_was_on
+ #if source == "server": cam_server.stop()
+ #elif source == "camtool": camtool.stop()
+ #elif source == "camtool": camtool.stop()
#else: image_stats.stop()
if not dry_run:
if laser_was_on: