In [13]:
from utils import *
# udc = create_udc('IA-08RaCtrl:CO-PSCtrl-SI3')
udc = create_udc('IA-02RaCtrl:CO-PSCtrl-BO')
ps1, ps2, ps3, ps4 = udc[1], udc[2], udc[3], udc[4]
psall = [ps1, ps2, ps3, ps4]
print()
print_info(psall)
In [17]:
%timeit ps1.parameter_read(3)
In [18]:
%timeit ps1.parameter_write(0, 'BO-03U:PS-CH / BO-03U:PS-CV / BO-05U:PS-CH / BO-05U:PS-CV')
# ps1.parameter_write(0, 'BO-03U:PS-CH,BO-03U:PS-CV,BO-05U:PS-CH,BO-05U:PS-CV')
In [4]:
ack, data = ps4.read_variable(0, timeout=100)
print(bin(data))
In [7]:
# Run timeit benchmarks
var_id=0
print('ps1.read_variable(var_id={})'.format(var_id))
%timeit ps1.read_variable(var_id, timeout=100)
print()
group_id=0
print('ps1.read_group_of_variables(group_id={})'.format(group_id))
%timeit ps1.read_group_of_variables(group_id, timeout=100)
print()
print('ps1.request_curve_block(curve_id=0, block=0)')
%timeit ps1.request_curve_block(curve_id=0, block=0, timeout=1000)
print()
print('ps1.psbsmp.wfmref_read()')
%timeit ps1.wfmref_read()
print()
c = [0.0 for i in range(1024)]
print('ps1.wfmref_write(size:{})'.format(len(c)))
%timeit ps1.wfmref_write(c)
print()
print('ps1.psbsmp.scope_read()')
%timeit ps1.scope_read()
print()
In [ ]:
# measure_duration_read_group_of_variables(ps1, group_id=0)
# measure_duration_request_curve_block(ps1, curve_id=0, block=0)
measure_duration_wfmref_read(ps1)
In [ ]:
# sharkwire filter: ip.addr == 10.128.108.121 and (tcp.port == 5000 or tcp.port == 6001) and data.len != 0
# Measurement 1
title = 'ps1.read_group_of_variables(group_id=0)'
python = [9.43, 9.57, 9.55, 10.24, 9.90, 9.51, 9.55, 9.44, 9.43, 9.40, ]
prulib = [9.20, 9.38, 9.33, 10.02, 9.69, 9.31, 9.33, 9.21, 9.22, 9.19, ]
tcp_ip = [9.05, 9.12, 9.12, 9.81, 9.47, 9.14, 9.10, 9.03, 9.01, 8.99, ]
serial = [0.59,] * len(python)
plt.plot(python, '-o', label='python')
plt.plot(prulib, '-o', label='prulib')
plt.plot(tcp_ip, '-o', label='tcp_ip')
plt.plot(serial, '-o', label='serial')
plt.xlabel('Index')
plt.ylabel('Time [ms]')
plt.ylim(0, 12)
plt.legend()
plt.title(title)
plt.show()
# Measurement 2
title = 'ps1.request_curve_block(curve_id=0, block=0)'
python = [20.89, 41.52, 20.53, 21.75, 21.77, 20.64, 21.18, 20.89, 20.70, 20.82, ]
prulib = [20.60, 41.14, 20.26, 21.45, 20.51, 20.37, 20.86, 20.52, 20.42, 20.52, ]
tcp_ip = [20.39, 40.76, 20.06, 21.08, 19.92, 19.13, 20.20, 20.12, 20.15, 20.26, ]
serial = [1.73,] * len(python)
plt.plot(python, '-o', label='python')
plt.plot(prulib, '-o', label='prulib')
plt.plot(tcp_ip, '-o', label='tcp_ip')
plt.plot(serial, '-o', label='serial')
plt.xlabel('Index')
plt.ylabel('Time [ms]')
plt.ylim(0, 45)
plt.legend()
plt.title(title)
plt.show()
# Measurement 3
title = 'ps1.wfmref_read'
python = [91.16, 91.96, 91.94, 91.20, 90.85, 97.44, 91.25, 93.24, 93.22, 91.88, ]
prulib = [89.48, 90.58, 90.63, 89.47, 89.57, 93.33, 89.73, 90.69, 91.90, 90.36, ]
tcp_ip = [90.58, 91.50, 91.27, 90.44, 90.39, 95.74, 90.66, 92.59, 92.33, 91.21, ]
serial = [7.03,] * len(python)
plt.plot(python, '-o', label='python')
plt.plot(prulib, '-o', label='prulib')
plt.plot(tcp_ip, '-o', label='tcp_ip')
plt.plot(serial, '-o', label='serial')
plt.xlabel('Index')
plt.ylabel('Time [ms]')
plt.ylim(0, 120)
plt.legend()
plt.title(title)
plt.show()
In [3]:
print('--- set slowref ---')
turn_on_opmode_slowref(psall)
print_status(psall)
print('---')
print_wfmref(psall)
print()
print('--- write zero ---')
set_wfmref(psall, amplitude=2.0)
print_status(psall)
print('---')
print_wfmref(psall)
plot_wfmref(psall)
print()
print('--- write amp-1.0 ---')
set_wfmref(psall, amplitude=1.0)
print_status(psall)
print('---')
print_wfmref(psall)
plot_wfmref(psall)
print()
In [ ]:
print('--- set slowref ---')
turn_on_opmode_slowref(psall)
print_status(psall)
print('---')
print_wfmref(psall)
print()
print('--- write zero ---')
set_wfmref(psall, amplitude=0.0)
print_status(psall)
print('---')
print_wfmref(psall)
plot_wfmref(psall)
print()
print('--- rmpwfm ---')
turn_on_opmode_rmpwfm(psall)
print_status(psall)
print('---')
print_wfmref(psall)
print()
print('--- write amp 1.0 A ---')
set_wfmref(psall, amplitude=1.0)
print_status(psall)
print('---')
print_wfmref(psall)
plot_wfmref(psall)
print()
input('Trigger timing and press ENTER:')
print()
print('--- status ---')
print_status(psall)
print('---')
print_wfmref(psall)
plot_wfmref(psall)
print()
In [ ]:
c = ps1.wfmref_read()
ps1.wfmref_write(c[::-1])
In [ ]:
c0 = ps1.curve_read(0)
c1 = ps1.curve_read(1)
plt.plot(c0, label='0')
plt.plot(c1, label='1')
plt.legend()
plt.show()
In [ ]:
print_info(ps1)
c0 = ps1.curve_read(0)
c1 = ps1.curve_read(1)
c2 = ps1.curve_read(2)
cs = ps1.wfmref_read()
plt.plot(c0, label='0')
plt.plot(c1, label='1')
plt.plot(c2, label='2')
plt.plot(cs, label='S')
plt.legend()
plt.show()
In [ ]:
psupply = PSupply(ps1)
In [ ]:
psupply.update_variables()
In [ ]:
# --- reseta udc --
# process_response(ps1.execute_function(41, timeout=100, read_flag=False))
# --- desliga fontes ---
# process_response(ps1.execute_function(1, timeout=100))
# process_response(ps2.execute_function(1, timeout=100))
# process_response(ps3.execute_function(1, timeout=100))
# process_response(ps4.execute_function(1, timeout=100))
# --- liga fontes ---
# process_response(ps1.execute_function(0, timeout=100))
# process_response(ps2.execute_function(0, timeout=100))
# process_response(ps3.execute_function(0, timeout=100))
# process_response(ps4.execute_function(0, timeout=100))
# --- print info ---
# print_info([ps1, ps2, ps3, ps4])
# --- read variables ---
# ps1.read_variable(0, timeout=100)
# udc.reset()
In [ ]:
print_info(ps1)
c1 = ps1.wfmref_read()
nc = c1[::-1]
ps1.wfmref_write(nc)
print_info(ps1)
c2 = ps1.wfmref_read()
plt.plot(c1, label='c1')
plt.plot(c2, label='c2')
plt.legend()
plt.show()
# psupply = PSupply(ps1)
# ps1.query_list_of_group_of_variables()
# %timeit psupply.update_groups()
# %timeit psupply.update_variables()
# %timeit psupply.update_wfm()
# %timeit psupply.update()
In [18]:
import epics
pvsp = epics.PV('BO-19U:PS-CH:Wfm-SP')
pvrb = epics.PV('BO-19U:PS-CH:Wfm-RB')
pvrm = epics.PV('BO-19U:PS-CH:WfmRef-Mon')
pvmo = epics.PV('BO-19U:PS-CH:Wfm-Mon')
print(pvsp.connected)
print(pvrb.connected)
print(pvrm.connected)
print(pvmo.connected)
In [38]:
# udc.bufsample_disable()
# b1 = ps1.scope_read()
# print(b1)
pvsp.value = np.cos([4*2*np.pi*i/979 for i in range(980)])
# pvsp.value = pvsp.value[::-1]
# c = pvmo.value
# plt.plot(c)
# plt.show()
In [34]:
# pvsp.value = [1.0*i/979 for i in range(980)]
In [ ]:
# curve = np.sin([2*np.pi*i/1023 for i in range(1024)])
curve = pvsp.value
maxv = min(8, max(curve) + 1)
curve = [maxv*i/1023 for i in range(1024)]
pvsp.value = curve
time.sleep(1.0)
plt.plot(pvsp.value)
plt.plot(pvrm.value)
plt.show()
In [ ]:
# ps1.scope_enable()
ps1.scope_read()
# ps1.execute_function(16, 5.0)
# ps1.read_variable(27, timeout=100)
In [ ]:
plt.plot(pvsp.value)
plt.plot(pvrm.value)
In [ ]:
print_info(ps1)
psupply1 = PSupply(ps1)
psupply1.update_groups()
%timeit psupply1.update_wfm()
# psupply1.update_wfm(interval=0.0)
# c1 = psupply1.wfmref_mon
# curve = psupply.psbsmp.wfmref_write(curve)
# psupply1.update_wfm(interval=0.0)
# c = psupply1.wfmref_mon
# plt.plot(c)
# # plt.show()