source: MML/trunk/mml/at/setcavity.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: 1.7 KB
Line 
1function ATCavityIndex = setcavity(InputString)
2%SETCAVITY - Set the RF cavity state
3%  ATCavityIndex = setcavity(InputString)
4%
5%  INPUTS
6%  1. 'On', 'Off', or PassMethod {Default: no change}
7%
8%  OUTPUTS
9%  1. ATCavityIndex - AT Index of the RF cavities
10%
11%  NOTE
12%  1. For more than one cavity, the InputString can have
13%     more than one row.
14%
15%  See also getcavity setradiation
16%
17%  Written by Greg Portmann
18
19global THERING
20
21if nargin == 0
22    InputString = '';
23end
24
25ATCavityIndex = findcells(THERING, 'Frequency');
26
27if isempty(InputString)
28    return;
29end
30
31if isempty(ATCavityIndex)
32    %fprintf('   No cavities were found in the lattice (setcavity).\');
33    return
34end
35
36
37ATCavityIndex =ATCavityIndex(:)';
38for iCavity = 1:length(ATCavityIndex)
39
40    if size(InputString,1) == 1
41        CavityString = deblank(InputString);
42    elseif size(InputString,1) == length(ATCavityIndex)
43        CavityString = deblank(InputString(iCavity,:));
44    else
45        error('Number of rows in the input string must be 1 row or equal to the number of cavities.');
46    end       
47   
48    if strcmpi(CavityString,'off')
49            if THERING{ATCavityIndex(iCavity)}.Length == 0;
50                THERING{ATCavityIndex(iCavity)}.PassMethod = 'IdentityPass';
51            else
52                THERING{ATCavityIndex(iCavity)}.PassMethod = 'DriftPass';
53            end
54
55    elseif strcmpi(CavityString,'on')
56
57            %if THERING{ATCavityIndex(iCavity)}.Length == 0;
58            %    THERING{ATCavityIndex(iCavity)}.PassMethod = 'ThinCavityPass';
59            %else
60                THERING{ATCavityIndex(iCavity)}.PassMethod = 'CavityPass';
61            %end
62           
63    else
64        THERING{ATCavityIndex(iCavity)}.PassMethod = CavityString;
65    end
66end
Note: See TracBrowser for help on using the repository browser.