source: MML/trunk/machine/THOMX/StorageRing/setthomxoperationalmode.m @ 5

Last change on this file since 5 was 5, checked in by zhangj, 11 years ago

ThomX MML version on the LAL server @ 17/12/2013

  • Property svn:executable set to *
File size: 25.0 KB
Line 
1function setthomxoperationalmode(ModeNumber)
2%SETOPERATIONALMODE - Switches between the various operational modes
3%  setoperationalmode(ModeNumber)
4%
5%  INPUTS
6%  1. ModeNumber = number
7%        1 '50 MeV, 3.17 1.72, r56=0.2', ...
8
9%  See also setoperationalmode, aoinit, updateatindex, soleilinit, setmmldirectories, lattice_prep
10
11%  NOTES
12% use local_set_config_mode for defining status of S11 et S12;
13
14
15% Based on setoperationalmode.m,
16% Modified by Jianfeng Zhang @ LAL 18/06/2013
17% FOR CVS
18% $Header$
19global THERING
20
21% Check if the AO exists
22checkforao;
23
24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25% Accelerator Dependent Modes %
26%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27if nargin < 1
28    ModeNumber = [];
29end
30if isempty(ModeNumber)
31    ModeCell = {...
32        ' 1/ 50 MeV, 3.17 1.72, r56=0.2', ...
33        };
34    [ModeNumber, OKFlag] = listdlg('Name','THOMX','PromptString','Select the Operational Mode:', ...
35        'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [450 200], 'InitialValue', 1);
36    if OKFlag ~= 1
37        fprintf('   Operational mode not changed\n');
38        return
39   % elseif ModeNumber == length(ModeCell);
40   %     ModeNumber = 100;  % Laurent
41   % end
42end
43
44
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46% Accelerator Data Structure %
47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48AD = getad;
49AD.Machine = 'THOMX';            % Will already be defined if setpathmml was used
50AD.MachineType = 'StorageRing';   % Will already be defined if setpathmml was used
51AD.SubMachine  = 'StorageRing';   % Will already be defined if setpathmml was used
52AD.OperationalMode = '';          % Gets filled in later
53AD.HarmonicNumber = 28;
54
55% Defaults RF for dispersion and chromaticity measurements (must be in Hardware units)
56AD.DeltaRFDisp = 100e-6;
57AD.DeltaRFChro = [-100 -50 0 50 100] * 1e-6;
58
59% Tune processor delay: delay required to wait
60% to have a fresh tune measurement after changing
61% a variable like the RF frequency.  Setpv will wait
62% 2.2 * TuneDelay to be guaranteed a fresh data point.
63%AD.BPMDelay  = 0.25; % use [N, BPMDelay]=getbpmaverages (AD.BPMDelay will disappear)
64AD.TuneDelay = 1;
65
66% The offset and golden orbits are stored at the end of this file
67% TODO
68%BuildOffsetAndGoldenOrbits;  % Local function
69
70
71% SP-AM Error level
72% AD.ErrorWarningLevel = 0 -> SP-AM errors are Matlab errors {Default}
73%                       -1 -> SP-AM errors are Matlab warnings
74%                       -2 -> SP-AM errors prompt a dialog box
75%                       -3 -> SP-AM errors are ignored (ErrorFlag=-1 is returned)
76AD.ErrorWarningLevel = 0;
77
78%%%%%%%%%%%%%%%%%%%%%
79% Operational Modes %
80%%%%%%%%%%%%%%%%%%%%%
81
82% Mode setup variables (mostly path and file names)
83% AD.OperationalMode - String used in titles
84% ModeName - String used for mode directory name off DataRoot/MachineName
85% OpsFileExtension - string add to default file names
86
87 
88
89
90%% ModeNumber == 9 bx=10m nominal lattice 2010 until installation of S11 and S12
91if ModeNumber == 9
92    % User mode - nominal lattice 2010 until installation of S11 and S12
93    AD.OperationalMode = '2.7391 GeV, 18.2 10.3';
94    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
95    ModeName = 'lat_2020_3170b';
96    OpsFileExtension = '_lat_2020_3170b';
97
98    % AT lattice
99    AD.ATModel = 'lat_2020_3170b';
100    eval(AD.ATModel);  %run model for compiler;
101
102    % Golden TUNE is with the TUNE family
103    % 18.2020 / 10.3170
104    AO = getao;
105    AO.TUNE.Monitor.Golden = [
106        0.2020
107        0.3170
108        NaN];
109
110    % Golden chromaticity is in the AD (Physics units)
111    AD.Chromaticity.Golden = [2; 2];
112
113    % Status factory
114    local_set_config_mode('normalconfig120');
115    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
116    setao(AO);
117
118    %% ModeNumber == 19 User mode - S11 betax=10m till November 2010
119elseif ModeNumber == 19
120    % User mode - S11 betax=10m 2010
121    AD.OperationalMode = '2.7391 GeV, 18.202 10.317 S11';
122    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
123    ModeName = 'lat_2020_3170f';
124    OpsFileExtension = '_lat_2020_3170f';
125
126    % AT lattice
127    AD.ATModel = 'lat_2020_3170f';
128    eval(AD.ATModel);  %run model for compiler;
129
130    % Golden TUNE is with the TUNE family
131    % 18.2020 / 10.3170
132    AO = getao;
133    AO.TUNE.Monitor.Golden = [
134        0.2020
135        0.3170
136        NaN];
137
138    % Golden chromaticity is in the AD (Physics units)
139    AD.Chromaticity.Golden = [2; 2.6];
140
141    % Status factory
142    local_set_config_mode('S11config120');
143    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
144    setao(AO);
145   
146    %% ModeNumber == 16 User mode - betax = 5m
147elseif ModeNumber == 16
148    % User mode - betax = 5m
149    AD.OperationalMode = '2.7391 GeV, 18.2 10.3';
150    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
151    ModeName = 'lat_2020_3170e';
152    OpsFileExtension = '_lat_2020_3170e';
153
154    % AT lattice
155    AD.ATModel = 'lat_2020_3170e';
156    eval(AD.ATModel);  %run model for compiler;
157
158    % Golden TUNE is with the TUNE family
159    % 18.2020 / 10.3170
160    % 18.1990 / 10.3170 April 2011
161    AO = getao;
162    AO.TUNE.Monitor.Golden = [
163        0.1990
164        0.3100
165        0.00642];
166
167    % Golden chromaticity is in the AD (Physics units)
168    AD.Chromaticity.Golden = [2; 2];
169
170    local_set_config_mode('S11config120');
171    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
172    setao(AO);
173
174    %% ModeNumber == 10 User mode - with PX2 corrector   
175elseif ModeNumber == 10
176    % User mode - with PX2 corrector
177    AD.OperationalMode = '2.7391 GeV, 18.2 10.3';
178    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
179    ModeName = 'lat_2020_3170bPX2';
180    OpsFileExtension = '_lat_2020_3170bPX2';
181
182    % AT lattice
183    AD.ATModel = 'lat_2020_3170bPX2';
184    eval(AD.ATModel);  %run model for compiler;
185
186    % Golden TUNE is with the TUNE family
187    % 18.2020 / 10.3170
188    AO = getao;
189    AO.TUNE.Monitor.Golden = [
190        0.2020
191        0.3170
192        NaN];
193
194    % Golden chromaticity is in the AD (Physics units)
195    AD.Chromaticity.Golden = [2; 2];
196
197    local_set_config_mode('normalconfig120');
198    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
199    setao(AO);
200
201    %% ModeNumber == 11  User mode - Nanoscopium
202elseif ModeNumber == 11 % User mode - Nanoscopium
203    AD.OperationalMode = '2.7391 GeV, 18.2175 10.3120';
204    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
205    ModeName = 'nano_2175_3120a';
206    OpsFileExtension = '_nano_2175_3120a';
207
208    % AT lattice
209    AD.ATModel = 'nano_2175_3120'; % new lattice version from Alex
210    eval(AD.ATModel);  %run model for compiler;
211
212    % Golden TUNE is with the TUNE family
213    AO = getao;
214    AO.TUNE.Monitor.Golden = [
215        0.2175
216        0.3120
217        NaN];
218
219    % Golden chromaticity is in the AD (Physics units)
220    AD.Chromaticity.Golden = [2; 2];
221
222    local_set_config_mode('nanoscopiumconfig');
223    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
224    setao(AO);
225
226 
227    % triplet upstreams and downstreams of SDL13 for nanoscopium
228    % Need to point to another family for magnetcoefficients (other range of current)
229    % Q1 upstream
230    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009('Q1');
231    AO.Q1.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
232    AO.Q1.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
233    AO.Q1.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
234    AO.Q1.Setpoint.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
235    % Q1 downstream
236    AO.Q1.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
237    AO.Q1.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
238    AO.Q1.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
239    AO.Q1.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
240    % Q2 upstream
241    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009('Q2');
242    AO.Q2.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
243    AO.Q2.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
244    AO.Q2.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
245    AO.Q2.Setpoint.Physics2HWParams{1}(6,:) = HW2PhysicsParams;
246    % Q2 downstream
247    AO.Q2.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
248    AO.Q2.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
249    AO.Q2.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
250    AO.Q2.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
251    % Q3 upstream
252    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009('Q1');
253    AO.Q3.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
254    AO.Q3.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
255    AO.Q3.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
256    AO.Q3.Setpoint.Physics2HWParams{1}(6,:) = HW2PhysicsParams;
257    % Q3 downstream
258    AO.Q3.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
259    AO.Q3.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
260    AO.Q3.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
261    AO.Q3.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
262   
263    setao(AO);
264
265    %% ModeNumber == 14 % User mode - Nanoscopium
266elseif ModeNumber == 14 % User mode - Nanoscopium
267    AD.OperationalMode = '2.7391 GeV, 18.2175 10.3120';
268    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
269    ModeName = 'nano_8000_7000a';
270    OpsFileExtension = '_nano_8000_7000a';
271
272    % AT lattice
273    AD.ATModel = 'nano_8000_7000'; % new lattice version from Alex
274    eval(AD.ATModel);  %run model for compiler;
275
276    % Golden TUNE is with the TUNE family
277    AO = getao;
278    AO.TUNE.Monitor.Golden = [
279        0.2175
280        0.3120
281        NaN];
282
283    % Golden chromaticity is in the AD (Physics units)
284    AD.Chromaticity.Golden = [2; 2];
285
286
287    local_set_config_mode('nanoscopiumconfig');
288    AO = local_setmagnetcoefficient(AO, @magnetcoefficients_new_calib_new_modele_juin2009);
289    setao(AO);
290
291    % triplet upstreams and downstreams of SDL13 for nanoscopium
292    % Need to point to another family for magnetcoefficients (other range of current)
293    % Q1 upstream
294    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009_nano_80_70('Q1');
295    AO.Q1.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
296    AO.Q1.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
297    AO.Q1.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
298    AO.Q1.Setpoint.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
299    % Q1 downstream
300    AO.Q1.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
301    AO.Q1.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
302    AO.Q1.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
303    AO.Q1.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
304    % Q2 upstream
305    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009_nano_80_70('Q2');
306    AO.Q2.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
307    AO.Q2.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
308    AO.Q2.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
309    AO.Q2.Setpoint.Physics2HWParams{1}(6,:) = HW2PhysicsParams;
310    % Q2 downstream
311    AO.Q2.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
312    AO.Q2.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
313    AO.Q2.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
314    AO.Q2.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
315    % Q3 upstream
316    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009_nano_80_70('Q1');
317    AO.Q3.Monitor.HW2PhysicsParams{1}(6,:)  = HW2PhysicsParams;
318    AO.Q3.Monitor.Physics2HWParams{1}(6,:)  = HW2PhysicsParams;
319    AO.Q3.Setpoint.HW2PhysicsParams{1}(6,:) = HW2PhysicsParams;
320    AO.Q3.Setpoint.Physics2HWParams{1}(6,:) = HW2PhysicsParams;
321    % Q3 downstream
322    AO.Q3.Monitor.HW2PhysicsParams{1}(7,:)  = HW2PhysicsParams;
323    AO.Q3.Monitor.Physics2HWParams{1}(7,:)  = HW2PhysicsParams;
324    AO.Q3.Setpoint.HW2PhysicsParams{1}(7,:) = HW2PhysicsParams;
325    AO.Q3.Setpoint.Physics2HWParams{1}(7,:) = HW2PhysicsParams;
326
327    % triplet nanoscopium
328    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009_nano_80_70('Q11');
329    AO.Q11.Monitor.HW2PhysicsParams{1}(1,:)  = HW2PhysicsParams;
330    AO.Q11.Setpoint.HW2PhysicsParams{1}(1,:) = HW2PhysicsParams;
331    AO.Q11.Monitor.Physics2HWParams{1}(1,:)  = HW2PhysicsParams;
332    AO.Q11.Setpoint.Physics2HWParams{1}(1,:) = HW2PhysicsParams;
333    AO.Q11.Monitor.HW2PhysicsParams{1}(2,:)  = HW2PhysicsParams;
334    AO.Q11.Setpoint.HW2PhysicsParams{1}(2,:) = HW2PhysicsParams;
335    AO.Q11.Monitor.Physics2HWParams{1}(2,:)  = HW2PhysicsParams;
336    AO.Q11.Setpoint.Physics2HWParams{1}(2,:) = HW2PhysicsParams;
337
338    HW2PhysicsParams = magnetcoefficients_new_calib_new_modele_juin2009_nano_80_70('Q2');
339    AO.Q12.Monitor.HW2PhysicsParams{1}(1,:)  = HW2PhysicsParams;
340    AO.Q12.Setpoint.HW2PhysicsParams{1}(1,:) = HW2PhysicsParams;
341    AO.Q12.Monitor.Physics2HWParams{1}(1,:)  = HW2PhysicsParams;
342    AO.Q12.Setpoint.Physics2HWParams{1}(1,:) = HW2PhysicsParams;
343
344
345    AO.Q11.Status = [1; 1];
346    AO.Q12.Status = 1;
347
348    setao(AO);
349   
350    %% ModeNumber == 1
351elseif ModeNumber == 1
352    % User mode -
353    AD.OperationalMode = '2.7391 GeV, 18.2 10.3';
354    AD.Energy = 2.7391; % Make sure this is the same as bend2gev at the production lattice!
355    ModeName = 'solamor2c';
356    OpsFileExtension = '_solamor2c';
357
358    % AT lattice
359    AD.ATModel = 'solamor2linc';
360    eval(AD.ATModel);  %run model for compilersolamor2linb;
361
362    % Golden TUNE is with the TUNE family
363    % 18.2020 / 10.3170
364    AO = getao;
365    AO.TUNE.Monitor.Golden = [
366        0.2020
367        0.3170
368        NaN];
369    % Golden chromaticity is in the AD (Physics units)
370    AD.Chromaticity.Golden = [2; 2];
371
372    % Status factory
373    local_set_config_mode('normalconfig120');
374    AO = local_setmagnetcoefficient(AO, @magnetcoefficients);
375    setao(AO);
376
377end
378   
379   
380% Force units to hardware
381switch2hw;
382
383% Activation of correctors of HU640
384if ModeNumber == 6
385  switchHU640Cor('ON');
386else
387  switchHU640Cor('OFF');
388end
389
390% Set the AD directory path
391setad(AD);
392MMLROOT = setmmldirectories(AD.Machine, AD.SubMachine, ModeName, OpsFileExtension);
393AD = getad;
394
395
396% SOLEIL specific path changes
397
398% Top Level Directories
399
400%AD.Directory.DataRoot       = fullfile(MMLROOT, 'measdata', 'SOLEIL', 'StorageRingdata', filesep);
401% RUCHE
402MMLDATAROOT = getmmldataroot;
403AD.Directory.Lattice        = fullfile(MMLROOT, 'machine', 'SOLEIL', 'StorageRing', 'Lattices', filesep);
404AD.Directory.Orbit          = fullfile(MMLROOT, 'machine', 'SOLEIL', 'StorageRing',  'orbit', filesep);
405
406% Data Archive Directories DO NOT REMOVE LINES
407
408% Insertion Devices
409
410
411% STANDALONE matlab applications
412AD.Directory.Standalone     = fullfile(MMLROOT, 'machine', 'THOMX', 'standalone_applications', filesep);
413
414% FOFB matlab applications
415
416% For coupling correction. Used by coupling.m
417
418% AD.Directory.InterlockData  = fullfile(AD.Directory.DataRoot, 'Interlock/'];
419
420%Response Matrix Directories
421
422% used by energytunette
423
424% used by MAT's Steerette application
425
426
427% Postmortem DATA
428
429%Default Data File Prefix
430AD.Default.BPMArchiveFile      = 'BPM';                %file in AD.Directory.BPM               orbit data
431AD.Default.TuneArchiveFile     = 'Tune';               %file in AD.Directory.Tune              tune data
432AD.Default.ChroArchiveFile     = 'Chro';               %file in AD.Directory.Chromaticity       chromaticity data
433AD.Default.DispArchiveFile     = 'Disp';               %file in AD.Directory.Dispersion       dispersion data
434AD.Default.CNFArchiveFile      = 'CNF';                %file in AD.Directory.CNF               configuration data
435AD.Default.QUADArchiveFile     = 'QuadBeta';           %file in AD.Directory.QUAD             betafunction for quadrupoles
436AD.Default.PINHOLEArchiveFile  = 'Pinhole';            %file in AD.Directory.PINHOLE             pinhole data
437AD.Default.SkewArchiveFile     = 'SkewQuad';           %file in AD.Directory.SkewQuad             SkewQuad data
438AD.Default.BBAArchiveFile      = 'BBA_DKmode';         %file in AD.Directory.BBA             BBA DK mode data
439
440%Default Response Matrix File Prefix
441AD.Default.BPMRespFile      = 'BPMRespMat';         %file in AD.Directory.BPMResponse       BPM response matrices
442AD.Default.TuneRespFile     = 'TuneRespMat';        %file in AD.Directory.TuneResponse      tune response matrices
443AD.Default.ChroRespFile     = 'ChroRespMat';        %file in AD.Directory.ChroResponse      chromaticity response matrices
444AD.Default.DispRespFile     = 'DispRespMat';        %file in AD.Directory.DispResponse      dispersion response matrices
445AD.Default.SkewRespFile     = 'SkewRespMat';        %file in AD.Directory.SkewResponse      skew quadrupole response matrices
446
447%Orbit Control and Feedback Files
448AD.Restore.GlobalFeedback   = 'Restore.m';
449
450% Circumference
451AD.Circumference = findspos(THERING,length(THERING)+1);
452setad(AD);
453
454% Updates the AT indices in the MiddleLayer with the present AT lattice
455updateatindex;
456
457% Set the model energy
458setenergymodel(AD.Energy);
459
460
461% Momentum compaction factor
462MCF = getmcf('Model');
463if isnan(MCF)
464    AD.MCF = 4.498325442923014e-04;
465    fprintf('   Model alpha calculation failed, middlelayer alpha set to  %f\n', AD.MCF);
466else
467    AD.MCF = MCF;
468    fprintf('   Middlelayer alpha set to %f (AT model).\n', AD.MCF);
469end
470setad(AD);
471
472
473% Add Gain & Offsets for magnet family
474fprintf('   Setting magnet monitor gains based on the production lattice.\n');
475%setgainsandoffsets;
476
477%% Config texttalker (right location ?)
478AD.TANGO.TEXTTALKERS={'ans/ca/texttalker.1', 'ans/ca/texttalker.2'};
479
480% set LOCO gain and roll to zero
481setlocodata('Nominal');
482
483%%%%%%%%%%%%%%%%%%%%%%
484% Final mode changes %
485%%%%%%%%%%%%%%%%%%%%%%
486if any(ModeNumber == [99])
487    % User mode - 2.75 GeV, Nominal lattice
488
489    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490    % Add LOCO Parameters to AO and AT-Model %
491    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
492    %     'Nominal'    - Sets nominal gains (1) / rolls (0) to the model.
493    %     'SetGains'   - Set gains/coupling from a LOCO file.
494    %     'SetModel'   - Set the model from a LOCO file.  But it only changes
495    %                    the part of the model that does not get corrected
496    %                    in 'Symmetrize' (also does a SetGains).
497    %     'LOCO2Model' - Set the model from a LOCO file (also does a SetGains).
498    %                    This sets all lattice machines fit in the LOCO run to the model.
499    %
500    % Basically, use 'SetGains' or 'SetModel' if the LOCO run was applied to the accelerator
501    %            use 'LOCO2Model' if the LOCO run was made after the final setup
502
503    % Store the LOCO file in the opsdata directory
504
505    % MCF depends on optics !!!
506
507    AD.OpsData.LOCOFile = [getfamilydata('Directory','OpsData'),'LOCO_163Quads_122BPMs'];
508   
509    try % TO BE DONE LATER IN 2012
510        setlocodata('LOCO2Model', AD.OpsData.LOCOFile);
511    catch
512        fprintf('\n%s\n\n', lasterr);
513        fprintf('   WARNING: there was a problem calibrating the model based on LOCO file %s.\n', AD.OpsData.LOCOFile);
514    end
515
516else
517    setlocodata('Nominal');
518end
519
520fprintf('   lattice files have changed or if the AT lattice has changed.\n');
521fprintf('   Middlelayer setup for operational mode: %s\n', AD.OperationalMode);
522
523setad(orderfields(AD));
524
525end
526
527function local_setmagnetcoefficient(magnetcoeff_function)
528% quadrupole magnet coefficients
529% number of status 1 quadrupole families
530
531AO = getao;
532   
533quadFamList = {'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', ...
534         'Q7', 'Q8', 'Q9', 'Q10'};
535   
536if family2status('Q11',1),
537        quadFamList = [quadFamList, {'Q11'}];
538end
539   
540if family2status('Q12',1),
541        quadFamList = [quadFamList, {'Q12'}];
542end
543       
544   
545for k = 1:length(quadFamList),
546        ifam = quadFamList{k};
547
548        HW2PhysicsParams = feval(magnetcoeff_function, AO.(ifam).FamilyName);
549        Physics2HWParams = HW2PhysicsParams;
550
551        nb = size(AO.(ifam).DeviceName,1);
552
553        for ii=1:nb,
554            val = 1.0;
555            AO.(ifam).Monitor.HW2PhysicsParams{1}(ii,:)                 = HW2PhysicsParams;
556            AO.(ifam).Monitor.HW2PhysicsParams{2}(ii,:)                 = val;
557            AO.(ifam).Monitor.Physics2HWParams{1}(ii,:)                 = Physics2HWParams;
558            AO.(ifam).Monitor.Physics2HWParams{2}(ii,:)                 = val;
559            AO.(ifam).Setpoint.HW2PhysicsParams{1}(ii,:)                = HW2PhysicsParams;
560            AO.(ifam).Setpoint.HW2PhysicsParams{2}(ii,:)                = val;
561            AO.(ifam).Setpoint.Physics2HWParams{1}(ii,:)                = Physics2HWParams;
562            AO.(ifam).Setpoint.Physics2HWParams{2}(ii,:)                = val;
563        end
564end
565
566% sextupole magnet coefficients
567% number of status 1 sextupole families
568sextuFamList = {'S1', 'S2', 'S3', 'S4', 'S5', 'S6', ...
569         'S7', 'S8', 'S9', 'S10'};
570   
571if family2status('S11',1),
572        sextuFamList = [sextuFamList, {'S11'}];
573end
574   
575if family2status('S12',1),
576        sextuFamList = [sextuFamList, {'S12'}];
577end
578
579for k = 1:length(sextuFamList),
580        ifam = sextuFamList{k};
581       
582        HW2PhysicsParams = feval(magnetcoeff_function, AO.(ifam).FamilyName);
583        Physics2HWParams = HW2PhysicsParams;
584       
585        val = 1.0;
586        AO.(ifam).Monitor.HW2PhysicsParams{1}(1,:)                 = HW2PhysicsParams;
587        AO.(ifam).Monitor.HW2PhysicsParams{2}(1,:)                 = val;
588        AO.(ifam).Monitor.Physics2HWParams{1}(1,:)                 = Physics2HWParams;
589        AO.(ifam).Monitor.Physics2HWParams{2}(1,:)                 = val;
590        AO.(ifam).Setpoint.HW2PhysicsParams{1}(1,:)                 = HW2PhysicsParams;
591        AO.(ifam).Setpoint.HW2PhysicsParams{2}(1,:)                 = val;
592        AO.(ifam).Setpoint.Physics2HWParams{1}(1,:)                 = Physics2HWParams;
593        AO.(ifam).Setpoint.Physics2HWParams{2}(1,:)                 = val;
594end
595setao(AO);
596
597end
598
599
600function  local_set_config_mode(configmode)
601% Function for activating new families of quadrupole and sextupoles
602% magnets.
603
604switch(configmode)
605    case 'S11config120' % with S11 120 BPMs to be obsolete
606        setfamilydata(1, 'S11', 'Status')
607        setfamilydata(0, 'S12', 'Status')
608        setfamilydata(0, 'Q11', 'Status')
609        setfamilydata(0, 'Q12', 'Status')
610        setfamilydata(0, 'HCOR', 'Status', [13 8]);
611        setfamilydata(0, 'VCOR', 'Status', [13 9]);
612        setfamilydata(0, 'CycleHCOR', 'Status', [13 8]);
613        setfamilydata(0, 'CycleVCOR', 'Status', [13 9]);
614        setfamilydata(0, 'BPMx', 'Status', [13 8; 13 9]);
615        setfamilydata(0, 'BPMz', 'Status', [13 8; 13 9]);
616    case 'S11config122' % with S11 122 BPMs
617        setfamilydata(1, 'S11', 'Status')
618        setfamilydata(0, 'S12', 'Status')
619        setfamilydata(0, 'Q11', 'Status')
620        setfamilydata(0, 'Q12', 'Status')
621        setfamilydata(1, 'HCOR', 'Status', [13 8]);
622        setfamilydata(1, 'VCOR', 'Status', [13 9]);
623        setfamilydata(1, 'CycleHCOR', 'Status', [13 8]);
624        setfamilydata(1, 'CycleVCOR', 'Status', [13 9]);
625        setfamilydata(1, 'BPMx', 'Status', [13 8; 13 9]);
626        setfamilydata(1, 'BPMz', 'Status', [13 8; 13 9]);
627    case 'normalconfig' % without S11 120 BPMs to be obsolete
628        setfamilydata(0, 'S11', 'Status')
629        setfamilydata(0, 'S12', 'Status')
630        setfamilydata(0, 'Q11', 'Status')
631        setfamilydata(0, 'Q12', 'Status')
632        setfamilydata(0, 'HCOR', 'Status', [13 8]);
633        setfamilydata(0, 'VCOR', 'Status', [13 9]);
634        setfamilydata(0, 'CycleHCOR', 'Status', [13 8]);
635        setfamilydata(0, 'CycleVCOR', 'Status', [13 9]);
636        setfamilydata(0, 'BPMx', 'Status', [13 8; 13 9]);
637        setfamilydata(0, 'BPMz', 'Status', [13 8; 13 9]);
638    case 'nanoscopiumconfig120' % 120 BPMs to be obsolete
639        setfamilydata(1, 'S11', 'Status')
640        setfamilydata(1, 'S12', 'Status')
641        setfamilydata(1, 'Q11', 'Status')
642        setfamilydata(1, 'Q12', 'Status')
643        setfamilydata(0, 'HCOR', 'Status', [13 8]);
644        setfamilydata(0, 'VCOR', 'Status', [13 9]);
645        setfamilydata(0, 'CycleHCOR', 'Status', [13 8]);
646        setfamilydata(0, 'CycleVCOR', 'Status', [13 9]);
647        setfamilydata(0, 'BPMx', 'Status', [13 8; 13 9]);
648        setfamilydata(0, 'BPMz', 'Status', [13 8; 13 9]);
649    case 'nanoscopiumconfig122' % 122 BPMs
650        setfamilydata(1, 'S11', 'Status')
651        setfamilydata(1, 'S12', 'Status')
652        setfamilydata(1, 'Q11', 'Status')
653        setfamilydata(1, 'Q12', 'Status')
654        setfamilydata(0, 'HCOR', 'Status', [13 8]);
655        setfamilydata(0, 'VCOR', 'Status', [13 9]);
656        setfamilydata(0, 'CycleHCOR', 'Status', [13 8]);
657        setfamilydata(0, 'CycleVCOR', 'Status', [13 9]);
658        setfamilydata(1, 'BPMx', 'Status', [13 8; 13 9]);
659        setfamilydata(1, 'BPMz', 'Status', [13 8; 13 9]);
660    case 'nanoscopiumconfig122C'
661        setfamilydata(1, 'S11', 'Status')
662        setfamilydata(1, 'S12', 'Status')
663        setfamilydata(1, 'Q11', 'Status')
664        setfamilydata(1, 'Q12', 'Status')
665        setfamilydata(1, 'HCOR', 'Status', [13 8]);
666        setfamilydata(1, 'VCOR', 'Status', [13 9]);
667        setfamilydata(1, 'CycleHCOR', 'Status', [13 8]);
668        setfamilydata(1, 'CycleVCOR', 'Status', [13 9]);
669        setfamilydata(1, 'BPMx', 'Status', [13 8; 13 9]);
670        setfamilydata(1, 'BPMz', 'Status', [13 8; 13 9]);
671    otherwise
672        error('Wrong mode')
673end
674
675% switch addition corrector for HU640... TO BE REMOVED LATER
676switchHU640Cor('OFF');
677end
Note: See TracBrowser for help on using the repository browser.