source: MML/trunk/machine/SOLEIL/common/family2coupling.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1function [AM ErrorFlag] = family2coupling(varargin)
2%FAMILY2DEVCELL - Returns the device list for a family and a cell
3%  DeviceList = family2dev(FamilyName, StatusFlag)
4%
5%  INPUTS
6%  1. Family = Family name ('BPMx', etc.)
7%              Data Structure (only the FamilyName field is used)
8%              Accelerator Object (only the FamilyName field is used)
9%              Cell Array
10%  2. DeviceList - DeviceList eg. 1, [2 3]
11%  3. StatusFlag - 0 return all devices
12%                  1 return only devices with good status {Default}
13%
14%  OUTPUTS
15%  1. AM - Structure with matrix for uncoupled BPM
16%                  Empty if not found
17%
18%  NOTES
19%  1. Matrix = inv [ HBPMGain      HBPMCoupling
20%                 VBPMCoupling  VBPMCoupling]
21%  Data come from LOCO
22%
23%  2. File used is generated by loco_build_BPMmat
24%
25%
26%  See Also dev2family, family2common, family2dev, family2handle
27%          family2status, family2tol, family2units, family2tango
28%          loco_build_BPMmat
29
30
31%
32%  Written by Laurent S. Nadolski
33
34% TODO
35% Choose other file than golden with a 'File' Flag
36
37ErrorFlag = 0;
38BPMFamily = 'BPMx';
39
40% Load golden file
41FileName      = getfamilydata('OpsData', 'BPMGainAndCouplingFile');
42DirectoryName = getfamilydata('Directory', 'OpsData');
43FileName      = fullfile(DirectoryName, FileName);
44Data          = load(FileName);
45
46% Return only device specified
47if ~isempty(varargin)
48    if isnumeric(varargin{1})
49        DeviceList = varargin{1};
50    elseif isfamily(varargin{1})
51        BPMFamily = varargin{1};
52        if length(varargin) >= 2
53            DeviceList = varargin{2};
54        else
55            DeviceList = family2dev(BPMFamily);
56        end       
57    end
58else % take all the BPM
59    DeviceList = family2dev(BPMFamily);
60end
61
62Cinv = cell(1, size(DeviceList,1));
63
64[iFound iNotFound] = findrowindex(DeviceList, Data.AM.DeviceList);
65
66[AM.Cinv] = Data.AM.Cinv(iFound);
67
68if ~isempty(iNotFound)
69    % warning message + ones
70    for ik=1:length(iNotFound),
71        fprintf('family2coupling: BPM [%d %d] not found Gain set to unity & coupling set to zero\n', DeviceList(iNotFound(ik),:))
72        if iNotFound(ik) == 1 %first element
73            AM.Cinv = [[1 0; 0 1]; AM.Cinv(:)];
74        elseif iNotFound(ik) < size(DeviceList,1)
75            AM.Cinv = [AM.Cinv(1:iNotFound(ik)-1); [1 0; 0 1]; AM.Cinv(iNotFound(ik):end)];
76        else % last element
77            AM.Cinv = [AM.Cinv(:); [1 0; 0 1]];
78        end
79    end
80    ErrorFlag = 1;
81end
82   
Note: See TracBrowser for help on using the repository browser.