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

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

Initial import--MML version from SOLEIL@2013

File size: 3.2 KB
Line 
1function [Family, Field, DeviceList, UnitsFlag, ModelFlag] = inputparsingffd(varargin)
2%INPUTPARSINGFFD - Parses the typical input line of Family, Field, DeviceList
3%  [Family, Field, DeviceList, UnitsFlag, ModeFlag] = inputparsingffd(varargin);
4%
5%  OUTPUTS
6%  1. Family
7%  2. Field
8%  3. DeviceList {Default: Entire family}
9%                If DeviceList is a string, then a common name conversion is tried.
10%  4. UnitsFlag - Units if the input was a data structure
11%  5. ModeFlag - Mode if the input was a data structure
12%
13%  Written by Greg Portmann
14
15
16UnitsFlag = '';
17ModelFlag = '';
18
19
20%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21% Family, Data Structure, or AO Structure %
22%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23if isstruct(varargin{1})
24    if isfield(varargin{1},'FamilyName') && isfield(varargin{1},'Field')
25        % Data structure inputs
26        Family = varargin{1}.FamilyName;
27
28        Field = varargin{1}.Field;
29        if length(varargin) >= 2
30            if ischar(varargin{2})
31                Field = varargin{2};
32                varargin(2) = [];
33            end
34        end
35        if length(varargin) >= 2
36            DeviceList = varargin{2};
37        else
38            DeviceList = varargin{1}.DeviceList;
39        end
40
41        if isfield(varargin{1},'Units')
42            UnitsFlag = varargin{1}.Units;
43        end
44        if isfield(varargin{1},'Mode')
45            ModeFlag = varargin{1}.Mode;
46        end
47
48    else
49
50        % AO Input
51        Family = varargin{1}.FamilyName;
52
53        Field = '';
54        if length(varargin) >= 2
55            if ischar(varargin{2})
56                Field = varargin{2};
57                varargin(2) = [];
58            end
59        end
60        if length(varargin) >= 2
61            DeviceList = varargin{2};
62        else
63            DeviceList = varargin{1}.DeviceList;
64        end
65        if isempty(DeviceList)
66            DeviceList = varargin{1}.DeviceList;
67        end
68    end
69
70else
71
72    % Family input
73    Family = varargin{1};
74
75    Field = '';
76    if length(varargin) >= 2
77        if ischar(varargin{2})
78            Field = varargin{2};
79            varargin(2) = [];
80        end
81    end
82    if length(varargin) >= 2
83        DeviceList = varargin{2};
84    else
85        DeviceList = [];
86    end
87
88end
89
90
91% Default field
92% if isempty(Field)
93%     Field = 'Monitor';
94% end
95
96
97% Default device list
98if isempty(DeviceList)
99    try
100        DeviceList = family2dev(Family);
101    catch
102    end
103end
104
105% Convert element list to a device list
106if (size(DeviceList,2) == 1)
107    DeviceList = elem2dev(Family, DeviceList);
108end
109
110
111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112% CommonName Input:  Convert common names to a varargin{3} %
113%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114
115% Check if the device list is a common name list
116if ischar(DeviceList)
117    DeviceList = common2dev(DeviceList, Family);
118    if isempty(DeviceList)
119        error('DeviceList was a string but common names could not be found.');
120    end
121end
122
123
124% Check if the family is a common name list
125% Just check the first name so it's a faster test, then convert them all if it passes
126[DeviceListTest, FamilyTest] = common2dev(Family(1,:));
127if ~isempty(FamilyTest)
128    % Common names where the family was the common name
129    [DeviceList, Family, ErrorFlag] = common2dev(Family(1,:));
130end
131
Note: See TracBrowser for help on using the repository browser.