diff --git a/config/config.properties b/config/config.properties
index 95c5dac..ed95f2e 100755
--- a/config/config.properties
+++ b/config/config.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 09:09:58 CET 2017
+#Wed Nov 15 16:28:05 CET 2017
autoSaveScanData=true
createSessionFiles=false
dataLayout=default
@@ -32,5 +32,5 @@ userAuthenticator=
userManagement=false
versionTrackingEnabled=true
versionTrackingLogin={context}/svcusr-hlapp_robot
-versionTrackingManual=false
+versionTrackingManual=true
versionTrackingRemote=git@git.psi.ch\:pshell_config/sf-op.git
diff --git a/config/devices.properties b/config/devices.properties
index fb1560a..9dfca2a 100755
--- a/config/devices.properties
+++ b/config/devices.properties
@@ -1,9 +1,10 @@
+dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
+cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
virtual_accelerator_set=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-MCRX070:I-SET|||true
virtual_accelerator_read=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-DBPM100:X1|||true
gun_solenoid=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:I-SET SINEG01-MSOL130:I-READ|||true
gun_phase=ch.psi.pshell.epics.Positioner|SINEG01-RSYS:SET-BEAM-PHASE SINEG01-RSYS:GET-BEAM-PHASE|||true
#SINSB01_phase=ch.psi.pshell.epics.Positioner|VA-SINSB01-RSYS100:SET-BEAM-PHASE VA-SINSB01-RSYS100:GET-BEAM-PHASE|||true
-dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
stream=ch.psi.pshell.bs.Stream|dispatcher|||true
#ref10=ch.psi.pshell.bs.Scalar|stream SINEG01-RLLE-REF10:SIG-PHASE-AVG 10|||
#ref20=ch.psi.pshell.bs.Scalar|stream SINEG01-RLLE-REF20:SIG-PHASE-AVG 10|||
@@ -42,8 +43,7 @@ gsx=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:X_SP SINEG01-MSOL130:X|||true
gsy=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:Y_SP SINEG01-MSOL130:Y|||true
gsrx=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_X_SP SINEG01-MSOL130:ROT_X|||true
gsry=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_Y_SP SINEG01-MSOL130:ROT_Y|||true
-camtool=ch.psi.pshell.bs.Camtool|localhost:10005|||
-cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
+#camtool=ch.psi.pshell.bs.Camtool|localhost:10005|||
#SINEG01-DBPM340:Q=ch.psi.pshell.device.Averager|SINEG01-DBPM340:Q|||true
#adc_xh1=ch.psi.pshell.epics.ChannelInteger|SARFE10-PBPG050:HAMP-014-x-h1-DATA-SUM|||true
#adc_yh2=ch.psi.pshell.epics.ChannelInteger|SARFE10-PBPG050:HAMP-011-y-h2-DATA-SUM|||true
diff --git a/devices/Beam phase.properties b/devices/Beam phase.properties
index 737c016..8336f35 100644
--- a/devices/Beam phase.properties
+++ b/devices/Beam phase.properties
@@ -1,4 +1,4 @@
-#Tue Nov 14 09:09:44 CET 2017
+#Fri Nov 24 07:52:19 CET 2017
maxValue=360.0
minValue=-360.0
offset=0.0
diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index 311039d..094f805 100644
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,19 +1,19 @@
-#Wed Nov 15 16:07:50 CET 2017
+#Sat Nov 25 15:14:11 CET 2017
\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
colormap=Flame
colormapAutomatic=true
-colormapMax=10239.0
-colormapMin=86.0
+colormapMax=2886.0
+colormapMin=71.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=1200
-imageWidth=1246
+imageHeight=600
+imageWidth=800
invert=false
-regionStartX=304
-regionStartY=8
+regionStartX=16
+regionStartY=16
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -24,9 +24,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
-spatialCalOffsetX=-50.075987841945285
-spatialCalOffsetY=-50.10141987829615
-spatialCalScaleX=-1.0
-spatialCalScaleY=-1.0
+spatialCalOffsetX=-371.495985377343
+spatialCalOffsetY=-65.07336431324175
+spatialCalScaleX=-8.737659474745154
+spatialCalScaleY=-8.834897904579043
spatialCalUnits=
transpose=false
diff --git a/devices/S20SY01-MQUA080.properties b/devices/S20SY01-MQUA080.properties
new file mode 100644
index 0000000..c52e4b8
--- /dev/null
+++ b/devices/S20SY01-MQUA080.properties
@@ -0,0 +1,8 @@
+#Tue Nov 21 10:54:40 CET 2017
+maxValue=10.0
+minValue=-10.0
+offset=0.0
+precision=3
+resolution=0.007
+scale=1.0
+unit=A
diff --git a/devices/S20SY01.MQUA080.properties b/devices/S20SY01.MQUA080.properties
new file mode 100644
index 0000000..d8077de
--- /dev/null
+++ b/devices/S20SY01.MQUA080.properties
@@ -0,0 +1,8 @@
+#Tue Nov 21 10:53:50 CET 2017
+maxValue=10.0
+minValue=-10.0
+offset=0.0
+precision=3
+resolution=0.007
+scale=1.0
+unit=null
diff --git a/devices/SARMA01-MQUA010.properties b/devices/SARMA01-MQUA010.properties
new file mode 100644
index 0000000..ecc76cd
--- /dev/null
+++ b/devices/SARMA01-MQUA010.properties
@@ -0,0 +1,8 @@
+#Tue Nov 21 08:36:17 CET 2017
+maxValue=10.0
+minValue=-10.0
+offset=0.0
+precision=3
+resolution=0.007
+scale=1.0
+unit=A
diff --git a/devices/SARMA01-MQUA10.properties b/devices/SARMA01-MQUA10.properties
new file mode 100644
index 0000000..0a8b9d7
--- /dev/null
+++ b/devices/SARMA01-MQUA10.properties
@@ -0,0 +1,8 @@
+#Tue Nov 21 08:23:50 CET 2017
+maxValue=10.0
+minValue=-10.0
+offset=0.0
+precision=3
+resolution=0.007
+scale=1.0
+unit=null
diff --git a/devices/WireScanner motor.properties b/devices/WireScanner motor.properties
index 0465f72..6749186 100644
--- a/devices/WireScanner motor.properties
+++ b/devices/WireScanner motor.properties
@@ -1,15 +1,16 @@
-#Tue Oct 03 14:58:01 CEST 2017
+#Tue Nov 21 11:59:54 CET 2017
defaultSpeed=4000.0
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=8000.0
-maxValue=51500.0
+maxValue=60528.0
minSpeed=50.0
-minValue=-56900.0
+minValue=-47999.0
offset=0.0
-precision=1
+precision=2
resolution=0.1
rotation=false
scale=1.0
+startRetries=1
unit=um
diff --git a/devices/cam1.properties b/devices/cam1.properties
index b362142..6115398 100644
--- a/devices/cam1.properties
+++ b/devices/cam1.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 14:02:48 CET 2017
+#Thu Nov 23 08:35:46 CET 2017
colormap=Temperature
colormapAutomatic=true
colormapMax=30000.0
diff --git a/devices/cam2.properties b/devices/cam2.properties
index c147201..2b84918 100644
--- a/devices/cam2.properties
+++ b/devices/cam2.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 14:02:48 CET 2017
+#Fri Nov 24 11:42:22 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
@@ -6,13 +6,13 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=-1
-imageWidth=-1
+imageHeight=1024
+imageWidth=1280
invert=false
offsetX=0.0
offsetY=0.0
-regionStartX=0
-regionStartY=0
+regionStartX=1
+regionStartY=1
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
diff --git a/devices/cam3.properties b/devices/cam3.properties
index 527c316..1b9460e 100644
--- a/devices/cam3.properties
+++ b/devices/cam3.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 14:02:49 CET 2017
+#Fri Nov 24 12:42:45 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
@@ -6,11 +6,11 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
-imageHeight=-1
-imageWidth=-1
+imageHeight=1024
+imageWidth=1280
invert=false
-regionStartX=0
-regionStartY=0
+regionStartX=1
+regionStartY=1
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
diff --git a/devices/cam_server.properties b/devices/cam_server.properties
index bfb80ba..34a9b02 100644
--- a/devices/cam_server.properties
+++ b/devices/cam_server.properties
@@ -1,4 +1,4 @@
-#Wed Nov 15 11:25:21 CET 2017
+#Thu Nov 23 17:13:12 CET 2017
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
-spatialCalOffsetX=-145.62499649229636
-spatialCalOffsetY=-440.5890253136218
-spatialCalScaleX=-8.737659322804419
-spatialCalScaleY=-8.834898186495984
+spatialCalOffsetX=-861.4939970777481
+spatialCalOffsetY=-820.4883730911062
+spatialCalScaleX=-18.90359092620482
+spatialCalScaleY=-19.37984500632817
spatialCalUnits=mm
transpose=false
diff --git a/devices/http:/sf-daqsync-01:8888.properties b/devices/http:/sf-daqsync-01:8888.properties
deleted file mode 100644
index dd604af..0000000
--- a/devices/http:/sf-daqsync-01:8888.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#Tue Sep 19 11:08:59 CEST 2017
-colormap=Grayscale
-colormapAutomatic=false
-colormapMax=NaN
-colormapMin=NaN
-flipHorizontally=false
-flipVertically=false
-grayscale=false
-invert=false
-rescaleFactor=1.0
-rescaleOffset=0.0
-roiHeight=-1
-roiWidth=-1
-roiX=0
-roiY=0
-rotation=0.0
-rotationCrop=false
-scale=1.0
-serverURL=localhost\:8888
-spatialCalOffsetX=NaN
-spatialCalOffsetY=NaN
-spatialCalScaleX=NaN
-spatialCalScaleY=NaN
-spatialCalUnits=mm
-transpose=false
diff --git a/devices/http:/sf-daqsync-01:8881.properties b/devices/pipeline_server.properties
similarity index 54%
rename from devices/http:/sf-daqsync-01:8881.properties
rename to devices/pipeline_server.properties
index c56b04d..6c78e50 100644
--- a/devices/http:/sf-daqsync-01:8881.properties
+++ b/devices/pipeline_server.properties
@@ -1,6 +1,6 @@
-#Tue Sep 19 11:06:51 CEST 2017
-colormap=Grayscale
-colormapAutomatic=false
+#Fri Nov 24 16:13:49 CET 2017
+colormap=Flame
+colormapAutomatic=true
colormapMax=NaN
colormapMin=NaN
flipHorizontally=false
@@ -16,10 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
-serverURL=localhost\:8888
-spatialCalOffsetX=NaN
-spatialCalOffsetY=NaN
-spatialCalScaleX=NaN
-spatialCalScaleY=NaN
+spatialCalOffsetX=-677.5082585941401
+spatialCalOffsetY=-627.4707187276099
+spatialCalScaleX=-8.737659534534535
+spatialCalScaleY=-8.834897886167417
spatialCalUnits=mm
transpose=false
diff --git a/plugins/SchottkyScan.form b/plugins/SchottkyScan.form
index 164ac6d..4068f20 100644
--- a/plugins/SchottkyScan.form
+++ b/plugins/SchottkyScan.form
@@ -25,10 +25,9 @@
-
-
+
@@ -40,15 +39,13 @@
-
-
-
+
@@ -227,73 +224,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/SchottkyScan.java b/plugins/SchottkyScan.java
index aa514ff..1e4c41e 100644
--- a/plugins/SchottkyScan.java
+++ b/plugins/SchottkyScan.java
@@ -31,7 +31,6 @@ public class SchottkyScan extends Panel {
public SchottkyScan() {
initComponents();
setPersistedComponents(SwingUtils.getComponentsByType(panelPars, JSpinner.class));
- buttonSet.setEnabled(false);
plot.setStyle(LinePlot.Style.ErrorY);
}
@@ -45,13 +44,11 @@ public class SchottkyScan extends Panel {
public void onStateChange(State state, State former) {
buttonAbort.setEnabled(state.isProcessing());
buttonStart.setEnabled(state == State.Ready);
- //buttonSet.setEnabled(buttonStart.isEnabled());
spinnerStart.setEnabled(buttonStart.isEnabled());
spinnerStop.setEnabled(buttonStart.isEnabled());
spinnerStep.setEnabled(buttonStart.isEnabled());
spinnerSamples.setEnabled(buttonStart.isEnabled());
spinnerLatency.setEnabled(buttonStart.isEnabled());
- //spinnerPhaseRef.setEnabled(buttonStart.isEnabled());
}
@Override
@@ -81,10 +78,6 @@ public class SchottkyScan extends Panel {
labelSamples = new javax.swing.JLabel();
spinnerStart = new javax.swing.JSpinner();
plot = new ch.psi.pshell.plot.LinePlotJFree();
- panelOutput = new javax.swing.JPanel();
- labelRefPhase = new javax.swing.JLabel();
- spinnerPhaseRef = new javax.swing.JSpinner();
- buttonSet = new javax.swing.JButton();
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
@@ -189,54 +182,6 @@ public class SchottkyScan extends Panel {
plot.setTitle("");
- panelOutput.setBorder(javax.swing.BorderFactory.createTitledBorder("Output"));
-
- labelRefPhase.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
- labelRefPhase.setText("Ref Phase:");
-
- spinnerPhaseRef.setModel(new javax.swing.SpinnerNumberModel(0.0d, -180.0d, 360.0d, 0.1d));
- spinnerPhaseRef.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- spinnerPhaseRefStateChanged(evt);
- }
- });
-
- buttonSet.setText("Set");
- buttonSet.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- buttonSetActionPerformed(evt);
- }
- });
-
- javax.swing.GroupLayout panelOutputLayout = new javax.swing.GroupLayout(panelOutput);
- panelOutput.setLayout(panelOutputLayout);
- panelOutputLayout.setHorizontalGroup(
- panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(panelOutputLayout.createSequentialGroup()
- .addContainerGap(25, Short.MAX_VALUE)
- .addGroup(panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelOutputLayout.createSequentialGroup()
- .addComponent(labelRefPhase)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(buttonSet, javax.swing.GroupLayout.Alignment.TRAILING))
- .addContainerGap())
- );
-
- panelOutputLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonSet, spinnerPhaseRef});
-
- panelOutputLayout.setVerticalGroup(
- panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(panelOutputLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(labelRefPhase)
- .addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(buttonSet)
- .addContainerGap(79, Short.MAX_VALUE))
- );
-
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -248,10 +193,9 @@ public class SchottkyScan extends Panel {
.addComponent(buttonStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort))
- .addComponent(panelPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(panelOutput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(panelPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
+ .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
.addContainerGap())
);
@@ -264,13 +208,11 @@ public class SchottkyScan extends Panel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(panelPars, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(panelOutput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort)))
- .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE))
.addGap(17, 17, 17))
);
@@ -280,7 +222,6 @@ public class SchottkyScan extends Panel {
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
//((Plugin)this).
plot.removeMarker(null);
- spinnerPhaseRef.setValue(0.0);
ArrayList parameters = new ArrayList();
parameters.add(spinnerStart.getValue());
parameters.add(spinnerStop.getValue());
@@ -295,9 +236,8 @@ public class SchottkyScan extends Panel {
getLogger().info("Exception executing scan: " + ex);
} else {
Double bph_ref = (Double) ((List)ret).get(0);
- spinnerPhaseRef.setValue(Convert.roundDouble(bph_ref, 1));
- buttonSet.setEnabled(true);
- spinnerPhaseRef.setEnabled(true);
+ //spinnerPhaseRef.setValue(Convert.roundDouble(bph_ref, 1));
+ //spinnerPhaseRef.setEnabled(true);
}
return ret;
});
@@ -316,50 +256,17 @@ public class SchottkyScan extends Panel {
}
}//GEN-LAST:event_buttonAbortActionPerformed
- private void spinnerPhaseRefStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerPhaseRefStateChanged
- try {
- plot.removeMarker(null);
- plot.addMarker((Double) spinnerPhaseRef.getValue(), Plot.AxisId.X, "Ref Phase", Color.GREEN);
- } catch (Exception ex) {
- showException(ex);
- }
- }//GEN-LAST:event_spinnerPhaseRefStateChanged
-
- private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed
- ArrayList parameters = new ArrayList();
- parameters.add((Double) spinnerPhaseRef.getValue());
- parameters.add(plot);
- try {
- //How to get a callback on the end of execution
- runAsync("RFscan/SchottkyScanSet", parameters).handle((ret, ex) -> {
- if (ex != null) {
- getLogger().info("Exception executing scan: " + ex);
- showException((Exception) ex);
- }
- buttonSet.setEnabled(false);
- spinnerPhaseRef.setEnabled(false);
- return ret;
- });
- } catch (Exception ex) {
- showException(ex);
- }
- }//GEN-LAST:event_buttonSetActionPerformed
-
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
- private javax.swing.JButton buttonSet;
private javax.swing.JButton buttonStart;
private javax.swing.JLabel labelLatency;
- private javax.swing.JLabel labelRefPhase;
private javax.swing.JLabel labelSamples;
private javax.swing.JLabel labelStart;
private javax.swing.JLabel labelStep;
private javax.swing.JLabel labelStop;
- private javax.swing.JPanel panelOutput;
private javax.swing.JPanel panelPars;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerLatency;
- private javax.swing.JSpinner spinnerPhaseRef;
private javax.swing.JSpinner spinnerSamples;
private javax.swing.JSpinner spinnerStart;
private javax.swing.JSpinner spinnerStep;
diff --git a/plugins/WireScan.java b/plugins/WireScan.java
index 02a8a59..f6ac679 100644
--- a/plugins/WireScan.java
+++ b/plugins/WireScan.java
@@ -816,15 +816,15 @@ public class WireScan extends Panel {
parameters.add(spinnerVel.getValue());
ArrayList bpms = new ArrayList();
for (JComboBox cb : bpmCombos){
- if (!cb.getSelectedItem().toString().isEmpty()){
+ if (cb.getSelectedItem()!=null && (!cb.getSelectedItem().toString().isEmpty())){
bpms.add(cb.getSelectedItem().toString());
}
}
parameters.add(bpms);
ArrayList blms = new ArrayList();
for (JComboBox cb : blmCombos){
- if (!cb.getSelectedItem().toString().isEmpty()){
- blms.add(cb.getSelectedItem().toString());
+ if ((cb.getSelectedItem()!=null) && (!cb.getSelectedItem().toString().isEmpty())){
+ blms.add(cb.getSelectedItem().toString());
}
}
parameters.add(blms);
@@ -853,6 +853,7 @@ public class WireScan extends Panel {
}
} catch (Exception ex) {
showException(ex);
+ ex.printStackTrace();
}
}//GEN-LAST:event_buttonScanActionPerformed
@@ -889,7 +890,8 @@ public class WireScan extends Panel {
}
}//GEN-LAST:event_buttonParkActionPerformed
- String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
+ //String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
+ String caqtdm = "caqtdm -noMsg -stylefile sfop.qss";
private void buttonMotorPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMotorPanelActionPerformed
try {
String cmd = caqtdm + " -macro 'P=" + comboWireScanner.getSelectedItem() + ":,M=MOTOR_1' /sf/common/config/qt/motorx_all.ui";
diff --git a/script/Diagnostics/CamtoolScan.py b/script/Diagnostics/CamtoolScan.py
index e93bbbd..4a78ea0 100644
--- a/script/Diagnostics/CamtoolScan.py
+++ b/script/Diagnostics/CamtoolScan.py
@@ -1,16 +1,18 @@
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
-
-CAMERA = "S10DI01-DSCR020"
+#This scan is dedicated to scan either one parameter (e.g. a quadrupole) and take a certain amount of images at every location
+CAMERA = "SARCL01-DSCR170" #Specify the camera we want to use
#CAMERA = "SINDI02-DLAC055"
-QUADRUPOLE = "S10CB01-MQUA430" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
-CHARGE_BPM = "SINEG01-DBPM340:Q1"
-CHARGE_ICT = "SINEG01-DICT215:B1_CHARGE-OP"
-RANGE = (-0.485, 1.515)
-STEPS = 100
+QUADRUPOLE = "S20SY01-MQUA080" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
+CHARGE_BPM = "SARCL01-DBPM120:Q1" #reading out the charge also
+CHARGE_ICT = "S10DI01-DICT025:B1_CHARGE-OP" #reading out the charge also
+RANGE = (0.382,8.382) #range for the quadrupole
+#RANGE = None #if range None, just NUM_IMAGES are recorded
+STEPS = 50 #step size for the quadrupole scan range
SETTLING_TIME = 0.1
+NUM_IMAGES = 10 #number of images for every step
print cam_server.cameras
-cam_server.start(CAMERA)
+cam_server.start(CAMERA + "_sp1", True)
wait_cam_server_message()
print cam_server.value.identifiers
m=cam_server.getDataMatrix()
@@ -46,7 +48,13 @@ try:
set_attribute("/", "Filter Position", caget(CAMERA + ":GET_FILTER", 's'))
except:
pass
-
+
+
+#cam_server.captureBackground(10)
+#cam_server.setBackgroundImage(img)
+#cam_server.setBackgroundSubtraction(False)
+former_value = quad.read()
+
try:
laser_off()
#save_dataset("/Background", m.read())
@@ -62,9 +70,29 @@ try:
readables = cam_server.stream.getReadables().clone() + [bpm, ict]
readables.remove(cam_server.stream.getChild("image"))
readables.insert(0,m)
- lscan(quad, readables, RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME)
+ if RANGE is None:
+ mscan(cam_server.stream, readables, NUM_IMAGES)
+ else:
+ if NUM_IMAGES<=1:
+ def wait_next():
+ cam_server.stream.waitCacheChange(10000)
+ lscan(quad, readables, RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME, before_read = wait_next)
+ else:
+ class ImageSampler(Writable):
+ def write(self, value):
+ cam_server.stream.waitCacheChange(10000)
+ image_sampler = ImageSampler()
+ ascan([quad, image_sampler], readables, [RANGE[0], 0], [RANGE[1], NUM_IMAGES-1], [STEPS, NUM_IMAGES-1], latency=SETTLING_TIME)
+
+ #vector=[]
+ #for pos in frange(RANGE[0], RANGE[1], STEP_SIZE):
+ # for img in range(NUM_IMAGES):
+ # vector.append(pos)
+ #vscan(quad, readables, vector)
+
finally:
+ quad.write(former_value)
quad.close()
cam_server.stop()
diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py
index 4740bcb..b560e8d 100644
--- a/script/Diagnostics/WireScan.py
+++ b/script/Diagnostics/WireScan.py
@@ -64,11 +64,13 @@ set_attribute("/", "BLMs", blms)
filename = get_exec_pars().path
+
+
#Stream creation
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
- st.addScalar(c[0], c[1], 10, 0)
+ st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
diff --git a/script/Photonics/KValueScanGas.py b/script/Photonics/KValueScanGas.py
new file mode 100644
index 0000000..d7632ac
--- /dev/null
+++ b/script/Photonics/KValueScanGas.py
@@ -0,0 +1,15 @@
+GAP = "SARUN03-UIND030"
+SAMPLES = 20
+TOLERANCE = 0.01
+TIMEOUT = 10.0
+
+intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det")
+
+gap = Channel(GAP + ":K_SET", alias = "gap")
+#readout = Channel(GAP + ":GAP")
+
+av = create_averager(intensity, SAMPLES, name = None)
+
+ret = lscan (gap, av, 1.195, 1.205, 10, latency=20.0)
+
+
diff --git a/script/Photonics/PhaseShifterScanGas.py b/script/Photonics/PhaseShifterScanGas.py
new file mode 100644
index 0000000..0cd2bce
--- /dev/null
+++ b/script/Photonics/PhaseShifterScanGas.py
@@ -0,0 +1,34 @@
+GAP = "SARUN07-UPHS060"
+SAMPLES = 20
+TOLERANCE = 0.01
+TIMEOUT = 10.0
+
+intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det")
+
+gap = Channel(GAP + ":GAP_SP", alias = "gap")
+readout = Channel(GAP + ":GAP")
+
+av = create_averager(intensity, SAMPLES, interval = -1, name = None)
+
+def before(position, scan):
+ caput(GAP + ":GO", 1)
+ 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)
+
+
+#run("CPython/wrapper")
+#xdata = ret.getPositions(0)
+#ydata = ret.getReadable(0)
+#(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(ydata , xdata)
+#print fit_amplitude, fit_phase_deg, fit_offset
+#plt = get_plots()[0]
+#if plt is not None:
+# plt.addSeries(LinePlotErrorSeries("fit"))
+# plt.getSeries(1).setData(fit_x, fit_y)
+# plt.getSeries(1).setPointsVisible(False)
+# plt.setLegendVisible(True)
diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py
index 804a394..7fabe54 100644
--- a/script/RFscan/SchottkyScan.py
+++ b/script/RFscan/SchottkyScan.py
@@ -14,8 +14,8 @@ if is_panel:
else:
start = -10.0
stop = 150.0
- step = 1.0
- nb = 4
+ step = 5.0
+ nb = 1
lat = 0.110
plt = plot(None, title="Output")[0]
@@ -91,13 +91,13 @@ y = charge[a:b+1]
p = (a0, a1) = fit_polynomial(y, x, 1)
f = PolynomialFunction(p)
x1 = -a0 / a1 if a1 != 0 else 0.0
-#x2 = beamphase[charge.index(max(charge))]
x2 = beamphase[b+1]
x_fit = frange(x1, x2, (x2-x1), True)
y_fit = [f.value(val) for val in x_fit]
plt.addSeries(LinePlotErrorSeries("Fit", Color.green))
plt.getSeries(1).setData(to_array(x_fit, 'd'), y_fit, [0.0] * len(x_fit))
plt.getSeries(1).setPointsVisible(False)
+plt.addMarker(x1, plt.AxisId.X, "%0.2f" % x1, Color.green)
#Setting the return value
bph_ref_guess = x1
@@ -118,7 +118,7 @@ if do_elog:
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % bph0 + " deg beam phase\n"
- log_msg = log_msg + "Ref. phase: %0.2f" % x1 + " deg \n"
+ log_msg = log_msg + "Charge onset: %0.2f" % x1 + " deg \n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
diff --git a/script/Tools/CameraTools.py b/script/Tools/CameraTools.py
index f79ceca..a441273 100644
--- a/script/Tools/CameraTools.py
+++ b/script/Tools/CameraTools.py
@@ -1,5 +1,9 @@
+import json
run("Devices/Elements")
+def get_processing_parameters(stream_value):
+ return json.loads(stream_value.getValue("processing_parameters"))
+
def _create_tables(paths, stream_value, data_type, shape):
root = paths["root"]
create_dataset(paths["image"], data_type, dimensions = [images, shape[0], shape[1]])
@@ -11,8 +15,12 @@ def _create_tables(paths, stream_value, data_type, shape):
pass
elif id == "processing_parameters":
val = json.loads(val)
- for key in val.keys():
- set_attribute(paths["image"], key, "" if val[key] is None else val[key] )
+ for key in val.keys():
+ if val[key] is not None and isinstance(val[key], dict):
+ for k in val[key].keys():
+ set_attribute(paths["image"], key + " " + k , "" if val[key][k] is None else val[key][k] )
+ else:
+ set_attribute(paths["image"], key, "" if val[key] is None else val[key] )
elif isinstance(val, PyArray):
create_dataset(root + id, 'd', dimensions = [images, len(val)])
elif isinstance(val, PyLong):
@@ -30,7 +38,7 @@ def _append_frame(paths, stream_value, index, data_type, shape):
root = paths["root"]
append_dataset(paths["image"], stream_value.getValue("image"),[index,0,0], type = data_type, shape=[1, shape[0], shape[1]])
append_dataset(paths["pid"], stream_value.getPulseId(), index)
- append_dataset(paths["timestamp_str"], datetime.datetime.fromtimestamp(stream_value.timestampNanos/1e9).strftime('%Y-%m-%d %H:%M:%S'), index)
+ append_dataset(paths["timestamp_str"], datetime.datetime.fromtimestamp(stream_value.timestampNanos/1e9).strftime('%Y-%m-%d %H:%M:%S.%f'), index)
for id in stream_value.identifiers:
try:
@@ -52,42 +60,42 @@ def _append_frame(paths, stream_value, index, data_type, shape):
print "Saved frame: ", index
-def _write_metadata(paths, camera_name, shared = False, images = 1, interval = -1):
+def _write_metadata(paths, camera, images = 1, interval = -1):
root = paths["root"]
- set_attribute(root, "Name", camera_name)
- set_attribute(root, "Shared", shared)
+ set_attribute(root, "Camera", camera)
set_attribute(root, "Images", images)
set_attribute(root, "Interval", interval)
- cam_type = get_camera_type(camera_name)
+ cam_type = get_camera_type(camera)
set_attribute(root, "Type", cam_type)
if cam_type=="ELECTRONS":
- set_attribute(root, "Screen", caget(camera_name + (":POSITION" if (camera_name.startswith("DSRM")) else ":GET_SCREEN1_POS"), 's'))
- set_attribute(root, "Filter", caget(camera_name + ":GET_FILTER", 's'))
+ set_attribute(root, "Screen", caget(camera + (":POSITION" if (camera.startswith("DSRM")) else ":GET_SCREEN1_POS"), 's'))
+ set_attribute(root, "Filter", caget(camera + ":GET_FILTER", 's'))
-def save_camera_data(server, camera_name, shared = False, root = "/", images = 1, interval = -1, parallel = True, pause = False):
+def save_camera_data(server, images = 1, interval = -1, root = "/camera1", parallel = True, pause = False):
stream_value = server.stream.take()
if stream_value is None:
server.waitNext(10000)
stream_value = server.stream.take()
if not root.endswith('/'):
root = root + "/"
+ camera = get_processing_parameters(stream_value)["camera_name"]
paths = {"root": root, "image":root+"image", "pid":root+"/pulse_id", "timestamp_str":root+"/timestamp_str"}
shape = [stream_value.getValue("height"),stream_value.getValue("width")]
data_type = stream_value.getValue("image").typecode
-
tasks = []
if pause:
server.paused = True
try:
for i in range(images):
+ print i
if i==0:
_create_tables(paths, stream_value, data_type, shape)
- _write_metadata(paths, camera_name, shared, images, interval)
+ _write_metadata(paths, camera, images, interval)
start = time.time()
stream_value = server.stream.take()
- if parallel:
+ if parallel:
tasks.extend( fork((_append_frame,(paths, stream_value, i, data_type, shape)),) )
else:
_append_frame(paths, stream_value, i, data_type, shape)
@@ -106,3 +114,6 @@ def save_camera_data(server, camera_name, shared = False, root = "/", images = 1
print "Waiting finish persisting..."
join(tasks)
print "Done"
+
+def save_camera_snapshot(server, file, format = "png"):
+ ImageBuffer.saveImage(server.output, file, "png")
diff --git a/script/Tools/save_camera_data.py b/script/Tools/save_camera_data.py
index 04c7740..a507b0d 100644
--- a/script/Tools/save_camera_data.py
+++ b/script/Tools/save_camera_data.py
@@ -5,43 +5,93 @@ import org.python.core.PyFloat as PyFloat
import json
import traceback
import datetime
+import ch.psi.pshell.bs.PipelineServer as PipelineServer
+import ch.psi.pshell.imaging.Colormap as Colormap
if get_exec_pars().source == CommandSource.ui:
camera_name = "SARBD02-DSCR050" # "SLG-LCAM-C041_sp"
- shared = True
- images = 5
+ #camera_name = "SARBD02-DSCR050_sp" # "SLG-LCAM-C041_sp"
+ #camera_name = "simulation_sp" # "SLG-LCAM-C041_sp"
+ shared = False
+ images = 1
interval = -1
- roi = "" #"[540, 200, 430,100]"
+ roi = ""
+ #roi = "[300, 200]"
+ #roi = "[540, 200, 430,100]"
+ snapshot = False
else:
camera_name = args[0]
shared = args[1].lower() == "true"
- images = int(args[2])
- interval = int(args[3])
- roi = args[4]
-
+ images = int(args[2]) if len(args)>2 else 1
+ interval = int(args[3]) if len(args)>3 else -1
+ roi = args[4] if len(args)>4 else ""
+ snapshot = args[5].lower() == "true" if len(args)>5 else False
+
+
+background = get_exec_pars().background
+
+
run("Tools/CameraTools")
-set_exec_pars(name="camera_snapshot")
+set_exec_pars(name="camera_data")
-root = "/camera1"
-parallel = True
-
-cam_server.start(camera_name + "_sp1" if shared else camera_name, shared)
-
-if roi is not None and len(roi.strip())>0:
- roi = json.loads(roi)
- cam_server.setRoi(roi[0], roi[2], roi[1], roi[3])
- while True:
- cam_server.waitNext(10000)
- r = json.loads(cam_server.stream.take()["processing_parameters"])
- if roi == r["image_region_of_interest"]:
- break;
+if background:
+ _server = PipelineServer("pipeline_server", cam_server.url)
+ _server.config.colormap = Colormap.Flame
+ _server.config.colormapAutomatic = True
+ _server.initialize()
else:
- cam_server.waitNext(10000)
+ _server = cam_server
-save_camera_data(cam_server, camera_name, shared, root, images, interval, parallel, pause=True)
+try:
+ _server.start(camera_name + "_sp1" if shared else camera_name, shared)
+
+ if roi is not None and len(roi.strip())>0:
+ roi = json.loads(roi)
+ if len(roi) == 2:
+
+ if _server.stream.take() == None:
+ _server.waitNext(10000)
+ while True:
+ if json.loads(_server.stream.take()["processing_parameters"])["image_region_of_interest"] == None:
+ break
+ _server.resetRoi()
+ _server.waitNext(10000)
+ iw, ih, cx, cy = _server.getValue("width"), _server.getValue("height"), _server.getValue("x_fit_mean"), _server.getValue("y_fit_mean")
+ xa, ya = _server.getValue("x_axis"), _server.getValue("y_axis")
+ cx = (cx - xa[0]) / (xa[-1]-xa[0]) * iw
+ cy = (cy - ya[0]) / (ya[-1]-ya[0]) * ih
+ w, h = roi[0], roi[1]
+ x, y = int(max(cx- (w/2), 0)), int(max(cy-(h/2), 0))
+ w, h = min(w, iw-x), min(h, ih-y)
+ roi = [x, w, y, h]
+ if (w<0) or (h<0):
+ raise Exception("Invalid ROI: " + str(roi))
+ _server.setRoi(roi[0], roi[2], roi[1], roi[3])
+ elif len(roi) == 4:
+ _server.setRoi(roi[0], roi[2], roi[1], roi[3])
+ else:
+ raise Exception("Invalid ROI: " + str(roi))
+ while True:
+ _server.waitNext(10000)
+ r = json.loads(_server.stream.take()["processing_parameters"])
+ if roi == r["image_region_of_interest"]:
+ break;
+ else:
+ _server.waitNext(10000)
+
+ save_camera_data(_server, images, interval, parallel = True, pause=True)
+
+ set_exec_pars(open = False)
+ data_file = get_exec_pars().path
+
+ if snapshot:
+ format ="png"
+ save_camera_snapshot(_server, data_file + "." + format, format)
+finally:
+ if background:
+ _server.close()
+ else:
+ _server.stop()
-cam_server.stop()
-
-data_file = get_exec_pars().path
set_return(data_file)
\ No newline at end of file
diff --git a/script/Tools/save_camera_data_client.py b/script/Tools/save_camera_data_client.py
new file mode 100644
index 0000000..7a4bae7
--- /dev/null
+++ b/script/Tools/save_camera_data_client.py
@@ -0,0 +1,19 @@
+def save_camera(name, shared = True, images = 1, interval = -1, roi=None, snapshot = False):
+ import requests
+ import urllib
+ roi = "" if roi == None else urllib.quote_plus(str(roi).replace(" ", ""))
+ base = "http://sf-daq-mgmt:8090/"
+ url = base + "run/Tools/save_camera_data(%s,%s,%s,%s,'%s',%s)&" % (name, str(shared), str(images), str(interval), roi, str(snapshot))
+ r = requests.get(url)
+ if r.status_code != 200:
+ raise Exception(r.text)
+ return r.text
+
+#start = time.time()
+#print save_camera("SARBD02-DSCR050")
+#print save_camera("SARBD02-DSCR050", False)
+#print save_camera("SARBD02-DSCR050", True)
+#print save_camera("simulation_sp", False, 10, roi=[500, 300, 400, 150], snapshot = True)
+#print save_camera("simulation_sp", False, 10, roi=[300, 200])
+
+#print time.time()-start
\ No newline at end of file
diff --git a/script/Tools/save_snapshot_client.py b/script/Tools/save_snapshot_client.py
index d288345..a388232 100644
--- a/script/Tools/save_snapshot_client.py
+++ b/script/Tools/save_snapshot_client.py
@@ -9,20 +9,3 @@ def save_snapshot(camera_name = "SLG-LCAM-C041_sp", shared = False ): #, logbook
#print "Ret: ", r.text
return json.loads(r.text.replace("'", '"') .replace('u"', '"'))
-
-r=None
-def save_snapshot_mult(camera_name = "SLG-LCAM-C041_sp", shared = False, images = 1, interval = 1000):
- global r
- import requests
- base = "http://sf-daq-mgmt:8090/"
- #url = base + "run/Tools/save_snapshot(%s,%s,%s,%s)" % (camera_name, str(shared), logbook, "'" + str(comment) + "'")
- url = base + "run/Tools/save_snapshot_mult(%s,%s, %s,%s)" % (camera_name, str(shared), str(images), str(interval))
- r = requests.get(url)
- if r.status_code != 200:
- raise Exception(r.text)
- #print "Ret: ", r.text
- #return json.loads(r.text.replace("'", '"') .replace('u"', '"'))
- return r
-
-
-print save_snapshot_mult()
\ No newline at end of file
diff --git a/script/local.py b/script/local.py
index 98513e1..274c113 100755
--- a/script/local.py
+++ b/script/local.py
@@ -160,6 +160,7 @@ def hfit(ydata, xdata = None):
print "max = ",max_x
p.addMarker(max_x, None, "Max="+str(round(max_x ,2)), Color.MAGENTA.darker())
return (amplitude, angular_frequency, phase, False, max_x, fit_x, fit_y)
+
def clear_convex_hull_plot(title):
plots = get_plots(title = title)
@@ -318,7 +319,7 @@ def get_camera_type(camera_name):
"PPRM" in camera_name or \
"PSSS" in camera_name or \
"PSCR" in camera_name or \
- "PSRD" in camera_name: return "ELECTRONS"
+ "PSRD" in camera_name: return "PHOTONICS"
return "UNKNOWN"
diff --git a/script/test/GunEnergyScan.py b/script/test/GunEnergyScan.py
new file mode 100644
index 0000000..9ffc6f5
--- /dev/null
+++ b/script/test/GunEnergyScan.py
@@ -0,0 +1,172 @@
+import ch.psi.pshell.epics.Positioner as Positioner
+from mathutils import PolynomialFunction
+
+dry_run = True
+do_elog = True
+is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
+
+def quadfit(xdata, ydata):
+ """
+ Quadratic fit
+ """
+ p = (a0, a1, a2) = fit_polynomial(ydata, xdata, 2)
+ f = PolynomialFunction(p)
+ if a1 != 0:
+ x_ext = -a1 / (2 * a0)
+ y_ext = f.value(x_ext)
+ else:
+ x_ext = None
+ y_ext = None
+ yhat = [f.value(val) for val in xdata]
+ ybar = sum(ydata)/len(ydata)
+ ssreg = sum([(val - ybar)**2 for val in yhat])
+ sstot = sum([(val - ybar)**2 for val in ydata])
+ R2 = ssreg / sstot
+ x1 = min(xdata)
+ x2 = max(xdata)
+ x_fit = frange(x1, x2, (x2-x1)/100, True)
+ y_fit = [f.value(val) for val in x_fit]
+ return (p, x_ext, y_ext, R2, x_fit, y_fit)
+
+#Parameters
+if is_panel:
+ start = args[0]
+ stop = args[1]
+ step = args[2]
+ nb = int(args[3])
+ lat = args[4]
+ disp = args[5]
+ p0 = args[6]
+ plt = args[7]
+else:
+ start = 44.0
+ stop = 65.0
+ step = 1.0
+ nb = 3
+ lat = 0.3
+ disp = -0.387
+ p0 = 7.1
+ plt = plot(None, title="Output")[0]
+
+A = p0 / disp / 1e6
+B = p0
+
+#Plot setup
+plt.clear()
+plt.removeMarker(None)
+plt.setStyle(plt.Style.ErrorY)
+plt.addSeries(LinePlotErrorSeries("Momentum", Color.red))
+plt.addSeries(LinePlotErrorSeries("Momentum Spread", Color.yellow, 2))
+plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
+plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
+plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
+plt.setLegendVisible(True)
+
+#Creating Phase positioner
+if dry_run:
+ phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
+ camera_name = "simulation"
+else:
+ phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
+ camera_name = "SINBD01-DSCR010"
+phase.config.minValue = -360.0
+phase.config.maxValue = 360.0
+phase.config.precision = 3
+phase.config.resolution = 0.1
+phase.config.rotation = False
+phase.config.save()
+phase.initialize()
+phase0 = phase.read()
+
+#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")
+
+#Creating averagers
+x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
+dx_averager = create_averager(dx, nb, -1)
+dx_averager.monitored = True # not blocking, will return last nb values
+
+#Record callback: uptate of output plot
+def after_sample(record, scan):
+ global A, B, plt
+ x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
+ x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
+ p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
+ dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
+ plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev)
+ plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev)
+
+#The scan loop
+try:
+ phase.write(start)
+ time.sleep(2.0)
+ r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
+finally:
+ phase.write(phase0)
+ phase.close()
+ cam_server.stop() # stops cam_server but does not close it cam_server is a global object
+
+ph = r.getPositions(0)
+p = [A * val.mean + B for val in r.getReadable(0)]
+dp = [abs(A) * val.mean for val in r.getReadable(1)]
+
+#Fitting and plotting
+try:
+ i_max = p.index(max(p))
+ i_min = dp.index(min(dp))
+ a,b = max(i_max-5, 0), min(i_max+6, len(p))
+ Xdat = ph[a:b]
+ Ydat = p[a:b]
+ (p_poly, ph_p_max, p_max, p_R2, ph_p_fit, p_fit) = quadfit(Xdat, Ydat)
+ a,b = max(i_min-5, 0), min(i_min+6, len(dp))
+ Xdat = ph[a:b]
+ Ydat = dp[a:b]
+ (dp_poly, ph_dp_min, dp_min, dp_R2, ph_dp_fit, dp_fit) = quadfit(Xdat, Ydat)
+ plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
+ plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
+ plt.getSeries(2).setData(ph_p_fit, p_fit)
+ plt.getSeries(3).setData(ph_dp_fit, dp_fit)
+ plt.getSeries(2).setPointsVisible(False)
+ plt.getSeries(3).setPointsVisible(False)
+ plt.addMarker(ph_p_max, plt.AxisId.X, "%3.2f" % ph_p_max, plt.getSeries(0).color)
+ plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color)
+except:
+ raise Exception("Fit failure")
+
+#Setting the return value
+set_return([ph_dp_min])
+
+#Saving metadata
+save_dataset(get_exec_pars().group + "/p", p)
+set_attribute(get_exec_pars().group + "/p", "p max", p_max)
+set_attribute(get_exec_pars().group + "/p", "p max phase", ph_p_max)
+set_attribute(get_exec_pars().group + "/p", "p fit R2", p_R2)
+save_dataset(get_exec_pars().group + "/dp", dp)
+set_attribute(get_exec_pars().group + "/dp", "dp min", dp_min)
+set_attribute(get_exec_pars().group + "/dp", "dp min phase", ph_dp_min)
+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"))
+ log_msg = "Data file: " + get_exec_pars().path + "\n\n"
+ log_msg = log_msg + "Laser: " + Laser + "\n"
+ if Laser == "Alcor":
+ log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
+ else:
+ log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
+ if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
+ log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
+ else:
+ log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
+ log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
+ log_msg = log_msg + "p-max: %0.2f" % p_max + " MeV/c at %0.2f" % ph_p_max + " deg beam phase\n"
+ log_msg = log_msg + "dp-min: %0.2f" % dp_min + " MeV/c at %0.2f" % ph_dp_min + " deg beam phase\n"
+ sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
+ file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
+ plt.saveSnapshot(file_name , "png")
+ elog("Gun Energy Scan", log_msg, [file_name,])
diff --git a/script/test/GunEnergyScanSet.py b/script/test/GunEnergyScanSet.py
new file mode 100644
index 0000000..d6ace45
--- /dev/null
+++ b/script/test/GunEnergyScanSet.py
@@ -0,0 +1,26 @@
+dry_run = True
+do_elog = True
+
+if get_exec_pars().source == CommandSource.ui:
+ bph_ref_user = 0.0
+ plt = None
+else:
+ bph_ref_user = args[0]
+ plt = args[1]
+phaseOffset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
+phaseOffset_new = 90 - bph_ref_user + phaseOffset_old
+if not dry_run:
+ caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phaseOffset_new)
+ caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1)
+if do_elog:
+ log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE \n"
+ log_msg = log_msg + "Old: %0.1f" % phaseOffset_old + " deg \n"
+ log_msg = log_msg + "New: %0.1f" % phaseOffset_new + " deg \n"
+ attachments = []
+ if plt is not None:
+ sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
+ file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanSetPlot.png")
+ plt.saveSnapshot(file_name , "png")
+ attachments = [file_name]
+ elog("Set gun phase", log_msg, attachments)
+show_message("Success setting phase reference")
diff --git a/script/test/QuadFit.py b/script/test/QuadFit.py
new file mode 100644
index 0000000..3a13173
--- /dev/null
+++ b/script/test/QuadFit.py
@@ -0,0 +1,28 @@
+from mathutils import PolynomialFunction
+
+def quadfit(xdata, ydata):
+ """
+ Quadratic fit
+ """
+ p = (a0, a1, a2) = fit_polynomial(ydata, xdata, 2)
+ f = PolynomialFunction(p)
+ if a1 != 0:
+ x_ext = -a1 / (2 * a0)
+ y_ext = f.value(x_ext)
+ else:
+ x_ext = None
+ y_ext = None
+ yhat = [f.value(val) for val in xdata]
+ ybar = sum(ydata)/len(ydata)
+ ssreg = sum([(val - ybar)**2 for val in yhat])
+ sstot = sum([(val - ybar)**2 for val in ydata])
+ R2 = ssreg / sstot
+ x1 = min(xdata)
+ x2 = max(xdata)
+ x_fit = frange(x1, x2, (x2-x1)/100, True)
+ y_fit = [f.value(val) for val in x_fit]
+ return (p, x_ext, y_ext, R2, x_fit, y_fit)
+
+xx=(1.0,2.0,3.0,4.0)
+yy=(1.1,3.9,8.5,15.8)
+quadfit(xx, yy)
\ No newline at end of file
diff --git a/script/test/SchottkyScan.py b/script/test/SchottkyScan.py
new file mode 100644
index 0000000..804a394
--- /dev/null
+++ b/script/test/SchottkyScan.py
@@ -0,0 +1,128 @@
+import ch.psi.pshell.epics.Positioner as Positioner
+import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
+
+dry_run = False
+do_elog = True
+is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
+if is_panel:
+ start = args[0]
+ stop = args[1]
+ step = args[2]
+ nb = int(args[3])
+ lat = args[4]
+ plt = args[5]
+else:
+ start = -10.0
+ stop = 150.0
+ step = 1.0
+ nb = 4
+ lat = 0.110
+ plt = plot(None, title="Output")[0]
+
+#Plot setup
+plt.clear()
+plt.removeMarker(None)
+plt.setStyle(plt.Style.ErrorY)
+plt.addSeries(LinePlotErrorSeries("Charge", Color.red))
+plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
+plt.getAxis(plt.AxisId.Y).setLabel("SINEG01-DICT215:B1_CHARGE (pC)")
+plt.setLegendVisible(True)
+
+if dry_run:
+ bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
+ rph = ChannelDouble("RF phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM")
+ q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE-SIM")
+ q.initialize()
+ q.monitored=True
+else:
+ bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
+ rph = ChannelDouble("RF phase", "SINEG01-RSYS:SET-VSUM-PHASE")
+ #st = Stream("ICTstream", dispatcher)
+ #q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
+ #st.initialize()
+ #st.start()
+ #st.waitValueChange(10000)
+ q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE")
+ q.initialize()
+ q.monitored=True
+bph.config.minValue = -360.0
+bph.config.maxValue = 360.0
+bph.config.precision = 3
+bph.config.rotation = True
+bph.config.resolution = 0.1
+bph.config.save()
+bph.initialize()
+rph.initialize()
+rph.monitored=True
+bph0 = bph.read()
+rph0 = rph.read()
+
+#Creating averagers
+rph_averager = create_averager(rph, nb, 0.1)
+q_averager = create_averager(q, nb, 0.1)
+q_averager.monitored=True
+
+#Record callback: uptate of output plot
+def after_sample(record, scan):
+ plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.values[1].mean, record.values[1].stdev)
+
+#The scan loop
+try:
+ r = lscan(bph, (rph_averager, q_averager), start, stop, step, latency=lat, after_read = after_sample)
+finally:
+ rph.write(rph0)
+ bph.close()
+ rph.close()
+ q.close()
+ #st.close()
+#beamphase = r.getPositions(0)
+beamphase = [(val + 90) % 360 - 90 for val in r.getPositions(0)]
+rfphase = [(val.mean + 90) % 360 - 90 for val in r.getReadable(0)]
+rfphaserms = [val.stdev for val in r.getReadable(0)]
+charge = [val.mean for val in r.getReadable(1)]
+chargerms = [val.stdev for val in r.getReadable(1)]
+
+#Fitting and plotting
+i, a, b = 0, 0, 0
+while charge[i] < (max(charge) * 0.20) : a = i; i = i + 1
+while charge[i] < (max(charge) * 0.60) : b = i; i = i + 1
+x = beamphase[a:b+1]
+y = charge[a:b+1]
+p = (a0, a1) = fit_polynomial(y, x, 1)
+f = PolynomialFunction(p)
+x1 = -a0 / a1 if a1 != 0 else 0.0
+#x2 = beamphase[charge.index(max(charge))]
+x2 = beamphase[b+1]
+x_fit = frange(x1, x2, (x2-x1), True)
+y_fit = [f.value(val) for val in x_fit]
+plt.addSeries(LinePlotErrorSeries("Fit", Color.green))
+plt.getSeries(1).setData(to_array(x_fit, 'd'), y_fit, [0.0] * len(x_fit))
+plt.getSeries(1).setPointsVisible(False)
+
+#Setting the return value
+bph_ref_guess = x1
+set_return([bph_ref_guess])
+
+#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"))
+ log_msg = "Data file: " + get_exec_pars().path + "\n\n"
+ log_msg = log_msg + "Laser: " + Laser + "\n"
+ if Laser == "Alcor":
+ log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
+ else:
+ log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
+ if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
+ log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
+ else:
+ log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
+ log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % bph0 + " deg beam phase\n"
+ log_msg = log_msg + "Ref. phase: %0.2f" % x1 + " deg \n"
+ attachments = []
+ if plt is not None:
+ sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
+ file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanPlot.png")
+ plt.saveSnapshot(file_name , "png")
+ attachments = [file_name]
+ elog("Schottky scan", log_msg, attachments)
diff --git a/script/test/offset.py b/script/test/offset.py
new file mode 100644
index 0000000..1378f3d
--- /dev/null
+++ b/script/test/offset.py
@@ -0,0 +1,11 @@
+devlist = ['SARUN01', 'SARUN02', 'SARUN03', 'SARUN04', 'SARUN05', \
+ 'SARUN06', 'SARUN07', 'SARUN08', 'SARUN09', 'SARUN10', \
+ 'SARUN11', 'SARUN12', 'SARUN13', '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
+ 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/offset2.py b/script/test/offset2.py
new file mode 100644
index 0000000..30c9751
--- /dev/null
+++ b/script/test/offset2.py
@@ -0,0 +1,6 @@
+devlist = ["SINEG01"]
+
+for dev in devlist:
+ val = caget(dev + "-MSOL010:I-SET")
+ val = val - 0.010
+ caput(dev + "-MSOL010:I-SET", float(val))
\ No newline at end of file
diff --git a/script/test/offset_linear.py b/script/test/offset_linear.py
new file mode 100644
index 0000000..ec278f1
--- /dev/null
+++ b/script/test/offset_linear.py
@@ -0,0 +1,17 @@
+devlist = ['SARUN01', 'SARUN02', 'SARUN03', 'SARUN04', 'SARUN05', \
+ 'SARUN06', 'SARUN07', 'SARUN08', 'SARUN09', 'SARUN10', \
+ 'SARUN11', 'SARUN12', 'SARUN13', 'SARUN14', 'SARUN15']#\
+# 'SARUN16' 'SARUN17' 'SARUN18' 'SARUN19' 'SARUN20' ]
+last_offset = -0.020
+devlist = devlist[10:]
+for i,dev in enumerate(devlist):
+# def func (off_last):
+# return
+ off_x = caget(dev + "-DBPM070:OFFS-X")
+ off_y = caget(dev + "-DBPM070:OFFS-Y")
+ off_x = off_x + last_offset*i/(len(devlist)-1)
+ off_y = off_y + 0.000
+ caput(dev + "-DBPM070:OFFS-X", float(off_x))
+ #caput(dev + "-DBPM070:OFFS-Y", float(off_y))
+ print('off_x: ', off_x)
+ print('dev: ', dev)
\ No newline at end of file