source: MML/trunk/mml/family2common.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: 1.9 KB
Line 
1function [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
22StatusFlag = 1;
23
24if nargin == 0
25    error('Must have at least one input.');
26end
27
28% StatusFlag
29if length(varargin) >= 1
30    StatusFlag = varargin{1};
31else
32    % This choice changes the default behavior for the entire middle layer !!!!
33    StatusFlag = 1;  % Only return good status devices
34end
35
36if 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
49end
50
51
52if nargin < 2
53    DeviceList = family2dev(Family,StatusFlag);
54end
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)
61if 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
68end
69
Note: See TracBrowser for help on using the repository browser.