Demonstration of PV datasource


In [31]:
from phantasy.library.pv import DataSource

In [32]:
db = './config/FRIB_TEST/baseline_channels.sqlite'
url = 'https://127.0.0.1:8181/ChannelFinder'

In [33]:
ds1 = DataSource(source=db)
ds2 = DataSource(source=url)

Get channels' data

Get all data from PV source


In [34]:
data = ds1.get_data()

In [5]:
data[0]


Out[5]:
[u'V_1:LS1_CA01:CAV1_D1127:PHA_CSET',
 [('elemHandle', u'setpoint'),
  ('elemName', u'LS1_CA01:CAV1_D1127'),
  ('epsilon', 0.0),
  ('virtual', 0),
  ('elemIndex', 3),
  ('elemType', u'CAV'),
  ('elemPosition', 0.4470635),
  ('elemLength', 0.24),
  ('archive', 0),
  ('elemField', u'PHA'),
  ('size', 0)],
 [u'phyutil.sub.CA01', u'phyutil.sys.LINAC', u'phyutil.sys.LS1']]

In [47]:
data_bpm = ds1.get_data(prop_filter=["*", ('elemType','BPM'),('elemField','Y')])

In [48]:
data_bpm[0]


Out[48]:
[u'V_1:LS1_CA01:BPM_D1129:Y_RD',
 [('elemHandle', u'readback'),
  ('elemName', u'LS1_CA01:BPM_D1129'),
  ('epsilon', 0.0),
  ('virtual', 0),
  ('elemIndex', 6),
  ('elemType', u'BPM'),
  ('elemPosition', 0.51132684),
  ('elemLength', 0.0),
  ('archive', 0),
  ('elemField', u'Y'),
  ('size', 0)],
 [u'phyutil.sub.CA01', u'phyutil.sys.LINAC', u'phyutil.sys.LS1']]

Filter property names (OR logical)


In [6]:
data = ds1.get_data(prop_filter='elem*')

In [7]:
data[0]


Out[7]:
[u'V_1:LS1_CA01:CAV1_D1127:PHA_CSET',
 [('elemHandle', u'setpoint'),
  ('elemName', u'LS1_CA01:CAV1_D1127'),
  ('elemIndex', 3),
  ('elemType', u'CAV'),
  ('elemPosition', 0.4470635),
  ('elemLength', 0.24),
  ('elemField', u'PHA')],
 [u'phyutil.sub.CA01', u'phyutil.sys.LINAC', u'phyutil.sys.LS1']]

Filter property configuration (AND logical)


In [8]:
data = ds1.get_data(prop_filter=[('elemHandle', 'readback')])

In [9]:
data[0]


Out[9]:
[u'V_1:LS1_CA01:CAV1_D1127:PHA_RD',
 [('elemHandle', u'readback')],
 [u'phyutil.sub.CA01', u'phyutil.sys.LINAC', u'phyutil.sys.LS1']]

Filter properties (mixed)


In [10]:
data = ds1.get_data(prop_filter=['elem*', ('elemHandle', 'readback')])

In [11]:
data[0]


Out[11]:
[u'V_1:LS1_CA01:CAV1_D1127:PHA_RD',
 [('elemHandle', u'readback'),
  ('elemName', u'LS1_CA01:CAV1_D1127'),
  ('elemIndex', 3),
  ('elemType', u'CAV'),
  ('elemPosition', 0.4470635),
  ('elemLength', 0.24),
  ('elemField', u'PHA')],
 [u'phyutil.sub.CA01', u'phyutil.sys.LINAC', u'phyutil.sys.LS1']]

Filter tags (AND logical)


In [17]:
data = ds1.get_data(prop_filter=['elem*', ('elemHandle', 'readback')], tag_filter='phyutil.sys.LS1')

In [18]:
len(data)


Out[18]:
621

In [19]:
data = ds1.get_data(prop_filter=['elem*', ('elemHandle', 'readback')], tag_filter='phyutil.sys.FS1')

In [21]:
len(data)


Out[21]:
222

Change source


In [25]:
print("Current PV source address is {}, source type is {}".format(ds1.source, ds1.source_type))


Current PV source address is ./config/FRIB_TEST/baseline_channels.sqlite, source type is sql

In [26]:
ds1.source = url

In [27]:
print("Now PV source address is {}, source type is {}".format(ds1.source, ds1.source_type))


Now PV source address is https://127.0.0.1:8181/ChannelFinder, source type is cfs

In [28]:
data = ds1.get_data(prop_filter=['elem*', ('elemHandle', 'readback')], tag_filter='phyutil.sys.LS1')

In [29]:
len(data)


Out[29]:
621

In [30]:
data[0]


Out[30]:
{u'name': u'V2:LS1_CA01:BPM_D1129:X_RD',
 u'owner': u'tong',
 u'properties': [{u'name': u'elemHandle',
   u'owner': u'tong',
   u'value': u'readback'},
  {u'name': u'elemName', u'owner': u'tong', u'value': u'LS1_CA01:BPM_D1129'},
  {u'name': u'elemType', u'owner': u'tong', u'value': u'BPM'},
  {u'name': u'elemIndex', u'owner': u'tong', u'value': u'6'},
  {u'name': u'elemPosition', u'owner': u'tong', u'value': u'0.51132684'},
  {u'name': u'elemLength', u'owner': u'tong', u'value': u'0.0'},
  {u'name': u'elemField', u'owner': u'tong', u'value': u'X'}],
 u'tags': [{u'name': u'phyutil.sys.LS1', u'owner': u'tong'},
  {u'name': u'phyutil.sub.CA01', u'owner': u'tong'},
  {u'name': u'T_A', u'owner': u'tong'},
  {u'name': u'T_B', u'owner': u'tong'}]}

In [ ]: