[4] | 1 | function 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 | |
---|
| 26 | Output = []; |
---|
| 27 | |
---|
| 28 | if nargin == 0 |
---|
| 29 | error('DEV2ELEM: one input required.'); |
---|
| 30 | end |
---|
| 31 | if nargin == 1 |
---|
| 32 | DevList = []; |
---|
| 33 | end |
---|
| 34 | if isempty(DevList) |
---|
| 35 | DevList = getlist(Family); |
---|
| 36 | if isempty(DevList) |
---|
| 37 | return |
---|
| 38 | end |
---|
| 39 | end |
---|
| 40 | if size(DevList,2) == 1 |
---|
| 41 | % Assume that the input was already a element list |
---|
| 42 | Output = DevList; |
---|
| 43 | return |
---|
| 44 | end |
---|
| 45 | |
---|
| 46 | Output = 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 | |
---|