Home > machine > Soleil > common > getmaxsp.m

getmaxsp

PURPOSE ^

GETMAXSP - Maximum value of the setpoint

SYNOPSIS ^

function S = getmaxsp(Family, DeviceList)

DESCRIPTION ^

GETMAXSP - Maximum value of the setpoint

  FamilyName/DeviceList Method
  SPmax = getmaxsp(Family, DeviceList)
  SPmax = getmaxsp(DataStructure)

  ChannelName Method
  SPmax = getmaxsp(ChannelNames)

  CommonName Method
  SPmax = getmaxsp(Family, CommonName)

  INPUTS
  1. Family = Family Name 
              Data Structure
              Accelerator Object
              Cell Array of Accelerator Objects or Family Names
              For CommonNames, Family=[] searches all families
     ChannelName = Channel access channel name
                   Matrix of channel names
                   Cell array of channel names
     CommonName = Common name
                  Matrix of common names
                  Cell array of common names
  2. DeviceList = [Sector Device #] or [element #] list {default or empty list: whole family}
                   Cell Array of DeviceList

  OUTPUTS
  1. SPmax = Maximum setpoint of the device
             Empty if not found

  See also getminsp, getfamilydata(Family, Field, 'Range')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function S = getmaxsp(Family, DeviceList)
0002 %GETMAXSP - Maximum value of the setpoint
0003 %
0004 %  FamilyName/DeviceList Method
0005 %  SPmax = getmaxsp(Family, DeviceList)
0006 %  SPmax = getmaxsp(DataStructure)
0007 %
0008 %  ChannelName Method
0009 %  SPmax = getmaxsp(ChannelNames)
0010 %
0011 %  CommonName Method
0012 %  SPmax = getmaxsp(Family, CommonName)
0013 %
0014 %  INPUTS
0015 %  1. Family = Family Name
0016 %              Data Structure
0017 %              Accelerator Object
0018 %              Cell Array of Accelerator Objects or Family Names
0019 %              For CommonNames, Family=[] searches all families
0020 %     ChannelName = Channel access channel name
0021 %                   Matrix of channel names
0022 %                   Cell array of channel names
0023 %     CommonName = Common name
0024 %                  Matrix of common names
0025 %                  Cell array of common names
0026 %  2. DeviceList = [Sector Device #] or [element #] list {default or empty list: whole family}
0027 %                   Cell Array of DeviceList
0028 %
0029 %  OUTPUTS
0030 %  1. SPmax = Maximum setpoint of the device
0031 %             Empty if not found
0032 %
0033 %  See also getminsp, getfamilydata(Family, Field, 'Range')
0034 
0035 %
0036 % Written by Gregory J. Portmann
0037 % Modified by Laurent S. Nadolski
0038 
0039 S = [];
0040 
0041 if nargin == 0
0042     error('At least one input required');
0043 end
0044 
0045 if iscell(Family)
0046     if nargin >= 2
0047         if ~iscell(DeviceList)
0048             error('If Family is a cell array, then DeviceList must be a cell array.');
0049         end
0050         if length(Family) ~= length(DeviceList)
0051             error('Family and DeviceList must be the same size cell arrays.');
0052         end
0053     end
0054     
0055     for i = 1:length(Family)
0056         if nargin == 1
0057             S{i} = getmaxsp(Family{i});
0058         else            
0059             S{i} = getmaxsp(Family{i}, DeviceList{i});
0060         end
0061     end
0062     return    
0063 end
0064 
0065 if isstruct(Family)
0066     if any(size(Family) > 1)
0067         error('Only structures of size = [1 1] allowed')
0068     end                
0069     if isfield(Family,'FamilyName') & isfield(Family,'Field')
0070         % Data structure
0071         S = getfamilydata(Family.FamilyName, Family.Field, 'Range', Family.DeviceList); 
0072         if ~isempty(S)
0073             S = S(:,2);
0074         end
0075         return
0076     else
0077         % AO structure
0078         if nargin < 2
0079             S = Family.Setpoint.Range;
0080         else
0081             if size(DeviceList,2) == 1
0082                 Index = findrowindex(DeviceList, ElementList);
0083             else
0084                 Index = findrowindex(DeviceList, Family.DeviceList);
0085             end
0086             S = Family.Setpoint.Range(Index,2);
0087         end
0088     end
0089 end
0090 
0091 
0092 if isempty(Family)
0093     % Common names with no family name
0094     if nargin < 2
0095             error('If Family=[], 2 inputs are required.');
0096     end
0097     CommonNames = DeviceList;
0098     for i = 1:size(CommonNames,1)
0099         Family = common2family(CommonNames(i,:));
0100         [FamilyIndex, ACCELERATOR_OBJECT] = isfamily(Family);
0101         DeviceList = common2dev(CommonNames(i,:), ACCELERATOR_OBJECT);
0102         if isempty(DeviceList) | isempty(DeviceList)
0103             error('Common name could not be converted to a Family and DeviceList.');
0104         end
0105         S(i,:) = getmaxsp(Family, DeviceList);
0106     end
0107     return
0108         
0109 elseif ~isfamily(Family(1,:))
0110     % Channel name method
0111     % Try to convert to a family and device
0112     
0113     ChannelNames = Family;
0114     for i = 1:size(ChannelNames,1)
0115         Family = channel2family(ChannelNames(i,:));
0116         [FamilyIndex, ACCELERATOR_OBJECT] = isfamily(Family);
0117         DeviceList = channel2dev(ChannelNames(i,:), ACCELERATOR_OBJECT);
0118         if isempty(DeviceList) | isempty(DeviceList)
0119             error('Channel name could not be converted to a Family and DeviceList.');
0120         end
0121         S(i,:) = getmaxsp(Family, DeviceList);
0122     end
0123     return
0124 end
0125 
0126 
0127 if nargin == 1
0128     S = getfamilydata(Family, 'Setpoint', 'Range', []);
0129 else            
0130     % Convert common name to a DeviceList
0131     if isstr(DeviceList)
0132         DeviceList = common2dev(DeviceList, Family);
0133     end
0134     S = getfamilydata(Family, 'Setpoint', 'Range', DeviceList);
0135 end
0136 if ~isempty(S)
0137     S = S(:,2);
0138 end

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