This commit is contained in:
root
2018-06-18 16:44:57 +02:00
parent 7da4e32097
commit bd9eaaf4d2
12 changed files with 189 additions and 61 deletions

View File

@@ -1,16 +1,16 @@
#Mon Jun 04 11:01:59 CEST 2018
#Mon Jun 18 16:41:56 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
colormapMax=2000.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=494
imageWidth=659
imageHeight=1200
imageWidth=1246
invert=false
regionStartX=0
regionStartY=0
regionStartX=304
regionStartY=8
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -21,10 +21,10 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=null
spatialCalOffsetX=-1279.4997788627065
spatialCalOffsetY=-1079.4997788915095
spatialCalScaleX=-53.02070816236811
spatialCalScaleY=-53.02454840203798
spatialCalOffsetX=-861.4939970777481
spatialCalOffsetY=-820.4883730911062
spatialCalScaleX=-18.90359092620482
spatialCalScaleY=-19.37984500632817
spatialCalUnits=null
t=
transpose=false

View File

@@ -1,4 +1,4 @@
#Thu May 17 08:46:52 CEST 2018
#Fri Jun 08 11:47:53 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=1000.0
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-50.03903200624512
spatialCalOffsetY=-50.048780487804876
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalOffsetX=-143.6163777820679
spatialCalOffsetY=-118.46093411080528
spatialCalScaleX=-15.559672914702317
spatialCalScaleY=-11.299434661865234
spatialCalUnits=null
transpose=false

View File

@@ -1,12 +1,12 @@
#Sat Jun 02 09:39:17 CEST 2018
#Mon Jun 18 12:03:16 CEST 2018
defaultSpeed=6000.0
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=8000.0
maxValue=51500.0
maxValue=64000.0
minSpeed=50.0
minValue=-56300.0
minValue=-47600.0
offset=0.0
precision=1
resolution=0.1

View File

@@ -1,4 +1,4 @@
#Fri Jun 01 12:45:57 CEST 2018
#Mon Jun 04 15:57:42 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-674.4869939208238
spatialCalOffsetY=-358.5976650464412
spatialCalScaleX=-18.903591266257227
spatialCalScaleY=-19.37984449994783
spatialCalOffsetX=-861.4939970777481
spatialCalOffsetY=-820.4883730911062
spatialCalScaleX=-18.90359092620482
spatialCalScaleY=-19.37984500632817
spatialCalUnits=mm
transpose=false

View File

@@ -47,6 +47,7 @@ import ch.psi.pshell.scripting.ScriptManager;
import ch.psi.pshell.swing.DeviceValueChart;
import ch.psi.pshell.swing.ValueSelection;
import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener;
import ch.psi.pshell.ui.Console;
import ch.psi.utils.Arr;
import ch.psi.utils.ArrayProperties;
import ch.psi.utils.Convert;
@@ -254,6 +255,7 @@ public class ScreenPanel3 extends Panel {
Frame currentFrame;
int imageBufferLenght = 1;
Text imagePauseOverlay;
final Console console;
public ScreenPanel3() {
try {
@@ -550,10 +552,43 @@ public class ScreenPanel3 extends Panel {
});
if (MainFrame.isDark()) {
textState.setDisabledTextColor(textState.getForeground());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
console = (!App.hasArgument("console")) ? null : new Console() {
/*
protected void onConsoleCommand(String name, String[] pars, String trimming) throws Exception {
switch (name) {
case "cam":
comboCameras.setSelectedItem(tokens[1]);
break;
}
}*/
@Override
protected void onConsoleCommand(String command) {
String[] tokens = command.split(" ");
if ((tokens.length > 1) && tokens[0].equals("cam")){
try{
if (!tokens[1].equals(comboCameras.getSelectedItem())){
setComboTypeSelection("All");
updateCameraList();
comboCameras.setSelectedItem(tokens[1]);
if (!tokens[1].equals(comboCameras.getSelectedItem())){
throw new Exception("Invalid camera name : " + tokens[1]);
}
System.out.println("Console set camera: " + tokens[1]);
}
} catch (Exception ex){
System.err.println(ex);
}
} else {
System.err.println("Invalid command: " + command);
}
}
};
}
void setIntegration(int frames) {
@@ -585,6 +620,9 @@ public class ScreenPanel3 extends Panel {
buttonServer.setSelected(!direct);
buttonDirect.setSelected(direct);
}
if (App.hasArgument("console")) {
console.start();
}
}
@Override
@@ -599,6 +637,13 @@ public class ScreenPanel3 extends Panel {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
if (console != null) {
console.stop();
}
} catch (Exception ex) {
ex.printStackTrace();
}
super.onStop();
}
@@ -628,8 +673,8 @@ public class ScreenPanel3 extends Panel {
updateCameraList();
comboCameras.setEnabled(true);
comboType.setEnabled(true);
setComboCameraSelection(-1);
setComboTypeSelection(0);
setComboCameraSelection(null);
setComboTypeSelection("All");
if (comboCameras.getModel().getSize() > 0) {
try {
@@ -794,7 +839,7 @@ public class ScreenPanel3 extends Panel {
Thread devicesInitTask;
void setCamera(String cameraName) throws IOException, InterruptedException {
System.out.println("Initializing");
System.out.println("Initializing: " + cameraName);
parseUserOverlays();
errorOverlay = null;
lastMarkerPos = null;
@@ -3765,11 +3810,13 @@ public class ScreenPanel3 extends Panel {
private void comboTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeActionPerformed
try {
updateCameraList();
if ((cameraName != null) && (!cameraName.equals(comboCameras.getSelectedItem()))) {
setCamera(null);
} else {
setCamera(cameraName);
if (!updatingCameraSelection) {
updateCameraList();
if ((cameraName != null) && (!cameraName.equals(comboCameras.getSelectedItem()))) {
setCamera(null);
} else {
setCamera(cameraName);
}
}
} catch (Exception ex) {

View File

@@ -313,16 +313,16 @@ def stop_blm_ws(blm):
caput(blm + ":WS_STOP.PROC", 1)
def set_blm_ws_gain(blm, gain):
caput(blm + ":WS_PMT_GAIN_VOLTS", 1)
caput(blm + ":WS_PMT_GAIN_VOLTS", float(gain))
def get_blm_ws_gain(blm, gain):
caget(blm + ":WS_PMT_GAIN_VOLTS")
def get_blm_ws_gain(blm):
return caget(blm + ":WS_PMT_GAIN_VOLTS")
def set_blm_ws_att(blm, att):
caput(blm + ":WS_PMT_ATT_VOLTS", 1)
caput(blm + ":WS_PMT_ATT_VOLTS", att)
def get_blm_ws_att(blm, att):
def get_blm_ws_att(blm):
"""
string 0: Reference
string 1: "2 dB"
@@ -341,4 +341,4 @@ def get_blm_ws_att(blm, att):
string 14: 28 dB
string 15: 30 dB
"""
caget(blm + ":WS_PMT_ATT_VOLTS", 'i')
return caget(blm + ":WS_PMT_ATT_VOLTS", 'i')

View File

@@ -68,7 +68,16 @@ class WireScanInfo(DeviceBase):
w2x = (pos_motor - self.home_offsets[2]) / -(math.sqrt(2))
w2y = (pos_motor - self.home_offsets[3]) / (math.sqrt(2))
return [w1x, w1y, w2x, w2y]
def get_motor_pos(self, pos_wire, wire_type):
if (pos_wire is None) or math.isnan(pos_wire):
return pos_wire
if wire_type == WireScanner.WireX1: return self.home_offsets[0] - pos_wire * math.sqrt(2)
if wire_type == WireScanner.WireY1: return self.home_offsets[1] + pos_wire * math.sqrt(2)
if wire_type == WireScanner.WireX2: return self.home_offsets[2] - pos_wire * math.sqrt(2)
if wire_type == WireScanner.WireY2: return self.home_offsets[3] + pos_wire * math.sqrt(2)
return None
def is_valid(self):
return caget(self.prefix + ":VALID", 'i')==1

View File

@@ -6,17 +6,31 @@ run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
ws_prefix = args[0] if is_panel else "S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" \\
plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibration")[0]
ws_wire = args[2] if is_panel else WireScanner.WireY2
cal_range = args[3] if is_panel else True
cal_gain = args[4] if is_panel else True
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#S10DI01-DBLM113:AL1-WS-PMT-GAIN
SATURATION = 19950 / 10
MIN_GAIN, MAX_GAIN = 0.5, 1.1
OPT_STEP = 0.01
OPT_STEP = 0.02
SCAN_RANGE_FACTOR = 6.0
def write_ws_gain(val):
set_setting(ws_blm + "GainWs" + ws_wire, val)
def read_ws_gain():
return get_setting(ws_blm + "GainWs" + ws_wire)
#2) Set the number of RF shots (N_shot) to be acquired during a single cycle WSC measurement (e.g.,N_shot=50)
n_shot = 200
@@ -29,7 +43,7 @@ rr = get_repetition_rate()
ws_speed = (x_max- x_min)*rr/n_shot
#5) Proceed with a test scan (1 cycle) according to the above defined motor settings
args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
@@ -42,8 +56,11 @@ start_blm_ws(ws_blm, 600.0)
#7) Move the wire to the X_CoM position and optimize the PMT-Gain so that the time-integral of the BLM voltage reaches a value equal to 90% of the Σsat level
offset = caget(ws_prefix + ":W1X_U0_SP")
motor_pos=offset - com * math.sqrt(2)
#offset = caget(ws_prefix + ":W1X_U0_SP")
#motor_pos=offset - com * math.sqrt(2)
ws_info = WireScanInfo("ws_info", ws_prefix )
motor_pos= ws_info.get_motor_pos(com, ws_wire)
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
#LOPR:0.5 HOPR:1.1
@@ -60,10 +77,11 @@ st.waitCacheChange(10000) #Wait stream be running before starting scan
def get_gain():
return caget(ws_blm + ":WS_PMT_GAIN_VOLTS")
return get_blm_ws_gain(ws_blm)
def set_gain(val):
caput(ws_blm + ":WS_PMT_GAIN_VOLTS", float(val))
set_blm_ws_gain(ws_blm,val)
def get_loss():
global ch
@@ -84,15 +102,28 @@ print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
def set_bml_ws_gain(gain):
def change_blm_ws_gain(gain):
set_gain(gain)
stop_blm_ws(ws_blm)
st.getChild("blm1_ws_mode").waitValue(0, SET_BLM_WS_BS_READBACK_TIMEOUT)
start_blm_ws(ws_blm, 600.0)
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
time.sleep(0.1)
#Search loop
for pos in frange(MIN_GAIN, MAX_GAIN, OPT_STEP, True):
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
"""
if start_val>target:
for pos in frange(start_gain, MIN_GAIN, -OPT_STEP, True):
set_bml_ws_gain(pos)
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss<=target:
@@ -101,13 +132,13 @@ if start_val>target:
elif start_val<target:
for pos in frange(start_gain, MAX_GAIN, OPT_STEP, True):
set_bml_ws_gain(pos)
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
"""
print "Final Gain = ", pos
print "Final Loss = ", loss
@@ -116,18 +147,18 @@ print get_loss()
#set_gain(0.6)
#set_gain(0.5)
st.close()
write_ws_gain(pos)
#UPDATE X1 range
#WIRE = 1X, 2X, 1Y, 2Y
def set_wire_scan_range(wire, start, end):
sel = {'X1':"W1X" , 'Y1': "W1Y", 'X2':"W2X", 'Y2' : "W2Y"}
start = min (max(start, -2000), 2000.0)
end = min (max(end, -2000), 2000.0)
caput((ws_prefix + ":W" + wire +"_START_SP"), x_range_min)
caput((ws_prefix + ":W" + wire +"_END_SP"), x_range_max)
caput((ws_prefix + ":" + sel[wire] +"_START_SP"), x_range_min)
caput((ws_prefix + ":" + sel[wire] +"_END_SP"), x_range_max)
#caget(ws_blm+":SAT_RAW_SUM")
@@ -136,11 +167,9 @@ args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_spe
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
x_range_min, x_range_max = com - SCAN_RANGE_FACTOR * sigma, com + SCAN_RANGE_FACTOR * sigma
set_wire_scan_range("1X", x_range_min, x_range_max)
set_wire_scan_range(ws_wire, x_range_min, x_range_max)

View File

@@ -41,7 +41,7 @@ phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:
phase.config.minValue =-90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.resolution = 0.1
phase.config.resolution = 0.3
phase.config.rotation = True
phase.initialize()
V = ChannelDouble(station + " Amplitude", station + "-RSYS:GET-VSUM-AMPLT")
@@ -144,6 +144,6 @@ if do_elog:
log_msg = log_msg + "Energy gain: %0.3f" % fit_amplitude + " MeV \n"
log_msg = log_msg + "VS-phase offset: %0.2f" % phase_offset + " deg \n"
log_msg = log_msg + "Amplitude scale: %0.3f" % amplitude_scale + " MV \n"
log_msg = log_msg + "Power scale: %0.6f" % power_scale + " MW/MV^2"
log_msg = log_msg + "Power scale: %0.7f" % power_scale + " MW/MV^2"
attachments = get_plot_snapshots(size=(600,400))
elog(title, log_msg, attachments)

View File

@@ -30,6 +30,6 @@ if n > 0:
log_msg = ""
if (phase_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset + " deg (was %0.2f" % phase_offset_old + " deg)\n"
if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %0.3f" % amplitude_scale + " MV (was %0.3f" % amplitude_scale_old + " MV)\n"
if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.5f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)"
if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.7f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)"
attachments = []
elog(title, log_msg, attachments)

View File

@@ -0,0 +1,44 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("K value", "SARUN12-UIND030:K_SET.VAL")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
K0 = 1.78*0.998
A1i = 1.764
A1f = 1.77
nstep = 41
lat = 1/25
nav = 100
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
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")
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()

View File

@@ -1,7 +1,6 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Phase (deg.)", "SARUN11-UIND030:PHI_SET")
A1 = ChannelDouble("Phase (deg.)", "SARUN11-UIND030:PHI_SET")
S1 = ChannelDouble("energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()