source: MML/trunk/mml/dev2elem.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: 2.3 KB
Line 
1function Output = dev2elem(Family, DevList)
2%DEV2ELEM - Converts an element list to a device list
3%  ElementList = dev2elem(Family, [Sector Device#])
4%
5%  This function convects between the two methods of representing
6%  the same device in the ring.  The "Device" method is a two column
7%  matrix with the first being sector number and the seconds being
8%  the device number in the sector.  The "Element" method is a one column
9%  matrix with each entry being the element number starting at sector 1.
10%
11%  The following are equivalent devices for VCMs at the ALS:
12%                     | 1  2 |                    |  2 |
13%                     | 1  3 |                    |  3 |
14%  [Sector Device#] = | 2  1 |    [ElementList] = |  9 |
15%                     | 2  2 |                    | 10 |
16%                     | 3  4 |                    | 20 |
17%
18%  NOTES
19%  1. If DevList is empty, the entire family list will be returned.
20%  2. If the device is not found, then an error will occur.
21%  3. If the Family is not found, then empty, [], is returned.
22%
23%  Written by Greg Portmann
24
25
26Output = [];
27
28if nargin == 0
29        error('DEV2ELEM:  one input required.');
30end
31if nargin == 1
32        DevList = [];
33end
34if isempty(DevList)
35        DevList = getlist(Family);
36        if isempty(DevList)
37                return
38        end
39end
40if size(DevList,2) == 1
41    % Assume that the input was already a element list
42    Output = DevList;
43    return
44end
45
46Output = getfamilydata(Family, 'ElementList', DevList);
47
48
49% [FamilyIndex, ACCELERATOR_OBJECT] = isfamily(Family);
50% if FamilyIndex   
51%     DeviceList  = ACCELERATOR_OBJECT.DeviceList;
52%     ElementList = ACCELERATOR_OBJECT.ElementList;
53%     
54%     Output = [];
55%     for j = 1:size(DevList,1)       
56%         ksector = find(DevList(j,1) == DeviceList(:,1));
57%         if isempty(ksector)
58%             warning(sprintf('Device [%d,%d] not found in Family %s, hence removed from list.', DevList(j,1), DevList(j,2), ACCELERATOR_OBJECT.FamilyName));
59%         else
60%             k = find(DevList(j,2) == DeviceList(ksector,2));
61%             
62%             if isempty(k)
63%                 warning(sprintf('Device [%d,%d] not found in Family %s, hence removed from list.',DevList(j,1),DevList(j,2),ACCELERATOR_OBJECT.FamilyName));
64%             else
65%                 Output = [Output; ElementList(ksector(k))];
66%             end
67%         end
68%     end
69% else
70%     Output = [];
71% end
72
Note: See TracBrowser for help on using the repository browser.