Home > mml > setrf.m

setrf

PURPOSE ^

SETRF - Sets the RF frequency

SYNOPSIS ^

function setrf(RF, varargin)

DESCRIPTION ^

SETRF - Sets the RF frequency
  setrf(RF, WaitFlag)

  INPUTS
  1. RF - RF frequency
  2. WaitFlag = 0    -> return immediately {SLAC default}
                > 0  -> wait until ramping is done then adds an extra delay equal to WaitFlag 
                = -1 -> wait until ramping is done
                = -2 -> wait until ramping is done then adds an extra delay for fresh data 
                        from the BPMs  {ALS default}
                = -3 -> wait until ramping is done then adds an extra delay for fresh data 
                        from the tune measurement system
                = -4 -> wait until ramping is done then wait for a carriage return
  3. 'Physics'  - Use physics  units (optional override of units)
     'Hardware' - Use hardware units (optional override of units)
     The actual physics or hardware strings can also be used.  
     For example, if the physics and hardware modes corresponds 
     to Hz and MHz then strings 'Hz' or 'MHz' can be used to specify units.
  4. 'Online' - Set data online (optional override of the mode)
     'Model'  - Set data on the model (optional override of the mode)
     'Manual' - Set data manually (optional override of the mode)

  setrf converts a string input to a number, hence, setrf 476.3 is the same as setrf(476.3)

  EXAMPES
  1. setrf(476, 'MHz')  or  setrf 476 MHz  => sets the RF frequency 476 KHz
  2. setrf 476000000 Hz                    => sets the RF frequency 476 KHz

  NOTES
  1. 'Hardware', 'Physics', 'MHz', 'Hz', 'Numeric', and 'Struct' are not case sensitive
  2. The length(RFam) will equal the number of cavities in the ring

  Written by Greg Portmann

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function setrf(RF, varargin)
0002 %SETRF - Sets the RF frequency
0003 %  setrf(RF, WaitFlag)
0004 %
0005 %  INPUTS
0006 %  1. RF - RF frequency
0007 %  2. WaitFlag = 0    -> return immediately {SLAC default}
0008 %                > 0  -> wait until ramping is done then adds an extra delay equal to WaitFlag
0009 %                = -1 -> wait until ramping is done
0010 %                = -2 -> wait until ramping is done then adds an extra delay for fresh data
0011 %                        from the BPMs  {ALS default}
0012 %                = -3 -> wait until ramping is done then adds an extra delay for fresh data
0013 %                        from the tune measurement system
0014 %                = -4 -> wait until ramping is done then wait for a carriage return
0015 %  3. 'Physics'  - Use physics  units (optional override of units)
0016 %     'Hardware' - Use hardware units (optional override of units)
0017 %     The actual physics or hardware strings can also be used.
0018 %     For example, if the physics and hardware modes corresponds
0019 %     to Hz and MHz then strings 'Hz' or 'MHz' can be used to specify units.
0020 %  4. 'Online' - Set data online (optional override of the mode)
0021 %     'Model'  - Set data on the model (optional override of the mode)
0022 %     'Manual' - Set data manually (optional override of the mode)
0023 %
0024 %  setrf converts a string input to a number, hence, setrf 476.3 is the same as setrf(476.3)
0025 %
0026 %  EXAMPES
0027 %  1. setrf(476, 'MHz')  or  setrf 476 MHz  => sets the RF frequency 476 KHz
0028 %  2. setrf 476000000 Hz                    => sets the RF frequency 476 KHz
0029 %
0030 %  NOTES
0031 %  1. 'Hardware', 'Physics', 'MHz', 'Hz', 'Numeric', and 'Struct' are not case sensitive
0032 %  2. The length(RFam) will equal the number of cavities in the ring
0033 %
0034 %  Written by Greg Portmann
0035 
0036 
0037 if nargin < 1
0038     error('No RF frequency input')
0039 end
0040 if ischar(RF)
0041     RF = str2num(RF);
0042 end
0043 
0044 WaitFlag = [];
0045 
0046 
0047 % Allow actual units for conversions
0048 HWUnits      = getfamilydata('RF','Setpoint','HWUnits');
0049 PhysicsUnits = getfamilydata('RF','Setpoint','PhysicsUnits');
0050 
0051 
0052 % Input line search
0053 for i = length(varargin):-1:1
0054     if strcmpi(varargin{i}, 'Struct')
0055         % Pass input thru to setpv
0056     elseif strcmpi(varargin{i}, 'Numeric')
0057         % Pass input thru to setpv
0058     elseif strcmpi(varargin{i},'simulator') || strcmpi(varargin{i},'model')
0059         % Pass input thru to setpv
0060     elseif strcmpi(varargin{i},'online')
0061         % Pass input thru to setpv
0062     elseif strcmpi(varargin{i},'manual')
0063         % Pass input thru to setpv
0064     elseif strcmpi(varargin{i},'Inc') || strcmpi(varargin{i},'Incremental')
0065         % Pass input thru to setpv
0066         IncrementalFlag = 1;
0067     elseif strcmpi(varargin{i}, 'Physics') || strcmpi(varargin{i}, PhysicsUnits)
0068         varargin{i} = 'Physics';
0069     elseif strcmpi(varargin{i}, 'Hardware') || strcmpi(varargin{i}, HWUnits)
0070         varargin{i} = 'Hardware';
0071     elseif isnumeric(varargin{i})
0072         WaitFlag = varargin{i};
0073         varargin(i) = [];
0074     else
0075         if ~isempty(varargin{i})
0076             if ischar(varargin{i})
0077                 fprintf('   Input ''%s'' ignored', varargin{i});
0078             else
0079                 fprintf('   Input ''%f'' ignored', varargin{i});
0080             end
0081         end
0082         varargin(i) = [];
0083     end
0084 end
0085 
0086 
0087 % Set RF
0088 if isstruct(RF)
0089     setpv(RF, WaitFlag, varargin{:});
0090 else
0091     setpv('RF', 'Setpoint', RF, [], WaitFlag, varargin{:});
0092 end
0093 
0094 
0095 
0096 
0097 
0098 % % Used for conversions
0099 % Units        = getfamilydata('RF','Setpoint','Units');
0100 % HWUnits      = getfamilydata('RF','Setpoint','HWUnits');
0101 % PhysicsUnits = getfamilydata('RF','Setpoint','PhysicsUnits');
0102 %
0103 %
0104 % % Input line search (if not a data structure)
0105 % if isstruct(RF)
0106 %     UnitsInput = RF.Units;
0107 %     UnitsString = RF.UnitsString;
0108 %     RF = RF.Data;
0109 % else
0110 %     UnitsInput = '';
0111 %     for i = length(varargin):-1:1
0112 %         if strcmpi(varargin{i}, 'Physics') | strcmpi(varargin{i}, PhysicsUnits)
0113 %             UnitsInput = 'Physics';
0114 %         elseif strcmpi(varargin{i}, 'Hardware') | strcmpi(varargin{i}, HWUnits)
0115 %             UnitsInput = 'Hardware';
0116 %         else
0117 %             if ~isempty(varargin{i})
0118 %                 if ischar(varargin{i})
0119 %                     fprintf('   Input %s ignored', varargin{i});
0120 %                 else
0121 %                     fprintf('   Input %f ignored', varargin{i});
0122 %                 end
0123 %             end
0124 %         end
0125 %         varargin(i) = [];
0126 %     end
0127 % end
0128 %
0129 % % Convert units if necessary
0130 % if ~isempty(UnitsInput)
0131 %     % 'Physics', 'Hardware', 'Hz', or 'Mz' was input
0132 %     if strcmpi(UnitsInput, 'Physics') & strcmpi(Units, 'Hardware')
0133 %         RF = physics2hw('RF', 'Setpoint', RF);
0134 %     elseif strcmpi(UnitsInput, 'Physics') & strcmpi(Units, 'Physics')
0135 %         % OK as is
0136 %     elseif strcmpi(UnitsInput, 'Hardware') & strcmpi(Units, 'Physics')
0137 %         RF = hw2physics('RF', 'Setpoint', RF);
0138 %     elseif strcmpi(UnitsInput, 'Hardware') & strcmpi(Units, 'Hardware')
0139 %         % OK as is
0140 %     else
0141 %         error(sprintf('"%s" units are an unknown type, hence no change to the RF frequency', UnitsInput));
0142 %     end
0143 % end
0144 %
0145 %
0146 % setsp('RF', RF);

Generated on Mon 21-May-2007 15:29:18 by m2html © 2003