コード例 #1
0
ファイル: dbr_putget.py プロジェクト: kant/data-broker
dbr_hdl = dbr.dbrCreate(dbr_name, level, group_list)
group = '0'

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

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

print 'Put ' + test_in + ' and Goodbye' 
out_size = ffi.new('int64_t*')
out_size[0] = 1024
q = dbr.createBuf('char[]', out_size[0])
group_t = 0
res = dbr.dbrRead(dbr_hdl, q, out_size, "testTup", "", group, dbr.DBR_FLAGS_NOWAIT)
print 'Read returned: ' +  q[:]
res = dbr.dbrGet(dbr_hdl, q, out_size, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print 'Get returned: ' + q[:]
#read again to check for failing
out_size[0] = 1024
q = dbr.createBuf('char[]', out_size[0])
res = dbr.dbrRead(dbr_hdl, q, out_size, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print 'Read returned: ' +  q[:]
res = dbr.dbrGet(dbr_hdl, q, out_size, "testTup", "", group, dbr.DBR_FLAGS_NONE)
print 'Get returned: ' + q[:]
print 'Delete Data Broker'
res = dbr.dbrDelete(dbr_name)
print 'Exit Status: ' + dbr.getErrorMessage(res)
コード例 #2
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))
コード例 #3
0
ファイル: dbr_putgetA.py プロジェクト: sureddy/data-broker
test_in = "Hello World!"
res = dbr.dbrPutA(dbr_hdl, test_in, "testTup", group)

print 'Async Put tuple: ' + test_in
out_size = ffi.new('int64_t*')
out_size[0] = 1024

q = dbr.createBuf('char[]', out_size[0])
tag = dbr.dbrGetA(dbr_hdl, q, out_size, "testTup", "", group)
if (tag != dbr.DBR_ERR_TAGERROR):
    state = dbr.dbrTest(tag)
    while (state == dbr.DBR_ERR_INPROGRESS):
        state = dbr.dbrTest(tag)
        pass
    else:
        print 'Async Get test returned ' + dbr.getErrorMessage(state)

print 'Tuple value: ' + q[:]

#read again to check for failing
out_size[0] = 1024
q = dbr.createBuf('char[]', out_size[0])

res = dbr.dbrRead(dbr_hdl, q, out_size, "testTup", "", group,
                  dbr.DBR_FLAGS_NONE)
print 'Read returned: ' + q[:]

print 'Delete Data Broker'
res = dbr.dbrDelete(dbr_name)
print 'Exit Status: ' + dbr.getErrorMessage(res)
コード例 #4
0
dbr_name = "DBRtestname"
group_list = ffi.new('DBR_GroupList_t')
dbr_hdl = ffi.new('DBR_Handle_t*')
level = dbr.DBR_PERST_VOLATILE_SIMPLE

# Create the Data Broker
dbr_hdl = dbr.create(dbr_name, level, group_list)
# Query the Data Broker 
dbr_state = ffi.new('DBR_State_t*')
res = dbr.query(dbr_hdl, dbr_state, dbr.DBR_STATE_MASK_ALL)

# Test if we can attach multiple times
for n in range(10):
    dbr_hdl = dbr.attach(dbr_name)
    assert dbr_hdl != None  

# test detach 
for n in range(10):
    res = dbr.detach(dbr_hdl)
    print('Detach #' + str(n+1) + ': ' + dbr.getErrorMessage(res))
    assert (res == dbr.DBR_SUCCESS)

# Delete the Data Broker    
print('Delete Data Broker')
res = dbr.delete(dbr_name)

# try to attach to the deleted Data Broker
dbr_hdl = dbr.attach(dbr_name)
assert dbr_hdl != None
print('Exit Status: ' + dbr.getErrorMessage(res))
コード例 #5
0
ファイル: dbr_numpy.py プロジェクト: systemsource/data-broker
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)))

print('\n- Put mixed types/mixed size array in DBR')