source: MML/trunk/mml/setrf.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 3.4 KB
Line 
1function ErrorFlag = setrf(RF, varargin)
2%SETRF - Sets the RF frequency
3%  setrf(RF, WaitFlag)
4%
5%  INPUTS
6%  1. RF - RF frequency
7%  2. WaitFlag = 0    -> return immediately {SLAC default}
8%                > 0  -> wait until ramping is done then adds an extra delay equal to WaitFlag
9%                = -1 -> wait until ramping is done
10%                = -2 -> wait until ramping is done then adds an extra delay for fresh data
11%                        from the BPMs  {ALS default}
12%                = -3 -> wait until ramping is done then adds an extra delay for fresh data
13%                        from the tune measurement system
14%                = -4 -> wait until ramping is done then wait for a carriage return
15%  3. 'Physics'  - Use physics  units (optional override of units)
16%     'Hardware' - Use hardware units (optional override of units)
17%     The actual physics or hardware strings can also be used. 
18%     For example, if the physics and hardware modes corresponds
19%     to Hz and MHz then strings 'Hz' or 'MHz' can be used to specify units.
20%  4. 'Online' - Set data online (optional override of the mode)
21%     'Model'  - Set data on the model (optional override of the mode)
22%     'Manual' - Set data manually (optional override of the mode)
23%
24%  setrf converts a string input to a number, hence, setrf 476.3 is the same as setrf(476.3)
25%
26%  EXAMPES
27%  1. setrf(476, 'MHz')  or  setrf 476 MHz  => sets the RF frequency 476 MHz
28%  2. setrf 476000000 Hz                    => sets the RF frequency 476 MHz
29%
30%  NOTES
31%  1. 'Hardware', 'Physics', 'MHz', 'Hz', 'Numeric', and 'Struct' are not case sensitive
32%  2. The length(RFam) will equal the number of cavities in the ring
33%
34%  Written by Greg Portmann
35
36
37if nargin < 1
38    error('No RF frequency input')
39end
40if ischar(RF)
41    RF = str2num(RF);
42end
43
44WaitFlag = [];
45
46
47% Allow actual units for conversions
48HWUnits      = getfamilydata('RF','Setpoint','HWUnits');
49PhysicsUnits = getfamilydata('RF','Setpoint','PhysicsUnits');
50
51
52% Input line search
53for i = length(varargin):-1:1
54    if strcmpi(varargin{i}, 'Struct')
55        % Pass input thru to setpv
56    elseif strcmpi(varargin{i}, 'Numeric')
57        % Pass input thru to setpv
58    elseif strcmpi(varargin{i},'simulator') || strcmpi(varargin{i},'model')
59        % Pass input thru to setpv
60    elseif strcmpi(varargin{i},'online')
61        % Pass input thru to setpv
62    elseif strcmpi(varargin{i},'manual')
63        % Pass input thru to setpv
64    elseif strcmpi(varargin{i},'Inc') || strcmpi(varargin{i},'Incremental')
65        % Pass input thru to setpv
66        %IncrementalFlag = 1;
67    elseif strcmpi(varargin{i},'Retry')
68        % Pass input thru to setpv
69    elseif strcmpi(varargin{i},'NoRetry')
70        % Pass input thru to setpv
71    elseif strcmpi(varargin{i}, 'Physics') || strcmpi(varargin{i}, PhysicsUnits)
72        varargin{i} = 'Physics';
73    elseif strcmpi(varargin{i}, 'Hardware') || strcmpi(varargin{i}, HWUnits)
74        varargin{i} = 'Hardware';
75    elseif isnumeric(varargin{i})
76        WaitFlag = varargin{i};
77        varargin(i) = [];       
78    else
79        if ~isempty(varargin{i})
80            if ischar(varargin{i})
81                fprintf('   Input ''%s'' ignored', varargin{i});
82            else
83                fprintf('   Input ''%f'' ignored', varargin{i});
84            end
85        end
86        varargin(i) = [];
87    end
88end
89
90
91% Set RF
92if isstruct(RF)
93    ErrorFlag = setpv(RF, WaitFlag, varargin{:});
94else
95    ErrorFlag = setpv('RF', 'Setpoint', RF, [], WaitFlag, varargin{:});
96end
97
Note: See TracBrowser for help on using the repository browser.