From 89adfb13b02aad4a0e526e7fce036440ec3264c2 Mon Sep 17 00:00:00 2001 From: voulot_d Date: Tue, 21 Feb 2017 08:44:20 +0100 Subject: [PATCH] Startup --- script/RFscan/SchottkyScan.py | 15 ++++------ script/RFscan/SchottkyScan_sim.py | 49 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 script/RFscan/SchottkyScan_sim.py diff --git a/script/RFscan/SchottkyScan.py b/script/RFscan/SchottkyScan.py index b58acc4..d803572 100644 --- a/script/RFscan/SchottkyScan.py +++ b/script/RFscan/SchottkyScan.py @@ -14,17 +14,16 @@ else: lat = args[4] -phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM") +phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE", "SINEG01-RSYS:GET-VSUM-PHASE") phase.config.minValue =-45.0 phase.config.maxValue = 360.0 phase.config.resolution = 0.5 phase.initialize() -#st = Stream("ICTstream", dispatcher) -#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE-SIM", 1, 0) -#st.initialize() -#st.start(True) -q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q') +st = Stream("ICTstream", dispatcher) +q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0) +st.initialize() +st.start(True) try: qb = create_averager(q, nb, 0.100) @@ -34,11 +33,9 @@ try: chargerms = [val.stdev for val in r.getReadable(0)] finally: phase.close() - q.close() - #st.close() + st.close() #Setting the return value -#set_return(50.0) y = charge x = rf_phase index_max = y.index(max(y)) diff --git a/script/RFscan/SchottkyScan_sim.py b/script/RFscan/SchottkyScan_sim.py new file mode 100644 index 0000000..b58acc4 --- /dev/null +++ b/script/RFscan/SchottkyScan_sim.py @@ -0,0 +1,49 @@ +import ch.psi.pshell.epics.ControlledVariable as ControlledVariable + +if get_exec_pars().source == CommandSource.ui: + start = 50.0 + stop = 230.0 + step = 5.0 + nb = 1 + lat = 0.100 +else: + start = args[0] + stop = args[1] + step = args[2] + nb = int(args[3]) + lat = args[4] + + +phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM") +phase.config.minValue =-45.0 +phase.config.maxValue = 360.0 +phase.config.resolution = 0.5 +phase.initialize() + +#st = Stream("ICTstream", dispatcher) +#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE-SIM", 1, 0) +#st.initialize() +#st.start(True) +q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q') + +try: + qb = create_averager(q, nb, 0.100) + r = lscan(phase, (qb), start, stop, step, latency=lat) + rf_phase = r.getPositions(0) + charge = [val.mean for val in r.getReadable(0)] + chargerms = [val.stdev for val in r.getReadable(0)] +finally: + phase.close() + q.close() + #st.close() + +#Setting the return value +#set_return(50.0) +y = charge +x = rf_phase +index_max = y.index(max(y)) +phase_ref = x[index_max] - 80 +phase_offset = - phase_ref +caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset) + +set_return(phase_ref) \ No newline at end of file