1 | function [CommonNames, ErrorFlag] = family2common(Family, DeviceList, varargin) |
---|
2 | %FAMILY2COMMON - Convert a family name, device list to a common name list |
---|
3 | % [CommonNames, ErrorFlag] = family2common(Family, DeviceList) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. Family - Family Name |
---|
7 | % Data Structure |
---|
8 | % Accelerator Object |
---|
9 | % or Cell Array of Families |
---|
10 | % 2. DeviceList ([Sector Device #] or [element #]) {Default: whole family} |
---|
11 | % 3. StatusFlag - 0 return all devices |
---|
12 | % 1 return only devices with good status {Default} |
---|
13 | % |
---|
14 | % OUTPUTS |
---|
15 | % 1. CommonNames - Common name corresponding to the Family and DeviceList |
---|
16 | % |
---|
17 | % See Also common2family |
---|
18 | |
---|
19 | % |
---|
20 | % Written by Gregory J. Portmann |
---|
21 | |
---|
22 | StatusFlag = 1; |
---|
23 | |
---|
24 | if nargin == 0 |
---|
25 | error('Must have at least one input.'); |
---|
26 | end |
---|
27 | |
---|
28 | % StatusFlag |
---|
29 | if length(varargin) >= 1 |
---|
30 | StatusFlag = varargin{1}; |
---|
31 | else |
---|
32 | % This choice changes the default behavior for the entire middle layer !!!! |
---|
33 | StatusFlag = 1; % Only return good status devices |
---|
34 | end |
---|
35 | |
---|
36 | if iscell(Family) |
---|
37 | for i = 1:length(Family) |
---|
38 | if nargin == 1 |
---|
39 | [CommonNames{i}, ErrorFlag{i}] = family2common(Family{i}); |
---|
40 | else |
---|
41 | if iscell(DeviceList) |
---|
42 | [CommonNames{i}, ErrorFlag{i}] = family2common(Family{i}, DeviceList{i}); |
---|
43 | else |
---|
44 | [CommonNames{i}, ErrorFlag{i}] = family2common(Family{i}, DeviceList); |
---|
45 | end |
---|
46 | end |
---|
47 | end |
---|
48 | return |
---|
49 | end |
---|
50 | |
---|
51 | |
---|
52 | if nargin < 2 |
---|
53 | DeviceList = family2dev(Family,StatusFlag); |
---|
54 | end |
---|
55 | |
---|
56 | |
---|
57 | [CommonNames, ErrorFlag] = getfamilydata(Family, 'CommonNames', DeviceList); |
---|
58 | |
---|
59 | |
---|
60 | % For machines that don't have common names, replace them with Family(Sector, Dev) |
---|
61 | if isempty(CommonNames) |
---|
62 | if nargin == 1 |
---|
63 | DeviceList = family2dev(Family, StatusFlag); |
---|
64 | end |
---|
65 | for i = 1:size(DeviceList,1) |
---|
66 | CommonNames = strvcat(CommonNames,sprintf('%s(%d,%d)', Family, DeviceList(i,1), DeviceList(i,2))); |
---|
67 | end |
---|
68 | end |
---|
69 | |
---|