01.2025
This commit is contained in:
@@ -9,22 +9,27 @@ run("Devices/Elements")
|
||||
run("Diagnostics/sig_process_wrapper")
|
||||
|
||||
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
|
||||
TRAVEL_SPEED = 0.001
|
||||
TRAVEL_SPEED = 0.05
|
||||
ADD_CHANNELS = []
|
||||
ADD_CHANNELS = ["SARFE10-PBPG050:HAMP-INTENSITY-CAL", "SARFE10-PBIG050-EVR0:CALCI"]
|
||||
|
||||
#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.12, 0.12]
|
||||
cycles = args[3] if is_panel else 1
|
||||
velocity = args[4] if is_panel else 0.00001
|
||||
scan_range = args[2] if is_panel else [-0.0, 1.7]
|
||||
cycles = args[3] if is_panel else 2
|
||||
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"]
|
||||
bkgrd = args[7] if is_panel else 5 #Number of beam synchronous messages
|
||||
plt = args[8] if is_panel else plot(None, title = "DLAC Scan")[0]
|
||||
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 = 199.484
|
||||
center_pos = 154.50
|
||||
beam_filter = get_beam_ok_channel(bunch) + " == 1"
|
||||
|
||||
scan_type_index = DLAC_POSITIONS.index(scan_type)
|
||||
if scan_type_index<0:
|
||||
raise Exception("Bad sample position name")
|
||||
@@ -60,7 +65,7 @@ park_pos = caget (prefix + ":P0_U0_SP")
|
||||
#List of stream channels
|
||||
channels = [] #[("m_pos", scanner.motor_bs_readback.get_channel_name()), ]
|
||||
for i in range (len(blms)):
|
||||
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
|
||||
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS_RAW"))
|
||||
series = LinePlotSeries(blms[i], None, min(i+1, 2))
|
||||
plt.addSeries(series)
|
||||
series.setLinesVisible(False)
|
||||
@@ -68,6 +73,9 @@ for i in range (len(blms)):
|
||||
for i in range (len(bpms)):
|
||||
for sensor in BPM_SENSORS:
|
||||
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
|
||||
channels.append(("beam_ok", get_beam_ok_channel(bunch)))
|
||||
for ch in ADD_CHANNELS:
|
||||
channels.append((ch, ch))
|
||||
|
||||
#Metadata
|
||||
set_attribute("/", "DLAC Scanner", prefix)
|
||||
@@ -93,12 +101,17 @@ if st.take() is None:
|
||||
raise Exception("Error initializing data stream")
|
||||
start = st.take().timestamp
|
||||
|
||||
st.setFilter(beam_filter)
|
||||
|
||||
|
||||
#Scan callback
|
||||
scan_complete, cur_cycle = False, 0
|
||||
scan, res = None, None
|
||||
destination = None
|
||||
def check_end_scan(record, scan):
|
||||
def check_end_scan(record, _scan):
|
||||
global scan_complete, start, destination
|
||||
global scan
|
||||
scan=_scan
|
||||
if motor.ready:
|
||||
#if motor.isInPosition(destination):
|
||||
print "Data aquisition completed"
|
||||
@@ -106,7 +119,8 @@ def check_end_scan(record, scan):
|
||||
scan.abort()
|
||||
record.cancel() #So it won't be saved
|
||||
else:
|
||||
position = float( record[1].timestamp - start )
|
||||
position = float( record[1].timestamp - start ) #TIME
|
||||
#position = motor.readback.take() #POSITION
|
||||
for i in range (len(blms)):
|
||||
plt.getSeries(i).appendData(position, record[2 + i])
|
||||
|
||||
@@ -133,7 +147,7 @@ msg = ""
|
||||
|
||||
print "Starting scan..."
|
||||
try:
|
||||
do_background()
|
||||
#do_background()
|
||||
|
||||
#plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
|
||||
for s in plt.getAllSeries():
|
||||
@@ -157,7 +171,7 @@ try:
|
||||
#else:
|
||||
# motor.moveAsync(center_pos + scan_range[0])
|
||||
start = st.take().timestamp
|
||||
mscan ( st, [motor.readback,] + st.getReadables(), -1, -1, take_initial = True, after_read = check_end_scan)
|
||||
res = mscan ( st, [motor.readback,] + st.getReadables(), -1, -1, take_initial = True, after_read = check_end_scan)
|
||||
except:
|
||||
print "Quit scan"
|
||||
if not scan_complete:
|
||||
@@ -174,9 +188,14 @@ try:
|
||||
"""
|
||||
|
||||
finally:
|
||||
print "Closing stream"
|
||||
st.close()
|
||||
print "Closing stream"
|
||||
motor.setSpeed(TRAVEL_SPEED)
|
||||
motor.stop()
|
||||
st.close()
|
||||
if res:
|
||||
plot(res["blm1"], xdata= res[motor.readback], title="BLM 1 x Motor")
|
||||
plot(res["blm2"], xdata= res[motor.readback], title="BLM 2 x Motor")
|
||||
|
||||
|
||||
print msg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user