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
ML.m
1function [ matlabResult ] = ML( pvaResult )
2 % Unpack using java first if this is still a PVStructure
3 if ( isa(pvaResult, 'org.epics.pvdata.factory.BasePVStructure'))
4 pvaResult = edu.stanford.slac.aida.client.AidaPvaClientUtils.pvaUnpack(pvaResult);
5 end
6
7 % If this is a Java array then convert to a matlab array and return
8 if (isa(pvaResult, 'java.lang.Object[]'))
9 matlabResult = toArray(pvaResult);
10
11 % If this is a PvaTable then convert to a matlab structure
12 elseif ( isa(pvaResult, 'edu.stanford.slac.aida.client.PvaTable'))
13 matlabResult = struct;
14 matlabResult.size = pvaResult.size.intValue;
15 matlabResult.labels = toArray(pvaResult.labels);
16 if ( pvaResult.units.length )
17 matlabResult.units = toArray(pvaResult.units);
18 else
19 matlabResult.units = [];
20 end
21 if ( pvaResult.descriptions.length )
22 matlabResult.descriptions = toArray(pvaResult.descriptions);
23 else
24 matlabResult.descriptions = [];
25 end
26 matlabResult.fieldnames = toArray(pvaResult.fieldNames);
27 matlabResult.values = [];
28 for fieldNumber = 1:pvaResult.fieldNames.length
29 fieldName = pvaResult.fieldNames(fieldNumber);
30 vector = toArray(pvaResult.get(fieldName));
31 matlabResult.values = setfield(matlabResult.values, char(fieldName), vector);
32 end
33
34 % A java type will never be returned but we keep these just in case
35 elseif (isa(pvaResult, 'java.lang.Byte'))
36 matlabResult = pvaResult.byteValue;
37
38 elseif (isa(pvaResult, 'java.lang.Boolean'))
39 matlabResult = pvaResult.booleanValue;
40
41 elseif (isa(pvaResult, 'java.lang.Short'))
42 matlabResult = pvaResult.shortValue;
43
44 elseif (isa(pvaResult, 'java.lang.Integer'))
45 matlabResult = pvaResult.intValue;
46
47 elseif (isa(pvaResult, 'java.lang.Long'))
48 matlabResult = pvaResult.longValue;
49
50 elseif (isa(pvaResult, 'java.lang.Float'))
51 matlabResult = pvaResult.floatValue;
52
53 elseif (isa(pvaResult, 'java.lang.Double'))
54 matlabResult = pvaResult.doubleValue;
55
56 elseif (isa(pvaResult, 'java.lang.String'))
57 matlabResult = char(pvaResult) ;
58
59 else
60 matlabResult = pvaResult;
61 end
62end