In [1]:
import phantasy
In [2]:
mp = phantasy.MachinePortal(machine='FRIB_FE', segment='LEBT')
In [3]:
mp.get_all_types()
Out[3]:
In [4]:
equads = mp.get_elements(type='EQUAD')
In [5]:
equads
Out[5]:
In [6]:
# first equad
equad0 = equads[0]
equad0
Out[6]:
In [7]:
print("Index : %d" % equad0.index)
print("Name : %s" % equad0.name)
print("Family : %s" % equad0.family)
print("Location : (begin) %f (end) %f" % (equad0.sb, equad0.se))
print("Length : %f" % equad0.length)
print("Groups : %s" % equad0.group)
print("PVs : %s" % equad0.pv())
print("Tags : %s" % equad0.tags)
print("Fields : %s" % equad0.fields)
In [8]:
equad0.V
Out[8]:
Get values
If only readback value is of interest, Approach 1 is recommanded and most natural.
In [9]:
# Approach 1: dynamic field feature (readback PV)
print("Readback: %f" % equad0.V)
In [10]:
# Approach 2: caget(pv_name)
pv_rdbk = equad0.pv(field='V', handle='readback')
print("Readback: %s" % phantasy.caget(pv_rdbk))
In [11]:
# Approach 3: CaField
v_field = equad0.get_field('V')
print("Readback: %f" % v_field.get(handle='readback'))
print("Setpoint: %f" % v_field.get(handle='setpoint'))
print("Readset : %f" % v_field.get(handle='readset'))
Set values
Always Approach 1 is recommanded.
In [12]:
# Save orignal set value for 'V' field
v0 = equad0.get_field('V').get(handle='setpoint')
In [13]:
# Approach 1: dynamic field feature (setpoint PV)
equad0.V = 2000
In [14]:
# Approach 2: caput(pv_name)
pv_cset = equad0.pv(field='V', handle='setpoint')
phantasy.caput(pv_cset, 1000)
Out[14]:
In [15]:
# Approach 3: CaField
v_field = equad0.get_field('V')
v_field.set(handle='setpoint', value=1500)