diff --git a/config/config.properties b/config/config.properties
index ed95f2e..2a63ffe 100755
--- a/config/config.properties
+++ b/config/config.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 16:28:05 CET 2017
+#Mon Feb 26 14:07:13 CET 2018
autoSaveScanData=true
createSessionFiles=false
dataLayout=default
@@ -14,7 +14,7 @@ devicePoolFile={config}/devices.properties
deviceUpdateStrategyFile={config}/update.properties
hostName=
instanceName=OP
-logDaysToLive=-1
+logDaysToLive=30
logLevel=Fine
logLevelConsole=Off
logPath={logs}/{date}_{time}
diff --git a/devices/Beam phase.properties b/devices/Beam phase.properties
index 6ebc4e9..0a1c38a 100644
--- a/devices/Beam phase.properties
+++ b/devices/Beam phase.properties
@@ -1,9 +1,9 @@
-#Tue Dec 19 08:09:06 CET 2017
+#Mon Mar 05 09:04:33 CET 2018
maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
-rotation=false
+rotation=true
scale=1.0
unit=deg
diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index 0a6b741..465a681 100644
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,19 +1,19 @@
-#Wed Jan 17 12:03:42 CET 2018
+#Mon Mar 05 21:23:13 CET 2018
\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=9280.0
-colormapMin=77.0
+colormapMax=18000.0
+colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=494
-imageWidth=659
+imageHeight=1200
+imageWidth=1246
invert=false
-regionStartX=0
-regionStartY=0
+regionStartX=304
+regionStartY=8
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -25,8 +25,8 @@ rotationCrop=false
scale=1.0
serverURL=localhost\:10000
spat=
-spatialCalOffsetX=-50.03909304143862
-spatialCalOffsetY=-50.048875855327466
+spatialCalOffsetX=-50.01953888237593
+spatialCalOffsetY=-50.02315886984715
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalUnits=null
diff --git a/devices/WireScanner motor.properties b/devices/WireScanner motor.properties
index 6749186..d66a230 100644
--- a/devices/WireScanner motor.properties
+++ b/devices/WireScanner motor.properties
@@ -1,12 +1,12 @@
-#Tue Nov 21 11:59:54 CET 2017
-defaultSpeed=4000.0
+#Mon Feb 19 17:21:23 CET 2018
+defaultSpeed=141.4213562373095
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=8000.0
-maxValue=60528.0
+maxValue=51500.0
minSpeed=50.0
-minValue=-47999.0
+minValue=-56100.0
offset=0.0
precision=2
resolution=0.1
diff --git a/devices/cam_server.properties b/devices/cam_server.properties
index a39f5ac..a21294c 100644
--- a/devices/cam_server.properties
+++ b/devices/cam_server.properties
@@ -1,4 +1,4 @@
-#Wed Dec 20 15:55:53 CET 2017
+#Wed Feb 14 07:23:04 CET 2018
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
diff --git a/devices/scanner.properties b/devices/scanner.properties
new file mode 100644
index 0000000..d0e3fa1
--- /dev/null
+++ b/devices/scanner.properties
@@ -0,0 +1,9 @@
+#Tue Feb 06 17:00:47 CET 2018
+maxValue=NaN
+minValue=NaN
+offset=0.0
+precision=-1
+resolution=NaN
+rotation=false
+scale=1.0
+unit=null
diff --git a/devices/test/positioner.properties b/devices/test/positioner.properties
new file mode 100644
index 0000000..250d915
--- /dev/null
+++ b/devices/test/positioner.properties
@@ -0,0 +1,9 @@
+#Fri Jan 26 14:32:22 CET 2018
+maxValue=NaN
+minValue=NaN
+offset=0.0
+precision=-1
+resolution=NaN
+rotation=false
+scale=1.0
+unit=null
diff --git a/plugins/Correlation.form b/plugins/Correlation.form
index 5ce1397..9a81870 100644
--- a/plugins/Correlation.form
+++ b/plugins/Correlation.form
@@ -20,7 +20,7 @@
-
+
@@ -50,7 +50,12 @@
-
+
+
+
+
+
+
@@ -63,23 +68,23 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
@@ -92,12 +97,14 @@
+
+
-
-
+
+
@@ -112,7 +119,7 @@
-
+
@@ -127,7 +134,7 @@
-
+
@@ -197,11 +204,6 @@
-
-
-
-
-
@@ -237,6 +239,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/Correlation.java b/plugins/Correlation.java
index 7077732..0f88f3c 100644
--- a/plugins/Correlation.java
+++ b/plugins/Correlation.java
@@ -17,7 +17,7 @@ public class Correlation extends Panel {
public Correlation() {
initComponents();
- this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, checkBS});
+ this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
}
@@ -34,8 +34,15 @@ public class Correlation extends Panel {
textDevY.setText(App.getArgumentValue("dy"));
}
try{
- if (App.hasArgument("bs")) {
- checkBS.setSelected(Boolean.valueOf(App.getArgumentValue("bs")));
+ if (App.hasArgument("dxtype")) {
+ comboTypeX.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dxtype")));
+ }
+ } catch (Exception ex){
+ System.err.println(ex.getMessage());
+ }
+ try{
+ if (App.hasArgument("dytype")) {
+ comboTypeY.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dytype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
@@ -110,7 +117,8 @@ public class Correlation extends Panel {
textDevY.setEnabled(state==State.Ready);
spinnerInterval.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
- checkBS.setEnabled(state==State.Ready);
+ comboTypeX.setEnabled(state==State.Ready);
+ comboTypeY.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
@@ -153,13 +161,14 @@ public class Correlation extends Panel {
buttonStart = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
- checkBS = new javax.swing.JCheckBox();
jLabel6 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
+ comboTypeX = new javax.swing.JComboBox();
+ comboTypeY = new javax.swing.JComboBox();
plot.setTitle("");
@@ -192,8 +201,6 @@ public class Correlation extends Panel {
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
- checkBS.setText("Beam synchronous");
-
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Liner fit:");
@@ -211,10 +218,18 @@ public class Correlation extends Panel {
checkQuadratic.setText("Quadratic fit");
+ comboTypeX.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
+
+ comboTypeY.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
+
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -227,21 +242,20 @@ public class Correlation extends Panel {
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(textDevX, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(textDevY, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(checkBS)
- .addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(checkLinear)
- .addComponent(checkQuadratic))
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
+ .addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
+ .addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
+ .addComponent(checkLinear)
+ .addComponent(checkQuadratic))
+ .addContainerGap())
+ .addComponent(textDevX)
+ .addComponent(textDevY)))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
@@ -250,7 +264,7 @@ public class Correlation extends Panel {
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textDevX, textDevY, textLinear, textQuadratic});
+ jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textLinear, textQuadratic});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -260,11 +274,13 @@ public class Correlation extends Panel {
.addComponent(jLabel1)
.addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(checkBS)
+ .addGap(3, 3, 3)
+ .addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
@@ -277,7 +293,7 @@ public class Correlation extends Panel {
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkQuadratic)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
@@ -289,7 +305,7 @@ public class Correlation extends Panel {
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(45, 45, 45))
);
@@ -302,7 +318,7 @@ public class Correlation extends Panel {
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))
+ .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -331,12 +347,13 @@ public class Correlation extends Panel {
args.put("dy", textDevY.getText());
args.put("interval", spinnerInterval.getValue());
args.put("window", spinnerWindow.getValue());
- args.put("bs", checkBS.isSelected());
+ args.put("dxtype", comboTypeX.getSelectedIndex());
+ args.put("dytype", comboTypeY.getSelectedIndex());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("p", plot);
- runAsync("Correlation/Correlation", args).handle((ok, ex) -> {
+ runAsync("Correlation/Correlation2", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
@@ -352,9 +369,10 @@ public class Correlation extends Panel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonStart;
- private javax.swing.JCheckBox checkBS;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
+ private javax.swing.JComboBox comboTypeX;
+ private javax.swing.JComboBox comboTypeY;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
diff --git a/plugins/Correlation2.form b/plugins/Correlation2.form
deleted file mode 100644
index 9a81870..0000000
--- a/plugins/Correlation2.form
+++ /dev/null
@@ -1,267 +0,0 @@
-
-
-
diff --git a/plugins/Correlation2.java b/plugins/Correlation2.java
deleted file mode 100644
index fc3e4b1..0000000
--- a/plugins/Correlation2.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
- */
-
-import ch.psi.pshell.plot.Plot;
-import ch.psi.pshell.ui.App;
-import ch.psi.pshell.ui.Panel;
-import ch.psi.utils.State;
-import java.awt.Component;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- *
- */
-public class Correlation2 extends Panel {
-
- public Correlation2() {
- initComponents();
- this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
- plot.getAxis(Plot.AxisId.X).setLabel(null);
- plot.getAxis(Plot.AxisId.Y).setLabel(null);
- }
-
- //Overridable callbacks
- @Override
- public void onInitialize(int runCount) {
- super.onInitialize(runCount);
- this.startTimer(100, 10);
- if (App.hasArgument("dx")) {
- textDevX.setText(App.getArgumentValue("dx"));
- }
- if (App.hasArgument("dy")) {
- textDevY.setText(App.getArgumentValue("dy"));
- }
- try{
- if (App.hasArgument("dxtype")) {
- comboTypeX.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dxtype")));
- }
- } catch (Exception ex){
- System.err.println(ex.getMessage());
- }
- try{
- if (App.hasArgument("dytype")) {
- comboTypeY.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dytype")));
- }
- } catch (Exception ex){
- System.err.println(ex.getMessage());
- }
- try{
- if (App.hasArgument("interval")) {
- spinnerInterval.setValue(Double.valueOf(App.getArgumentValue("interval")));
- }
- } catch (Exception ex){
- System.err.println(ex.getMessage());
- }
- try{
- if (App.hasArgument("window")) {
- spinnerWindow.setValue(Integer.valueOf(App.getArgumentValue("window")));
- }
- } catch (Exception ex){
- System.err.println(ex.getMessage());
- }
- }
-
- @Override
- protected void onTimer(){
- if (isRunning()){
- updateResults();
- }
- }
-
- //DecimalFormat formatter = new DecimalFormat("0.##E0");
- void updateResults(){
- try{
- textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
- } catch (Exception ex){
- textCorrelation.setText("");
- }
-
- if (checkLinear.isSelected()){
- try{
- List pars = (List)getContext().getInterpreterVariable("pars_lin");
- //textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
- textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
- } catch (Exception ex){
- textLinear.setText("");
- }
- }
-
- if (checkQuadratic.isSelected()){
- try{
- List pars = (List)getContext().getInterpreterVariable("pars_quad");
- //textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
- textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
- //textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
-
- } catch (Exception ex){
- textQuadratic.setText("");
- }
- }
- }
-
- @Override
- public void onStateChange(State state, State former) {
- buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
- if (isRunning()){
- if (state==State.Ready){
- buttonStart.setText("Start");
- }
- } else {
- if (state==State.Busy){
- buttonStart.setText("Stop");
- }
- }
- textDevX.setEnabled(state==State.Ready);
- textDevY.setEnabled(state==State.Ready);
- spinnerInterval.setEnabled(state==State.Ready);
- spinnerWindow.setEnabled(state==State.Ready);
- comboTypeX.setEnabled(state==State.Ready);
- comboTypeY.setEnabled(state==State.Ready);
- checkLinear.setEnabled(state==State.Ready);
- checkQuadratic.setEnabled(state==State.Ready);
-
- if ((former==State.Initializing) && (state == State.Ready)){
- if (App.hasArgument("start")) {
- buttonStartActionPerformed(null);
- }
- }
-
- }
-
- boolean isRunning(){
- return buttonStart.getText().equals("Stop");
- }
-
- @Override
- public void onExecutedFile(String fileName, Object result) {
- }
-
-
- //Callback to perform update - in event thread
- @Override
- protected void doUpdate() {
- }
-
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- plot = new ch.psi.pshell.plot.LinePlotJFree();
- jPanel1 = new javax.swing.JPanel();
- jLabel1 = new javax.swing.JLabel();
- textDevX = new javax.swing.JTextField();
- textDevY = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- spinnerInterval = new javax.swing.JSpinner();
- jLabel4 = new javax.swing.JLabel();
- spinnerWindow = new javax.swing.JSpinner();
- buttonStart = new javax.swing.JButton();
- jLabel5 = new javax.swing.JLabel();
- textCorrelation = new javax.swing.JTextField();
- jLabel6 = new javax.swing.JLabel();
- textLinear = new javax.swing.JTextField();
- jLabel7 = new javax.swing.JLabel();
- textQuadratic = new javax.swing.JTextField();
- checkLinear = new javax.swing.JCheckBox();
- checkQuadratic = new javax.swing.JCheckBox();
- comboTypeX = new javax.swing.JComboBox();
- comboTypeY = new javax.swing.JComboBox();
-
- plot.setTitle("");
-
- jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- jLabel1.setText("X device:");
-
- jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- jLabel2.setText("Y device:");
-
- jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- jLabel3.setText("Interval (s):");
-
- spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.1d), Double.valueOf(0.001d), null, Double.valueOf(1.0d)));
-
- jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- jLabel4.setText("Window size:");
-
- spinnerWindow.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(50), Integer.valueOf(3), null, Integer.valueOf(1)));
-
- buttonStart.setText("Start");
- buttonStart.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- buttonStartActionPerformed(evt);
- }
- });
-
- jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
- jLabel5.setText("Correlation:");
-
- textCorrelation.setEditable(false);
- textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
-
- jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
- jLabel6.setText("Liner fit:");
-
- textLinear.setEditable(false);
- textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
-
- jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
- jLabel7.setText("Quadratric fit:");
-
- textQuadratic.setEditable(false);
- textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
-
- checkLinear.setSelected(true);
- checkLinear.setText("Linear fit");
-
- checkQuadratic.setText("Quadratic fit");
-
- comboTypeX.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
-
- comboTypeY.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
-
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
- .addComponent(checkLinear)
- .addComponent(checkQuadratic))
- .addContainerGap())
- .addComponent(textDevX)
- .addComponent(textDevY)))
- );
-
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
-
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerWindow});
-
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
-
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textLinear, textQuadratic});
-
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(3, 3, 3)
- .addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel4)
- .addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addComponent(checkLinear)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(checkQuadratic)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
- .addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel5))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
- .addComponent(jLabel6)
- .addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
- .addComponent(jLabel7)
- .addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
- .addComponent(buttonStart)
- .addGap(45, 45, 45))
- );
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createSequentialGroup()
- .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addContainerGap())))
- );
- }// //GEN-END:initComponents
-
- private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
- try {
- if (isRunning()){
- abort();
- updateResults();
- //buttonStart.setText("Start");
- } else {
- textCorrelation.setText("");
- textLinear.setText("");
- textQuadratic.setText("");
- HashMap args = new HashMap();
- args.put("dx", textDevX.getText());
- args.put("dy", textDevY.getText());
- args.put("interval", spinnerInterval.getValue());
- args.put("window", spinnerWindow.getValue());
- args.put("dxtype", comboTypeX.getSelectedIndex());
- args.put("dytype", comboTypeY.getSelectedIndex());
- args.put("linear_fit", checkLinear.isSelected());
- args.put("quadratic_fit", checkQuadratic.isSelected());
-
- args.put("p", plot);
- runAsync("Correlation/Correlation2", args).handle((ok, ex) -> {
- if (ex != null) {
- ex.printStackTrace();
- }
- return ok;
- });
- ///buttonStart.setText("Stop");
- }
-
- } catch (Exception ex) {
- showException(ex);
- }
- }//GEN-LAST:event_buttonStartActionPerformed
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton buttonStart;
- private javax.swing.JCheckBox checkLinear;
- private javax.swing.JCheckBox checkQuadratic;
- private javax.swing.JComboBox comboTypeX;
- private javax.swing.JComboBox comboTypeY;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- private javax.swing.JPanel jPanel1;
- private ch.psi.pshell.plot.LinePlotJFree plot;
- private javax.swing.JSpinner spinnerInterval;
- private javax.swing.JSpinner spinnerWindow;
- private javax.swing.JTextField textCorrelation;
- private javax.swing.JTextField textDevX;
- private javax.swing.JTextField textDevY;
- private javax.swing.JTextField textLinear;
- private javax.swing.JTextField textQuadratic;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/plugins/GunEnergyScan.form b/plugins/GunEnergyScan.form
index b0e8849..f6f57b0 100644
--- a/plugins/GunEnergyScan.form
+++ b/plugins/GunEnergyScan.form
@@ -380,6 +380,7 @@
+
diff --git a/plugins/GunEnergyScan.java b/plugins/GunEnergyScan.java
index 541c072..711dfad 100644
--- a/plugins/GunEnergyScan.java
+++ b/plugins/GunEnergyScan.java
@@ -37,7 +37,7 @@ public class GunEnergyScan extends Panel {
spinnerLatency.setEnabled(enabled);
spinnerDispersion.setEnabled(enabled);
spinnerEnergy.setEnabled(enabled);
- buttonPhaseSet.setEnabled(enabled && !buttonPhaseSet.getText().isEmpty());
+ buttonPhaseSet.setEnabled(enabled && !textRefPhase.getText().trim().isEmpty());
}
@Override
@@ -224,6 +224,7 @@ public class GunEnergyScan extends Panel {
jLabel1.setText("Ref phase:");
buttonPhaseSet.setText("Set");
+ buttonPhaseSet.setEnabled(false);
buttonPhaseSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPhaseSetActionPerformed(evt);
@@ -323,6 +324,7 @@ public class GunEnergyScan extends Panel {
try{
double phase = ((Number)ret).doubleValue();
textRefPhase.setText(String.format("%1.2f",phase));
+ buttonPhaseSet.setEnabled(true);
} catch (Exception e) {
showException(e);
}
diff --git a/plugins/ScreenPanel2.form b/plugins/ScreenPanel2.form
index a3e2931..c08702e 100644
--- a/plugins/ScreenPanel2.form
+++ b/plugins/ScreenPanel2.form
@@ -38,7 +38,7 @@
-
+
@@ -68,7 +68,7 @@
-
+
@@ -78,7 +78,7 @@
-
+
@@ -97,6 +97,7 @@
+
@@ -433,16 +434,27 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -483,6 +495,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -865,19 +887,13 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -885,61 +901,16 @@
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -977,30 +948,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1106,6 +1053,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1113,6 +1073,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/ScreenPanel2.java b/plugins/ScreenPanel2.java
index 20f2fd2..3278abb 100644
--- a/plugins/ScreenPanel2.java
+++ b/plugins/ScreenPanel2.java
@@ -18,6 +18,10 @@ import ch.psi.pshell.bs.StreamValue;
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.data.DataManager;
import ch.psi.pshell.device.Device;
+import ch.psi.pshell.device.Readable.ReadableArray;
+import ch.psi.pshell.device.Readable.ReadableNumber;
+import ch.psi.pshell.device.ReadableRegister.ReadableRegisterArray;
+import ch.psi.pshell.device.ReadableRegister.ReadableRegisterNumber;
import ch.psi.pshell.epics.ChannelInteger;
import ch.psi.pshell.epics.DiscretePositioner;
import ch.psi.pshell.epics.Epics;
@@ -40,11 +44,13 @@ import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.scripting.InterpreterResult;
import ch.psi.pshell.scripting.ScriptManager;
+import ch.psi.pshell.swing.DeviceValueChart;
import ch.psi.pshell.swing.ValueSelection;
import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener;
import ch.psi.utils.Arr;
import ch.psi.utils.ArrayProperties;
import ch.psi.utils.Convert;
+import ch.psi.utils.Str;
import ch.psi.utils.swing.Editor.EditorDialog;
import ch.psi.utils.swing.MainFrame;
import ch.psi.utils.swing.StandardDialog;
@@ -52,14 +58,19 @@ import ch.psi.utils.swing.StandardDialog.StandardDialogListener;
import ch.psi.utils.swing.SwingUtils.OptionResult;
import ch.psi.utils.swing.SwingUtils.OptionType;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
@@ -77,7 +88,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
@@ -133,6 +143,9 @@ public class ScreenPanel2 extends Panel {
String serverUrl;
String camServerUrl;
String instanceName;
+ Overlay titleOv = null;
+
+ String pipelineSuffix = "_sp";
Double getServerDouble(String name) {
return (Double) Convert.toDouble(server.getValue(name));
@@ -241,7 +254,7 @@ public class ScreenPanel2 extends Panel {
((JSpinner.DefaultEditor) editor).getTextField().setHorizontalAlignment(JTextField.RIGHT);
}
renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin"));
- setPersistedComponents(new Component[]{buttonServer, buttonDirect});
+ //setPersistedComponents(new Component[]{buttonServer, buttonDirect});
comboCameras.setEnabled(false);
comboType.setEnabled(false);
@@ -288,6 +301,9 @@ public class ScreenPanel2 extends Panel {
if (App.hasArgument("calc")) {
useServerStats = false;
}
+ if (App.hasArgument("suffix")) {
+ pipelineSuffix = App.getArgumentValue("suffix");
+ }
renderer.setProfileNormalized(true);
renderer.setShowProfileLimits(false);
@@ -301,8 +317,8 @@ public class ScreenPanel2 extends Panel {
}
});
- JMenuItem menuCameraConfig = new JMenuItem("Renderer Config");
- menuCameraConfig.addActionListener((ActionEvent e) -> {
+ JMenuItem menuRendererConfig = new JMenuItem("Renderer Parameters");
+ menuRendererConfig.addActionListener((ActionEvent e) -> {
try {
if (camera != null) {
this.showDeviceConfigDialog(camera, false);
@@ -312,6 +328,52 @@ public class ScreenPanel2 extends Panel {
}
});
+ JMenuItem menuCameraConfig = new JMenuItem("Camera Configurarion");
+ menuCameraConfig.addActionListener((ActionEvent e) -> {
+ try {
+ if (camera != null) {
+ String cameraConfigJson = null;
+ if (usingServer) {
+ String cameraServerUrl = (camServerUrl == null) ? server.getUrl().substring(0, server.getUrl().length() - 1) + "8" : camServerUrl;
+ try (CameraServer srv = new CameraServer("CamServer", cameraServerUrl)) {
+ srv.initialize();
+ //TODO: replace into encodeMultiline
+ 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");
+ cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
+ }
+ TextEditor configEditor = new TextEditor();
+ configEditor.setText(cameraConfigJson);
+ configEditor.setReadOnly(true);
+ configEditor.setTitle(cameraName);
+ EditorDialog dlg = configEditor.getDialog(getTopLevel(), false);
+ dlg.setSize(480, 640);
+ dlg.setVisible(true);
+ SwingUtils.centerComponent(getTopLevel(), dlg);
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ });
+
+
+
+ JMenuItem menuSetImageBufferSize = new JMenuItem("Set Stack Size...");
+ menuSetImageBufferSize.addActionListener((ActionEvent e) -> {
+ try {
+ String ret = SwingUtils.getString(getTopLevel(), "Enter size of image buffer: ", String.valueOf(imageBufferLenght));
+ if (ret!=null){
+ this.setImageBufferSize(Integer.valueOf(ret));
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ });
+
JMenuItem menuSaveStack = new JMenuItem("Save Stack");
menuSaveStack.addActionListener((ActionEvent e) -> {
try {
@@ -319,8 +381,8 @@ public class ScreenPanel2 extends Panel {
} catch (Exception ex) {
showException(ex);
}
- });
- menuSaveStack.setEnabled(imageBufferLenght > 0);
+ });
+
JMenuItem menuSetROI = new JMenuItem("Set ROI...");
menuSetROI.addActionListener((ActionEvent e) -> {
@@ -369,10 +431,13 @@ public class ScreenPanel2 extends Panel {
});
renderer.getPopupMenu().addSeparator();
+ renderer.getPopupMenu().add(menuRendererConfig);
renderer.getPopupMenu().add(menuCameraConfig);
- renderer.getPopupMenu().add(menuCalibrate);
+ renderer.getPopupMenu().add(menuSetImageBufferSize);
renderer.getPopupMenu().add(menuSaveStack);
renderer.getPopupMenu().addSeparator();
+ renderer.getPopupMenu().add(menuCalibrate);
+ renderer.getPopupMenu().addSeparator();
renderer.getPopupMenu().add(menuSetROI);
renderer.getPopupMenu().add(menuResetROI);
renderer.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
@@ -382,6 +447,8 @@ public class ScreenPanel2 extends Panel {
menuSetROI.setEnabled(server != null);
menuCalibrate.setVisible(server != null);
menuCalibrate.setEnabled((calibrationDialolg == null) || (!calibrationDialolg.isShowing()));
+ menuSaveStack.setEnabled(imageBufferLenght > 0);
+ menuSetImageBufferSize.setEnabled(!renderer.isPaused());
}
@Override
@@ -407,9 +474,9 @@ public class ScreenPanel2 extends Panel {
}
}
});
- imageBufferOverlay = new Text(renderer.getPenErrorText(), "", new Font("Verdana", Font.PLAIN, 12), new Point(-100, 20));
+ imageBufferOverlay = new Text(renderer.getPenErrorText(), "", new Font("Verdana", Font.PLAIN, 12), new Point(-100, 42));
imageBufferOverlay.setFixed(true);
- imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_TOP_RIGHT);
+ imageBufferOverlay.setAnchor(Overlay.ANCHOR_VIEWPORT_OR_IMAGE_TOP_RIGHT);
if (MainFrame.isDark()) {
textState.setDisabledTextColor(textState.getForeground());
}
@@ -603,6 +670,21 @@ public class ScreenPanel2 extends Panel {
}
}
+ void manageTitleOverlay() {
+ Overlay to = null;
+ if ((buttonTitle.isSelected()) && (cameraName != null)) {
+ Font font = new Font("Arial", Font.PLAIN, 28);
+ to = new Text(renderer.getPenErrorText(), cameraName, font, new Point(-SwingUtils.getTextSize(cameraName, renderer.getGraphics().getFontMetrics(font)).width - 14, 26));
+ to.setFixed(true);
+ to.setAnchor(Overlay.ANCHOR_VIEWPORT_OR_IMAGE_TOP_RIGHT);
+ }
+
+ synchronized (lockOverlays) {
+ renderer.updateOverlays(to, titleOv);
+ titleOv = to;
+ }
+ }
+
@Override
public void onStateChange(State state, State former) {
@@ -680,16 +762,21 @@ public class ScreenPanel2 extends Panel {
filter.close();
filter = null;
}
- if (renderer.isPaused()){
+ if (renderer.isPaused()) {
renderer.resume();
renderer.removeOverlay(imageBufferOverlay);
pauseSelection.setVisible(false);
+ panelCameraSelection.setVisible(true);
}
- }
+ }
+ manageTitleOverlay();
+ if (App.isDetached()) {
+ getTopLevel().setTitle(cameraName == null ? "ScreenPanel" : cameraName);
+ }
if (cameraName == null) {
return;
}
-
+
System.out.println("Setting camera: " + cameraName + " [" + (buttonServer.isSelected() ? "server" : "direct") + "]");
try {
if (buttonServer.isSelected()) {
@@ -710,8 +797,8 @@ public class ScreenPanel2 extends Panel {
System.out.println("Camera initialization OK");
if (server != null) {
//server.start(cameraName, false);
- String pipelineName = cameraName + "_sp";
- instanceName = cameraName + "_sp1";
+ String pipelineName = cameraName + pipelineSuffix;
+ instanceName = cameraName + pipelineSuffix +"1";
if (!server.getPipelines().contains(pipelineName)) {
System.out.println("Creating pipeline: " + pipelineName);
HashMap config = new HashMap<>();
@@ -734,7 +821,7 @@ public class ScreenPanel2 extends Panel {
}
camera.setBackgroundEnabled(checkBackground.isSelected());
}
- updateButtons();
+ updateButtons();
camera.getConfig().save();
renderer.setDevice(camera);
renderer.setAutoScroll(true);
@@ -1001,31 +1088,31 @@ public class ScreenPanel2 extends Panel {
}
boolean isCameraStopped() {
- if ((server != null) && !server.isStarted()){
+ if ((server != null) && !server.isStarted()) {
return true;
}
return ((camera == null) || camera.isClosed());
}
-
+
boolean updatingButtons;
- void updateButtons(){
+
+ void updateButtons() {
updatingButtons = true;
- try{
- boolean active = !isCameraStopped() ;//(camera != null);
- buttonArgs.setEnabled(active);
+ try {
+ boolean active = !isCameraStopped();//(camera != null);
buttonSave.setEnabled(active);
buttonGrabBackground.setEnabled(active);
buttonMarker.setEnabled(active);
buttonProfile.setEnabled(active);
buttonFit.setEnabled(active);
- buttonReticle.setEnabled(active && camera.getConfig().isCalibrated());
- buttonStreamData.setEnabled(active && (server!=null));
- buttonPause.setEnabled(active);
+ buttonReticle.setEnabled(active && camera.getConfig().isCalibrated());
+ buttonStreamData.setEnabled(active && (server != null));
+ buttonPause.setEnabled(active);
//buttonPause.setIcon(getIcon("Play"));
//buttonPause.setToolTipText("Resume");
//buttonPause.setIcon(getIcon("Pause"));
//buttonPause.setToolTipText("Pause");
-
+
if (renderer.isPaused() != buttonPause.isSelected()) {
buttonPause.setSelected(renderer.isPaused());
buttonPauseActionPerformed(null);
@@ -1037,8 +1124,8 @@ public class ScreenPanel2 extends Panel {
buttonMarker.setSelected(false);
}
buttonSave.setSelected(renderer.isSnapshotDialogVisible());
-
- } finally{
+
+ } finally {
updatingButtons = false;
}
}
@@ -1051,7 +1138,7 @@ public class ScreenPanel2 extends Panel {
}
}
- textState.setText((camera == null) ? "" : camera.getState().toString());
+ textState.setText((camera == null) ? "" : camera.getState().toString());
if (App.hasArgument("s")) {
try {
((Source) getDevice("image")).initialize();
@@ -1066,7 +1153,7 @@ public class ScreenPanel2 extends Panel {
}
updateZoom();
updateColormap();
- updateButtons();
+ updateButtons();
checkHistogram.setSelected((histogramDialog != null) && (histogramDialog.isShowing()));
}
@@ -1095,6 +1182,17 @@ public class ScreenPanel2 extends Panel {
return null;
}
+ void setImageBufferSize(int size) {
+ if (renderer.isPaused()) {
+ throw new RuntimeException("Cannot change buffer size whn paused");
+ }
+ synchronized (imageBuffer) {
+ imageBufferLenght = size;
+ imageBuffer.clear();
+ }
+
+ }
+
Overlay[][] getFitOverlays(Data data) {
Overlays.Polyline hgaussian = null;
Overlays.Polyline vgaussian = null;
@@ -1103,11 +1201,11 @@ public class ScreenPanel2 extends Panel {
Double xMean = null, xSigma = null, xNorm = null, xCom = null, xRms = null;
Double yMean = null, ySigma = null, yNorm = null, yCom = null, yRms = null;
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 height = data.getHeight();
+ int width = data.getWidth();
int profileSize = renderer.getProfileSize();
if ((useServerStats) && (server != null)) {
try {
@@ -1692,6 +1790,9 @@ public class ScreenPanel2 extends Panel {
manageUserOverlays(image, data);
}
}
+ if ((dataTableDialog != null) && (dataTableDialog.isShowing())) {
+ updateStreamData();
+ }
}
void saveSnapshot() throws Exception {
@@ -1936,7 +2037,6 @@ public class ScreenPanel2 extends Panel {
scrollPane.setPreferredSize(new Dimension(300, 400));
dataTableDialog.setContentPane(scrollPane);
dataTableDialog.pack();
- SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
dataTableDialog.setVisible(true);
dataTableDialog.addWindowListener(new WindowAdapter() {
@Override
@@ -1944,6 +2044,62 @@ public class ScreenPanel2 extends Panel {
dataTableModel = null;
}
});
+ dataTable.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ try {
+ int index = dataTable.getSelectedRow();
+ dataTable.setToolTipText(null);
+ if (index>1){
+ String id = String.valueOf(dataTable.getModel().getValueAt(index, 0));
+ String locator = String.valueOf(dataTable.getModel().getValueAt(0, 1));
+ dataTable.setToolTipText(locator + " " + id);
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(new StringSelection(locator+ " " + id), (Clipboard clipboard1, Transferable contents) -> {});
+ if ((e.getClickCount() == 2) && (!e.isPopupTrigger())) {
+ Object obj = getCurrentFrame().cache.getValue(id);
+ if (id.equals("image")) {
+ } else if (id.equals("processing_parameters")) {
+ Map pars = getProcessingParameters(getCurrentFrame().cache);
+ StringBuilder sb = new StringBuilder();
+ for (String key : pars.keySet()) {
+ sb.append(key).append(" = ").append(Str.toString(pars.get(key), 10)).append("\n");
+ }
+ SwingUtils.showMessage(dataTableDialog, "Processing Parameters", sb.toString());
+ } else if ((obj!=null) && (obj.getClass().isArray() || (obj instanceof Number))) {
+ DeviceValueChart chart = new DeviceValueChart();
+ Device dev = null;
+ if (obj.getClass().isArray()){
+ dev = new ReadableRegisterArray(new ReadableArray() {
+ @Override
+ public Object read() throws IOException, InterruptedException {
+ return Convert.toDouble(getCurrentFrame().cache.getValue(id));
+ }
+ @Override
+ public int getSize() {
+ return Array.getLength(getCurrentFrame().cache.getValue(id));
+ }
+ });
+ } else {
+ dev = new ReadableRegisterNumber(new ReadableNumber() {
+ @Override
+ public Object read() throws IOException, InterruptedException {
+ return Convert.toDouble(getCurrentFrame().cache.getValue(id));
+ }
+ });
+ }
+ dev.setPolling(1000);
+ chart.setDevice(dev);
+ JDialog dlg = SwingUtils.showDialog(dataTableDialog, cameraName +" " + id, null, chart);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }
+ });
+ SwingUtils.centerComponent(getTopLevel(), dataTableDialog);
}
}
@@ -1969,30 +2125,34 @@ public class ScreenPanel2 extends Panel {
dataTableModel.addRow(new Object[]{id, ""});
}
}
- 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()) {
- obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
- } else if (obj instanceof Double) {
- obj = Convert.roundDouble((Double) obj, 1);
- } else if (obj instanceof Float) {
- obj = Convert.roundDouble((Float) obj, 1);
+ Frame frame = getCurrentFrame();
+ if ((frame != null) && (frame.cache!=null)){
+ for (int i = 2; i < dataTableModel.getRowCount(); i++) {
+ String id = String.valueOf(dataTableModel.getValueAt(i, 0));
+ //Object obj = server.getValue(id);
+ Object obj = frame.cache.getValue(id);
+ if (obj != null) {
+ if (obj.getClass().isArray()) {
+ obj = obj.getClass().getComponentType().getSimpleName() + "[" + Array.getLength(obj) + "]";
+ } else if (obj instanceof Double) {
+ obj = Convert.roundDouble((Double) obj, 1);
+ } else if (obj instanceof Float) {
+ obj = Convert.roundDouble((Float) obj, 1);
+ }
}
+ dataTableModel.setValueAt(String.valueOf(obj), i, 1);
}
- dataTableModel.setValueAt(String.valueOf(obj), i, 1);
}
}
}
- ImageIcon getIcon(String name) {
+ ImageIcon getIcon(String name) {
ImageIcon ret = null;
try {
//Path path = Paths.get(getClass().getProtectionDomain().getCodeSource().getLocation().getPath(),"resources", name + ".png");
- String dir = getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + "resources/";
- if (new File(dir + name + ".png").exists()){
- ret =new javax.swing.ImageIcon(dir + name + ".png");
+ String dir = getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + "resources/";
+ if (new File(dir + name + ".png").exists()) {
+ ret = new javax.swing.ImageIcon(dir + name + ".png");
} else {
ret = new ImageIcon(ch.psi.pshell.ui.App.class.getResource("/ch/psi/pshell/ui/" + name + ".png"));
if (MainFrame.isDark()) {
@@ -2000,7 +2160,7 @@ public class ScreenPanel2 extends Panel {
ret = new ImageIcon(ch.psi.pshell.ui.App.class.getResource("/ch/psi/pshell/ui/dark/" + name + ".png"));
} catch (Exception e) {
}
- }
+ }
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -2051,6 +2211,7 @@ public class ScreenPanel2 extends Panel {
buttonServer = new javax.swing.JRadioButton();
buttonDirect = new javax.swing.JRadioButton();
textState = new javax.swing.JTextField();
+ filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
panelScreen = new javax.swing.JPanel();
valueScreen = new ch.psi.pshell.swing.DeviceValuePanel();
comboScreen = new javax.swing.JComboBox();
@@ -2075,15 +2236,9 @@ public class ScreenPanel2 extends Panel {
labelSlOrientation = new javax.swing.JLabel();
spinnerSlOrientation = new javax.swing.JSpinner();
topPanel = new javax.swing.JPanel();
- comboCameras = new javax.swing.JComboBox();
- jLabel1 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- comboType = new javax.swing.JComboBox();
toolBar = new javax.swing.JToolBar();
buttonSidePanel = new javax.swing.JToggleButton();
buttonStreamData = new javax.swing.JButton();
- buttonArgs = new javax.swing.JButton();
- jSeparator5 = new javax.swing.JToolBar.Separator();
buttonSave = new javax.swing.JToggleButton();
buttonGrabBackground = new javax.swing.JButton();
buttonPause = new javax.swing.JToggleButton();
@@ -2092,7 +2247,13 @@ public class ScreenPanel2 extends Panel {
buttonProfile = new javax.swing.JToggleButton();
buttonFit = new javax.swing.JToggleButton();
buttonReticle = new javax.swing.JToggleButton();
+ buttonTitle = new javax.swing.JToggleButton();
pauseSelection = new ch.psi.pshell.swing.ValueSelection();
+ panelCameraSelection = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ comboCameras = new javax.swing.JComboBox();
+ jLabel5 = new javax.swing.JLabel();
+ comboType = new javax.swing.JComboBox();
renderer = new ch.psi.pshell.imaging.Renderer();
setPreferredSize(new java.awt.Dimension(873, 600));
@@ -2352,15 +2513,23 @@ public class ScreenPanel2 extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(56, 56, 56))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(4, 4, 4)
- .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(buttonServer)
- .addComponent(buttonDirect)
- .addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel5Layout.createSequentialGroup()
+ .addComponent(textState, 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)
+ .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonServer)
+ .addComponent(buttonDirect)))
.addContainerGap())
);
@@ -2627,7 +2796,7 @@ public class ScreenPanel2 extends Panel {
.addComponent(panelScreen2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelScreen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelFilter, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
sidePanelLayout.setVerticalGroup(
sidePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -2643,30 +2812,10 @@ public class ScreenPanel2 extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(panelFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(panelFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- comboCameras.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
- comboCameras.setMaximumRowCount(30);
- comboCameras.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- comboCamerasActionPerformed(evt);
- }
- });
-
- jLabel1.setText("Camera:");
-
- jLabel5.setText("Type:");
-
- comboType.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
- comboType.setMaximumRowCount(30);
- comboType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Laser", "Electrons", "Photonics" }));
- comboType.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- comboTypeActionPerformed(evt);
- }
- });
-
toolBar.setFloatable(false);
toolBar.setRollover(true);
@@ -2695,22 +2844,6 @@ public class ScreenPanel2 extends Panel {
});
toolBar.add(buttonStreamData);
- buttonArgs.setIcon(getIcon("Data"));
- buttonArgs.setText(" ");
- buttonArgs.setToolTipText("Camera Setup");
- buttonArgs.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- buttonArgs.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- buttonArgsActionPerformed(evt);
- }
- });
- toolBar.add(buttonArgs);
-
- jSeparator5.setMaximumSize(new java.awt.Dimension(20, 32767));
- jSeparator5.setPreferredSize(new java.awt.Dimension(20, 0));
- jSeparator5.setRequestFocusEnabled(false);
- toolBar.add(jSeparator5);
-
buttonSave.setIcon(getIcon("Save"));
buttonSave.setText(" ");
buttonSave.setToolTipText("Save Snapshot");
@@ -2797,42 +2930,90 @@ public class ScreenPanel2 extends Panel {
});
toolBar.add(buttonReticle);
+ buttonTitle.setIcon(getIcon("Title"));
+ buttonTitle.setText(" ");
+ buttonTitle.setToolTipText("Show Camera Name");
+ buttonTitle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ buttonTitle.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonTitleActionPerformed(evt);
+ }
+ });
+ toolBar.add(buttonTitle);
+
pauseSelection.setDecimals(0);
+ jLabel1.setText("Camera:");
+
+ comboCameras.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
+ comboCameras.setMaximumRowCount(30);
+ comboCameras.setMinimumSize(new java.awt.Dimension(127, 27));
+ comboCameras.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ comboCamerasActionPerformed(evt);
+ }
+ });
+
+ jLabel5.setText("Type:");
+
+ comboType.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
+ comboType.setMaximumRowCount(30);
+ comboType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Laser", "Electrons", "Photonics" }));
+ comboType.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ comboTypeActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelCameraSelectionLayout = new javax.swing.GroupLayout(panelCameraSelection);
+ panelCameraSelection.setLayout(panelCameraSelectionLayout);
+ panelCameraSelectionLayout.setHorizontalGroup(
+ panelCameraSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelCameraSelectionLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1)
+ .addGap(0, 0, 0)
+ .addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel5)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(comboType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(0, 0, 0))
+ );
+ panelCameraSelectionLayout.setVerticalGroup(
+ panelCameraSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelCameraSelectionLayout.createSequentialGroup()
+ .addGap(0, 0, 0)
+ .addGroup(panelCameraSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(comboType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel5)
+ .addComponent(jLabel1)
+ .addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(0, 0, 0))
+ );
+
javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
topPanel.setLayout(topPanelLayout);
topPanelLayout.setHorizontalGroup(
topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(topPanelLayout.createSequentialGroup()
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, topPanelLayout.createSequentialGroup()
.addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel5)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(comboType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(panelCameraSelection, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
- .addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, 0))
+ .addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
);
topPanelLayout.setVerticalGroup(
topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(topPanelLayout.createSequentialGroup()
.addGap(1, 1, 1)
- .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel5)
- .addComponent(comboType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addComponent(pauseSelection, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(pauseSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(panelCameraSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
- topPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, comboType, toolBar});
-
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -2842,7 +3023,7 @@ public class ScreenPanel2 extends Panel {
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(sidePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE))
+ .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
@@ -3205,24 +3386,32 @@ public class ScreenPanel2 extends Panel {
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
try {
- renderer.removeOverlay(imageBufferOverlay);
- if (camera != null) {
- boolean pause = !renderer.isPaused();
- synchronized (imageBuffer) {
- if (pause) {
- renderer.pause();
- } else {
- imageBuffer.clear();
- renderer.resume();
- }
- pauseSelection.setVisible(pause && (imageBuffer.size() > 1));
- if (pauseSelection.isVisible()) {
- renderer.addOverlay(imageBufferOverlay);
- pauseSelection.setMaxValue(imageBuffer.size());
- pauseSelection.setValue(imageBuffer.size());;
+ if (!updatingButtons){
+ renderer.removeOverlay(imageBufferOverlay);
+ if (camera != null) {
+ boolean pause = !renderer.isPaused();
+ synchronized (imageBuffer) {
+ if (pause) {
+ renderer.pause();
+ } else {
+ imageBuffer.clear();
+ renderer.resume();
+ }
+
+ if (pause && (imageBuffer.size() > 1)) {
+ panelCameraSelection.setVisible(false);
+ pauseSelection.setVisible(true);
+ renderer.addOverlay(imageBufferOverlay);
+ pauseSelection.setMaxValue(imageBuffer.size());
+ pauseSelection.setValue(imageBuffer.size());;
+ updatePause();
+ } else {
+ pauseSelection.setVisible(false);
+ panelCameraSelection.setVisible(true);
+ }
}
+ updateStreamData();
}
- updateStreamData();
}
} catch (Exception ex) {
showException(ex);
@@ -3273,41 +3462,11 @@ public class ScreenPanel2 extends Panel {
try {
saveSnapshot();
} catch (Exception ex) {
+ Logger.getLogger(getClass().getName()).log(Level.WARNING, null, ex);
showException(ex);
}
}//GEN-LAST:event_buttonSaveActionPerformed
- private void buttonArgsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonArgsActionPerformed
- try {
- if (camera != null) {
- String cameraConfigJson = null;
- if (usingServer) {
- String cameraServerUrl = (camServerUrl == null) ? server.getUrl().substring(0, server.getUrl().length() - 1) + "8" : camServerUrl;
- try (CameraServer srv = new CameraServer("CamServer", cameraServerUrl)) {
- srv.initialize();
- //TODO: replace into encodeMultiline
- 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");
- cameraConfigJson = configFile.toFile().exists() ? new String(Files.readAllBytes(configFile)) : null;
- }
- TextEditor editor = new TextEditor();
- editor.setText(cameraConfigJson);
- editor.setReadOnly(true);
- editor.setTitle(cameraName);
- EditorDialog dlg = editor.getDialog(getTopLevel(), false);
- dlg.setSize(480, 640);
- dlg.setVisible(true);
- SwingUtils.centerComponent(getTopLevel(), dlg);
- }
- } catch (Exception ex) {
- showException(ex);
- }
- }//GEN-LAST:event_buttonArgsActionPerformed
-
private void buttonStreamDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStreamDataActionPerformed
try {
showStreamData();
@@ -3331,7 +3490,7 @@ public class ScreenPanel2 extends Panel {
} catch (Exception ex) {
ex.printStackTrace();
- } finally{
+ } finally {
updateButtons();
}
}//GEN-LAST:event_comboTypeActionPerformed
@@ -3377,9 +3536,17 @@ public class ScreenPanel2 extends Panel {
}
}//GEN-LAST:event_comboCamerasActionPerformed
+ private void buttonTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTitleActionPerformed
+ try {
+ manageTitleOverlay();
+ } catch (Exception ex) {
+ showException(ex);
+ } finally {
+ }
+ }//GEN-LAST:event_buttonTitleActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btFixColormapRange;
- private javax.swing.JButton buttonArgs;
private javax.swing.JRadioButton buttonAutomatic;
private javax.swing.JRadioButton buttonDirect;
private javax.swing.JToggleButton buttonFit;
@@ -3398,6 +3565,7 @@ public class ScreenPanel2 extends Panel {
private javax.swing.JRadioButton buttonServer;
private javax.swing.JToggleButton buttonSidePanel;
private javax.swing.JButton buttonStreamData;
+ private javax.swing.JToggleButton buttonTitle;
private javax.swing.JRadioButton buttonZoom025;
private javax.swing.JRadioButton buttonZoom05;
private javax.swing.JRadioButton buttonZoom2;
@@ -3414,6 +3582,7 @@ public class ScreenPanel2 extends Panel {
private javax.swing.JComboBox comboFilter;
private javax.swing.JComboBox comboScreen;
private javax.swing.JComboBox comboType;
+ private javax.swing.Box.Filler filler1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
@@ -3422,7 +3591,6 @@ public class ScreenPanel2 extends Panel {
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel5;
private javax.swing.JProgressBar jProgressBar1;
- private javax.swing.JToolBar.Separator jSeparator5;
private javax.swing.JToolBar.Separator jSeparator6;
private javax.swing.JLabel labelGrScale;
private javax.swing.JLabel labelGrThreshold;
@@ -3431,6 +3599,7 @@ public class ScreenPanel2 extends Panel {
private javax.swing.JLabel labelSlNumber;
private javax.swing.JLabel labelSlOrientation;
private javax.swing.JLabel labelSlScale;
+ private javax.swing.JPanel panelCameraSelection;
private javax.swing.JPanel panelFilter;
private javax.swing.JPanel panelScreen;
private javax.swing.JPanel panelScreen2;
diff --git a/plugins/WireScan.form b/plugins/WireScan.form
index fe232cb..701d207 100644
--- a/plugins/WireScan.form
+++ b/plugins/WireScan.form
@@ -79,7 +79,7 @@
-
+
@@ -263,7 +263,7 @@
-
+
@@ -349,7 +349,7 @@
-
+
diff --git a/plugins/WireScan.java b/plugins/WireScan.java
index 0fa4945..9c531ab 100644
--- a/plugins/WireScan.java
+++ b/plugins/WireScan.java
@@ -94,10 +94,10 @@ public class WireScan extends Panel {
}
comboWireScannerActionPerformed(null);
- Device dev = new ChannelInteger (null, "SIN-TIMAST-TMA:Evt-15-Freq-I");
+ Device dev = new ChannelDouble (null, "SIN-TIMAST-TMA:Evt-15-Freq-I");
dev.setMonitored(true);
dev.initialize();
- panelPosition1.setDevice(dev);
+ panelRepRate.setDevice(dev);
} catch (Exception ex) {
showException(ex);
@@ -138,6 +138,7 @@ public class WireScan extends Panel {
homed = false;
}
onStateChange(getState(), getState());
+ panelRepRate.getDevice().update();
} catch (Exception ex){
}
}
@@ -333,7 +334,7 @@ public class WireScan extends Panel {
ledHomed = new ch.psi.pshell.swing.Led();
comboScanType = new javax.swing.JComboBox();
spinnerCycles = new javax.swing.JSpinner();
- panelPosition1 = new ch.psi.pshell.swing.DeviceValuePanel();
+ panelRepRate = new ch.psi.pshell.swing.DeviceValuePanel();
labelEndY = new javax.swing.JLabel();
comboBlm1 = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
@@ -609,7 +610,7 @@ public class WireScan extends Panel {
.addComponent(labelPosX, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelPosY, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(panelLeftLayout.createSequentialGroup()
- .addComponent(panelPosition1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(panelRepRate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -681,7 +682,7 @@ public class WireScan extends Panel {
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonMotorPanel, buttonScannerPanel});
- panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {labelPosX, labelPosY, panelPosition, panelPosition1});
+ panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {labelPosX, labelPosY, panelPosition, panelRepRate});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerBackground, spinnerCycles, spinnerEndX, spinnerEndY});
@@ -766,7 +767,7 @@ public class WireScan extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel15)
- .addComponent(panelPosition1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(panelRepRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(ledHomed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonHoming))
@@ -793,7 +794,7 @@ public class WireScan extends Panel {
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerCycles, spinnerEndX, spinnerEndY});
- panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelPosition1, panelStatus});
+ panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelRepRate, panelStatus});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -948,6 +949,7 @@ public class WireScan extends Panel {
parameters.add(blms);
parameters.add(spinnerBackground.getValue());
parameters.add(plot);
+ parameters.add(checkSaveRaw.isSelected());
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
if (ex != null) {
@@ -1125,7 +1127,7 @@ public class WireScan extends Panel {
private ch.psi.pshell.swing.Led ledHomed;
private javax.swing.JPanel panelLeft;
private ch.psi.pshell.swing.DeviceValuePanel panelPosition;
- private ch.psi.pshell.swing.DeviceValuePanel panelPosition1;
+ private ch.psi.pshell.swing.DeviceValuePanel panelRepRate;
private ch.psi.pshell.swing.DeviceValuePanel panelStatus;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerBackground;
diff --git a/plugins/resources/Title.png b/plugins/resources/Title.png
new file mode 100644
index 0000000..d07dc34
Binary files /dev/null and b/plugins/resources/Title.png differ
diff --git a/script/Diagnostics/ICT_timing_fine.py b/script/Diagnostics/ICT_timing_fine.py
index 7884101..71ff683 100644
--- a/script/Diagnostics/ICT_timing_fine.py
+++ b/script/Diagnostics/ICT_timing_fine.py
@@ -2,8 +2,8 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = False
do_elog = True
-base_name = "SINEG01-DICT009" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599
-dev_name = "SINEG01-DICT215" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030
+base_name = "SARBD01-DICT599" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599
+dev_name = "SARBD01-DICT030" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030
run("CPython/wrapper")
@@ -22,10 +22,10 @@ V.initialize()
t0 = t.read()
-start = 2.2
-stop = 7.0
+start = 3
+stop = 10
step = 0.1
-nb = 10
+nb = 4
lat = 0.150
plt = plot(None, title="Output")[0]
@@ -64,7 +64,7 @@ finally:
try:
i_max = charge.index(max(charge))
min_i, max_i = max(i_max-30, 0), min(i_max+31, len(charge))
- (delay_max, charge_max, delay_fit, charge_fit) = extremum(delay[min_i:max_i], charge[min_i:max_i])
+ (delay_max, charge_max, delay_fit, charge_fit, R2) = extremum(delay[min_i:max_i], charge[min_i:max_i])
print delay_max, charge_max
except:
raise Exception("Fit failure")
diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py
index 49fe0e2..62f140b 100644
--- a/script/Diagnostics/WireScan.py
+++ b/script/Diagnostics/WireScan.py
@@ -19,17 +19,18 @@ blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
bkgrd = args[7] if is_panel else 10
plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if is_panel else False
-do_elog = True if is_panel else True
+do_elog = False if (plt is None) else (True if is_panel else True)
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd
#Plot setup
-plt.clear()
-plt.removeMarker(None)
-plt.getAxis(plt.AxisId.X).setLabel("Position");
-plt.getAxis(plt.AxisId.Y).setLabel("");
-plt.getAxis(plt.AxisId.Y2).setLabel("");
-plt.setLegendVisible(True);
+if plt is not None:
+ plt.clear()
+ plt.removeMarker(None)
+ plt.getAxis(plt.AxisId.X).setLabel("Position");
+ plt.getAxis(plt.AxisId.Y).setLabel("");
+ plt.getAxis(plt.AxisId.Y2).setLabel("");
+ plt.setLegendVisible(True);
snapshots = []
#Creating WireScanner object
@@ -44,10 +45,11 @@ channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("scanning", scanner.status_channels[0].get_name())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
- series = LinePlotSeries(blms[i], None, min(i+1, 2))
- plt.addSeries(series)
- series.setLinesVisible(False)
- series.setPointSize(2)
+ if plt is not None:
+ series = LinePlotSeries(blms[i], None, min(i+1, 2))
+ plt.addSeries(series)
+ series.setLinesVisible(False)
+ series.setPointSize(2)
if save_raw:
channels.append (("blm" + str(i+1) + "_raw" , blms[i] + ":LOSS_SIGNAL_RAW"))
for i in range (len(bpms)):
@@ -106,9 +108,10 @@ def check_end_scan(record, scan):
if record[3] != cur_cycle:
cur_cycle = record[3]
get_context().dataManager.splitScanData(scan)
- #for s in plt.getAllSeries(): s.clear()
- for i in range (len(blms)):
- plt.getSeries(i).appendData(position, record[5 + i])
+ #if plt is not None: for s in plt.getAllSeries(): s.clear()
+ if plt is not None:
+ for i in range (len(blms)):
+ plt.getSeries(i).appendData(position, record[5 + i])
#Process background
def do_background():
@@ -122,30 +125,42 @@ def do_background():
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", mean(d))
set_attribute(path, "Sigma", stdev(d) )
-
+
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
set_exec_pars(group=wire+"_{count}", reset=True)
scanner.set_selection(get_scan_selection(scan_type, index))
- if wire == "x":
- plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
- else:
- plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
+ if plt is not None:
+ if wire == "x":
+ plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
+ else:
+ plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
scanner.init(wait=True)
scanner.curr_cycl.write(0)
scan_complete=False
cur_cycle = 1.0
- for s in plt.getAllSeries():
- s.clear()
- plt.removeMarker(None)
+
+ if plt is not None:
+ for s in plt.getAllSeries():
+ s.clear()
+ plt.removeMarker(None)
try:
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
st.getChild("scanning").waitValue(1.0, 10000)
- mscan (st, [w_pos()] + st.getReadables() + [Timestamp(),], -1, -1, take_initial = True, after_read = check_end_scan)
+ #print st.getValues()
+
+ #TODO: Check what the problem is
+ #mscan (st, [w_pos(),] + st.getReadables() + [Timestamp(),], -1, -1, take_initial = True, after_read = check_end_scan)
+
+ l=[w_pos()] ; l.extend(st.getReadables()); l.append(Timestamp())
+ mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan)
+
+ #tscan([w_pos()] + st.getReadables() + [Timestamp(),], 10, 0.5)
except:
+ print sys.exc_info()[1]
if not scanner.isReady():
print "Aborting scan"
scanner.abort()
@@ -160,10 +175,12 @@ def do_scan(index):
calculate()
img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
time.sleep(0.1) #Give some time to plot finish (async)
- plt.saveSnapshot(img_file, "png")
- snapshots.append(img_file)
+ if plt is not None:
+ plt.saveSnapshot(img_file, "png")
+ snapshots.append(img_file)
msg = ""
+ret = []
def calculate():
global msg
stats = []
@@ -172,8 +189,9 @@ def calculate():
try:
bg = get_attributes("background/blm" + str(i+1))["Mean"] if bkgrd>0 else 0.0
samples = [[], [], [], []]
- for cycle in range (cycles):
- pos = load_data(wire+"_" + ("%04d" % (cycle+1)) + "/w_pos")
+ for cycle in range (cycles):
+ pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/w_pos"
+ pos = load_data(pos_path)
path = wire+"_" + ("%04d" % (cycle+1)) + "/blm" + str(i+1)
data = load_data(path)
sp = blm_remove_spikes(data)
@@ -194,14 +212,16 @@ def calculate():
#from mathutils import Gaussian
#g = Gaussian(amp, com, sigma)
#gauss = [g.value(v)+off for v in pos]
- #plot([data, sp, sig, gauss], ["data", "sp", "signal", "gauss", ], xdata = pos, title="Fit blm" + str(i+1) + " - " + str(cycle+1))
+ #plot([data, sp, sig, gauss], ["data", "sp", "signal", "gauss", ], xdata = pos, title="Fit blm" + str(i+1) + " - " + str(cycle+1))
+ ret.extend([rms_com, rms_sigma, com, sigma, get_exec_pars().path + "|"+ pos_path, get_exec_pars().path + "|"+ path])
stats.append([])
for sample in samples:
sample = [v for v in sample if v is not None]
stats[i].append( (mean(sample), stdev(sample)) if len(sample)>0 else (float("nan"), float("nan")) )
- plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
- plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
+ if plt is not None:
+ plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
+ plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
msg += " RMS COM: " + "%.4f" % stats[i][0][0] + " +- " +"%.4f" % stats[i][0][1] + "\n" #unichr(0x03C3) + "="
msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
@@ -243,3 +263,5 @@ if do_elog:
log_msg = log_msg + "\n" + msg
elog("Wire Scan", log_msg, snapshots)
+set_exec_pars(open=False)
+set_return(ret)
\ No newline at end of file
diff --git a/script/K-calc.py b/script/K-calc.py
new file mode 100644
index 0000000..5c94a6e
--- /dev/null
+++ b/script/K-calc.py
@@ -0,0 +1,9 @@
+Eph1 = 2365
+Eph2 = 2150
+
+undlist = (SARUN03,SARUN04,SARUN05,SARUN06,SARUN07,SARUN08,SARUN09,SARUN10,SARUN11,SARUN12,SARUN13,SARUN14,SARUN15)
+
+
+for und in undlist
+ K1 = caget(und + "-RSYS:SET-SCAN-START")
+ K2 = SQRT(2*(Eph1/Eph2*(1+0.5*K1^2)-1))
\ No newline at end of file
diff --git a/script/Photonics/KValueScanGas.py b/script/Photonics/KValueScanGas.py
index d7632ac..515fcb7 100644
--- a/script/Photonics/KValueScanGas.py
+++ b/script/Photonics/KValueScanGas.py
@@ -1,4 +1,4 @@
-GAP = "SARUN03-UIND030"
+GAP = "SARUN14-UIND030"
SAMPLES = 20
TOLERANCE = 0.01
TIMEOUT = 10.0
diff --git a/script/Photonics/PhaseShifterScanGas.py b/script/Photonics/PhaseShifterScanGas.py
index 0cd2bce..e042e76 100644
--- a/script/Photonics/PhaseShifterScanGas.py
+++ b/script/Photonics/PhaseShifterScanGas.py
@@ -1,24 +1,26 @@
-GAP = "SARUN07-UPHS060"
-SAMPLES = 20
+GAP = "SARUN03-UPHS060"
+SAMPLES = 10
TOLERANCE = 0.01
TIMEOUT = 10.0
-intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det")
+#intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det")
+#gap = Channel(GAP + ":GAP_SP", alias = "gap")
-gap = Channel(GAP + ":GAP_SP", alias = "gap")
readout = Channel(GAP + ":GAP")
-av = create_averager(intensity, SAMPLES, interval = -1, name = None)
+av = create_averager("ca://SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US",
+ SAMPLES, interval =0.1, name = "gas det")
def before(position, scan):
caput(GAP + ":GO", 1)
- start = time.time()
- while abs(readout.read() - gap.read()) > TOLERANCE:
+ start = time.time()
+ while abs(readout.read() - GAP.read()) > TOLERANCE:
time.sleep(0.1)
if time.time() - start > TIMEOUT:
raise Exception ("Timeout waiting gap change")
-ret = lscan (gap, av, 17.5, 19.5, 20, latency=20.0, before_read=before)
+ret = lscan ("ca://" + GAP + ":GAP_SP?name=gap", av, 14, 16, 20,
+ latency=20.0, before_read=before)
#run("CPython/wrapper")
diff --git a/script/RFscan/GunEnergyScan.py b/script/RFscan/GunEnergyScan.py
index b81196f..9c75362 100644
--- a/script/RFscan/GunEnergyScan.py
+++ b/script/RFscan/GunEnergyScan.py
@@ -57,19 +57,13 @@ phase.config.save()
phase.initialize()
phase0 = phase.read()
-##Camtool setup
-#kill_camtool()
-#check_camtool()
-#camtool.start(camera_name)
-#wait_camtool_message()
-#x = camtool.stream.getChild("x_fit_mean")
-#dx = camtool.stream.getChild("x_fit_standard_deviation")
-
#Camera setup
cam_server.start(camera_name)
wait_cam_server_message()
-x = cam_server.stream.getChild("x_fit_mean")
-dx = cam_server.stream.getChild("x_fit_standard_deviation")
+#x = cam_server.stream.getChild("x_fit_mean")
+#dx = cam_server.stream.getChild("x_fit_standard_deviation")
+x = cam_server.stream.getChild("x_center_of_mass")
+dx = cam_server.stream.getChild("x_rms")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
@@ -105,9 +99,9 @@ dp = [abs(A) * val.mean for val in r.getReadable(1)]
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
- min_i, max_i = max(i_max-5, 0), min(i_max+6, len(p))
+ min_i, max_i = max(i_max-8, 0), min(i_max+6, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i])
- min_i, max_i = max(i_min-5, 0), min(i_min+6, len(dp))
+ min_i, max_i = max(i_min-8, 0), min(i_min+6, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
@@ -133,7 +127,7 @@ set_attribute(get_exec_pars().group + "/dp", "dp fit R2", dp_R2)
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
- Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
+ Laser = str(caget("SLG-LGEN:WHICH_LASER"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py
index 190b6f1..7d47b52 100644
--- a/script/RFscan/phase_scan_caqtdm.py
+++ b/script/RFscan/phase_scan_caqtdm.py
@@ -15,27 +15,43 @@ stop = caget(station + "-RSYS:SET-SCAN-STOP")
step = caget(station + "-RSYS:SET-SCAN-STEP")
lat = caget(station + "-RSYS:SET-SCAN-WAIT-TIME")
nb = caget(station + "-RSYS:SET-NUM-AVERAGE")
-disp = caget(bpm_ch + ":DISPERSION")
-energy0 = caget(bpm_ch + ":ENERGY-OP")
-A = energy0 / disp / 1e3
+disp = caget(bpm_ch + ":DISPERSION-OP")
+def mbnd(bpm_ch):
+ return {
+ 'SINLH02-DBPM210': 'SINLH02-MBND100',
+ 'SINLH02-DBPM240': 'SINLH02-MBND100',
+ 'SINBC02-DBPM140': 'SINBC02-MBND100',
+ 'SINBC02-DBPM320': 'SINBC02-MBND100',
+ 'S10DI01-DBPM020': 'S10DI01-MBND100',
+ 'S10BC02-DBPM140': 'S10BC02-MBND100',
+ 'S10BC02-DBPM320': 'S10BC02-MBND100',
+ 'SARCL02-DBPM110': 'SARCL02-MBND100',
+ 'SARCL02-DBPM220': 'SARCL02-MBND100',
+ 'SARCL02-DBPM260': 'SARCL02-MBND100',
+ 'SARCL02-DBPM330': 'SARCL02-MBND100',
+ 'SARCL02-DBPM470': 'SARCL02-MBND100'
+ }[bpm_ch]
+p0 = caget(mbnd(bpm_ch) + ":P-READ")
+energy0 = p0 - 0.511
+A = energy0 / (disp * 1000)
B = energy0
phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
-phase.config.minValue =-360.0
+phase.config.minValue =-90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
-phase.config.rotation = False
+phase.config.rotation = True
phase.config.resolution = 0.1
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
-V.initialize()
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
+V.initialize()
P.initialize()
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
x.initialize()
-phase0 = phase.read()
+phase0 = phase.read() % 360
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", float('nan'))
@@ -56,9 +72,11 @@ def after(rec):
try:
phase.write(start)
time.sleep(1.0)
- x_averager = create_averager(x, nb, 0.100)
+ x_averager = create_averager(x, nb, lat)
r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after)
rf_phase = r.getPositions(0)
+ if start < 0:
+ rf_phase = [((ph + 90) % 360) -90 for ph in rf_phase ]
energy = [A * val.mean + B for val in r.getReadable(0)]
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(energy, 'd'))
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
@@ -66,17 +84,17 @@ try:
run("CPython/wrapper")
(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
except:
- raise Exception("Fit failure")
-# plt = plot(None,name="phase scan")[0]
-# # This only works when pshell is visible not in server mode to be fixed
-# if plt is not None:
-# plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d'))
-# plt.getSeries(0).setPointSize(6)
-# plt.getSeries(0).setLinesVisible(False)
-# plt.addSeries(LinePlotSeries("fit"))
-# plt.getSeries(1).setData(fit_x, fit_y)
-# plt.getSeries(1).setPointsVisible(False)
-# plt.setLegendVisible(True)
+ raise Exception("Fit failure")
+ plt = plot(None,name="phase scan")[0]
+ if plt is not None:
+ plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d'))
+ plt.getSeries(0).setPointSize(6)
+ plt.getSeries(0).setLinesVisible(False)
+ plt.addSeries(LinePlotSeries("fit"))
+ plt.getSeries(1).setData(fit_x, fit_y)
+ plt.getSeries(1).setPointsVisible(False)
+ plt.setLegendVisible(True)
+ ph_crest = ph_crest % 360
phase.write(ph_crest)
time.sleep(lat)
Ampl = V.read()
@@ -95,7 +113,7 @@ finally:
x.close()
phase_corr = caget(station + "-RSYS:GET-VSUM-PHASE-OFFSET-CORR")
phase_offset = 90.0 - ph_crest - phase_corr
-amplitude_scale = fit_amplitude / Ampl
+amplitude_scale = fit_amplitude / Ampl if Ampl != 0 else 0.0
power_scale = Power / fit_amplitude**2 if fit_amplitude != 0 else 0.0
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
@@ -120,12 +138,12 @@ set_attribute(get_exec_pars().group + "/BPM-X averager" , "Unit", "mm"
#Elog entry
if do_elog:
- title = "Phase scan" + station
+ title = "Phase scan " + station
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "On-crest VS phase: %0.2f" % ph_crest + " deg \n"
log_msg = log_msg + "Energy gain: %0.3f" % fit_amplitude + " MeV \n"
log_msg = log_msg + "VS-phase offset: %0.2f" % phase_offset + " deg \n"
log_msg = log_msg + "Amplitude scale: %0.3f" % amplitude_scale + " MV \n"
log_msg = log_msg + "Power scale: %0.6f" % power_scale + " MW/MV^2"
- attachments = get_plot_snapshots()
+ attachments = get_plot_snapshots(size=(600,400))
elog(title, log_msg, attachments)
diff --git a/script/RFscan/phase_scan_caqtdm_set.py b/script/RFscan/phase_scan_caqtdm_set.py
index 21160e1..d8f9a4b 100644
--- a/script/RFscan/phase_scan_caqtdm_set.py
+++ b/script/RFscan/phase_scan_caqtdm_set.py
@@ -29,7 +29,7 @@ if n > 0:
title = "Set RF calibration:" + station
log_msg = ""
if (phase_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset + " deg (was %0.2f" % phase_offset_old + " deg)\n"
- if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %0.3f" % amplitude_scale + " MV (was %0.3f" % amplitude_scale_old + " MV)\n"
- if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.5f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)"
+ if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %0.3f" % amplitude_scale + " MV (was %0.3f" % amplitude_scale_old + " MV)\n"
+ if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.5f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)"
attachments = []
elog(title, log_msg, attachments)
diff --git a/script/test/DataLink.py b/script/test/DataLink.py
new file mode 100644
index 0000000..b371532
--- /dev/null
+++ b/script/test/DataLink.py
@@ -0,0 +1,21 @@
+import random
+
+positioner = DummyPositioner("positioner")
+
+class Sensor(Readable):
+ def __init__(self):
+ self.index = -1
+ def read(self):
+ #time.sleep(0.001)
+ self.index +=1
+ return self.index
+ #noise = (random.random() - 0.5) / 10.0
+ #return math.sin(time.time()) + noise
+sensor = Sensor()
+
+
+ret = lscan(positioner, sensor, scan_start, scan_stop, scan_steps, 0.01)
+av = mean(ret.getReadable(0))
+set_exec_pars(open=False)
+set_return([av, ret.path + sensor.name])
+
diff --git a/script/test/WireScanMock.py b/script/test/WireScanMock.py
new file mode 100644
index 0000000..a6e01a3
--- /dev/null
+++ b/script/test/WireScanMock.py
@@ -0,0 +1,259 @@
+import traceback
+
+is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
+
+
+
+BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
+
+#Paramter parsing
+prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
+scan_type = args[1] if is_panel else "X1"
+scan_range = args[2] if is_panel else [-200, 200, -200, 200]
+cycles = args[3] if is_panel else 3
+velocity = args[4] if is_panel else 200
+bpms = args[5] if is_panel else ["BPM1", "BPM2"]
+blms = args[6] if is_panel else ["BLM1", "BLM2"]
+bkgrd = args[7] if is_panel else 10
+plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
+save_raw = args[9] if is_panel else False
+do_elog = False if (plt is None) else (True if is_panel else False)
+print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd
+
+
+#Plot setup
+if plt is not None:
+ plt.clear()
+ plt.removeMarker(None)
+ plt.getAxis(plt.AxisId.X).setLabel("Position");
+ plt.getAxis(plt.AxisId.Y).setLabel("");
+ plt.getAxis(plt.AxisId.Y2).setLabel("");
+ plt.setLegendVisible(True);
+snapshots = []
+
+#Creating WireScanner object
+print "Creating scanner..."
+scanner = DummyPositioner("scanner")
+
+
+class Sensor(ReadonlyRegisterBase):
+ def __init__(self, name):
+ ReadonlyRegisterBase.__init__(self, name)
+ self.index = -1
+ self.initialize()
+
+ def doRead(self):
+ self.index +=1
+ return float(self.index)
+
+
+#Lis of stream channels
+channels = [Sensor("m_pos"),
+ Sensor("cur_cycle"),
+ Sensor("scanning")]
+for i in range (len(blms)):
+ channels.append (Sensor("blm" + str(i+1)))
+ if plt is not None:
+ series = LinePlotSeries(blms[i], None, min(i+1, 2))
+ plt.addSeries(series)
+ series.setLinesVisible(False)
+ series.setPointSize(2)
+ if save_raw:
+ channels.append (Sensor("blm" + str(i+1) + "_raw"))
+for i in range (len(bpms)):
+ for sensor in BPM_SENSORS:
+ channels.append (Sensor("bpm" + str(i+1) + "_" + sensor[0]))
+
+#Metadata
+set_attribute("/", "Wire Scanner", prefix)
+set_attribute("/", "Scan Type", scan_type)
+set_attribute("/", "Range", scan_range)
+set_attribute("/", "Cycles", cycles)
+set_attribute("/", "Motor Velocity", velocity*math.sqrt(2))
+set_attribute("/", "Wire Velocity", velocity)
+set_attribute("/", "Background Measures", bkgrd)
+set_attribute("/", "BPMs", bpms)
+set_attribute("/", "BLMs", blms)
+
+filename = get_exec_pars().path
+
+
+
+class Timestamp(Readable):
+ def read(self):
+ return time.time()
+
+
+
+
+#End of scan checking
+scan_complete, cur_cycle, wire = None, None, None
+
+def check_end_scan(record, scan):
+ global scan_complete,cur_cycle
+ if record[4]<1:
+ print "Data aquisition completed"
+ scan_complete=True
+ scan.abort()
+ record.cancel() #So it won't be saved
+ else:
+ position = record[0]
+ if record[3] != cur_cycle:
+ cur_cycle = record[3]
+ get_context().dataManager.splitScanData(scan)
+ #if plt is not None: for s in plt.getAllSeries(): s.clear()
+ if plt is not None:
+ for i in range (len(blms)):
+ plt.getSeries(i).appendData(position, record[5 + i])
+
+#Process background
+def do_background():
+ #Store Background
+ if bkgrd>0:
+
+ set_exec_pars(group = "background")
+ r = tscan ( channels, bkgrd, 0.01)
+ for i in range(len(r.getReadables())):
+ d = r.getReadable(i)
+ path = get_exec_pars().group + "/"+ r.getReadables()[i].name
+ set_attribute(path, "Mean", mean(d))
+ set_attribute(path, "Sigma", stdev(d) )
+
+#Scan
+def do_scan(index):
+ global scan_complete, cur_cycle, wire
+ wire = "y" if (index==1) or (scan_type in ["Y1", "Y2"]) else "x"
+
+
+ if plt is not None:
+ if wire == "x":
+ plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
+ else:
+ plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
+
+
+ scan_complete=False
+ cur_cycle = 1.0
+
+ if plt is not None:
+ for s in plt.getAllSeries():
+ s.clear()
+ plt.removeMarker(None)
+ try:
+
+ #TODO: Check what the problem is
+ #mscan (st, [w_pos(),] + st.getReadables() + [Timestamp(),], -1, -1, take_initial = True, after_read = check_end_scan)
+
+ l=[Sensor("w_pos")] ; l.extend(channels); l.append(Timestamp())
+ #mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan)
+
+ #tscan([w_pos()] + getReadables() + [Timestamp(),], 10, 0.5)
+ for i in range(cycles):
+ set_exec_pars(group=wire+"_{count}", reset=(i==0))
+ tscan(l, 10, 0.5)
+ except:
+ print sys.exc_info()[1]
+
+ if not scan_complete:
+ raise
+ finally:
+ #Combining data of multiple series
+ #s=plt.getSeries(0)
+ #indexes = sorted(range(len(s.x)),key=lambda x:s.x[x])
+ #x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
+ #plot(y, xdata = x)
+ calculate()
+ img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
+ time.sleep(0.1) #Give some time to plot finish (async)
+ if plt is not None:
+ plt.saveSnapshot(img_file, "png")
+ snapshots.append(img_file)
+
+msg = ""
+ret = []
+def calculate():
+ global msg
+ stats = []
+ for i in range(len(blms)):
+ msg += "Wire " + wire + " - BLM " + str(i+1) + ":\n"
+ try:
+ bg = get_attributes("background/blm" + str(i+1))["Mean"] if bkgrd>0 else 0.0
+ samples = [[], [], [], []]
+ for cycle in range (cycles):
+ pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/w_pos"
+ pos = load_data(pos_path)
+ path = wire+"_" + ("%04d" % (cycle+1)) + "/blm" + str(i+1)
+ data = load_data(path)
+ sp = data #blm_remove_spikes(data)
+ sig = sp if bg is None else [v-bg for v in sp]
+
+ rms_com, rms_sigma = [10.0, 20.0] #[profile_rms_stats(pos, sig,noise_std=0, n_sigma=3.5)
+ set_attribute(path, "RMS COM", float("nan") if (rms_com is None) else rms_com)
+ set_attribute(path, "RMS Sigma", float("nan") if (rms_sigma is None) else rms_sigma)
+
+ #print [com, rms]
+ [off, amp, com, sigma] = [30.0, 40.0, 50.0, 60.0] #profile_gauss_stats(pos, sig, off=None, amp=None, com=None, sigma=None)
+ set_attribute(path, "Gauss COM", float("nan") if (com is None) else com)
+ set_attribute(path, "Gauss Sigma", float("nan") if (sigma is None) else sigma)
+
+ samples[0].append(rms_com);samples[1].append(rms_sigma);samples[2].append(com);samples[3].append(sigma)
+ print get_exec_pars().path + " | "+ path
+ ret.append([rms_com, rms_sigma, com, sigma, get_exec_pars().path + "|"+ pos_path, get_exec_pars().path + "|"+ path])
+ #print [off, amp, com, sigma]
+
+ #from mathutils import Gaussian
+ #g = Gaussian(amp, com, sigma)
+ #gauss = [g.value(v)+off for v in pos]
+ #plot([data, sp, sig, gauss], ["data", "sp", "signal", "gauss", ], xdata = pos, title="Fit blm" + str(i+1) + " - " + str(cycle+1))
+ print "X"
+ stats.append([])
+ for sample in samples:
+ sample = [v for v in sample if v is not None]
+ stats[i].append( (mean(sample), stdev(sample)) if len(sample)>0 else (float("nan"), float("nan")) )
+ if plt is not None:
+ plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
+ plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
+
+ msg += " RMS COM: " + "%.4f" % stats[i][0][0] + " +- " +"%.4f" % stats[i][0][1] + "\n" #unichr(0x03C3) + "="
+ msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
+ msg += " Gauss COM: " + "%.4f" % stats[i][2][0] + " +- " + "%.4f" % stats[i][2][1] + "\n"
+ msg += " Gauss Sigma: " + "%.4f" % stats[i][3][0] + " +- " + "%.4f" % stats[i][3][1] + "\n"
+
+ except Exception, e:
+ print >> sys.stderr, traceback.format_exc()
+ msg += str(e)+ "\n"
+
+
+print "Starting scan..."
+try:
+ do_background()
+ do_scan(0)
+ if scan_type in ["Set1", "Set2"]:
+ do_scan(1)
+finally:
+ print "Closing scanner"
+
+ print "Closing stream"
+
+
+print msg
+
+# save the entry in the logbook
+if do_elog:
+ if get_option("Generated data file:\n" + filename +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
+ log_msg = "Data file: " + filename
+ log_msg = log_msg + "\nWire Scanner: " + prefix
+ log_msg = log_msg + "\nScan Type: " + str(scan_type)
+ log_msg = log_msg + "\nRange: " + str(scan_range)
+ log_msg = log_msg + "\nCycles: " + str(cycles)
+ log_msg = log_msg + "\nWire Velocity: " + str(velocity)
+ log_msg = log_msg + "\nBackground Measures: " + str(bkgrd)
+ log_msg = log_msg + "\nBPMs: " + str(bpms)
+ log_msg = log_msg + "\nBLMs: " + str(blms)
+
+ log_msg = log_msg + "\n" + msg
+ elog("Wire Scan", log_msg, snapshots)
+
+
+set_exec_pars(open=False)
+set_return(ret)
diff --git a/script/test/offset.py b/script/test/offset.py
index 1378f3d..15b3dd0 100644
--- a/script/test/offset.py
+++ b/script/test/offset.py
@@ -1,11 +1,12 @@
-devlist = ['SARUN01', 'SARUN02', 'SARUN03', 'SARUN04', 'SARUN05', \
- 'SARUN06', 'SARUN07', 'SARUN08', 'SARUN09', 'SARUN10', \
- 'SARUN11', 'SARUN12', 'SARUN13', 'SARUN14', 'SARUN15']#\
+devlist = ['SARUN13']#\
+#'SARUN01', 'SARUN02', 'SARUN03', 'SARUN04', 'SARUN05', \
+# 'SARUN06', 'SARUN07', 'SARUN08', 'SARUN09', 'SARUN10', \
+# 'SARUN11', 'SARUN12', , 'SARUN14', 'SARUN15'
# 'SARUN16' 'SARUN17' 'SARUN18' 'SARUN19' 'SARUN20' ]
for dev in devlist:
off_x = caget(dev + "-DBPM070:OFFS-X")
off_y = caget(dev + "-DBPM070:OFFS-Y")
- off_x = off_x + 0.000
- off_y = off_y + 0.010
+ off_x = off_x + 0.010
+ off_y = off_y - 0.000
caput(dev + "-DBPM070:OFFS-X", float(off_x))
caput(dev + "-DBPM070:OFFS-Y", float(off_y))
\ No newline at end of file
diff --git a/script/test/offset_1.py b/script/test/offset_1.py
new file mode 100644
index 0000000..dc1ffc3
--- /dev/null
+++ b/script/test/offset_1.py
@@ -0,0 +1,25 @@
+devlist = ['SARUN08', 'SARUN09', 'SARUN10', \
+ 'SARUN11', 'SARUN12', 'SARUN13', 'SARUN14', 'SARUN15']#\
+#'SARUN01', 'SARUN02', 'SARUN03', 'SARUN04', 'SARUN05', \
+# 'SARUN06', 'SARUN07',
+# 'SARUN16' 'SARUN17' 'SARUN18' 'SARUN19' 'SARUN20' ]
+namex = '-MQUA080:X'
+namey = '-MQUA080:Y'
+n = 0
+
+for dev in devlist:
+ n = n + 1
+ off_x = caget(dev + namex)
+ off_y = caget(dev + namey)
+ off_x = off_x + (0.006 * float(n))
+ off_y = off_y + (0.000 * float(n))
+ caput(dev + namex, float(off_x))
+ caput(dev + namey, float(off_y))
+
+#for dev in devlist:
+# off_x = caget(dev + "-DBPM070:OFFS-X")
+# off_y = caget(dev + "-DBPM070:OFFS-Y")
+# off_x = off_x - 0.009
+# off_y = off_y + 0.000
+# caput(dev + "-DBPM070:OFFS-X", float(off_x))
+# caput(dev + "-DBPM070:OFFS-Y", float(off_y))
\ No newline at end of file
diff --git a/script/test/offset_K.py b/script/test/offset_K.py
new file mode 100644
index 0000000..59d973b
--- /dev/null
+++ b/script/test/offset_K.py
@@ -0,0 +1,14 @@
+devlist = ['SARUN03', 'SARUN04', 'SARUN05', \
+ 'SARUN06', 'SARUN07''SARUN08', 'SARUN09', 'SARUN10', \
+ 'SARUN11', 'SARUN12', 'SARUN13', 'SARUN14', 'SARUN15']#\
+#'SARUN01', 'SARUN02', ,
+# 'SARUN16' 'SARUN17' 'SARUN18' 'SARUN19' 'SARUN20' ]
+
+name = '-UIND030:K-SET'
+n = 0
+
+for dev in devlist:
+ n = n + 1
+ off_x = caget(dev + name)
+ off_x = off_x + (0.006 * float(n))
+ caput(dev + namex, float(off_x))
diff --git a/script/test/phase_scan_caqtdm_dv.py b/script/test/phase_scan_caqtdm_dv.py
index 8b8c316..2a78033 100644
--- a/script/test/phase_scan_caqtdm_dv.py
+++ b/script/test/phase_scan_caqtdm_dv.py
@@ -15,27 +15,43 @@ stop = caget(station + "-RSYS:SET-SCAN-STOP")
step = caget(station + "-RSYS:SET-SCAN-STEP")
lat = caget(station + "-RSYS:SET-SCAN-WAIT-TIME")
nb = caget(station + "-RSYS:SET-NUM-AVERAGE")
-disp = caget(bpm_ch + ":DISPERSION")
-energy0 = caget(bpm_ch + ":ENERGY")
-A = energy0 / disp / 1e3
+disp = caget(bpm_ch + ":DISPERSION-OP")
+def mbnd(bpm_ch):
+ return {
+ 'SINLH02-DBPM210': 'SINLH02-MBND100',
+ 'SINLH02-DBPM240': 'SINLH02-MBND100',
+ 'SINBC02-DBPM140': 'SINBC02-MBND100',
+ 'SINBC02-DBPM320': 'SINBC02-MBND100',
+ 'S10DI01-DBPM020': 'S10DI01-MBND100',
+ 'S10BC02-DBPM140': 'S10BC02-MBND100',
+ 'S10BC02-DBPM320': 'S10BC02-MBND100',
+ 'SARCL02-DBPM110': 'SARCL02-MBND100',
+ 'SARCL02-DBPM220': 'SARCL02-MBND100',
+ 'SARCL02-DBPM260': 'SARCL02-MBND100',
+ 'SARCL02-DBPM330': 'SARCL02-MBND100',
+ 'SARCL02-DBPM470': 'SARCL02-MBND100'
+ }[bpm_ch]
+p0 = caget(mbnd(bpm_ch) + ":P-READ")
+energy0 = p0 - 0.511
+A = energy0 / (disp * 1000)
B = energy0
phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
-phase.config.minValue =-360.0
+phase.config.minValue =-90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
-phase.config.rotation = False
+phase.config.rotation = True
phase.config.resolution = 0.1
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
-V.initialize()
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
+V.initialize()
P.initialize()
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
x.initialize()
-phase0 = phase.read()
+phase0 = phase.read() % 360
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", float('nan'))
@@ -56,9 +72,11 @@ def after(rec):
try:
phase.write(start)
time.sleep(1.0)
- x_averager = create_averager(x, nb, 0.100)
+ x_averager = create_averager(x, nb, lat)
r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after)
rf_phase = r.getPositions(0)
+ if start < 0:
+ rf_phase = [((ph + 90) % 360) -90 for ph in rf_phase ]
energy = [A * val.mean + B for val in r.getReadable(0)]
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(energy, 'd'))
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
@@ -67,15 +85,16 @@ try:
(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
except:
raise Exception("Fit failure")
- # This only works when pshell is visible not in server mode to be fixed
plt = plot(None,name="phase scan")[0]
- plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d'))
- plt.getSeries(0).setPointSize(6)
- plt.getSeries(0).setLinesVisible(False)
- plt.addSeries(LinePlotSeries("fit"))
- plt.getSeries(1).setData(fit_x, fit_y)
- plt.getSeries(1).setPointsVisible(False)
- plt.setLegendVisible(True)
+ if plt is not None:
+ plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d'))
+ plt.getSeries(0).setPointSize(6)
+ plt.getSeries(0).setLinesVisible(False)
+ plt.addSeries(LinePlotSeries("fit"))
+ plt.getSeries(1).setData(fit_x, fit_y)
+ plt.getSeries(1).setPointsVisible(False)
+ plt.setLegendVisible(True)
+ ph_crest = ph_crest % 360
phase.write(ph_crest)
time.sleep(lat)
Ampl = V.read()
@@ -92,19 +111,39 @@ finally:
V.close()
P.close()
x.close()
-phase_offset = 90.0 - ph_crest
-amplitude_scale = fit_amplitude / Ampl
-power_scale = Power / math.pow(fit_amplitude,2)
+phase_corr = caget(station + "-RSYS:GET-VSUM-PHASE-OFFSET-CORR")
+phase_offset = 90.0 - ph_crest - phase_corr
+amplitude_scale = fit_amplitude / Ampl if Ampl != 0 else 0.0
+power_scale = Power / fit_amplitude**2 if fit_amplitude != 0 else 0.0
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC", power_scale)
+
+#Saving metadata
+save_dataset (get_exec_pars().group + "/Station" , station )
+save_dataset (get_exec_pars().group + "/Energy" , energy )
+save_dataset (get_exec_pars().group + "/Energy gain" , fit_amplitude )
+save_dataset (get_exec_pars().group + "/On-crest VS-phase" , ph_crest )
+save_dataset (get_exec_pars().group + "/VS-phase offset" , phase_offset )
+save_dataset (get_exec_pars().group + "/Amplitude scale" , amplitude_scale )
+save_dataset (get_exec_pars().group + "/Power scale" , power_scale )
+set_attribute(get_exec_pars().group + "/Energy" , "Unit", "MeV" )
+set_attribute(get_exec_pars().group + "/Energy gain" , "Unit", "MeV" )
+set_attribute(get_exec_pars().group + "/On-crest VS-phase" , "Unit", "deg" )
+set_attribute(get_exec_pars().group + "/VS-phase offset" , "Unit", "deg" )
+set_attribute(get_exec_pars().group + "/Amplitude scale" , "Unit", "MV" )
+set_attribute(get_exec_pars().group + "/Power scale" , "Unit", "MW/MV^2" )
+set_attribute(get_exec_pars().group + "/Phase" , "Unit", "deg" )
+set_attribute(get_exec_pars().group + "/BPM-X averager" , "Unit", "mm" )
+
+#Elog entry
if do_elog:
- title = "Phase scan" + station
+ title = "Phase scan " + station
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "On-crest VS phase: %0.2f" % ph_crest + " deg \n"
- log_msg = log_msg + "Energy Gain: %0.3f" % fit_amplitude + " MeV \n"
- log_msg = log_msg + "VS -phase Offset: %0.2f" % phase_offset + " deg \n"
- 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
+ log_msg = log_msg + "Energy gain: %0.3f" % fit_amplitude + " MeV \n"
+ log_msg = log_msg + "VS-phase offset: %0.2f" % phase_offset + " deg \n"
+ log_msg = log_msg + "Amplitude scale: %0.3f" % amplitude_scale + " MV \n"
+ log_msg = log_msg + "Power scale: %0.6f" % power_scale + " MW/MV^2"
+ attachments = get_plot_snapshots(size=(600,400))
+ elog(title, log_msg, attachments)