Exemple #1
0
 def _execute_rpc(self, request):
     method = pvaccess.PvObject({'method': pvaccess.STRING})
     method.set({'method': request.path[1]})
     # Connect to the channel and create the RPC client
     rpc = pvaccess.RpcClient(request.path[0], method)
     # Construct the pv object from the parameters
     params = dict_to_pv_object(request.parameters)
     # Call the method on the RPC object
     value = rpc.invoke(params)
     # Now create the Return object and populate it with the response
     d = strip_tuples(value.toDict(True))
     response = self._response_from_dict(request, d)
     return response
Exemple #2
0
def get_full_machine_model(use_design=False):
	if not PVACCESS_AVAILABLE:
		raise NoPVAccessException
	request = pvaccess.PvObject(OrderedDict([('scheme', pvaccess.STRING), ('path', pvaccess.STRING)]), 'epics:nt/NTURI:1.0')
	model_type = "EXTANT"
	if use_design:
		model_type = "DESIGN"
	path = "MODEL:RMATS:{}:FULLMACHINE".format(model_type)
	rpc = pvaccess.RpcClient(path)
	request.set(OrderedDict([('scheme', 'pva'), ('path', path)]))
	response = rpc.invoke(request).getStructure()
	m = np.zeros(len(response['ELEMENT_NAME']), dtype=[('ordinal', 'i16'),('element_name', 'a60'), ('epics_channel_access_name', 'a60'), ('position_index', 'a6'), ('z_position', 'float32'), ('r_mat', 'float32', (6,6))])
	m['ordinal'] = response['ORDINAL']
	m['element_name'] = response['ELEMENT_NAME']
	m['epics_channel_access_name'] = response['EPICS_CHANNEL_ACCESS_NAME']
	m['position_index'] = response['POSITION_INDEX']
	m['z_position'] = response['Z_POSITION']
	m['r_mat'] = np.reshape(np.array([response['R11'], response['R12'], response['R13'], response['R14'], response['R15'], response['R16'], response['R21'], response['R22'], response['R23'], response['R24'], response['R25'], response['R26'], response['R31'], response['R32'], response['R33'], response['R34'], response['R35'], response['R36'], response['R41'], response['R42'], response['R43'], response['R44'], response['R45'], response['R46'], response['R51'], response['R52'], response['R53'], response['R54'], response['R55'], response['R56'], response['R61'], response['R62'], response['R63'], response['R64'], response['R65'], response['R66']]).T, (-1,6,6))
	return m
Exemple #3
0
 def execute_rpc(self, request):
     method = pvaccess.PvObject({'method': pvaccess.STRING})
     method.set({'method': request["endpoint"][1]})
     # Connect to the channel and create the RPC client
     rpc = pvaccess.RpcClient(request["endpoint"][0], method)
     # Construct the pv object from the parameters
     params = self.dict_to_pv_object(request["parameters"])
     self.log_debug("PvObject parameters: %s", params)
     # Call the method on the RPC object
     response = rpc.invoke(params)
     self.log_debug("Response: %s", response)
     # Now create the Return object and populate it with the response
     value = response.toDict(True)
     if 'typeid' in value:
         if value['typeid'] == 'malcolm:core/Error:1.0':
             return_object = Error(id_=request["id"], message=value['message'])
         else:
             return_object = Return(id_=request["id"], value=value)
     else:
         return_object = Error(id_=request["id"], message="No valid return typeid")
     return return_object
Exemple #4
0
    def _get_rpc_client(self, ch_name):
        """Get pvAccess RPC Client

        Parameters
        ----------
        ch_name : str
            pvAccess channel name

        Returns
        -------
        pvaccess.RpcClient
            pvAccess RPC Client for channel name
        """
        self._check_ch_name(ch_name)
        name = str(ch_name)

        with self._lock:
            if name not in self._clients:
                self._clients[name] = pva.RpcClient(name)
            client = self._clients[name]

        return client
Exemple #5
0
 def __init__(self, channelname = 'masarService'):
     """
     masar service client library. Default channel name is masarService.
     """
     #self.channelname = channelname
     self.rpc = pvaccess.RpcClient(channelname)
Exemple #6
0
#!/usr/bin/env python

import pvaccess
import random

rpc = pvaccess.RpcClient('createNtTable')
request = pvaccess.PvObject({'nRows' : pvaccess.INT, 'nColumns' : pvaccess.INT})
request.set({'nRows' : 10, 'nColumns' : 10})
print "Sending request for createNtTable:"
print request

print "Got response:"
response = rpc.invoke(request)
print response

print "Converting to NtTable:"
ntTable = pvaccess.NtTable(response)
print ntTable
print "Get column 3:"
print ntTable.getColumn(3)
print "Get descriptor:"
print ntTable.getDescriptor()

Exemple #7
0
from pvaccess import PvObject, STRING, DOUBLE, NtTable

import pvaccess

pvObject = PvObject({
    'labels': [STRING],
    'value': {
        'column0': [DOUBLE],
        'column1': [DOUBLE],
        'column2': [DOUBLE]
    }
})

pvObject.setScalarArray('labels', ['x', 'y', 'z'])
pvObject.setStructure(
    'value', {
        'column0': [0.1, 0.2, 0.3],
        'column1': [1.1, 1.2, 1.3],
        'column2': [2.1, 2.2, 2.3]
    })
table3 = NtTable(pvObject)

print table3

rpc = pvaccess.RpcClient('table')
request = table3

rpc.invoke(request)