This commit is contained in:
root
2019-08-08 10:10:28 +02:00
parent 1f4edcbc88
commit 7f88d445af
37 changed files with 6480 additions and 501 deletions

View File

@@ -0,0 +1,35 @@
number_of_frames = 3
module = 1
camera_name = "SARFE10-PPRM064"
st1 = Stream("st1", dispatcher)
def init_bs():
w,h = caget(camera_name + ":WIDTH", 'i'), caget(camera_name + ":HEIGHT", 'i')
st1.addScalar("GasDet", "SARFE10-PBPG050:", module, 0)
st1.addScalar("Y1", "SINEG01-DBPM340:Y1", module, 0)
st1.addScalar("Q1", "SINEG01-DBPM340:Q1", module, 0)
st1.addMatrix("VCC", camera_name + ":FPICTURE", module, 0, w,h)
st1.initialize()
st1.start()
st1.waitCacheChange(10000)
def init_cam():
cam_server.start(camera_name+ "_sp")
x = cam_server.stream.getChild("x_fit_mean")
y = cam_server.stream.getChild("y_fit_mean")
cam_server.stream.waitCacheChange(10000);
def scan_bs():
bscan (st1, number_of_frames, title = "BSscan", tag = "BSscan")
def scan_cam():
mscan (cam_server.stream, (x, y), number_of_frames, title = "CAMscan", tag = "CAMscan")
try:
parallelize(init_bs, init_cam)
parallelize(scan_bs, scan_cam)
finally:
st1.close()
#cam_server.stop()

19
script/test/TestWS.py Normal file
View File

@@ -0,0 +1,19 @@
run("Devices/Elements")
run("Devices/WireScanner")
#ws_prefix = "SINDI01-DWSC090"
ws_prefix = "S10DI01-DWSC010"
plt = plot(None, title = "Wire Scan Calibration")[0]
ws_wire = WireScanner.WireX1
range_start = -900
range_end = 100
n_shot = 200
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#Calculate speed
x_min, x_max = range_start, range_end
#rr = get_repetition_rate()
#ws_speed = (x_max- x_min)*rr/n_shot
for xx in range(10):
__args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, n_shot, [], [ws_blm], 1, plt, False,1,0]
ret = run("Diagnostics/WireScan", __args)

View File

@@ -0,0 +1,38 @@
blm = "S10DI01-DBLM045"
channels = ["S10DI01-DWSC010:CURR_CYCL","S10CB02-DBPM420:X1","S10DI01-DWSC010:SCANNING",blm+":WS_RUNNING", \
"S10CB02-DBPM420:Y1","S10DI01-DBLM015:B1_LOSS","S10CB02-DBPM420:Q1","S10BD01-DBPM020:Q1","S10DI01-DWSC010:ENC_1_BS", \
"S10BD01-DBPM020:X1","S10BD01-DBPM020:Y1",blm+":B1_LOSS","SIN-CVME-TIFGUN-EVR0:BEAMOK"]
blm = "SARCL02-DBLM135"
channels =[blm+":B1_LOSS", blm+":WS_RUNNING",
"SARCL01-DWSC160:CURR_CYCL","SARCL01-DWSC160:SCANNING","SARCL02-DBPM110:Q1","SARCL02-DBPM110:X1",
,"SARCL01-DBPM150:Y1","SARCL01-DBPM150:X1","SARCL01-DWSC160:ENC_1_BS","SARCL02-DBPM110:Y1",\
"SARCL01-DBPM150:Q1","SIN-CVME-TIFGUN-EVR0:BEAMOK",
#"SARCL02-DBLM355:B1_LOSS" ,
]
st1 = Stream("st1", dispatcher)
add_device(st1, force = True)
for channel in channels:
st1.addScalar(channel, channel, 10, 0)
st1.initialize()
st1.start(True)
try:
#bscan (st1, 10, title="bscan")
#tscan (st1.getReadables(), 10, 1, title="tscan")
x = st1.take()
start_blm_ws(blm, 55.5)
#TODO: Wait for stream variable indicate bllm is in ws mode
print "Waiting for WS mode..."
#time.sleep(SET_BLM_WS_SETTLING_TIME)
st1.getChild(blm+":WS_RUNNING").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
print "Ok"
finally:
stop_blm_ws(blm)
st1.close()

9
script/test/blm.py Normal file
View File

@@ -0,0 +1,9 @@
run("Devices/Elements")
plot(get_blm_raw("SINLH02-DBLM230"))
print get_blm_baseline("SINLH02-DBLM230")
print get_blm_range("SINLH02-DBLM230")
for blm in get_blms():
print blm, " - " , get_blm_baseline(blm), " - " , min(get_blm_raw(blm)), " - " , get_blm_range(blm)

View File

@@ -0,0 +1,34 @@
MIN_GAIN, MAX_GAIN = 0.5, 1.1
DECREMENT_STEP = 0.02
INCREMENT_FACTOR = 0.5
SCAN_RANGE_FACTOR = 6
MAX_RANGE_STEP = 200
new_gain, new_voltage = None, None
desired_loss=get_blm_saturation(blms[i])
current_voltage = get_blm_ws_gain(blms[i]) #read_ws_gain (blms[i], wire)
#current_loss = float(get_blm_loss(blms[i]))
current_loss = 1700
current_gain = get_gain_from_voltage(current_voltage)
if False: #current_loss > desired_loss:
#Gain must decrease. Fixed steps down
if current_voltage > MIN_GAIN:
new_gain = max(current_voltage - DECREMENT_STEP, MIN_GAIN)
else:
#Gain must be increasede. Step proportional to the difference
dg = current_gain * (desired_loss/ current_loss -1)
new_gain = current_gain + dg * INCREMENT_FACTOR
new_voltage = get_voltage_from_gain(new_gain)
new_voltage = max(min(new_voltage, MAX_GAIN),MIN_GAIN)
print "dg=", dg, " ng=", new_gain
if (new_voltage is not None) and (new_voltage != current_voltage):
logstr= "Adapting " , blms[i], " - ", wire, "gain: ", new_voltage
print logstr
log(logstr)
write_ws_gain(blms[i], wire, new_voltage)