Accelerator Independent Data Access / PVAccess 2.0
AIDA-PVA is the latest version of the AIDA framework. Built on top of EPICS 7 it enables client applications to programmatically access and manage any device or database on the SLAC Network using simple channel names.
Loading...
Searching...
No Matches
ezrpc.m
1function [ PVDATA ] = ezrpc( NTURI )
2 import('org.epics.pvaccess.*')
3 import('org.epics.pvaccess.easyPVA.*')
4 import('org.epics.pvdata.*')
5
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; '];
12
13 PVDATA = NaN;
14 nturi_pvs = NTURI;
15
16 % Get an easyPVA interface.
17 easypva = EasyPVAFactory.get();
18
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
23
24 % If channel connection to the given PV was successful, proceed.
25 if (iss==true)
26 easyrpc = easychan.createRPC();
27
28 % iss = easypva.getStatus();
29 % if ~isempty(easyrpc)
30 iss = easyrpc.getStatus();
31 % If successful, get data from the channel
32 if ( iss.isOK() )
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();
38 if (~iss.isOK())
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()));
42 end
43 else
44 % Issue diagnostic msg of connect if unsuccessful.
45 error(connecterr,char(easypva.getStatus().getMessage()));
46 end
47 else
48 % For infrastrcuture errors, issue whole status object toString.
49 error(pvasystemerr, char(iss) );
50 end
51 else
52 % Could not create channel connection, probably a mistake in pv name.
53 error(createchannelerror,createchannelerrormsg,char(pvname));
54 end
55
56 % Reset output var if all went well.
57 if ( iss.isOK() )
58 PVDATA = pvs;
59 end