diff --git a/config/devices.properties b/config/devices.properties
index 75516b5..3c9b088 100755
--- a/config/devices.properties
+++ b/config/devices.properties
@@ -6,8 +6,8 @@ rep_rate_bunch_2=ch.psi.pshell.epics.ProcessVariable|SIN-TIMAST-TMA:Bunch-2-Appl
destination_AR=ch.psi.pshell.epics.ChannelString|SF:MODE_AR false|||
energy_AR=ch.psi.pshell.epics.ProcessVariable|SF:ENERGY_AR|||
laser=ch.psi.pshell.epics.ChannelString|SLG-LGEN:WHICH_LASER false|||
-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
+#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
@@ -45,13 +45,13 @@ fampltms=ch.psi.pshell.imaging.RegisterMatrixSource|fampltm||-100|
#cam1=ch.psi.pshell.epics.PsiCamera|SINEG01-DSCR350||-200|false
#cam2=ch.psi.pshell.epics.PsiCamera|SLG-LCAM-C041||-200|
#cam3=SfCamera|SLG-LCAM-C041||-200|
-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
+#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|||
#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
#blm_raw_test=ch.psi.pshell.epics.ChannelDoubleArray|SINDI02-DBLM025:LOSS_SIGNAL_RAW|||true
-mps_beam_ok=ch.psi.pshell.epics.ChannelInteger|SGE-EMED-LLRF:ALL_OK_L1_MA|||
+#mps_beam_ok=ch.psi.pshell.epics.ChannelInteger|SGE-EMED-LLRF:ALL_OK_L1_MA|||
diff --git a/config/variables.properties b/config/variables.properties
index a3a61b3..b729c5a 100755
--- a/config/variables.properties
+++ b/config/variables.properties
@@ -1,4 +1,4 @@
-#Thu Jan 23 10:21:47 CET 2025
-LastRunDate=250123
-FileSequentialNumber=13160
-DaySequentialNumber=2
+#Tue Aug 12 11:55:44 CEST 2025
+LastRunDate=250812
+FileSequentialNumber=15036
+DaySequentialNumber=1
diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties
index bda6c65..192eebe 100755
--- a/devices/CurrentCamera.properties
+++ b/devices/CurrentCamera.properties
@@ -1,4 +1,5 @@
-#Thu Jan 23 13:12:24 CET 2025
+#Wed Aug 13 09:56:10 CEST 2025
+\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\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\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000=
@@ -9,29 +10,29 @@
\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\u0000\u0000\u0000\u0000=
colormapLogarithmic=false
-spatialCalScaleX=-8.828541763475837
-spatialCalScaleY=-8.834897818216463
+spatialCalScaleX=-6.675964236212876
+spatialCalScaleY=-6.557376778528833
serverURL=null
rescaleOffset=0.0
roiWidth=-1
colormap=Flame
imageWidth=1744
invert=false
-colormapMin=0.0
+colormapMin=500.0
rotationCrop=false
+1=
roiHeight=-1
colormapAutomatic=true
roiY=0
roiX=0
-spatialCalOffsetY=-907.000013614636
-spatialCalOffsetX=-627.9999990131071
+spatialCalOffsetY=-901.0000457331158
+spatialCalOffsetX=-787.0000049160263
scale=1.0
regionStart=
grayscale=false
rtY=1
-colormapMax=20.0
+colormapMax=65000.0
spat=
rotation=0.0
rescaleFactor=1.0
diff --git a/devices/WireScanner motor.properties b/devices/WireScanner motor.properties
index 9aeab0d..3f3173b 100755
--- a/devices/WireScanner motor.properties
+++ b/devices/WireScanner motor.properties
@@ -1,6 +1,6 @@
-#Mon Jan 13 16:51:03 CET 2025
+#Mon Jul 14 16:37:26 CEST 2025
offset=0.0
-maxValue=68500.0
+maxValue=51500.0
precision=1
rotation=false
scale=1.0
@@ -10,7 +10,7 @@ maxSpeed=2000.0
resolution=0.1
homingType=None
startRetries=1
-minValue=-57027.0
+minValue=-56937.0
unit=um
defaultSpeed=2000.0
hasEnable=false
diff --git a/devices/cam_server.properties b/devices/cam_server.properties
index dcb05ae..e90eede 100755
--- a/devices/cam_server.properties
+++ b/devices/cam_server.properties
@@ -1,11 +1,11 @@
-#Wed Jan 22 09:48:29 CET 2025
-spatialCalOffsetY=-819.9999871547424
+#Mon Jun 30 17:38:12 CEST 2025
+spatialCalOffsetY=-829.0000262816876
spatialCalOffsetX=-861.0000211619925
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-18.90359092620482
-spatialCalScaleY=-19.37984500632817
+spatialCalScaleY=-19.607842977590828
colormapMax=NaN
rescaleOffset=0.0
roiWidth=-1
diff --git a/plugins/BunchLength.java b/plugins/BunchLength.java
index 3bc2480..f6eabc6 100755
--- a/plugins/BunchLength.java
+++ b/plugins/BunchLength.java
@@ -6,6 +6,8 @@ import ch.psi.pshell.core.Context;
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.plot.LinePlotSeries;
import ch.psi.pshell.ui.Panel;
+import ch.psi.pshell.ui.App;
+import ch.psi.pshell.ui.AppListener;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Color;
@@ -28,6 +30,20 @@ public class BunchLength extends Panel {
plot12.setStyle(LinePlot.Style.Normal);
plot21.setStyle(LinePlot.Style.ErrorY);
plot22.setStyle(LinePlot.Style.Normal);
+ App.getInstance().addListener(new AppListener() {
+ public boolean canExit(Object source) {
+ if (getState()==State.Ready){
+ ArrayList parameters = new ArrayList();
+ parameters.add(spinnerStation.getValue());
+ try {
+ run("Tools/BunchLengthRestore", parameters);
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }
+ return true;
+ }
+ });
}
//Overridable callbacks
diff --git a/plugins/WireScan.form b/plugins/WireScan.form
index f993b40..1e54461 100755
--- a/plugins/WireScan.form
+++ b/plugins/WireScan.form
@@ -118,11 +118,23 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -250,18 +262,21 @@
+
+
+
@@ -329,7 +344,7 @@
-
+
@@ -473,7 +488,7 @@
-
+
@@ -639,7 +654,7 @@
-
+
@@ -733,6 +748,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/WireScan.java b/plugins/WireScan.java
index fa2a14e..bb2040e 100755
--- a/plugins/WireScan.java
+++ b/plugins/WireScan.java
@@ -196,11 +196,14 @@ public class WireScan extends Panel {
void updateRawButtons(){
boolean validWireScan = isValidScanner();
Object sel = comboBlm1.getSelectedItem();
- buttonRaw1.setEnabled(validWireScan && (sel!=null) && (!sel.toString().isEmpty()));
+ buttonRaw1.setEnabled(validWireScan && (sel!=null) && (!sel.toString().isEmpty()));
+ buttonPMT1.setEnabled(buttonRaw1.isEnabled());
sel = comboBlm2.getSelectedItem();
buttonRaw2.setEnabled(validWireScan && (sel!=null) && (!sel.toString().isEmpty()));
+ buttonPMT2.setEnabled(buttonRaw2.isEnabled());
sel = comboBlm3.getSelectedItem();
- buttonRaw3.setEnabled(validWireScan && (sel!=null) && (!sel.toString().isEmpty()));
+ buttonRaw3.setEnabled(validWireScan && (sel!=null) && (!sel.toString().isEmpty()));
+ buttonPMT3.setEnabled(buttonRaw3.isEnabled());
}
@Override
@@ -343,6 +346,33 @@ public class WireScan extends Panel {
showException(ex);
}
}
+
+
+ void showPmtPanel(String blm){
+ try {
+ if ((blm==null) || (blm.isEmpty())){
+ return;
+ }
+
+ eval("run('Devices/Elements')", true);
+ String prefix = (String )eval("get_blm_ioc_prefix('" + blm + "')", true);
+ if (prefix==null){
+ throw new Exception("Unknown BLM IOC");
+ }
+ String[] tokens = prefix.split(":");
+ String ioc = tokens[0];
+ String al = tokens[1].substring(0, 3);
+ String macro = "DEV=" + ioc + ", INST=$(INST), ALARM=" + al + ", INTV=7";
+ String cmd = "caqtdm -macro \"" + macro + "\" S_DI_GPAC_BLM_WS.ui";
+ System.out.println(cmd);
+ //caqtdm -macro "DEV=SARCL02-DBLM457, INST=$(INST), ALARM=AL0, INTV=7" S_DI_GPAC_BLM_WS.ui
+ //caqtdm -macro "DEV=SARCL02-DBLM457, INST=$(INST), ALARM=AL0, INTV=7" S_DI_WSC_EXPERT.ui
+ Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
+
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
@@ -413,10 +443,13 @@ public class WireScan extends Panel {
comboAdaptive = new javax.swing.JComboBox();
jLabel22 = new javax.swing.JLabel();
checkFilterBeamOk = new javax.swing.JCheckBox();
+ buttonPMT1 = new javax.swing.JButton();
+ buttonPMT2 = new javax.swing.JButton();
+ buttonPMT3 = new javax.swing.JButton();
plot.setTitle("");
- buttonRaw1.setText("Raw Signal");
+ buttonRaw1.setText("Raw");
buttonRaw1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonRaw1ActionPerformed(evt);
@@ -502,7 +535,7 @@ public class WireScan extends Panel {
spinnerPoints.setModel(new javax.swing.SpinnerNumberModel(200, 1, 10000, 1));
- buttonRaw2.setText("Raw Signal");
+ buttonRaw2.setText("Raw");
buttonRaw2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonRaw2ActionPerformed(evt);
@@ -593,7 +626,7 @@ public class WireScan extends Panel {
spinnerEndX.setModel(new javax.swing.SpinnerNumberModel(1000.0d, -10000.0d, 10000.0d, 1.0d));
- buttonRaw3.setText("Raw Signal");
+ buttonRaw3.setText("Raw");
buttonRaw3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonRaw3ActionPerformed(evt);
@@ -645,6 +678,27 @@ public class WireScan extends Panel {
checkFilterBeamOk.setSelected(true);
checkFilterBeamOk.setText("Filter Beam Ok");
+ buttonPMT1.setText("PMT");
+ buttonPMT1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonPMT1ActionPerformed(evt);
+ }
+ });
+
+ buttonPMT2.setText("PMT");
+ buttonPMT2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonPMT2ActionPerformed(evt);
+ }
+ });
+
+ buttonPMT3.setText("PMT");
+ buttonPMT3.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonPMT3ActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup(
@@ -710,11 +764,20 @@ public class WireScan extends Panel {
.addComponent(comboBlm3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(buttonRaw1, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(buttonRaw2, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(buttonRaw3, javax.swing.GroupLayout.Alignment.TRAILING)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
+ .addComponent(buttonPMT1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonRaw1))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
+ .addComponent(buttonPMT2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonRaw2))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
+ .addComponent(buttonPMT3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonRaw3))))
.addComponent(comboBpm2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -825,17 +888,20 @@ public class WireScan extends Panel {
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18)
.addComponent(comboBlm1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(buttonRaw1))
+ .addComponent(buttonRaw1)
+ .addComponent(buttonPMT1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboBlm2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel17)
- .addComponent(buttonRaw2))
+ .addComponent(buttonRaw2)
+ .addComponent(buttonPMT2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboBlm3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel16)
- .addComponent(buttonRaw3))
+ .addComponent(buttonRaw3)
+ .addComponent(buttonPMT3))
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(26, 26, 26)
@@ -1259,11 +1325,26 @@ ChannelDouble channelEndY;
}
}//GEN-LAST:event_spinnerBunchStateChanged
+ private void buttonPMT1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPMT1ActionPerformed
+ showPmtPanel(comboBlm1.getSelectedItem().toString());
+ }//GEN-LAST:event_buttonPMT1ActionPerformed
+
+ private void buttonPMT2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPMT2ActionPerformed
+ showPmtPanel(comboBlm2.getSelectedItem().toString());
+ }//GEN-LAST:event_buttonPMT2ActionPerformed
+
+ private void buttonPMT3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPMT3ActionPerformed
+ showPmtPanel(comboBlm3.getSelectedItem().toString());
+ }//GEN-LAST:event_buttonPMT3ActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonCalibration;
private javax.swing.JButton buttonHoming;
private javax.swing.JButton buttonMoveStart;
+ private javax.swing.JButton buttonPMT1;
+ private javax.swing.JButton buttonPMT2;
+ private javax.swing.JButton buttonPMT3;
private javax.swing.JButton buttonPark;
private javax.swing.JButton buttonParkAll;
private javax.swing.JButton buttonRaw1;
diff --git a/script/Devices/BlmIocs.py b/script/Devices/BlmIocs.py
new file mode 100644
index 0000000..9b84833
--- /dev/null
+++ b/script/Devices/BlmIocs.py
@@ -0,0 +1,14 @@
+BLM_IOC_PREFIXES = {
+ "SARCL01-DBLM195": "SARCL02-DBLM457:AL2-",
+ "SARCL02-DBLM050": "SARCL02-DBLM457:AL0-",
+ "SARCL02-DBLM355": "SARCL02-DBLM469:AL0-",
+ "SARUN04-DBLM030": "SARUN04-DBLM516:AL0-",
+ "SARUN05-DBLM030": "SARUN04-DBLM516:AL1-",
+ "SARUN03-DBLM030": "SARUN01-DBLM499:AL1-",
+ "S20SY02-DBLM075": "S20SY03-DBLM269:AL0-",
+ "S20SY03-DBLM025": "S20SY03-DBLM292:AL0-",
+ "S20SY03-DBLM110": "S20SY03-DBLM292:AL1-",
+ "S30CB02-DBLM415": "S30CB02-DBLM310:AL0-",
+
+}
+
diff --git a/script/Devices/Elements.py b/script/Devices/Elements.py
index caff755..5344fee 100755
--- a/script/Devices/Elements.py
+++ b/script/Devices/Elements.py
@@ -1,3 +1,5 @@
+run("Devices/BlmIocs")
+
DBPM = 1
DWSC = 2
DBLM = 3
@@ -395,6 +397,13 @@ def get_gain_from_voltage(voltage):
return a*math.exp(b*voltage)
+def get_blm_ioc_prefix(blm):
+ return BLM_IOC_PREFIXES.get(blm, None)
+
+def get_blm_int_range(blm):
+ prefix = get_blm_ioc_prefix(blm)
+ return caget(prefix+"0-WR-LBOUND"), caget(prefix+"0-WR-HBOUND")
+
###################################################################################################
## WSCs
###################################################################################################
@@ -410,3 +419,4 @@ def set_wire_scan_range(wsc, wire, start, end):
end = min (max(end, -2000), 2000.0)
caput((wsc + ":" + sel[wire] +"_START_SP"), start)
caput((wsc + ":" + sel[wire] +"_END_SP"), end)
+
diff --git a/script/Diagnostics/DLACScan.py b/script/Diagnostics/DLACScan.py
index 7b84929..eb98364 100755
--- a/script/Diagnostics/DLACScan.py
+++ b/script/Diagnostics/DLACScan.py
@@ -15,9 +15,9 @@ ADD_CHANNELS = ["SARFE10-PBPG050:HAMP-INTENSITY-CAL", "SARFE10-PBIG050-EVR0:CALC
#Paramter parsing
prefix = args[0] if is_panel else "SINDI02-DLAC055"
-scan_type = args[1] if is_panel else "Shrom3"
-scan_range = args[2] if is_panel else [-0.0, 1.7]
-cycles = args[3] if is_panel else 2
+scan_type = args[1] if is_panel else "Shrom2"
+scan_range = args[2] if is_panel else [-0.5, 0.5]
+cycles = args[3] if is_panel else 1
velocity = args[4] if is_panel else 0.005
bpms = args[5] if is_panel else ["SINDI02-DBPM040", "SINDI02-DBPM080"]
blms = args[6] if is_panel else ["SINDI02-DBLM085", "S10DI01-DBLM045"]
@@ -27,7 +27,7 @@ bunch = args[9] if is_panel else 1
do_elog = True if is_panel else False
print "DLAC scan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd
-center_pos = 154.50
+center_pos = 179.40
beam_filter = get_beam_ok_channel(bunch) + " == 1"
scan_type_index = DLAC_POSITIONS.index(scan_type)
diff --git a/script/Diagnostics/WireScan.py b/script/Diagnostics/WireScan.py
index 94c3e8e..84fdf76 100644
--- a/script/Diagnostics/WireScan.py
+++ b/script/Diagnostics/WireScan.py
@@ -94,8 +94,17 @@ scanner = WireScanner(prefix, scan_range, cycles, None, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_channel_name()),
("cur_cycle", scanner.curr_cycl.get_channel_name()),
- ("scanning", scanner.status_channels[0].get_channel_name())]
+ ("scanning", scanner.status_channels[0].get_channel_name()),
+ ("gas_detector_cal", "SARFE10-PBPG050:HAMP-INTENSITY-CAL"),
+ ("gas_detector_raw", "SARFE10-PBIG050-EVR0:CALCI"),
+ ]
+snaps = []
+pmt_gains = []
+blm_ranges = []
+blm_raws = []
+blm_mins = []
+snaps.append(Channel(get_repetition_rate_rb_channel(bunch)))
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B" + str(bunch) + "_LOSS_RAW"))
@@ -106,7 +115,14 @@ for i in range (len(blms)):
series.setLinesVisible(False)
series.setPointSize(2)
if save_raw:
- channels.append (("blm" + str(i+1) + "_raw" , blms[i] + ":LOSS_SIGNAL_RAW"))
+ dev_name = "blm" + str(i+1) + "_raw"
+ blm_ranges.append(get_blm_int_range(blms[i]))
+ blm_raws.append(dev_name)
+ blm_mins.append(2048)
+ channels.append ((dev_name , blms[i] + ":LOSS_SIGNAL_RAW"))
+ pmt_gain = Channel(blms[i] + ":WS_PMT_GAIN_VOLTS")
+ pmt_gains.append(pmt_gain.read())
+ snaps.append(pmt_gain)
for i in range (len(bpms)):
for sensor in BPM_SENSORS:
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
@@ -190,7 +206,18 @@ def check_end_scan(record, scan):
scan_complete=True
scan.abort()
record.cancel() #So it won't be saved
- else:
+ else:
+ if save_raw:
+ for i in range (len(blms)):
+ try:
+ ch = blm_raws[i]
+ rg = blm_ranges[i]
+ raw = record[ch]
+ min_val = min(raw[int(rg[0]):int(rg[1])+1])
+ blm_mins[i] = min(blm_mins[i], min_val)
+ except:
+ blm_mins[i] = -1000
+
position = record["w_pos"]
if record["cur_cycle"] != cur_cycle:
cur_cycle = record["cur_cycle"]
@@ -280,7 +307,7 @@ def do_scan(index):
l=[w_pos()] ; l.extend(st.getReadables()); l.append(Timestamp())
print "Start scan"
- mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan)
+ mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan, snaps=snaps)
print "End scan"
#tscan([w_pos()] + st.getReadables() + [Timestamp(),], 10, 0.5)
except:
@@ -335,7 +362,7 @@ def calculate():
data = load_data(path + DATASET_SUFIX)
print "OK"
sp = data #blm_remove_spikes(data)
- sig = sp if bg is None else [v-bg for v in sp]
+ sig = sp if bg is None else [v-bg for v in sp] #Background Subtraction
#print [com, rms]
[off, amp, com, sigma] = profile_gauss_stats(pos, sig, off=None, amp=None, com=None, sigma=None)
@@ -511,7 +538,9 @@ finally:
print "Closing scanner"
scanner.close()
print "Closing stream"
- st.close()
+ st.close()
+ for dev in snaps:
+ dev.close
print msg
@@ -530,6 +559,9 @@ if do_elog:
log_msg = log_msg + "\nBPMs: " + str(bpms)
log_msg = log_msg + "\nBLMs: " + str(blms)
log_msg = log_msg + "\nBunch: " + str(bunch)
+ log_msg = log_msg + "\nRepetition Rate: " + str(rr)
+ log_msg = log_msg + "\nPMT gains: " + str(pmt_gains)
+ log_msg = log_msg + "\nMinimum raw: " + str(blm_mins)
log_msg = log_msg + "\n" + msg
elog("Wire Scan", log_msg, snapshots)
diff --git a/script/RFscan/GunEnergyScan.py b/script/RFscan/GunEnergyScan.py
index 1c40958..d6df9ef 100644
--- a/script/RFscan/GunEnergyScan.py
+++ b/script/RFscan/GunEnergyScan.py
@@ -5,7 +5,6 @@ do_elog = True
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
USE_SCREEN_PANEL = False
-#run("CPython/wrapper")
import_py("CPython/extremum", "extremum")
#Parameters
@@ -110,19 +109,20 @@ try:
i = dp.index(min(dp))
a, b = max(i-6, 0), min(i+6, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[a:b], dp[a:b])
- 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).setData(ph_p_fit, p_fit, to_array([0.0]*len(ph_p_fit), 'd'), to_array([0.0]*len(ph_p_fit), 'd'))
- #plt.getSeries(3).setData(ph_dp_fit, dp_fit, to_array([0.0]*len(ph_dp_fit), 'd'), to_array([0.0]*len(ph_dp_fit), 'd'))
- 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 :
print sys.exc_info()
raise Exception("Fit failure")
+
+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).setData(ph_p_fit, p_fit, to_array([0.0]*len(ph_p_fit), 'd'), to_array([0.0]*len(ph_p_fit), 'd'))
+#plt.getSeries(3).setData(ph_dp_fit, dp_fit, to_array([0.0]*len(ph_dp_fit), 'd'), to_array([0.0]*len(ph_dp_fit), 'd'))
+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)
# Calculating laser offset in deg
las_offset_deg = ph_dp_min - 90.0
diff --git a/script/RFscan/phase_scan_caqtdm.py b/script/RFscan/phase_scan_caqtdm.py
index 92f4541..ec07da2 100644
--- a/script/RFscan/phase_scan_caqtdm.py
+++ b/script/RFscan/phase_scan_caqtdm.py
@@ -1,11 +1,12 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
+import_py("CPython/hfitoff", "hfitoff")
dry_run = False
do_elog = True
-station = "S30CB12" # define param locally
-bpm_ch = "SARCL02-DBPM110"
-bpm_field = "X1"
+#station = "SINSB02" # define param locally
+#bpm_ch = "SINBC02-DBPM140"
+#bpm_field = "X1"
run("RFscan/phase_scan_data.py")
if get_exec_pars().args: # args is set by callin process (Qt panel)
@@ -54,7 +55,6 @@ def after(rec):
#scan and plot
try:
- phase.write(start)
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", float('nan'))
caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", float('nan'))
caput(station + "-RSYS:GET-ONCREST-E-GAIN", float('nan'))
@@ -68,7 +68,15 @@ try:
feedback_state = caget(feedback_channel)
feedback_state_init[feedback_channel] = feedback_state
caput(feedback_channel, 0)
+ phase_tol_init = caget(station + "-RSYS:SET-PHASE-TOL")
+ if phase_tol_init < 10.0 :
+ caput(station + "-RSYS:SET-PHASE-TOL", 10.0)
+ nominal_beam_phase = 270.0 if station == "SINXB01" else 90.0
+ caput(station + "-RSYS:SET-BEAM-PHASE", nominal_beam_phase)
time.sleep(1.0)
+ ph_crest0 = phase.read()
+ phase.write(start)
+ time.sleep(2.0)
caput(station + "-RSYS:PHASE-SCAN-MESSAGE", "scanning " + station)
r = lscan(phase, bpm_averager, start, end, step, latency=lat, after_read = after)
energy = [A * val.mean + B for val in r.getReadable(0)] # convert bpm mm to MeV
@@ -80,21 +88,19 @@ try:
caput("SF-PHASE-GLOBAL:GET-ENERGY-ARRAY", to_array(energy, 'd'))
caput("SF-PHASE-GLOBAL:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
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]
- 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)
- nominal_phase = ph_crest + 180 if station == "SINXB01" else ph_crest
- phase.write(nominal_phase)
+ 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 + 180) % 360 if station == "SINXB01" else ph_crest # take "on-crest" as 270 deg for SINXB01
+ phase.write(ph_crest)
time.sleep(1.0)
nominal_ampl = amplt.read()
nominal_power = power.read()
@@ -106,11 +112,13 @@ try:
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", fit_y)
caput("SF-PHASE-GLOBAL:GET-FIT-PHASE-ARRAY", fit_x)
caput("SF-PHASE-GLOBAL:GET-FIT-ENERGY-ARRAY", fit_y)
- message = "on-crest phase " + str('{:.2f}'.format(ph_crest))
- message = message + ", delta " + str('{:.2f}'.format(ph_crest - phase0))
+ now = str(caget("SF-TIME:FULL-DATE"))
+ now = now[:16] if now[0].isdigit() else ""
+ message = now + " " + str('{:.2f}'.format(ph_crest)) + " deg"
+ message = message + " (" + str('{:.2f}'.format(ph_crest - ph_crest0)) + ")"
caput(station + "-RSYS:PHASE-SCAN-MESSAGE", message)
phase_corr = caget(station + "-RSYS:GET-VSUM-PHASE-OFFSET-CORR")
- phase_offset = 90.0 - ph_crest - phase_corr # nominal on-crest phase is 90 deg (also for SINXB01)
+ phase_offset = nominal_beam_phase - ph_crest - phase_corr
amplitude_scale = fit_amplitude / nominal_ampl if nominal_ampl != 0 else 0.0
power_scale = nominal_power / fit_amplitude**2 if fit_amplitude != 0 else 0.0
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
@@ -120,7 +128,14 @@ finally:
for feedback_channel in station_list[station]["feedback"]:
feedback_state = feedback_state_init[feedback_channel]
caput(feedback_channel, feedback_state)
+ caput(station + "-RSYS:SET-PHASE-TOL", phase_tol_init)
phase.write(phase0)
+ Ph_Beam = caget(station + "-RSYS:SET-BEAM-PHASE")
+ while Ph_Beam > 360:
+ Ph_Vsum = Ph_Beam - 360
+ while Ph_Beam < 0:
+ Ph_Beam = Ph_Beam + 360
+ caput(station + "-RSYS:SET-BEAM-PHASE", Ph_Beam)
phase.close()
amplt.close()
power.close()
diff --git a/script/RFscan/phase_scan_caqtdm_cleanup.py b/script/RFscan/phase_scan_caqtdm_cleanup.py
new file mode 100644
index 0000000..b148b9b
--- /dev/null
+++ b/script/RFscan/phase_scan_caqtdm_cleanup.py
@@ -0,0 +1,8 @@
+for feedback_channel in station_list[station]["feedback"]:
+ feedback_state = feedback_state_init[feedback_channel]
+ caput(feedback_channel, feedback_state)
+phase.write(phase0)
+phase.close()
+amplt.close()
+power.close()
+bpm_val.close()
diff --git a/script/RFscan/phase_scan_data.py b/script/RFscan/phase_scan_data.py
index e915a4e..95f2acc 100644
--- a/script/RFscan/phase_scan_data.py
+++ b/script/RFscan/phase_scan_data.py
@@ -1,10 +1,12 @@
#phase scan config
-station_list = {"STEST01": {"bpm_ch": "SINBC02-DBPM140", "feedback": []},
- "SINSB01": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2"]},
- "SINSB02": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2"]},
- "SINSB03": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2"]},
- "SINSB04": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2"]},
- "SINXB01": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2"]},
+station_table = ["SINSB01", "SINSB02", "SINSB03", "SINSB04", "SINXB01", "S10CB01", "S10CB02", "S10CB03", "S10CB04", "S10CB05", "S10CB06",
+ "S10CB07", "S10CB08", "S10CB09", "S20CB01", "S20CB02", "S20CB03", "S20CB04", "S30CB01", "S30CB02", "S30CB03", "S30CB04",
+ "S30CB05", "S30CB06", "S30CB07", "S30CB08", "S30CB09", "S30CB10", "S30CB11", "S30CB12", "S30CB13", "SATCB01", "STEST01"]
+station_list = {"SINSB01": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2", "SINULH:SET-OP-MODE", "SINDI02-DBLM085:B1_ROI_ACTIVE_OP"]},
+ "SINSB02": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2", "SINULH:SET-OP-MODE"]},
+ "SINSB03": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2", "SINDLH:SET-OP-MODE"]},
+ "SINSB04": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2", "SINDLH:SET-OP-MODE"]},
+ "SINXB01": {"bpm_ch": "SINBC02-DBPM140", "feedback": ["SFB_ARRIVAL_TIME_GUN_AR:ONOFF1", "SFB_ARRIVAL_TIME_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF1", "SFB_COMPRESSION_BC1_AR:ONOFF2", "SINDLH:SET-OP-MODE"]},
"S10CB01": {"bpm_ch": "S10BC02-DBPM140", "feedback": ["SFB_COMPRESSION_BC2_AR:ONOFF1", "SFB_COMPRESSION_BC2_AR:ONOFF3", "SFB_COMPRESSION_BC2_AR:ONOFF2", "S10:SET-OP-MODE"]},
"S10CB02": {"bpm_ch": "S10BC02-DBPM140", "feedback": ["SFB_COMPRESSION_BC2_AR:ONOFF1", "SFB_COMPRESSION_BC2_AR:ONOFF3", "SFB_COMPRESSION_BC2_AR:ONOFF2", "S10:SET-OP-MODE"]},
"S10CB03": {"bpm_ch": "S10BC02-DBPM140", "feedback": ["SFB_COMPRESSION_BC2_AR:ONOFF1", "SFB_COMPRESSION_BC2_AR:ONOFF3", "SFB_COMPRESSION_BC2_AR:ONOFF2", "S10:SET-OP-MODE"]},
@@ -31,7 +33,8 @@ station_list = {"STEST01": {"bpm_ch": "SINBC02-DBPM140", "feedback": []},
"S30CB11": {"bpm_ch": "SARCL02-DBPM110", "feedback": ["SFB_BEAM_ENERGY_ECOL_AR:ONOFF1", "S20:SET-OP-MODE", "S30:SET-OP-MODE"]},
"S30CB12": {"bpm_ch": "SARCL02-DBPM110", "feedback": ["SFB_BEAM_ENERGY_ECOL_AR:ONOFF1", "S20:SET-OP-MODE", "S30:SET-OP-MODE"]},
"S30CB13": {"bpm_ch": "SARCL02-DBPM110", "feedback": ["SFB_BEAM_ENERGY_ECOL_AR:ONOFF1", "S20:SET-OP-MODE", "S30:SET-OP-MODE"]},
- "SATCB01": {"bpm_ch": "SATBD02-DBPM010", "feedback": ["SFB_BEAM_DUMP_AT:ONOFF1"]}}
+ "SATCB01": {"bpm_ch": "SATBD02-DBPM010", "feedback": ["SFB_BEAM_DUMP_AT:ONOFF1"]},
+ "STEST01": {"bpm_ch": "SINBC02-DBPM140", "feedback": []}}
bpm_list = {"SINLH02-DBPM210": {"bpm_field": "X1", "mbnd": "SINLH02-MBND100"},
"SINLH02-DBPM240": {"bpm_field": "X1", "mbnd": "SINLH02-MBND100"},
"SINBC02-DBPM140": {"bpm_field": "X1", "mbnd": "SINBC02-MBND100"},
diff --git a/script/RFscan/phase_scan_global.py b/script/RFscan/phase_scan_global.py
index 42b6d6b..aca8c1b 100644
--- a/script/RFscan/phase_scan_global.py
+++ b/script/RFscan/phase_scan_global.py
@@ -1,6 +1,6 @@
run("RFscan/phase_scan_data.py")
-for station in station_list:
+for station in station_table:
req = caget(station + "-RSYS:PHASE-SCAN-REQUIRED")
if req == "True":
feedback_list = station_list[station]["feedback"]
diff --git a/script/RFscan/setRFscanRange.py b/script/RFscan/setRFscanRange.py
index c7c44c4..ce3a0a2 100644
--- a/script/RFscan/setRFscanRange.py
+++ b/script/RFscan/setRFscanRange.py
@@ -1,5 +1,5 @@
# set scan parameters globally for the qt phasing tool
-scan_range = 60.0
+scan_range_global = 60.0
nb_steps = 21
nb_average = 10
wait_time = 0.1
@@ -12,6 +12,7 @@ stationlist = ("SINSB01","SINSB02","SINSB03","SINSB04","SINXB01",
phase_start, phase_stop = {}, {}
for station in stationlist:
+ scan_range = 20 if station == "SINSB01" else scan_range_global
Ph_Beam = caget(station + "-RSYS:SET-BEAM-PHASE")
Ph_Vsum = caget(station + "-RSYS:SET-VSUM-PHASE")
Ph_Offset = caget(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
@@ -32,6 +33,7 @@ for station in stationlist:
phase_start[station], phase_stop[station] = range_start, range_stop
for station in stationlist:
+ scan_range = 20 if station == "SINSB01" else scan_range_global
caput(station + "-RSYS:SET-SCAN-START", phase_start[station])
caput(station + "-RSYS:SET-SCAN-STOP", phase_stop[station])
caput(station + "-RSYS:SET-SCAN-STEP", scan_range / (nb_steps - 1))
diff --git a/script/Tools/BunchLengthPrep.py b/script/Tools/BunchLengthPrep.py
index 564fb74..18ecc23 100644
--- a/script/Tools/BunchLengthPrep.py
+++ b/script/Tools/BunchLengthPrep.py
@@ -6,16 +6,16 @@ else:
tds = "S30CB14"
run("Tools/BunchLengthTDSdata.py")
-# stop the beam and set rates to 1 Hz
+# stop the beam and set rep. rate
if tds == "SATMA02":
caput("SIN-TIMAST-TMA:Bunch-2-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
- caput("SIN-TIMAST-TMA:Bunch-2-Freq-Sel", 6)
+ caput("SIN-TIMAST-TMA:Bunch-2-Freq-Sel", 6) # 10 Hz
else :
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
- caput("SIN-TIMAST-TMA:Bunch-1-Freq-Sel", 10)
- caput("SIN-TIMAST-TMA:Bunch-2-Freq-Sel", 10)
+ caput("SIN-TIMAST-TMA:Bunch-1-Freq-Sel", 10) # 1 Hz
+ caput("SIN-TIMAST-TMA:Bunch-2-Freq-Sel", 10) # 1 Hz
# set mode and coll.
gap_init = []
diff --git a/script/Tools/BunchLengthRestore.py b/script/Tools/BunchLengthRestore.py
index 7e86535..36e21aa 100644
--- a/script/Tools/BunchLengthRestore.py
+++ b/script/Tools/BunchLengthRestore.py
@@ -6,23 +6,29 @@ else:
tds = "S30CB14"
run("Tools/BunchLengthTDSdata.py")
-# stop the beam and set rates to 1 Hz
+# stop the beam
if tds == "SATMA02":
caput("SIN-TIMAST-TMA:Bunch-2-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
-else :
+else:
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
# collimators
if tds == "S30CB14":
- caputq("SARCL02-VCOL290:GAP", gap_init[0])
+ try:
+ caputq("SARCL02-VCOL290:GAP", gap_init[0])
+ except:
+ print("gap_init not defined")
# restore nominal optics
quads = tds_data[tds]["quads"]
-for i in range(len(quads)):
- caput(quads[i] + ":I-SET", i_set_init[i])
- caput(quads[i] + ":CYCLE", 2)
+try:
+ for i in range(len(quads)):
+ caput(quads[i] + ":I-SET", i_set_init[i])
+ caput(quads[i] + ":CYCLE", 2)
+except:
+ print("i_set_init not defined")
#switch BLMs on
blm = tds_data[tds]["BLM"]
diff --git a/script/Tools/BunchLengthScan.py b/script/Tools/BunchLengthScan.py
index c189df8..14855a5 100644
--- a/script/Tools/BunchLengthScan.py
+++ b/script/Tools/BunchLengthScan.py
@@ -18,8 +18,8 @@ if is_panel:
tds = args[6]
bunch = args[7]
screen = args[8]
- user_calib_enabled = args[9]
- user_calib = args[10]
+ user_calib_enabled = args[9]
+ user_calib = args[10]
plt11 = args[11]
plt12 = args[12]
plt21 = args[13]
@@ -33,9 +33,9 @@ else:
thr = 20
tds = "SATMA02"
bunch = "Bunch2"
- screen = "SATBD01-DSCR120"
- user_calib_enabled = False
- user_calib = 1.0
+ screen = "SATBD02-DSCR050"
+ user_calib_enabled = False
+ user_calib = 1.0
plt11 = plot(None, title="Output")[0]
plt12 = plot(None, title="Output")[0]
plt21 = plot(None, title="Output")[0]
@@ -88,14 +88,15 @@ init_plots(plt12, plt22)
#Creating Phase positioner
if dry_run:
phase = DummyPositioner("TDS Phase")
+ screen = "simulation"
else:
phase = Positioner("TDS Phase", tds + "-RSYS:SET-BEAM-PHASE", tds + "-RSYS:SET-BEAM-PHASE")
-camera_name = screen
+camera_name = screen
phase.config.minValue = -90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.resolution = 0.05
-phase.config.rotation = True
+#phase.config.rotation = True # this may cause trouble when scanning around zero
phase.config.save()
phase.initialize()
phase0 = phase.read() % 360
@@ -154,7 +155,7 @@ try:
time.sleep(3.0)
r2 = lscan(phase, sensor_list, start, stop, step , latency=lat, after_read = update_plot_2)
finally:
- phase.write(phase0)
+ phase.write(0.001) # 0.0 seems to give 360 deg?!
phase.close()
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
@@ -171,8 +172,8 @@ def write_output(r, plt):
phase_pos = r.getPositions(0)
rf_period = 1 / MO_FREQ / tds_data[tds]["harm"]
time_pos = [val / 360.0 * rf_period * 1e15 for val in phase_pos] # in fs
- bunch_center = [val.mean for val in r.getReadable(0)]
- bunch_center_stdev = [val.stdev for val in r.getReadable(0)]
+ bunch_center = [val.mean for val in r.getReadable(0)]
+ bunch_center_stdev = [val.stdev for val in r.getReadable(0)]
a0, a1 = fit_polynomial(time_pos, bunch_center, 1)
calib = abs(a1) # in fs/um
if user_calib_enabled:
@@ -211,10 +212,10 @@ calib = (calib1 + calib2) / 2
#archiver channels
if do_elog:
if bunch == "Bunch1":
- caput(tds + "-RTDS100:BD-BUNCH1-DURATION", bunch_length_rms)
+ caput(tds + "-RTDS100:BD-BUNCH1-DURATION", bunch_length_fit)
caput(tds + "-RTDS100:BD-BUNCH1-CALIBRATION", 1 / calib)
else:
- caput(tds + "-RTDS100:BD-BUNCH2-DURATION", bunch_length_rms)
+ caput(tds + "-RTDS100:BD-BUNCH2-DURATION", bunch_length_fit)
caput(tds + "-RTDS100:BD-BUNCH2-CALIBRATION", 1 / calib)
#Elog entry
@@ -253,3 +254,4 @@ if do_elog:
set_return([bunch_length_rms_average1, bunch_length_fw_average1, bunch_length_fit_average1, calib1,
bunch_length_rms_average2, bunch_length_fw_average2, bunch_length_fit_average2, calib2,
bunch_length_rms, bunch_length_fw, bunch_length_fit, calib])
+
diff --git a/script/Tools/BunchLengthTDSdata.py b/script/Tools/BunchLengthTDSdata.py
index 595b42a..6bf0a8b 100644
--- a/script/Tools/BunchLengthTDSdata.py
+++ b/script/Tools/BunchLengthTDSdata.py
@@ -7,7 +7,7 @@ tds_data = {"SINDI01": {"harm": 21,
[-0.391000, 0.325000, 0.067500,
0.175300],
"BLM": [],
- "DEFAULTS" : {"Start": -2.0, "Stop": 2.0, "Step": 2.0, "Nb": 10, "Lat": 2.0,
+ "DEFAULTS" : {"Start": -2.0, "Stop": 2.0, "Step": 2.0, "Nb": 5, "Lat": 2.0,
"Thr": 25, "Scr": "SINDI02-DSCR075", "plane": "y"}},
"S30CB14": {"harm": 40,
"quads":
@@ -28,15 +28,13 @@ tds_data = {"SINDI01": {"harm": 21,
"SARUN09-DBLM030", "SARUN10-DBLM030", "SARUN11-DBLM030",
"SARUN12-DBLM030", "SARUN13-DBLM030", "SARUN14-DBLM030",
"SARUN15-DBLM030", "SARUN15-DBLM035", "SARUN20-DBLM035"],
- "DEFAULTS" : {"Start": -0.15, "Stop": 0.15, "Step": 0.15, "Nb": 10, "Lat": 2.0,
+ "DEFAULTS" : {"Start": -0.15, "Stop": 0.15, "Step": 0.15, "Nb": 5, "Lat": 2.0,
"Thr": 200, "Scr": "SARCL01-DSCR170", "plane": "y"}},
"SATMA02": {"harm": 84,
"quads":
- ["SATBD01-MQUA010", "SATBD01-MQUA030", "SATBD01-MQUA050",
- "SATBD01-MQUA070", "SATBD01-MQUA090", "SATBD02-MQUA030"],
+ [],
"K1L-meas":
- [ 0.152300, -0.185800, 0.039800,
- 0.142400, -0.223600, -0.315600],
- "BLM": ["SATBD01-DBLM205", "SATUN22-DBLM005"],
- "DEFAULTS" : {"Start": -0.2, "Stop": 0.2, "Step": 0.2, "Nb": 10, "Lat": 2.0,
+ [],
+ "BLM": ["SATBD01-DBLM205", "SATUN22-DBLM075"],
+ "DEFAULTS" : {"Start": -0.2, "Stop": 0.2, "Step": 0.2, "Nb": 5, "Lat": 2.0,
"Thr": 300, "Scr": "SATBD02-DSCR050", "plane": "x"}}}
diff --git a/script/Undulators/und_scan.py b/script/Undulators/und_scan.py
new file mode 100644
index 0000000..fc80d61
--- /dev/null
+++ b/script/Undulators/und_scan.py
@@ -0,0 +1,121 @@
+import ch.psi.pshell.epics.Positioner as Positioner
+import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
+import_py("CPython/hfitoff", "hfitoff")
+import_py("CPython/extremum", "extremum")
+
+
+dry_run = False
+do_elog = False
+
+if get_exec_pars().args: # args is set by callin process (Qt panel)
+ und = args[0]
+ scan = args[1]
+
+if dry_run:
+ und = "STEST01"
+ scan = "AR_PHI"
+
+if scan == "AR_K" or scan == "AT_K":
+ x_channel = und + "-UIND030:K_SET"
+ message_channel = und + ":K-SCAN-MESSAGE"
+ x0 = caget(x_channel)
+ start = x0 - 0.005
+ end = x0 + 0.005
+ step = 10
+ lat = 0.1
+ nb = 90
+
+if scan == "AR_PHI" or scan == "AT_PHI":
+ message_channel = und + ":PHI-SCAN-MESSAGE"
+ start = -180
+ end = 180
+ step = 12
+ lat = 0.1
+ nb = 90
+
+if scan == "AR_K":
+ x_ok_channel = und + "-UPHS060:GAP-POS-OK" # UPHS is slower
+ y_channel = "SARFE10-PBIG050-EVR0:CALCI"
+elif scan == "AT_K":
+ x_ok_channel = und + "-UIND030:RADIAL-POS-OK"
+ y_channel = "SATFE10-PEPG046-EVR0:CALCI"
+elif scan == "AR_PHI":
+ x_channel = und + "-UPHS060:PHI_SET"
+ x_ok_channel = und + "-UPHS060:GAP-POS-OK"
+ y_channel = "SARFE10-PBIG050-EVR0:CALCI"
+elif scan == "AT_PHI":
+ x_channel = und + "-UDLY060:PH-SHIFT-OP"
+ x_ok_channel = und + "-UDLY060:GAP-COMP-OP"
+ y_channel = "SATFE10-PEPG046-EVR0:CALCI"
+
+if und == "STEST01" and scan == "AR_K":
+ y_channel = "STEST01:K-CALCI"
+if und == "STEST01" and scan == "AR_PHI":
+ y_channel = "STEST01:PHI-CALCI"
+
+x_val = ChannelDouble(x_channel, x_channel)
+x_val.initialize()
+y_val = ChannelDouble(y_channel, y_channel)
+y_val.initialize()
+x_val0 = x_val.read()
+y_averager = create_averager(y_val, nb, lat)
+
+#check mover position
+def before():
+ time.sleep(1.0)
+ timeout = 10.0
+ start_time = time.time()
+ while (True):
+ mover_status = caget(x_ok_channel)
+ print(mover_status)
+ if mover_status=="OK" or mover_status=="True":
+ break
+ if time.time() - start_time > timeout:
+ raise Exception("mover timeout")
+
+#update the plot dynamically
+arr_x, arr_y = [],[]
+def after(rec):
+ arr_x.append(rec.positions[0])
+ arr_y.append(rec.readables[0].mean)
+ caput("SF-SCAN-GLOBAL:X-ARRAY", to_array(arr_x, 'd'))
+ caput("SF-SCAN-GLOBAL:Y-ARRAY", to_array(arr_y, 'd'))
+
+#scan and plot
+try:
+ caput("SF-SCAN-GLOBAL:FIT-X-ARRAY", to_array([0.0], 'd'))
+ caput("SF-SCAN-GLOBAL:FIT-Y-ARRAY", to_array([0.0], 'd'))
+ x_val.write(start)
+ time.sleep(5.0)
+ caput(message_channel, "scanning ")
+ r = lscan(x_val, y_averager, start, end, step, latency=lat, before_read = before, after_read = after)
+ x_array = r.getPositions(0)
+ y_array = energy = [val.mean for val in r.getReadable(0)]
+ caput("SF-SCAN-GLOBAL:X-ARRAY", to_array(x_array, 'd'))
+ caput("SF-SCAN-GLOBAL:Y-ARRAY", to_array(y_array, 'd'))
+ try:
+ if scan == "AR_K" or scan == "AT_K":
+ x_max, y_max, fit_x, fit_y, R2 = extremum(x_array, y_array)
+ if scan == "AR_PHI" or scan == "AT_PHI":
+ fit_amplitude, fit_x_deg, fit_offset, x_max, fit_x, fit_y = hfitoff(y_array, x_array)
+ except:
+ raise Exception("Fit failure")
+ plt = plot(None, name="param scan")[0]
+ plt.getSeries(0).setData(to_array(x_array,'d'), to_array(y_array,'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)
+ caput(und + ":SCAN-CREST", x_max)
+ caput("SF-SCAN-GLOBAL:FIT-X-ARRAY", fit_x)
+ caput("SF-SCAN-GLOBAL:FIT-Y-ARRAY", fit_y)
+ if scan == "AR_K" or scan == "AT_K":
+ caput(message_channel, "on-crest: " + ("%.4f" % x_max))
+ if scan == "AR_PHI" or scan == "AT_PHI":
+ caput(message_channel, "on-crest: " + ("%.1f" % x_max))
+finally:
+ x_val.write(x_val0)
+ x_val.close()
+ y_val.close()
diff --git a/script/Undulators/und_scan_global.py b/script/Undulators/und_scan_global.py
new file mode 100644
index 0000000..916d312
--- /dev/null
+++ b/script/Undulators/und_scan_global.py
@@ -0,0 +1,9 @@
+und_table = ["SARUN03", "SARUN04", "SARUN05", "SARUN06", "SARUN07",
+ "SARUN08", "SARUN09", "SARUN10", "SARUN11", "SARUN12",
+ "SARUN13", "SARUN13", "SARUN13", "STEST01"]
+
+for und in und_table:
+ req = caget(und + "-RSYS:PHASE-SCAN-REQUIRED")
+ if req == "True":
+ run("Undulators/und_scan.py")
+ caput(und + ":PHASE-SCAN-REQUIRED", 0)
diff --git a/script/Undulators/und_scan_set.py b/script/Undulators/und_scan_set.py
new file mode 100644
index 0000000..5436a5a
--- /dev/null
+++ b/script/Undulators/und_scan_set.py
@@ -0,0 +1,16 @@
+if get_exec_pars().args: # args is set by callin process (Qt panel)
+ und = args[0]
+ scan = args[1]
+
+if scan == "AR_K":
+ set_channel = und + "-UIND030:K_SET"
+elif scan == "AR_PHI":
+ set_channel = und + "-UPHS060:PHI_SET"
+elif scan == "AT_K":
+ set_channel = und + "-UIND030:K_SET"
+elif scan == "AT_PHI":
+ set_channel = und + "-UDLY060:PH-SHIFT-OP"
+
+set_value = caget(und + ":SCAN-CREST")
+caput(set_channel, set_value)
+
diff --git a/script/local.py b/script/local.py
index 1bf3f9e..d1b6e1d 100755
--- a/script/local.py
+++ b/script/local.py
@@ -105,16 +105,20 @@ def is_timing_ok():
def get_repetition_rate(bunch=1, setp=None):
if not setp:
- if bunch==2:
- ret = caget("SIN-TIMAST-TMA:Bunch-2-Appl-Freq-RB", 'd')
- else:
- ret = caget("SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB", 'd')
+ ret = caget(get_repetition_rate_rb_channel(bunch), 'd')
if setp==False or ret > 0:
return ret
print "Readback is 0: returning Setpoint"
sel = caget("SIN-TIMAST-TMA:Bunch-" + str(bunch) + "-Freq-Sel")
return float(sel.split(" ")[0])
+
+def get_repetition_rate_rb_channel(bunch=1):
+ if bunch==2:
+ return "SIN-TIMAST-TMA:Bunch-2-Appl-Freq-RB"
+ else:
+ return "SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB"
+
def ws_status():
"""
Display status of all wire scanners
diff --git a/script/test/TestArray10.py b/script/test/TestArray10.py
new file mode 100644
index 0000000..1d09180
--- /dev/null
+++ b/script/test/TestArray10.py
@@ -0,0 +1,3 @@
+a = Array10("a1", "tcp://sf-daq-6.psi.ch:30031", 2)
+add_device(a, True)
+a.start()
\ No newline at end of file
diff --git a/script/test/TestBsreadCamera.py b/script/test/TestBsreadCamera.py
index 414de59..4b510c9 100644
--- a/script/test/TestBsreadCamera.py
+++ b/script/test/TestBsreadCamera.py
@@ -1,3 +1,4 @@
+MODE = SocketType.PULL
CAMERA = "SARES20-CAMS142-M3"
#CAMERA = "SARFE10-PSSS059"
#CAMERA = "SATES31-CAMS187-RIXS1"
@@ -6,12 +7,26 @@ CAMERA = "SARES20-CAMS142-M3"
#CAMERA = "SATBD02-DSCR050"
#CAMERA = "SARCL01-DSCR170"
CAMERA = "SATBD02-DSCR050"
+CAMERA = "S10BC02-DSRM310"
+CAMERA = "SARBD02-DSCR051"
+CAMERA = "SATOP21-PMOS127-1D"
+CAMERA = "SATBD01-DSCR210"
CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://")
#CAMERA_URL= "tcp://sf-sioc-cs-83:9020"
#sCAMERA_URL= "tcp://sf-daqsync-17:9002"
-print CAMERA_URL
-add_device(Stream("st1", CAMERA_URL, SocketType.PULL), True)
+#CAMERA_URL= "tcp://sf-daq-6.psi.ch:30031"
+#MODE = SocketType.SUB
+print CAMERA_URL, MODE
+
+add_device(Stream("st1", CAMERA_URL, MODE), True)
+sts = caget(CAMERA + ":CAMERASTATUS", 'i')
+if sts == 0:
+ raise Exception("Camera is offline")
+if sts == 1:
+ print "Camera is idle... starting - " + CAMERA + ":CAMERASTATUS"
+ caput(CAMERA + ":CAMERASTATUS", 2)
+
st1.start()
st1.waitCacheChange(3000)
try:
diff --git a/script/test/test_sleep.py b/script/test/test_sleep.py
new file mode 100644
index 0000000..67e5c44
--- /dev/null
+++ b/script/test/test_sleep.py
@@ -0,0 +1 @@
+sleep(3.0)
\ No newline at end of file