Startup
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#Mon May 01 09:48:54 CEST 2017
|
||||
#Tue May 02 13:16:18 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=false
|
||||
colormapMax=500.0
|
||||
colormapAutomatic=true
|
||||
colormapMax=0.0
|
||||
colormapMin=0.0
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
flipHorizontally=true
|
||||
flipVertically=true
|
||||
grayscale=false
|
||||
imageHeight=2148
|
||||
imageWidth=2272
|
||||
imageHeight=2160
|
||||
imageWidth=2560
|
||||
invert=false
|
||||
regionStartX=129
|
||||
regionStartY=7
|
||||
regionStartX=1
|
||||
regionStartY=1
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
@@ -21,9 +21,9 @@ rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
serverURL=localhost\:10000
|
||||
spatialCalOffsetX=-226.5485440792231
|
||||
spatialCalOffsetY=-401.5108176113712
|
||||
spatialCalScaleX=-7.61744675127048
|
||||
spatialCalScaleY=-7.774538465366242
|
||||
spatialCalOffsetX=-1292.0
|
||||
spatialCalOffsetY=-1062.0
|
||||
spatialCalScaleX=-8.784773060029282
|
||||
spatialCalScaleY=-8.854454897620366
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#Thu Apr 27 15:00:47 CEST 2017
|
||||
#Tue May 02 15:46:31 CEST 2017
|
||||
defaultSpeed=282.842712474619
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
homingType=None
|
||||
maxSpeed=8000.0
|
||||
maxValue=64000.0
|
||||
maxValue=51500.0
|
||||
minSpeed=50.0
|
||||
minValue=-47600.0
|
||||
minValue=-56789.2
|
||||
offset=0.0
|
||||
precision=1
|
||||
resolution=0.1
|
||||
|
||||
+1
-52
@@ -7,11 +7,6 @@ import ch.psi.pshell.device.DeviceAdapter;
|
||||
import ch.psi.pshell.epics.ChannelDouble;
|
||||
import ch.psi.pshell.epics.ChannelInteger;
|
||||
import ch.psi.pshell.epics.Epics;
|
||||
import ch.psi.pshell.plot.LinePlotSeries;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.ui.App;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
@@ -35,25 +30,14 @@ import javax.swing.JTextField;
|
||||
*
|
||||
*/
|
||||
public class WireScan extends Panel {
|
||||
final String[] seriesNames = new String[]{"bpm1_x", "bpm1_y", "bpm1_q", "bpm2_x", "bpm2_y", "bpm2_q"};
|
||||
final JComboBox[] bpmCombos;
|
||||
final JComboBox[] blmCombos;
|
||||
final int[] seriesYAxis = new int[]{1, 1, 2, 1, 1, 2};
|
||||
LinePlotSeries[] series = new LinePlotSeries[seriesNames.length];
|
||||
boolean homed;
|
||||
boolean parked;
|
||||
String currentScannner;
|
||||
|
||||
public WireScan() {
|
||||
initComponents();
|
||||
for (int i=0; i< seriesNames.length; i++){
|
||||
series[i] = new LinePlotSeries(seriesNames[i], null, seriesYAxis[i]);
|
||||
plot.addSeries(series[i]);
|
||||
}
|
||||
plot.getAxis(Plot.AxisId.X).setLabel("Position");
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("mm");
|
||||
plot.getAxis(Plot.AxisId.Y2).setLabel("pc");
|
||||
plot.setLegendVisible(true);
|
||||
bpmCombos = new JComboBox[]{comboBpm1, comboBpm2, comboBpm3};
|
||||
blmCombos = new JComboBox[]{comboBlm1, comboBlm2, comboBlm3};
|
||||
}
|
||||
@@ -193,41 +177,6 @@ public class WireScan extends Panel {
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
//Plot management
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
@Override
|
||||
public void onScanStarted(Scan scan, String plotTitle) {
|
||||
if ("WireScan".equals(getContext().getExecutionPars().getName())) {
|
||||
for (LinePlotSeries s : series){
|
||||
s.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
try{
|
||||
if ("WireScan".equals(getContext().getExecutionPars().getName())) {
|
||||
double position = (Double) record.getValues()[0];
|
||||
for (int i=0; i< series.length; i++){
|
||||
Double val = (Double) record.getValues()[5 + i];
|
||||
if (val != null){
|
||||
series[i].appendData(position, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanEnded(Scan scan, Exception ex) {
|
||||
getContext().removeScanListener(this);
|
||||
}
|
||||
};
|
||||
|
||||
boolean isValidScanner(){
|
||||
return (currentScannner!=null) && (!currentScannner.isEmpty());
|
||||
}
|
||||
@@ -798,8 +747,8 @@ public class WireScan extends Panel {
|
||||
}
|
||||
}
|
||||
parameters.add(blms);
|
||||
parameters.add(plot);
|
||||
|
||||
getContext().addScanListener(scanListener);
|
||||
try {
|
||||
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
|
||||
+13
-11
@@ -263,19 +263,21 @@ def get_wire_scanners_bpms(wire_scan):
|
||||
|
||||
def get_wire_scanners_blms(wire_scan):
|
||||
last = None
|
||||
ret = []
|
||||
for element in elements:
|
||||
ret = None
|
||||
for element in elements:
|
||||
if element[0]==DWSC and element[1] == wire_scan:
|
||||
ret = [last,]
|
||||
elif element[0]==DBLM:
|
||||
if get_beamline(element[1]) == get_beamline(wire_scan):
|
||||
if len(ret) > 0:
|
||||
if ret[0] is None: ret[0] = "S30CB02-DBLM445"
|
||||
return [ret[0],element[1]]
|
||||
last = element[1]
|
||||
return None
|
||||
ret = []
|
||||
elif element[0]==DBLM and (ret is not None):
|
||||
bl = get_beamline(element[1])
|
||||
if bl == get_beamline(wire_scan):
|
||||
ret.append(element[1])
|
||||
if len(ret) == 2:
|
||||
return ret
|
||||
if ret is not None and len(ret)==1:
|
||||
ret.append(None)
|
||||
return ret
|
||||
|
||||
|
||||
#for w in get_wire_scanners():
|
||||
# print w, get_wire_scanners_bpms(w)
|
||||
# print w, get_wire_scanners_blms(w)
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
|
||||
|
||||
CAMERA = "S10DI01-DSCR020" #"simulation"
|
||||
QUADRUPOLE = "S10CB02-MQUA230"
|
||||
#CAMERA = "S10DI01-DSCR020" #"simulation"
|
||||
CAMERA = "SINDI02-DLAC055" #"simulation"
|
||||
QUADRUPOLE = "S10CB02-MQUA230" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
|
||||
CHARGE_BPM = "SINEG01-DBPM340:Q1"
|
||||
CHARGE_ICT = "SINEG01-DICT215:B1_CHARGE-OP"
|
||||
RANGE = (-2.0, 2.0)
|
||||
STEPS = 10
|
||||
SETTLING_TIME = 1.0
|
||||
RANGE = (-3.0, 0.0)
|
||||
STEPS = 100
|
||||
SETTLING_TIME = 1
|
||||
|
||||
#kill_camtool()
|
||||
check_camtool()
|
||||
@@ -48,7 +49,7 @@ try:
|
||||
set_attribute("/", "Quadrupole", QUADRUPOLE)
|
||||
set_attribute("/", "Scan Parameters", RANGE + (STEPS,))
|
||||
set_attribute("/", "Screen Position", caget(CAMERA + ":GET_SCREEN1_POS", 's'))
|
||||
set_attribute("/", "Camera", CAMERA)
|
||||
set_attribute("/", "Filter Position", caget(CAMERA + ":GET_FILTER", 's'))
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@@ -6,15 +6,25 @@ run("Devices/WireScanner")
|
||||
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
|
||||
|
||||
#Paramter parsing
|
||||
prefix = args[0] if is_panel else "SINDI01-DWSC090" #"S30CB09-DWSC440"
|
||||
prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
|
||||
scan_type = args[1] if is_panel else WireScanner.WireX1
|
||||
scan_range = args[2] if is_panel else [-2000, 2000, -2000, 2000]
|
||||
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
|
||||
cycles = args[3] if is_panel else 5
|
||||
velocity = args[4] if is_panel else 200
|
||||
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
|
||||
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
|
||||
plt = args[7] if is_panel else plot(None, title = "Wire Scan")[0]
|
||||
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, cycles, bpms
|
||||
|
||||
|
||||
#Plot setup
|
||||
plt.clear()
|
||||
plt.getAxis(plt.AxisId.X).setLabel("Position");
|
||||
plt.getAxis(plt.AxisId.Y).setLabel("");
|
||||
plt.getAxis(plt.AxisId.Y2).setLabel("");
|
||||
plt.setLegendVisible(True);
|
||||
snapshots = []
|
||||
|
||||
#Creating WireScanner object
|
||||
print "Creating scanner..."
|
||||
if prefix not in get_wire_scanners():
|
||||
@@ -29,11 +39,13 @@ scanner.waitValue("At start", 60000)
|
||||
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
|
||||
("cur_cycle", scanner.curr_cycl.get_name()),
|
||||
("scanning", scanner.status_channels[0].get_name())]
|
||||
for i in range (len(blms)):
|
||||
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
|
||||
plt.addSeries(LinePlotSeries(blms[i], None, min(i+1, 2)))
|
||||
|
||||
for i in range (len(bpms)):
|
||||
for sensor in BPM_SENSORS:
|
||||
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
|
||||
for i in range (len(blms)):
|
||||
channels.append ("blm" + str(i+1), blms[i] + ":B1_LOSS")
|
||||
|
||||
#Stream creation
|
||||
print "Starting stream..."
|
||||
@@ -62,9 +74,13 @@ def check_end_scan(record, scan):
|
||||
scan_complete=True
|
||||
scan.abort()
|
||||
record.cancel() #So it won't be saved
|
||||
elif record[3] != cur_cycle:
|
||||
cur_cycle = record[3]
|
||||
get_context().dataManager.splitScanData(scan)
|
||||
else:
|
||||
position = record[0]
|
||||
for i in range (len(blms)):
|
||||
plt.getSeries(i).appendData(position, record[5 + i])
|
||||
if record[3] != cur_cycle:
|
||||
cur_cycle = record[3]
|
||||
get_context().dataManager.splitScanData(scan)
|
||||
|
||||
#Metadata
|
||||
set_attribute("/", "Wire Scanner", prefix)
|
||||
@@ -80,6 +96,8 @@ def do_scan():
|
||||
global scan_complete, cur_cycle
|
||||
scan_complete=False
|
||||
cur_cycle = 1
|
||||
for s in plt.getAllSeries():
|
||||
s.clear()
|
||||
try:
|
||||
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
|
||||
mscan (st, [w_pos()] + st.getReadables(), -1, -1, after_read = check_end_scan)
|
||||
@@ -89,6 +107,12 @@ def do_scan():
|
||||
scanner.abort()
|
||||
if not scan_complete:
|
||||
raise
|
||||
finally:
|
||||
img_file = os.path.abspath(get_exec_pars().path + "_" + get_exec_pars().group[0:1] + ".png")
|
||||
time.sleep(0.1) #Give some time to plot finish (async)
|
||||
plt.saveSnapshot(img_file, "png")
|
||||
snapshots.append(img_file)
|
||||
|
||||
|
||||
|
||||
print "Starting scan..."
|
||||
@@ -110,7 +134,8 @@ try:
|
||||
gsa_log_msg = gsa_log_msg + "\nRange: " + str(scan_range)
|
||||
gsa_log_msg = gsa_log_msg + "\nCycles: " + str(cycles)
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Velocity: " + str(velocity)
|
||||
elog("Wire Scan", gsa_log_msg)
|
||||
|
||||
elog("Wire Scan", gsa_log_msg, snapshots)
|
||||
|
||||
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user