コード例 #1
0
from dbr_module import dbr

dbr_name = "DBRtestname"
level = dbr.DBR_PERST_VOLATILE_SIMPLE
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
dbr_hdl = dbr.create(dbr_name, level, group_list)
group = dbr.DBR_GROUP_EMPTY

# query the DB to see if successful
dbr_state = ffi.new('DBR_State_t*')
res = dbr.query(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

test_in = "Hello World!"
res = dbr.put(dbr_hdl, test_in, "testTup", group)
res = dbr.put(dbr_hdl, "Goodbye!", "testTup", group)

print('Put ' + test_in + ' and Goodbye!')
group_t = 0
value, res = dbr.read(dbr_hdl, "testTup", "", group, dbr.DBR_FLAGS_NOWAIT)
print('Read returned: ' + value + " - status: ", dbr.getErrorMessage(res))
value, res = dbr.get(dbr_hdl, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print('Get returned: ' + value + " - status: ", dbr.getErrorMessage(res))
value, res = dbr.read(dbr_hdl, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print('Read returned: ' + value + " - status: ", dbr.getErrorMessage(res))
value, res = dbr.get(dbr_hdl, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print('Get returned: ' + value + " - status: ", dbr.getErrorMessage(res))
print('Delete Data Broker')
res = dbr.delete(dbr_name)
print('Exit Status: ' + dbr.getErrorMessage(res))
コード例 #2
0
dbr_hdl = dbr.create(dbr_name, level, group_list)
group = dbr.DBR_GROUP_EMPTY

# query the DBR to see if successful
dbr_state = ffi.new('DBR_State_t*')
ret = dbr.query(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

test_in = "Hello World!"
ret = dbr.put(dbr_hdl, test_in, "HelloTuple", group)
ret = dbr.put(dbr_hdl, "Goodbye World!", "GoodbyeTuple", group)

######
#test the directory command and list all tuple names/keys
size = 1024
count = 1000
keys,rsize,res = dbr.directory(dbr_hdl, "*", group, count, size)

print('Keys on DBR: ' + str(keys[:]))
tsize=[64]
value, ret = dbr.read(dbr_hdl, keys[1], "", group, dbr.DBR_FLAGS_NOWAIT)
print('Read returned: ' + value + " - status: " + dbr.getErrorMessage(ret))
value, ret = dbr.get(dbr_hdl, keys[1], "", group, dbr.DBR_FLAGS_NONE)
print('Get returned: ' + value + " - status: " + dbr.getErrorMessage(ret))
value, ret = dbr.read(dbr_hdl, keys[0], "", group, dbr.DBR_FLAGS_NONE)
print('Read returned: ' +  value +  " - status: " + dbr.getErrorMessage(ret))
value, ret = dbr.get(dbr_hdl, keys[0], "", group, dbr.DBR_FLAGS_NONE)
print('Get returned: ' + value + " - status: " + dbr.getErrorMessage(ret))
print('Delete Data Broker')
res = dbr.delete(dbr_name)
print('Exit Status: ' + dbr.getErrorMessage(res))
コード例 #3
0
dbr_name = "DBRtestname"
level = dbr.DBR_PERST_VOLATILE_SIMPLE
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
dbr_hdl = dbr.create(dbr_name, level, group_list)
group = dbr.DBR_GROUP_EMPTY

# query the DB to see if successful
dbr_state = ffi.new('DBR_State_t*')
res = dbr.query(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

# put a set of keys
for i in range(10):
    key = "simple_key_" + str(i)
    print('Putting key: ' + key)
    res = dbr.put(dbr_hdl, "test-value-" + str(i), key, dbr.DBR_GROUP_EMPTY)

iterator = dbr.DBR_ITERATOR_NEW
key, iterator = dbr.iterator(dbr_hdl, iterator, dbr.DBR_GROUP_EMPTY, "")

while iterator != dbr.DBR_ITERATOR_DONE:
    value, res = dbr.get(dbr_hdl, key, "", dbr.DBR_GROUP_EMPTY,
                         dbr.DBR_FLAGS_NONE)
    print('On key ' + key + ' Get returned: ' + value)
    key, iterator = dbr.iterator(dbr_hdl, iterator, dbr.DBR_GROUP_EMPTY, "")

print('Delete Data Broker')
res = dbr.delete(dbr_name)
print('Exit Status: ' + dbr.getErrorMessage(res))
コード例 #4
0
ファイル: dbr_numpy.py プロジェクト: systemsource/data-broker
import dbr_module
from _dbr_interface import ffi
from dbr_module import dbr
import numpy as np

dbr_name = "DBRtestname"
level = dbr.DBR_PERST_VOLATILE_SIMPLE
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
dbr_hdl = dbr.create(dbr_name, level, group_list)
group = dbr.DBR_GROUP_EMPTY

print('- Put float array in DBR')
input_array = np.array([[[1, 2, 3.0], [1, 1, 1]], [[4, 5, 6], [7, 8, 9]]])
res = dbr.put(dbr_hdl, input_array, "testNumpy", group)
ret_array, ret = dbr.get(dbr_hdl, "testNumpy", "", group, dbr.DBR_FLAGS_NONE,
                         [256])
print("Get returned status: " + dbr.getErrorMessage(ret))
print('Check input and output array are the same: ' +
      str(np.array_equal(input_array, ret_array)))

print('\n- Put integer multidimensional array in DBR')
np.random.seed(0)
input_array = np.random.randint(3, size=(2, 2, 3))
res = dbr.put(dbr_hdl, input_array, "testNumpy", group)
ret_array = None
ret_array, ret = dbr.get(dbr_hdl, "testNumpy", "", group, dbr.DBR_FLAGS_NONE,
                         [256])
print("Get returned status: " + dbr.getErrorMessage(ret))
print('Check input and output array are the same: ' +
      str(np.array_equal(input_array, ret_array)))