1 | function Mode = getmode(Family, Field) |
---|
2 | %GETMODE - Returns the present family mode ('Online', 'Simulator', 'Manual', 'Special', etc) |
---|
3 | % Mode = getmode(Family, Field) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. Family - Family Name |
---|
7 | % Data Structure |
---|
8 | % Accelerator Object |
---|
9 | % (or a cell array of the above types) |
---|
10 | % 2. Field - Accelerator Object field name ('Monitor', 'Setpoint', etc) {Default: 'Monitor'} |
---|
11 | % |
---|
12 | % OUTPUTS |
---|
13 | % 1. Mode - Mode string corresponding to the Family and Field |
---|
14 | % |
---|
15 | % NOTES |
---|
16 | % 1. If the inputs are cell arrays, then the outputs are cell arrays |
---|
17 | |
---|
18 | % |
---|
19 | % Written by Greg Portmann |
---|
20 | |
---|
21 | |
---|
22 | if nargin == 0 |
---|
23 | error('Must have at least one input (''Family'')!'); |
---|
24 | end |
---|
25 | |
---|
26 | |
---|
27 | %%%%%%%%%%%%%%%%%%%%% |
---|
28 | % Cell Array Inputs % |
---|
29 | %%%%%%%%%%%%%%%%%%%%% |
---|
30 | if iscell(Family) |
---|
31 | for i = 1:length(Family) |
---|
32 | if nargin < 2 |
---|
33 | Mode{i} = getmode(Family{i}); |
---|
34 | elseif nargin < 3 |
---|
35 | if iscell(Field) |
---|
36 | Mode{i} = getmode(Family{i}, Field{i}); |
---|
37 | else |
---|
38 | Mode{i} = getmode(Family{i}, Field); |
---|
39 | end |
---|
40 | end |
---|
41 | end |
---|
42 | return |
---|
43 | end |
---|
44 | |
---|
45 | |
---|
46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
47 | % Family or data structure inputs beyond this point % |
---|
48 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
49 | if isstruct(Family) |
---|
50 | % Data structure inputs |
---|
51 | if nargin < 2 |
---|
52 | if isfield(Family,'Field') |
---|
53 | Field = Family.Field; |
---|
54 | else |
---|
55 | Field = ''; |
---|
56 | end |
---|
57 | end |
---|
58 | if isfield(Family,'FamilyName') |
---|
59 | Family = Family.FamilyName; |
---|
60 | else |
---|
61 | error('For data structure inputs FamilyName field must exist') |
---|
62 | end |
---|
63 | else |
---|
64 | % Family string input |
---|
65 | if nargin < 2 |
---|
66 | Field = ''; |
---|
67 | end |
---|
68 | end |
---|
69 | if isempty(Field) |
---|
70 | Field = 'Monitor'; |
---|
71 | end |
---|
72 | |
---|
73 | |
---|
74 | %%%%%%%%%%%% |
---|
75 | % Get data % |
---|
76 | %%%%%%%%%%%% |
---|
77 | Mode = getfamilydata(Family, Field, 'Mode'); |
---|