source: MML/trunk/mml/getmode.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.8 KB
Line 
1function 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
22if nargin == 0
23    error('Must have at least one input (''Family'')!');
24end
25
26
27%%%%%%%%%%%%%%%%%%%%%
28% Cell Array Inputs %
29%%%%%%%%%%%%%%%%%%%%%
30if 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   
43end
44
45
46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47% Family or data structure inputs beyond this point %
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49if 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
63else
64    % Family string input
65    if nargin < 2
66        Field = '';
67    end
68end
69if isempty(Field)
70    Field = 'Monitor';
71end
72
73
74%%%%%%%%%%%%
75% Get data %
76%%%%%%%%%%%%
77Mode = getfamilydata(Family, Field, 'Mode');
Note: See TracBrowser for help on using the repository browser.