1function [ PVDATA ] = ezrpc( NTURI )
2 import(
'org.epics.pvaccess.*')
3 import(
'org.epics.pvaccess.easyPVA.*')
4 import(
'org.epics.pvdata.*')
6 servererr=
'MEME:ematrpc:servererror'; % server side issued an error
7 connecterr=
'MEME:ematrpc:connectionerror'; % pvAccess connection error
8 pvasystemerr=
'MEME:ematrpc:pvaccesserror'; % pvAccess
internal error
9 createchannelerror=
'MEME:eget:createchannelerror'; % Could not create channel link to given pv name
10 createchannelerrormsg=['Could not create channel to %s, check validity and spelling of channel,'...
11 ' then status of PVA server; '];
16 % Get an easyPVA interface.
17 easypva = EasyPVAFactory.get();
19 % Create a channel to the given pv, and attempt connection.
20 pvname = nturi_pvs.getStringField(
'path').get();
21 easychan = easypva.createChannel(pvname);
22 iss=easychan.connect(5.0); % 5 second timeout
24 % If channel connection to the given PV was successful, proceed.
26 easyrpc = easychan.createRPC();
28 % iss = easypva.getStatus();
29 %
if ~isempty(easyrpc)
30 iss = easyrpc.getStatus();
31 % If successful,
get data from the channel
33 % Connect the RPC to service PV and
if successful
34 % request data given arguments.
35 if (easyrpc.connect())
36 pvs = easyrpc.request(nturi_pvs);
37 iss=easyrpc.getStatus();
39 % Issue result of statment that got twiss data. Server
40 % side generated errors will be issued by this.
41 error(servererr,
char(iss.getMessage()));
44 % Issue diagnostic msg of connect
if unsuccessful.
45 error(connecterr,
char(easypva.getStatus().getMessage()));
48 % For infrastrcuture errors, issue whole status
object toString.
49 error(pvasystemerr,
char(iss) );
52 % Could not create channel connection, probably a mistake in pv name.
53 error(createchannelerror,createchannelerrormsg,
char(pvname));
56 % Reset output var
if all went well.