1 | function [Family] = tango2family(TangoNames); |
---|
2 | % TANGO2FAMILY - Convert TANGO name to Family name |
---|
3 | % [Family] = tango2family(TangoNames) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. TangoNames = List of Tango names (string, matrix, or cell array) |
---|
7 | % |
---|
8 | % OUTPUTS |
---|
9 | % 1. Family = Family name corresponding to the channel name |
---|
10 | % If the Tango name cannot be found an empty strings |
---|
11 | % (or a blank string for matrix inputs) is returned |
---|
12 | % ErrorFlag = number of errors found |
---|
13 | % |
---|
14 | % EXAMPLES |
---|
15 | % 1. tango2family('ANS-C01/DG/BPM.1/XPosSA') |
---|
16 | |
---|
17 | % |
---|
18 | % Written by Laurent S. Nadolski, SOLEIL |
---|
19 | |
---|
20 | % |
---|
21 | % 6/12/05 'row' option commented for intersect command |
---|
22 | % avoid message Warning: 'rows' flag is ignored for cell arrays |
---|
23 | |
---|
24 | if nargin < 1 |
---|
25 | error('Must have 1 input (''TangoNames'')'); |
---|
26 | end |
---|
27 | |
---|
28 | % Cell inputs |
---|
29 | if iscell(TangoNames) |
---|
30 | for i = 1:length(TangoNames) |
---|
31 | [Family{i}, ErrorFlag{i}] = tango2family(TangoNames{i}); |
---|
32 | end |
---|
33 | return |
---|
34 | end |
---|
35 | % End cell input |
---|
36 | |
---|
37 | Family = []; |
---|
38 | FamilyList = getfamilylist; |
---|
39 | |
---|
40 | for i = 1:size(TangoNames,1) |
---|
41 | if length(findstr(TangoNames(i,:),'/')) ~= 3 |
---|
42 | error('%s is not an attribute', TangoNames(i,:)) |
---|
43 | end |
---|
44 | Found = 0; |
---|
45 | for l = 1:size(FamilyList, 1) |
---|
46 | |
---|
47 | FamilyTest = deblank(FamilyList(l,:)); |
---|
48 | |
---|
49 | Fields = fieldnames(getfamilydata(FamilyTest)); |
---|
50 | for m = 1:length(Fields) |
---|
51 | TangoNamesTotal = getfamilydata(FamilyTest, Fields{m}, 'TangoNames'); |
---|
52 | |
---|
53 | if ~isempty(TangoNamesTotal) |
---|
54 | Name = deblank(TangoNames(i,:)); |
---|
55 | [name,j,k] = intersect(Name, TangoNamesTotal); |
---|
56 | % [name,j,k] = intersect(Name, TangoNamesTotal, 'rows'); |
---|
57 | |
---|
58 | if isempty(name) & length(Name)~=size(TangoNamesTotal) |
---|
59 | Name = [repmat(' ',size(Name,1),size(TangoNamesTotal,2)-size(Name,2)) Name]; |
---|
60 | [name,j,k] = intersect(Name, TangoNamesTotal); |
---|
61 | % [name,j,k] = intersect(Name, TangoNamesTotal, 'rows'); |
---|
62 | end |
---|
63 | |
---|
64 | if isempty(name) |
---|
65 | Name = deblank(TangoNames(i,:)); |
---|
66 | if length(Name)~=size(TangoNamesTotal) |
---|
67 | Name = [Name repmat(' ',size(Name,1),size(TangoNamesTotal,2)-size(Name,2))]; |
---|
68 | [name,j,k] = intersect(Name, TangoNamesTotal); |
---|
69 | % [name,j,k] = intersect(Name, TangoNamesTotal, 'rows'); |
---|
70 | end |
---|
71 | end |
---|
72 | |
---|
73 | if ~isempty(k) |
---|
74 | Found = 1; |
---|
75 | break |
---|
76 | end |
---|
77 | end |
---|
78 | if Found |
---|
79 | break |
---|
80 | end |
---|
81 | end |
---|
82 | if Found |
---|
83 | break |
---|
84 | end |
---|
85 | end |
---|
86 | if Found |
---|
87 | FamilyTest = FamilyTest; |
---|
88 | else |
---|
89 | FamilyTest = ' '; |
---|
90 | end |
---|
91 | Family = strvcat(Family, FamilyTest); |
---|
92 | end |
---|
93 | Family = deblank(Family); |
---|
94 | % End all family search |
---|
95 | |
---|
96 | |
---|
97 | |
---|