Home > machine > Soleil > common > family2devcell.m

family2devcell

PURPOSE ^

FAMILY2DEVCELL - Returns the device list for a family and a cell

SYNOPSIS ^

function DeviceList = family2devcell(Family, varargin);

DESCRIPTION ^

FAMILY2DEVCELL - Returns the device list for a family and a cell
  DeviceList = family2dev(FamilyName, StatusFlag)

  INPUTS
  1. Family = Family name ('BEND', 'Q1', 'S1', 'S2', 'HCOR', 'VCOR', etc.)
              Data Structure (only the FamilyName field is used)
              Accelerator Object (only the FamilyName field is used)
              Cell Array
  2. CellNumber - Cell number eg. 1, [2 3]
  3. StatusFlag - 0 return all devices
                  1 return only devices with good status {Default}

  OUTPUTS
  1. DeviceList - Device list corresponding to the Family
                  Empty if not found

  See Also dev2family, family2common, family2dev, family2handle
          family2status, family2tol, family2units, family2tango

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function DeviceList = family2devcell(Family, varargin);
0002 %FAMILY2DEVCELL - Returns the device list for a family and a cell
0003 %  DeviceList = family2dev(FamilyName, StatusFlag)
0004 %
0005 %  INPUTS
0006 %  1. Family = Family name ('BEND', 'Q1', 'S1', 'S2', 'HCOR', 'VCOR', etc.)
0007 %              Data Structure (only the FamilyName field is used)
0008 %              Accelerator Object (only the FamilyName field is used)
0009 %              Cell Array
0010 %  2. CellNumber - Cell number eg. 1, [2 3]
0011 %  3. StatusFlag - 0 return all devices
0012 %                  1 return only devices with good status {Default}
0013 %
0014 %  OUTPUTS
0015 %  1. DeviceList - Device list corresponding to the Family
0016 %                  Empty if not found
0017 %
0018 %  See Also dev2family, family2common, family2dev, family2handle
0019 %          family2status, family2tol, family2units, family2tango
0020 
0021 %
0022 %  Written by Laurent S. Nadolski
0023 
0024 if nargin == 0
0025     error('Must have at least one input.');
0026 end
0027 
0028 % Status input
0029 if nargin >= 2
0030     CellNumber = varargin{1};
0031     if nargin >= 3
0032         StatusFlag = varargin{2};
0033     else
0034         % This choice changes the default behavior for the entire middle layer !!!!
0035         StatusFlag = 1;  % Only return good status devices
0036     end
0037 else
0038     CellNumber = 1;
0039     StatusFlag = 1;  % Only return good status devices
0040 end
0041 
0042 %%%%%%%%%%%%%%%%%%%%%
0043 % Cell Array Inputs %
0044 %%%%%%%%%%%%%%%%%%%%%
0045 if iscell(Family)
0046     for i = 1:length(Family)
0047         if iscell(StatusFlag)
0048             DeviceList{i} = family2devcell(Family{i}, StatusFlag{i});
0049         else
0050             DeviceList{i} = family2devcell(Family{i}, StatusFlag);
0051         end
0052     end
0053     return    
0054 end
0055 
0056 
0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0058 % Family or data structure inputs beyond this point %
0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060 if isstruct(Family)
0061     % Structures can be an accelerator object or a data structure (as returned by getpv)
0062     if isfield(Family, 'FamilyName')
0063         % Data structure
0064         Family = Family.FamilyName;   
0065     else
0066         error('Family input of unknown type');
0067     end
0068 end
0069 
0070 
0071 [DeviceList, ErrorFlag] = getfamilydata(Family, 'DeviceList');
0072 if isempty(DeviceList)
0073     error(sprintf('%s family not found', Family));
0074 end
0075 
0076 ind = [];
0077 for k = 1:length(CellNumber)
0078     ind = [ind; find(DeviceList(:,1) == CellNumber(k))];
0079 end
0080 DeviceList = DeviceList(ind,:);
0081 
0082 if StatusFlag
0083     Status = getfamilydata(Family, 'Status', DeviceList);
0084     if isempty(Status)
0085         fprintf('   WARNING:  Status field not in the AO, hence ignored.\n');
0086     else
0087         DeviceList = DeviceList(find(Status),:);
0088     end
0089 end

Generated on Mon 21-May-2007 15:35:27 by m2html © 2003