1 | function setoperationalmode(ModeNumber) |
---|
2 | %SETOPERATIONALMODE - Switches between the various operational modes |
---|
3 | % setoperationalmode(ModeNumber) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. ModeNumber = 1. 2.7391 GeV, multibunch |
---|
7 | % |
---|
8 | % 100. Laurent's Mode |
---|
9 | % |
---|
10 | % See also aoinit, updateatindex, LT2init, setpathsoleil |
---|
11 | |
---|
12 | % |
---|
13 | % Written by Laurent S. Nadolski |
---|
14 | |
---|
15 | global THERING |
---|
16 | |
---|
17 | % Check if the AO exists |
---|
18 | checkforao; |
---|
19 | |
---|
20 | |
---|
21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
22 | % Accelerator Dependent Modes % |
---|
23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
24 | if nargin < 1 |
---|
25 | ModeNumber = []; |
---|
26 | end |
---|
27 | if isempty(ModeNumber) |
---|
28 | ModeCell = {'2.7391 GeV, multibunch', ... |
---|
29 | 'Laurent''s Mode'}; |
---|
30 | [ModeNumber, OKFlag] = listdlg('Name','SOLEIL','PromptString','Select the Operational Mode:', 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [450 200]); |
---|
31 | if OKFlag ~= 1 |
---|
32 | fprintf(' Operational mode not changed\n'); |
---|
33 | return |
---|
34 | elseif ModeNumber == 2 |
---|
35 | ModeNumber = 100; % Laurent |
---|
36 | end |
---|
37 | end |
---|
38 | |
---|
39 | |
---|
40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
41 | % Accelerator Data Structure % |
---|
42 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
43 | AD = getad; |
---|
44 | AD.Machine = 'SOLEIL'; % Will already be defined if setpathmml was used |
---|
45 | AD.MachineType = 'StorageRing'; % Will already be defined if setpathmml was used |
---|
46 | AD.SubMachine = 'LT2'; % Will already be defined if setpathmml was used |
---|
47 | AD.OperationalMode = ''; % Gets filled in later |
---|
48 | |
---|
49 | |
---|
50 | % Tune processor delay: delay required to wait |
---|
51 | % to have a fresh tune measurement after changing |
---|
52 | % a variable like the RF frequency. Setpv will wait |
---|
53 | % 2.2 * TuneDelay to be guaranteed a fresh data point. |
---|
54 | AD.BPMDelay = 0.25; % use [N, BPMDelay]=getbpmsaverages (AD.BPMDelay will disappear) |
---|
55 | AD.TuneDelay = 0.1; |
---|
56 | |
---|
57 | |
---|
58 | % SP-AM Error level |
---|
59 | % AD.ErrorWarningLevel = 0 -> SP-AM errors are Matlab errors {Default} |
---|
60 | % -1 -> SP-AM errors are Matlab warnings |
---|
61 | % -2 -> SP-AM errors prompt a dialog box |
---|
62 | % -3 -> SP-AM errors are ignored (ErrorFlag=-1 is returned) |
---|
63 | AD.ErrorWarningLevel = 0; |
---|
64 | |
---|
65 | %%%%%%%%%%%%%%%%%%%%% |
---|
66 | % Operational Modes % |
---|
67 | %%%%%%%%%%%%%%%%%%%%% |
---|
68 | |
---|
69 | % Mode setup variables (mostly path and file names) |
---|
70 | % AD.OperationalMode - String used in titles |
---|
71 | % ModeName - String used for mode directory name off DataRoot/MachineName |
---|
72 | % OpsFileExtension - string add to default file names |
---|
73 | |
---|
74 | if ModeNumber == 1 |
---|
75 | % LT2 Nominal Lattice |
---|
76 | AD.OperationalMode = '2.7391 GeV, multibunch'; |
---|
77 | AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice! |
---|
78 | ModeName = 'LT2lattice'; |
---|
79 | OpsFileExtension = '_LT2lattice'; |
---|
80 | |
---|
81 | % AT lattice |
---|
82 | AD.ATModel = 'LT2lattice'; |
---|
83 | eval(AD.ATModel); %run model for compilersolamor2linb; |
---|
84 | |
---|
85 | switch2hw; |
---|
86 | |
---|
87 | elseif ModeNumber == 100 |
---|
88 | % User mode - High Tune, Top Off injection |
---|
89 | error('To be completed'); |
---|
90 | |
---|
91 | else |
---|
92 | error('Operational mode unknown'); |
---|
93 | end |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | % Set the AD directory path |
---|
98 | setad(AD); |
---|
99 | MMLROOT = setmmldirectories(AD.Machine, AD.SubMachine, ModeName, OpsFileExtension); |
---|
100 | AD = getad; |
---|
101 | |
---|
102 | % SOLEIL specific path changes |
---|
103 | |
---|
104 | % Top Level Directories |
---|
105 | MMLDATAROOT = getmmldataroot; |
---|
106 | |
---|
107 | AD.Directory.DataRoot = fullfile(MMLDATAROOT, 'measdata', 'SOLEIL', 'LT2data', filesep); |
---|
108 | AD.Directory.OpsData = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT2OpsData', filesep); |
---|
109 | AD.Directory.Lattice = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT2', 'Lattices', filesep); |
---|
110 | AD.Directory.Synchro = fullfile(MMLROOT, 'machine', 'SOLEIL', 'common', 'synchro', filesep); |
---|
111 | |
---|
112 | AD.Directory.EMITData = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT2', 'emittance', filesep); |
---|
113 | AD.Directory.Timing = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT2', 'Timing', filesep); |
---|
114 | |
---|
115 | AD.Directory.ConfigData = fullfile(MMLROOT, 'machine', 'SOLEIL', 'LT2', 'MachineConfig', filesep); |
---|
116 | AD.Directory.Archiving = fullfile(AD.Directory.DataRoot, 'ArchivingData', filesep); |
---|
117 | |
---|
118 | %Operational Files |
---|
119 | AD.OpsData.LatticeFile = 'GoldenLattice'; %Golden Lattice File (setup for users) |
---|
120 | AD.OpsData.PhysDataFile = 'GoldenPhysData'; |
---|
121 | |
---|
122 | % Circumference |
---|
123 | AD.Circumference = findspos(THERING,length(THERING)+1); |
---|
124 | setad(AD); |
---|
125 | |
---|
126 | % Updates the AT indices in the MiddleLayer with the present AT lattice |
---|
127 | updateatindex; |
---|
128 | |
---|
129 | % Set the model energy |
---|
130 | setenergymodel(AD.Energy); |
---|
131 | |
---|
132 | fprintf(' lattice files have changed or if the AT lattice has changed.\n'); |
---|
133 | fprintf(' Middlelayer setup for operational mode: %s\n', AD.OperationalMode); |
---|
134 | |
---|
135 | setad(orderfields(AD)); |
---|