source: MML/trunk/machine/THOMX/common/optics_TL.m @ 5

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

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

  • Property svn:executable set to *
File size: 62.6 KB
Line 
1function varargout = optics_TL(varargin)
2%OPTICS_LT1_LT2 - M-file for optics_LT1_LT2.fig
3%      OPTICS_LT1_LT2, by itself, creates a new OPTICS_LT1_LT2 or raises the existing
4%      singleton*.
5%
6%      H = OPTICS_LT1_LT2 returns the handle to a new OPTICS_LT1_LT2 or the handle to
7%      the existing singleton*.
8%
9%      OPTICS_LT1_LT2('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in OPTICS_LT1_LT2.M with the given input arguments.
11%
12%      OPTICS_LT1_LT2('Property','Value',...) creates a new OPTICS_LT1_LT2 or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before optics_LT1_LT2_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to optics_LT1_LT2_OpeningFcn via varargin.
17%
18%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19%      instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22
23% Edit the above text to modify the response to help optics_LT1_LT2
24
25% Last Modified by GUIDE v2.5 25-Oct-2013 14:42:37
26
27% Begin initialization code - DO NOT EDIT
28gui_Singleton = 1;
29gui_State = struct('gui_Name',       mfilename, ...
30                   'gui_Singleton',  gui_Singleton, ...
31                   'gui_OpeningFcn', @optics_TL_OpeningFcn, ...
32                   'gui_OutputFcn',  @optics_TL_OutputFcn, ...
33                   'gui_LayoutFcn',  [] , ...
34                   'gui_Callback',   []);
35if nargin && ischar(varargin{1})
36    gui_State.gui_Callback = str2func(varargin{1});
37end
38
39if nargout
40    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41else
42    gui_mainfcn(gui_State, varargin{:});
43end
44% End initialization code - DO NOT EDIT
45
46% --- Executes just before optics_LT1_LT2 is made visible.
47function optics_TL_OpeningFcn(hObject, eventdata, handles, varargin)
48% This function has no output args, see OutputFcn.
49% hObject    handle to figure
50% eventdata  reserved - to be defined in a future version of MATLAB
51% handles    structure with handles and user data (see GUIDATA)
52% varargin   command line arguments to optics_LT1_LT2 (see VARARGIN)
53
54% Choose default command line output for optics_LT1_LT2
55handles.output = hObject;
56
57%mat: utilite ???
58setappdata(handles.figure1, 'twissdatain',struct([]));
59
60% construct initial twiss parameters
61
62Machine = getfamilydata('SubMachine');
63
64switch Machine
65    case {'TL'}
66
67        twissdatain.ElemIndex  = 1;
68        twissdatain.SPos       = 0;
69        twissdatain.ClosedOrbit= [1e-3 0 2e-3 0]'*0;
70        twissdatain.M44        = eye(4);
71        % theorique
72        twissdatain.beta       = [34.46 33.94];
73        twissdatain.alpha      = [-4.24 -4.34];
74        % mesure 2006-02-06
75        %twissdatain.beta       = [9.5 13.5];
76        %twissdatain.alpha      = [-1.16 -2.43];
77        twissdatain.mu         = [0 0];
78        twissdatain.Dispersion = [0 0 0 0]';
79        set(handles.figure1,'Name', 'TL Optical functions');
80       
81    case {'EL'}
82       
83        twissdatain.ElemIndex  = 1;
84        twissdatain.SPos       = 0;
85        twissdatain.ClosedOrbit= [1e-3 0 2e-3 0]'*0;
86        twissdatain.M44        = eye(4);
87        twissdatain.beta       = [6.0 6.0];
88        twissdatain.alpha      = [-1.8 1.5];
89        twissdatain.mu         = [0 0];
90        twissdatain.Dispersion = [0 0 0 0]';
91        set(handles.figure1,'Name', 'EL Optical functions');
92
93    otherwise
94        error('No Machine loaded')       
95end
96
97setappdata(handles.figure1, 'twissdatain0',twissdatain);
98handles.restart = 1;
99
100%% Initialize structure for handling TL and EL magnets
101handles = init_handles(handles);
102
103% Update handles structure
104guidata(hObject, handles);
105
106AO = getao;
107% setappdata(handles.figure1,'AOmagnet', AO);
108
109%set(handles.(name),'Max',9, 'Min', -9)
110
111% min et max des sliders (figé à l'ouverture puis modifiable par SETBAR)
112% the values are set in TLinit.m
113for i=1:7
114    val_max(i) = getmaxsp(['QP',num2str(i),'L']);
115    val_min(i) = getminsp(['QP',num2str(i),'L']);
116end
117
118%% Number of sliders   
119handles.sliderNumber = 7;
120
121for k = 1:handles.sliderNumber,
122    name = strcat('sliderQP',num2str(k),'L');
123    %set(handles.(name),'Max',val_max(k),'Min',val_min(k));
124    set(handles.(name),'Max',max(val_max),'Min',min(val_min)); % set the change range of magnets
125end
126
127
128%% liste de aimants a controler (menu deroulant)
129list = [...
130        AO.QP1L.CommonNames;...
131        AO.QP2L.CommonNames;...
132        AO.QP3L.CommonNames;...
133        AO.QP4L.CommonNames;...
134        AO.QP5L.CommonNames;...
135        AO.QP6L.CommonNames;...
136        AO.QP7L.CommonNames;...
137        AO.BEND1.CommonNames;...
138        AO.BEND2.CommonNames;...
139        AO.HCOR.CommonNames; ...
140        AO.VCOR.CommonNames
141        ];
142   
143
144%% Automatic configuration for sliders
145for k = 1:handles.sliderNumber
146    name = ['popupmenu_bar' num2str(k)];
147    set(handles.(name),'String',list);
148    set(handles.(name),'Value',k);
149end
150
151%% graphe par defaut
152axes(handles.axes1);
153handles.xtype = 'spos';
154handles.ytype = 'beta';
155
156%% initialisation AT et IHM
157handles = restart(handles);
158
159%% Read Tango values
160%read_tango(handles);
161
162% UIWAIT makes optics_LT1_LT2 wait for user response (see UIRESUME)
163% uiwait(handles.figure1);
164set(0,'DefaultAxesXgrid','on','DefaultAxesYgrid','on');
165
166%% graphe symboles
167axes(handles.axes2);
168drawlattice(0,0.8);
169set(handles.axes2,'Xlim',[handles.spos(1) handles.spos(end)], ...
170    'XTick',[],'YTick',[]);
171
172
173% Update handles structure
174guidata(hObject, handles);
175
176%% -------------------------------------
177function handles = computeTwiss(handles)
178% update ATmodel
179% compute new twiss parameters
180%
181global THERING;
182
183%%% parameters at the entrance of the line
184% twissdatain.ElemIndex=1;
185% twissdatain.SPos=0;
186% twissdatain.ClosedOrbit=[1e-3 0 2e-3 0]'*0;
187% twissdatain.M44=eye(4);
188%
189% if isequal(isfield(twissdatain,'beta'),0)
190 
191 if handles.restart == 1
192     twissdatain = getappdata(handles.figure1,'twissdatain0');
193     handles.restart = 0;
194 else
195     twissdatain = getappdata(handles.figure1,'twissdatain');
196 end
197%     twissdatain.beta= [8.1 8.1];
198%     twissdatain.alpha= [0 0];
199% else
200%     twissdatain = getappdata(handles.figure1,'twissdatain')
201% end
202
203% twissdatain.mu= [0 0];
204% twissdatain.Dispersion= [0 0 0 0]';
205
206%%% get twiss paramaters
207TD = twissline(THERING,0.0,twissdatain,1:length(THERING),'chroma');
208
209handles.twissdatain = twissdatain;
210handles.beta  = cat(1,TD.beta);
211handles.cod   = cat(2,TD.ClosedOrbit)';
212handles.eta   = cat(2,TD.Dispersion)';
213handles.spos  = cat(1,TD.SPos);
214handles.phase = cat(1,TD.mu);
215
216setappdata(handles.figure1,'twissdatain',twissdatain);
217
218% --- Outputs from this function are returned to the command line.
219function varargout = optics_TL_OutputFcn(hObject, eventdata, handles)
220% varargout  cell array for returning output args (see VARARGOUT);
221% hObject    handle to figure
222% eventdata  reserved - to be defined in a future version of MATLAB
223% handles    structure with handles and user data (see GUIDATA)
224
225% Get default command line output from handles structure
226varargout{1} = handles.output;
227
228% --- Executes during object creation, after setting all properties.
229function sliderQP1L_CreateFcn(hObject, eventdata, handles)
230% hObject    handle to sliderQP1L (see GCBO)
231% eventdata  reserved - to be defined in a future version of MATLAB
232% handles    empty - handles not created until after all CreateFcns called
233
234% Hint: slider controls usually have a light gray background, change
235%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
236usewhitebg = 1;
237if usewhitebg
238    set(hObject,'BackgroundColor',[.9 .9 .9]);
239else
240    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
241end
242
243% --- Executes on slider movement.
244function sliderQP1L_Callback(hObject, eventdata, handles)
245% hObject    handle to sliderQP1L (see GCBO)
246% eventdata  reserved - to be defined in a future version of MATLAB
247% handles    structure with handles and user data (see GUIDATA)
248
249% Hints: get(hObject,'Value') returns position of slider
250%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
251
252handles = setslider(hObject,handles);
253guidata(hObject, handles);
254
255% --- Executes during object creation, after setting all properties.
256function editQP1L_CreateFcn(hObject, eventdata, handles)
257% hObject    handle to editQP1L (see GCBO)
258% eventdata  reserved - to be defined in a future version of MATLAB
259% handles    empty - handles not created until after all CreateFcns called
260
261% Hint: edit controls usually have a white background on Windows.
262%       See ISPC and COMPUTER.
263if ispc
264    set(hObject,'BackgroundColor','green');
265else
266    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
267end
268
269% --- Executes on slider movement.
270function editQP1L_Callback(hObject, eventdata, handles)
271% hObject    handle to editQP1L (see GCBO)
272% eventdata  reserved - to be defined in a future version of MATLAB
273% handles    structure with handles and user data (see GUIDATA)
274
275% Hints: get(hObject,'String') returns contents of editQP1L as text
276%        str2double(get(hObject,'String')) returns contents of editQP1L as a double
277handles = setedit(handles);
278guidata(hObject, handles);
279
280% --- Executes during object creation, after setting all properties.
281function sliderQP2L_CreateFcn(hObject, eventdata, handles)
282% hObject    handle to sliderQP2L (see GCBO)
283% eventdata  reserved - to be defined in a future version of MATLAB
284% handles    empty - handles not created until after all CreateFcns called
285
286% Hint: slider controls usually have a light gray background, change
287%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
288usewhitebg = 1;
289if usewhitebg
290    set(hObject,'BackgroundColor',[.9 .9 .9]);
291else
292    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
293end
294
295% --- Executes on slider movement.
296function sliderQP2L_Callback(hObject, eventdata, handles)
297% hObject    handle to sliderQP2L (see GCBO)
298% eventdata  reserved - to be defined in a future version of MATLAB
299% handles    structure with handles and user data (see GUIDATA)
300
301% Hints: get(hObject,'Value') returns position of slider
302%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
303handles = setslider(hObject,handles);
304guidata(hObject, handles);
305
306% --- Executes during object creation, after setting all properties.
307function editQP2L_CreateFcn(hObject, eventdata, handles)
308% hObject    handle to editQP2L (see GCBO)
309% eventdata  reserved - to be defined in a future version of MATLAB
310% handles    empty - handles not created until after all CreateFcns called
311
312% Hint: edit controls usually have a white background on Windows.
313%       See ISPC and COMPUTER.
314if ispc
315    set(hObject,'BackgroundColor','white');
316else
317    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
318end
319
320function editQP2L_Callback(hObject, eventdata, handles)
321% hObject    handle to editQP2L (see GCBO)
322% eventdata  reserved - to be defined in a future version of MATLAB
323% handles    structure with handles and user data (see GUIDATA)
324
325% Hints: get(hObject,'String') returns contents of editQP2L as text
326%        str2double(get(hObject,'String')) returns contents of editQP2L as a double
327handles = setedit(handles);
328guidata(hObject, handles);
329
330% --- Executes during object creation, after setting all properties.
331function sliderQP3L_CreateFcn(hObject, eventdata, handles)
332% hObject    handle to sliderQP3L (see GCBO)
333% eventdata  reserved - to be defined in a future version of MATLAB
334% handles    empty - handles not created until after all CreateFcns called
335
336% Hint: slider controls usually have a light gray background, change
337%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
338usewhitebg = 1;
339if usewhitebg
340    set(hObject,'BackgroundColor',[.9 .9 .9]);
341else
342    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
343end
344
345% --- Executes on slider movement.
346function sliderQP3L_Callback(hObject, eventdata, handles)
347% hObject    handle to sliderQP3L (see GCBO)
348% eventdata  reserved - to be defined in a future version of MATLAB
349% handles    structure with handles and user data (see GUIDATA)
350
351% Hints: get(hObject,'Value') returns position of slider
352%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
353handles = setslider(hObject,handles);
354guidata(hObject, handles);
355
356
357% --- Executes during object creation, after setting all properties.
358function editQP3L_CreateFcn(hObject, eventdata, handles)
359% hObject    handle to editQP3L (see GCBO)
360% eventdata  reserved - to be defined in a future version of MATLAB
361% handles    empty - handles not created until after all CreateFcns called
362
363% Hint: edit controls usually have a white background on Windows.
364%       See ISPC and COMPUTER.
365if ispc
366    set(hObject,'BackgroundColor','white');
367else
368    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
369end
370
371function editQP3L_Callback(hObject, eventdata, handles)
372% hObject    handle to editQP3L (see GCBO)
373% eventdata  reserved - to be defined in a future version of MATLAB
374% handles    structure with handles and user data (see GUIDATA)
375
376% Hints: get(hObject,'String') returns contents of editQP3L as text
377%        str2double(get(hObject,'String')) returns contents of editQP3L as a double
378handles = setedit(handles);
379guidata(hObject, handles);
380
381% --- Executes during object creation, after setting all properties.
382function editQP4L_CreateFcn(hObject, eventdata, handles)
383% hObject    handle to editQP4L (see GCBO)
384% eventdata  reserved - to be defined in a future version of MATLAB
385% handles    empty - handles not created until after all CreateFcns called
386
387% Hint: edit controls usually have a white background on Windows.
388%       See ISPC and COMPUTER.
389if ispc
390    set(hObject,'BackgroundColor','white');
391else
392    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
393end
394
395function editQP4L_Callback(hObject, eventdata, handles)
396% hObject    handle to editQP4L (see GCBO)
397% eventdata  reserved - to be defined in a future version of MATLAB
398% handles    structure with handles and user data (see GUIDATA)
399
400% Hints: get(hObject,'String') returns contents of editQP4L as text
401%        str2double(get(hObject,'String')) returns contents of editQP4L as a double
402handles = setedit(handles);
403
404
405% --- Executes during object creation, after setting all properties.
406function sliderQP4L_CreateFcn(hObject, eventdata, handles)
407% hObject    handle to sliderQP4L (see GCBO)
408% eventdata  reserved - to be defined in a future version of MATLAB
409% handles    empty - handles not created until after all CreateFcns called
410
411% Hint: slider controls usually have a light gray background, change
412%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
413usewhitebg = 1;
414if usewhitebg
415    set(hObject,'BackgroundColor',[.9 .9 .9]);
416else
417    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
418end
419
420
421% --- Executes on slider movement.
422function sliderQP4L_Callback(hObject, eventdata, handles)
423% hObject    handle to sliderQP4L (see GCBO)
424% eventdata  reserved - to be defined in a future version of MATLAB
425% handles    structure with handles and user data (see GUIDATA)
426
427% Hints: get(hObject,'Value') returns position of slider
428%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
429handles = setslider(hObject,handles);
430guidata(hObject, handles);
431
432% --- Executes during object creation, after setting all properties.
433function editQP5L_CreateFcn(hObject, eventdata, handles)
434% hObject    handle to editQP5L (see GCBO)
435% eventdata  reserved - to be defined in a future version of MATLAB
436% handles    empty - handles not created until after all CreateFcns called
437
438% Hint: edit controls usually have a white background on Windows.
439%       See ISPC and COMPUTER.
440if ispc
441    set(hObject,'BackgroundColor','white');
442else
443    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
444end
445
446
447function editQP5L_Callback(hObject, eventdata, handles)
448% hObject    handle to editQP5L (see GCBO)
449% eventdata  reserved - to be defined in a future version of MATLAB
450% handles    structure with handles and user data (see GUIDATA)
451
452% Hints: get(hObject,'String') returns contents of editQP5L as text
453%        str2double(get(hObject,'String')) returns contents of editQP5L as a double
454handles = setedit(handles);
455guidata(hObject, handles);
456
457% --- Executes during object creation, after setting all properties.
458function sliderQP5L_CreateFcn(hObject, eventdata, handles)
459% hObject    handle to sliderQP5L (see GCBO)
460% eventdata  reserved - to be defined in a future version of MATLAB
461% handles    empty - handles not created until after all CreateFcns called
462
463% Hint: slider controls usually have a light gray background, change
464%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
465usewhitebg = 1;
466if usewhitebg
467    set(hObject,'BackgroundColor',[.9 .9 .9]);
468else
469    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
470end
471
472% --- Executes on slider movement.
473function sliderQP5L_Callback(hObject, eventdata, handles)
474% hObject    handle to sliderQP5L (see GCBO)
475% eventdata  reserved - to be defined in a future version of MATLAB
476% handles    structure with handles and user data (see GUIDATA)
477
478% Hints: get(hObject,'Value') returns position of slider
479%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
480handles = setslider(hObject,handles);
481guidata(hObject, handles);
482
483% --- Executes during object creation, after setting all properties.
484function sliderQP6L_CreateFcn(hObject, eventdata, handles)
485% hObject    handle to sliderQP6L (see GCBO)
486% eventdata  reserved - to be defined in a future version of MATLAB
487% handles    empty - handles not created until after all CreateFcns called
488
489% Hint: slider controls usually have a light gray background, change
490%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
491usewhitebg = 1;
492if usewhitebg
493    set(hObject,'BackgroundColor',[.9 .9 .9]);
494else
495    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
496end
497
498% --- Executes on slider movement.
499function sliderQP6L_Callback(hObject, eventdata, handles)
500% hObject    handle to sliderQP6L (see GCBO)
501% eventdata  reserved - to be defined in a future version of MATLAB
502% handles    structure with handles and user data (see GUIDATA)
503
504% Hints: get(hObject,'Value') returns position of slider
505%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
506handles = setslider(hObject,handles);
507guidata(hObject, handles);
508
509% --- Executes during object creation, after setting all properties.
510function editQP6L_CreateFcn(hObject, eventdata, handles)
511% hObject    handle to editQP6L (see GCBO)
512% eventdata  reserved - to be defined in a future version of MATLAB
513% handles    empty - handles not created until after all CreateFcns called
514
515% Hint: edit controls usually have a white background on Windows.
516%       See ISPC and COMPUTER.
517if ispc
518    set(hObject,'BackgroundColor','white');
519else
520    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
521end
522
523function editQP6L_Callback(hObject, eventdata, handles)
524% hObject    handle to editQP6L (see GCBO)
525% eventdata  reserved - to be defined in a future version of MATLAB
526% handles    structure with handles and user data (see GUIDATA)
527
528% Hints: get(hObject,'String') returns contents of editQP6L as text
529%        str2double(get(hObject,'String')) returns contents of editQP6L as a double
530handles = setedit(handles);
531guidata(hObject, handles);
532
533% --- Executes during object creation, after setting all properties.
534function editQP7L_CreateFcn(hObject, eventdata, handles)
535% hObject    handle to editQP7L (see GCBO)
536% eventdata  reserved - to be defined in a future version of MATLAB
537% handles    empty - handles not created until after all CreateFcns called
538
539% Hint: edit controls usually have a white background on Windows.
540%       See ISPC and COMPUTER.
541if ispc
542    set(hObject,'BackgroundColor','white');
543else
544    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
545end
546
547function editQP7L_Callback(hObject, eventdata, handles)
548% hObject    handle to editQP7L (see GCBO)
549% eventdata  reserved - to be defined in a future version of MATLAB
550% handles    structure with handles and user data (see GUIDATA)
551
552% Hints: get(hObject,'String') returns contents of editQP7L as text
553%        str2double(get(hObject,'String')) returns contents of editQP7L as a double
554handles = setedit(handles);
555
556
557% --- Executes during object creation, after setting all properties.
558function sliderQP7L_CreateFcn(hObject, eventdata, handles)
559% hObject    handle to sliderQP7L (see GCBO)
560% eventdata  reserved - to be defined in a future version of MATLAB
561% handles    empty - handles not created until after all CreateFcns called
562
563% Hint: slider controls usually have a light gray background, change
564%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
565usewhitebg = 1;
566if usewhitebg
567    set(hObject,'BackgroundColor',[.9 .9 .9]);
568else
569    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
570end
571
572% --- Executes on slider movement.
573function sliderQP7L_Callback(hObject, eventdata, handles)
574% hObject    handle to sliderQP7L (see GCBO)
575% eventdata  reserved - to be defined in a future version of MATLAB
576% handles    structure with handles and user data (see GUIDATA)
577
578% Hints: get(hObject,'Value') returns position of slider
579%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
580handles = setslider(hObject,handles);
581guidata(hObject, handles);
582
583%-----------------------------------------------------------------------
584function plot_axes(handles,quoi)
585%%% fonction generique
586
587axes(handles.axes1); cla; hold on;
588
589switch handles.xtype
590    case 'spos'
591        x=handles.(handles.xtype);
592    case 'phase'
593        x=handles.(handles.xtype); x = x(:,1);
594end
595
596switch quoi
597    case 'beta'
598        plot(x,handles.beta(:,1),'r.-');
599        plot(x,handles.beta(:,2),'b.-');
600        ylabel('\beta (m)');
601        %mat
602   %ylim([0 130]);
603       
604    case 'eta'       
605        plot(x,handles.eta(:,1),'r.-');
606        plot(x,handles.eta(:,3),'b.-');
607        ylabel('\eta (m)');
608    case 'cod'       
609        plot(x,handles.cod(:,1)*1e3,'r.-');
610        plot(x,handles.cod(:,3)*1e3,'b.-');
611        ylabel('cod (mm)');
612    case 'phase'       
613        plot(x,handles.phase(:,1),'r.-');
614        plot(x,handles.phase(:,2),'b.-');
615        ylabel('phase ');
616end
617axis([x(1) x(end) -inf inf]);
618datalabel on
619
620%--------------------------------------------------------------------------
621function handles = setslider(hObject, handles)
622%%% fonction generique pour un slider de type aimant
623
624AOmagnet = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
625%% extrait le numero
626tagstring = get(hObject,'Tag');
627num = tagstring(regexp(tagstring,'\d'));
628magnet0 = ['QP' num2str(num),'L'];
629val =  get(hObject,'Value');
630str = num2str(val);
631set(handles.(['edit' magnet0]),'string',str);
632
633%% Cherche le nom de l'aimant
634h = handles.(['popupmenu_bar' num]);
635contents = get(h,'String');
636magnet = contents{get(h,'Value')};
637handles = setATmagnet(handles,magnet,val);
638
639%AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val;
640AOmagnet.(magnet).ModelVal = val;
641% save data
642setappdata(handles.figure1,'AOmagnet',AOmagnet)
643
644%--------------------------------------------------------------------------
645function handles = setATmagnet(handles,magnet,val)
646% function handles = setATmagnet(handles,magnet,val)
647% set  val as new setvalue of element 'magnet'
648% Replot current graph
649
650AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO
651
652% set value to AT model
653setsp(common2family(magnet), val, common2dev(magnet),'Model');
654
655% Recompute twiss parameters
656handles = computeTwiss(handles);
657% Replot everything
658plot_axes(handles,handles.ytype);
659%mat
660%ylim([0 130]);
661
662%--------------------------------------------------------------------------
663function handles = setedit(handles)
664% function setedit(handles)
665% generic callback for an edit box
666
667AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO
668
669%% construction automatique du nom du slider
670val = str2double(get(gcbo,'String'));
671tagstring = get(gcbo,'Tag');
672num = tagstring(regexp(tagstring,'\d'));
673magnet0=['QP' num2str(num)];
674name = handles.(['slider' magnet0]);
675%% Cherche le nom de l'aimant
676h = handles.(['popupmenu_bar' num]);
677contents = get(h,'String');
678magnet = contents{get(h,'Value')};
679
680%%% Test si dans les limites
681if val<get(name,'Max') && val> get(name,'Min')
682  set(name,'Value',val);
683  handles = setATmagnet(handles,magnet,val);
684  AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val;
685else % message d'erreur
686  warndlg('Wrong value for K','Edit Box','Modal')
687  set(hObject,'String',num2str(get(name,'Value')));
688end
689
690% Save data
691setappdata(handles.figure1,'AOmagnet',AOmagnet);
692
693%---------------------------------
694function mutual_exclude(off)
695% function mutual_exclude(off)
696% fonction pour faire des radioboutons
697set(off,'Value',0);
698
699% --- Executes during object creation, after setting all properties.
700function popupmenu_y_CreateFcn(hObject, eventdata, handles)
701% hObject    handle to popupmenu_y (see GCBO)
702% eventdata  reserved - to be defined in a future version of MATLAB
703% handles    empty - handles not created until after all CreateFcns called
704
705% Hint: popupmenu controls usually have a white background on Windows.
706%       See ISPC and COMPUTER.
707if ispc
708    set(hObject,'BackgroundColor','white');
709else
710    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
711end
712
713
714% --- Executes on selection change in popupmenu_y.
715function popupmenu_y_Callback(hObject, eventdata, handles)
716% hObject    handle to popupmenu_y (see GCBO)
717% eventdata  reserved - to be defined in a future version of MATLAB
718% handles    structure with handles and user data (see GUIDATA)
719
720% Hints: contents = get(hObject,'String') returns popupmenu_y contents as cell array
721%        contents{get(hObject,'Value')} returns selected item from popupmenu_y
722contents = get(hObject,'String');
723plot_axes(handles, contents{get(hObject,'Value')});
724%mat
725     %ylim([0 130]);
726handles.ytype = contents{get(hObject,'Value')};       
727guidata(hObject, handles);
728
729% --- Executes during object creation, after setting all properties.
730function popupmenu_x_CreateFcn(hObject, eventdata, handles)
731% hObject    handle to popupmenu_x (see GCBO)
732% eventdata  reserved - to be defined in a future version of MATLAB
733% handles    empty - handles not created until after all CreateFcns called
734
735% Hint: popupmenu controls usually have a white background on Windows.
736%       See ISPC and COMPUTER.
737if ispc
738    set(hObject,'BackgroundColor','white');
739else
740    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
741end
742
743% --- Executes on selection change in popupmenu_x.
744function popupmenu_x_Callback(hObject, eventdata, handles)
745% hObject    handle to popupmenu_x (see GCBO)
746% eventdata  reserved - to be defined in a future version of MATLAB
747% handles    structure with handles and user data (see GUIDATA)
748
749% Hints: contents = get(hObject,'String') returns popupmenu_x contents as cell array
750%        contents{get(hObject,'Value')} returns selected item from popupmenu_x
751contents = get(hObject,'String');       
752handles.xtype = contents{get(hObject,'Value')};       
753guidata(hObject, handles);
754plot_axes(handles, handles.ytype);
755%mat
756      %ylim([0 130]);
757
758% --- Executes during object creation, after setting all properties.
759function popupmenu_plane_CreateFcn(hObject, eventdata, handles)
760% hObject    handle to popupmenu_plane (see GCBO)
761% eventdata  reserved - to be defined in a future version of MATLAB
762% handles    empty - handles not created until after all CreateFcns called
763
764% Hint: popupmenu controls usually have a white background on Windows.
765%       See ISPC and COMPUTER.
766if ispc
767    set(hObject,'BackgroundColor','white');
768else
769    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
770end
771
772
773% --- Executes on selection change in popupmenu_plane.
774function popupmenu_plane_Callback(hObject, eventdata, handles)
775% hObject    handle to popupmenu_plane (see GCBO)
776% eventdata  reserved - to be defined in a future version of MATLAB
777% handles    structure with handles and user data (see GUIDATA)
778
779% Hints: contents = get(hObject,'String') returns popupmenu_plane contents as cell array
780%        contents{get(hObject,'Value')} returns selected item from popupmenu_plane
781
782
783% --- Executes on button press in pushbutton_reload.
784function pushbutton_reload_Callback(hObject, eventdata, handles)
785% hObject    handle to pushbutton_reload (see GCBO)
786% eventdata  reserved - to be defined in a future version of MATLAB
787% handles    structure with handles and user data (see GUIDATA)
788
789handles = restart(handles);
790guidata(hObject,handles);
791
792%--------------------------------------------------------
793function handles = restart(handles)
794% function handles = restart(handles)
795% Reinitialise la maille et l'IHM
796
797AD = getad;
798run(AD.ATModel); %% Load lattice
799global THERING
800% MAT ET LAURENT : TEMPORAIRE
801%warning('66 MeV');
802%setenergymodel(0.066);
803
804%
805setappdata(handles.figure1, 'TL', THERING);
806
807handles.restart = 1;
808handles         = computeTwiss(handles);
809
810plot_axes(handles,handles.ytype);
811%mat
812   
813%ylim([0 130]);
814
815handles.modelMagnetVal  = {'chModelVal', 'cvModelVal', ...
816    'quadrupoleModelVal', 'dipoleModelVal'};
817
818store_model_values(handles);
819
820% Relaod Accelerator Object
821AO  = getao;
822
823%% Initialise les sliders et editboxes
824for k = 1:handles.sliderNumber
825    name = ['popupmenu_bar' num2str(k)];
826    contents = get(handles.(name),'String');
827    magnet = contents{get(handles.(name),'Value')};
828   
829    Qname = ['QP' num2str(k),'L'];   
830   
831    % Read AT values
832    val  = getam(common2family(magnet),common2dev(magnet),'Model');
833   
834    set(handles.(['slider' Qname]),'Value', val);
835    set(handles.(['edit' Qname]),'string', num2str(val));
836end
837
838
839% --- Executes during object creation, after setting all properties.
840function popupmenu_bar1_CreateFcn(hObject, eventdata, handles)
841% hObject    handle to popupmenu_bar1 (see GCBO)
842% eventdata  reserved - to be defined in a future version of MATLAB
843% handles    empty - handles not created until after all CreateFcns called
844
845% Hint: popupmenu controls usually have a white background on Windows.
846%       See ISPC and COMPUTER.
847if ispc
848    set(hObject,'BackgroundColor','white');
849else
850    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
851end
852
853
854% --- Executes on selection change in popupmenu_bar1.
855function popupmenu_bar1_Callback(hObject, eventdata, handles)
856% hObject    handle to popupmenu_bar1 (see GCBO)
857% eventdata  reserved - to be defined in a future version of MATLAB
858% handles    structure with handles and user data (see GUIDATA)
859
860% Hints: contents = get(hObject,'String') returns popupmenu_bar1 contents as cell array
861%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar1
862
863setbar(handles);
864
865%----------------------------------------------------------
866function setbar(handles)
867%% aimant selectionne
868contents = get(gcbo,'String');
869magnet = contents{get(gcbo,'Value')}
870
871%% mets a jour l'IHM pour cet aimant
872tagstring = get(gcbo,'Tag');
873num = tagstring(regexp(tagstring,'\d'));
874slidername = ['sliderQP' num, 'L'];
875editboxname = ['editQP' num, 'L'];
876
877AOmagnet  = getappdata(handles.figure1,'AOmagnet');
878
879switch magnet
880    case AOmagnet.HCOR.CommonNames
881%         val_max = getmaxsp('HCOR');
882%         for k = 1:7
883%             name = strcat('sliderQP',num2str(k),'L')
884%             set(handles.(name),'Max',val_max(1));
885%         end
886        val = AOmagnet.HCOR.ModelVal(str2double(magnet(end)));
887    case AOmagnet.VCOR.CommonNames
888        val = AOmagnet.VCOR.ModelVal(str2double(magnet(end)));
889    case AOmagnet.QP1L.CommonNames
890        val = AOmagnet.QP1L.ModelVal;
891    case AOmagnet.QP2L.CommonNames
892        val = AOmagnet.QP2L.ModelVal;
893    case AOmagnet.QP3L.CommonNames
894        val = AOmagnet.QP3L.ModelVal;
895    case AOmagnet.QP4L.CommonNames
896        val = AOmagnet.QP4L.ModelVal;
897    case AOmagnet.QP5L.CommonNames
898        val = AOmagnet.QP5L.ModelVal;
899    case AOmagnet.QP6L.CommonNames
900        val = AOmagnet.QP6L.ModelVal;
901    case AOmagnet.QP7L.CommonNames
902        val = AOmagnet.QP7L.ModelVal;
903    case AOmagnet.BEND1.CommonNames
904        val = AOmagnet.BEND1.ModelVal(str2double(magnet(end)));
905    case AOmagnet.BEND2.CommonNames
906        val = AOmagnet.BEND2.ModelVal(str2double(magnet(end)));
907end
908
909str = num2str(val);
910set(handles.(slidername),'Value',val); % writes slider
911set(handles.(editboxname),'String',str); % writes editbox
912
913% --- Executes during object creation, after setting all properties.
914function popupmenu_bar2_CreateFcn(hObject, eventdata, handles)
915% hObject    handle to popupmenu_bar2 (see GCBO)
916% eventdata  reserved - to be defined in a future version of MATLAB
917% handles    empty - handles not created until after all CreateFcns called
918
919% Hint: popupmenu controls usually have a white background on Windows.
920%       See ISPC and COMPUTER.
921if ispc
922    set(hObject,'BackgroundColor','white');
923else
924    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
925end
926
927% --- Executes on selection change in popupmenu_bar2.
928function popupmenu_bar2_Callback(hObject, eventdata, handles)
929% hObject    handle to popupmenu_bar2 (see GCBO)
930% eventdata  reserved - to be defined in a future version of MATLAB
931% handles    structure with handles and user data (see GUIDATA)
932
933% Hints: contents = get(hObject,'String') returns popupmenu_bar2 contents as cell array
934%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar2
935setbar(handles);
936
937% --- Executes during object creation, after setting all properties.
938function popupmenu_bar3_CreateFcn(hObject, eventdata, handles)
939% hObject    handle to popupmenu_bar3 (see GCBO)
940% eventdata  reserved - to be defined in a future version of MATLAB
941% handles    empty - handles not created until after all CreateFcns called
942
943% Hint: popupmenu controls usually have a white background on Windows.
944%       See ISPC and COMPUTER.
945if ispc
946    set(hObject,'BackgroundColor','white');
947else
948    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
949end
950
951% --- Executes on selection change in popupmenu_bar3.
952function popupmenu_bar3_Callback(hObject, eventdata, handles)
953% hObject    handle to popupmenu_bar3 (see GCBO)
954% eventdata  reserved - to be defined in a future version of MATLAB
955% handles    structure with handles and user data (see GUIDATA)
956
957% Hints: contents = get(hObject,'String') returns popupmenu_bar3 contents as cell array
958%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar3
959setbar(handles);
960
961% --- Executes during object creation, after setting all properties.
962function popupmenu_bar4_CreateFcn(hObject, eventdata, handles)
963% hObject    handle to popupmenu_bar4 (see GCBO)
964% eventdata  reserved - to be defined in a future version of MATLAB
965% handles    empty - handles not created until after all CreateFcns called
966
967% Hint: popupmenu controls usually have a white background on Windows.
968%       See ISPC and COMPUTER.
969if ispc
970    set(hObject,'BackgroundColor','white');
971else
972    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
973end
974
975% --- Executes on selection change in popupmenu_bar4.
976function popupmenu_bar4_Callback(hObject, eventdata, handles)
977% hObject    handle to popupmenu_bar4 (see GCBO)
978% eventdata  reserved - to be defined in a future version of MATLAB
979% handles    structure with handles and user data (see GUIDATA)
980
981% Hints: contents = get(hObject,'String') returns popupmenu_bar4 contents as cell array
982%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar4
983setbar(handles);
984
985% --- Executes during object creation, after setting all properties.
986function popupmenu_bar5_CreateFcn(hObject, eventdata, handles)
987% hObject    handle to popupmenu_bar5 (see GCBO)
988% eventdata  reserved - to be defined in a future version of MATLAB
989% handles    empty - handles not created until after all CreateFcns called
990
991% Hint: popupmenu controls usually have a white background on Windows.
992%       See ISPC and COMPUTER.
993if ispc
994    set(hObject,'BackgroundColor','white');
995else
996    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
997end
998
999% --- Executes on selection change in popupmenu_bar5.
1000function popupmenu_bar5_Callback(hObject, eventdata, handles)
1001% hObject    handle to popupmenu_bar5 (see GCBO)
1002% eventdata  reserved - to be defined in a future version of MATLAB
1003% handles    structure with handles and user data (see GUIDATA)
1004
1005% Hints: contents = get(hObject,'String') returns popupmenu_bar5 contents as cell array
1006%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar5
1007setbar(handles);
1008
1009% --- Executes during object creation, after setting all properties.
1010function popupmenu_bar6_CreateFcn(hObject, eventdata, handles)
1011% hObject    handle to popupmenu_bar6 (see GCBO)
1012% eventdata  reserved - to be defined in a future version of MATLAB
1013% handles    empty - handles not created until after all CreateFcns called
1014
1015% Hint: popupmenu controls usually have a white background on Windows.
1016%       See ISPC and COMPUTER.
1017if ispc
1018    set(hObject,'BackgroundColor','white');
1019else
1020    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1021end
1022
1023
1024% --- Executes on selection change in popupmenu_bar6.
1025function popupmenu_bar6_Callback(hObject, eventdata, handles)
1026% hObject    handle to popupmenu_bar6 (see GCBO)
1027% eventdata  reserved - to be defined in a future version of MATLAB
1028% handles    structure with handles and user data (see GUIDATA)
1029
1030% Hints: contents = get(hObject,'String') returns popupmenu_bar6 contents as cell array
1031%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar6
1032setbar(handles);
1033
1034% --- Executes during object creation, after setting all properties.
1035function popupmenu_bar7_CreateFcn(hObject, eventdata, handles)
1036% hObject    handle to popupmenu_bar7 (see GCBO)
1037% eventdata  reserved - to be defined in a future version of MATLAB
1038% handles    empty - handles not created until after all CreateFcns called
1039
1040% Hint: popupmenu controls usually have a white background on Windows.
1041%       See ISPC and COMPUTER.
1042if ispc
1043    set(hObject,'BackgroundColor','white');
1044else
1045    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1046end
1047
1048% --- Executes on selection change in popupmenu_bar7.
1049function popupmenu_bar7_Callback(hObject, eventdata, handles)
1050% hObject    handle to popupmenu_bar7 (see GCBO)
1051% eventdata  reserved - to be defined in a future version of MATLAB
1052% handles    structure with handles and user data (see GUIDATA)
1053
1054% Hints: contents = get(hObject,'String') returns popupmenu_bar7 contents as cell array
1055%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar7
1056setbar(handles);
1057
1058
1059% --- Executes on button press in pushbutton_refresh.
1060function pushbutton_refresh_Callback(hObject, eventdata, handles)
1061% hObject    handle to pushbutton_refresh (see GCBO)
1062% eventdata  reserved - to be defined in a future version of MATLAB
1063% handles    structure with handles and user data (see GUIDATA)
1064
1065%--------------------------------------------------------------------------
1066function read_tango(handles)
1067% Reads Tango values for LT1.
1068
1069% Get magnet AO
1070AOmagnet = getappdata(handles.figure1,'AOmagnet');
1071FamilyName = fieldnames(AOmagnet);
1072
1073for k1 = 1:length(FamilyName)
1074        % get attribute readback value
1075        magnet = AOmagnet.(FamilyName{k1});
1076        AOmagnet.(FamilyName{k1}).TangoVal = ...
1077            getam(FamilyName{k1},'Online');
1078end
1079
1080% save data
1081setappdata(handles.figure1,'AOmagnet',AOmagnet)
1082
1083%--------------------------------------------------------------------------
1084function write_tango(handles);
1085%-- Writes Tango values
1086%% Ecriture courant aimant sur les devices serveurs
1087
1088% Get magnet AO
1089AOmagnet = getappdata(handles.figure1,'AOmagnet');
1090
1091FamilyName = fieldnames(AOmagnet);
1092for k1 = 1:length(FamilyName)
1093    magnet = AOmagnet.(FamilyName{k1});
1094    setsp(magnet, magnet.ModelVal,'Online');
1095end
1096
1097%--------------------------------------------------------------------------
1098function devicelist = get_device_name(machine,property,magnet)
1099% get device list from mapping read in tango database
1100
1101map        = tango_get_db_property(machine,property);
1102sep        = cell2mat(regexpi(map,'::','once'))-1;
1103devicelist = regexprep(map,[magnet '\d*::'],'')';
1104
1105% --- Executes during object creation, after setting all properties.
1106function pushbutton_reload_CreateFcn(hObject, eventdata, handles)
1107% hObject    handle to pushbutton_reload (see GCBO)
1108% eventdata  reserved - to be defined in a future version of MATLAB
1109% handles    empty - handles not created until after all CreateFcns called
1110
1111% --- Executes on button press in pushbutton_model2online.
1112function pushbutton_model2online_Callback(hObject, eventdata, handles)
1113% hObject    handle to pushbutton_model2online (see GCBO)
1114% eventdata  reserved - to be defined in a future version of MATLAB
1115% handles    structure with handles and user data (see GUIDATA)
1116
1117AOmagnet      = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
1118
1119user_response = questdlg('Do you want to write setvalues to LT1?');
1120switch user_response
1121    case{'No','Cancel'}
1122        return;
1123    case{'Yes'}
1124        FamilyName = fieldnames(AOmagnet);
1125        for k1 = 1:length(FamilyName)
1126            AOmagnet.(FamilyName{k1}).TangoVal = ...
1127                AOmagnet.(FamilyName{k1}).ModelVal;
1128        end
1129        write_tango(handles);
1130end
1131
1132% save data
1133setappdata(handles.figure1,'AOmagnet',AOmagnet)
1134
1135% --- Executes on button press in pushbutton_online2model.
1136function pushbutton_online2model_Callback(hObject, eventdata, handles)
1137% hObject    handle to pushbutton_online2model (see GCBO)
1138% eventdata  reserved - to be defined in a future version of MATLAB
1139% handles    structure with handles and user data (see GUIDATA)
1140
1141% Online values stored in model values except dipoles
1142user_response = questdlg('Do you want to read TANGO setvalues from LT1?');
1143switch user_response
1144    case{'No','Cancel'}
1145        return;
1146    case{'Yes'}
1147        read_tango(handles);
1148end
1149
1150AOmagnet    = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
1151
1152FamilyName = fieldnames(AOmagnet);
1153for k1 = 1:length(FamilyName)   
1154        AOmagnet.(FamilyName{k1}).ModelVal = AOmagnet.(FamilyName{k1}).TangoVal;
1155end
1156       
1157%% Initialise les sliders et editboxes
1158for k = 1:handles.sliderNumber
1159    name = ['popupmenu_bar' num2str(k)];
1160    contents = get(handles.(name),'String');
1161    magnet = contents{get(handles.(name),'Value')};
1162   
1163    Qname = ['QP' num2str(k)];   
1164   
1165    switch magnet
1166        case AOmagnet.QP.CommonNames           
1167            val = AOmagnet.QP.TangoVal(str2double(magnet(end)));
1168        case AOmagnet.CH.CommonNames
1169            val = AOmagnet.CH.TangoVal(str2double(magnet(end)));
1170        case AOmagnet.CV.CommonNames
1171            val = AOmagnet.CV.TangoVal(str2double(magnet(end)));
1172    end
1173   
1174    set(handles.(['slider' Qname]),'Value', val);
1175    set(handles.(['edit' Qname]),'string', num2str(val));
1176end
1177
1178set_model_values(handles);
1179
1180handles = computeTwiss(handles);
1181plot_axes(handles,handles.ytype);
1182%mat
1183        %ylim([0 130]);
1184% Update handles structure
1185guidata(hObject, handles);
1186
1187%% Update date
1188set(handles.text_date,'String',datestr(now,0));
1189
1190%save data
1191setappdata(handles.figure1,'AOmagnet',AOmagnet);
1192
1193%--------------------------------------------------------------------------
1194function handles = init_handles(handles)
1195%% Inits structure storing all the magnet data
1196
1197%% AT model used
1198% global THERING;
1199
1200A1 = getao; % Load AO for the first time
1201AOmagnet = [];
1202list = findmemberof('Magnet');
1203for k = 1:length(list)
1204    AOmagnet.(list{k}) = A1.(list{k});
1205end
1206clear A1;
1207
1208%save data
1209setappdata(handles.figure1,'AOmagnet',AOmagnet);
1210
1211store_model_values(handles);
1212
1213%% Update time
1214set(handles.text_date,'String',datestr(now,0));
1215
1216%--------------------------------------------------------------------------
1217function store_model_values(handles)
1218%% Stores model values in AOmagnet
1219
1220AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure
1221
1222% Loop over magnet types
1223FamilyName = fieldnames(AOmagnet);
1224
1225for k1 = 1:length(FamilyName)
1226    AOmagnet.(FamilyName{k1}).ModelVal = getam(FamilyName{k1},'Model');
1227end
1228
1229setappdata(handles.figure1,'AOmagnet',AOmagnet);
1230
1231%--------------------------------------------------------------------------
1232function set_model_values(handles)
1233% Set Modelvalue into LT1 AT model
1234
1235AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure
1236
1237%% Set model values to AT
1238FamilyName = fieldnames(AOmagnet);
1239
1240for k1 = 1:length(FamilyName)
1241    magnet = AOmagnet.(FamilyName{k1});
1242    setsp(FamilyName{k1}, magnet.ModelVal,'Model');
1243end
1244
1245
1246%--------------------------------------------------------------------------
1247function submenu_print_setpoint_Callback(hObject, eventdata, handles)
1248% hObject    handle to submenu_print_setpoint (see GCBO)
1249% eventdata  reserved - to be defined in a future version of MATLAB
1250% handles    structure with handles and user data (see GUIDATA)
1251
1252
1253%--------------------------------------------------------------------------
1254function submenu_print_model_Callback(hObject, eventdata, handles)
1255% hObject    handle to submenu_print_model (see GCBO)
1256% eventdata  reserved - to be defined in a future version of MATLAB
1257% handles    structure with handles and user data (see GUIDATA)
1258
1259
1260% -------------------------------------------------------------------------
1261function submenu_save_setpoint_Callback(hObject, eventdata, handles)
1262% hObject    handle to submenu_save_setpoint (see GCBO)
1263% eventdata  reserved - to be defined in a future version of MATLAB
1264% handles    structure with handles and user data (see GUIDATA)
1265
1266
1267% -------------------------------------------------------------------------
1268function submenu_save_model_Callback(hObject, eventdata, handles)
1269% hObject    handle to submenu_save_model (see GCBO)
1270% eventdata  reserved - to be defined in a future version of MATLAB
1271% handles    structure with handles and user data (see GUIDATA)
1272
1273
1274% -------------------------------------------------------------------------
1275function submenu_load_setpoint_Callback(hObject, eventdata, handles)
1276% hObject    handle to submenu_load_setpoint (see GCBO)
1277% eventdata  reserved - to be defined in a future version of MATLAB
1278% handles    structure with handles and user data (see GUIDATA)
1279
1280
1281%--------------------------------------------------------------------------
1282function submenu_load_model_Callback(hObject, eventdata, handles)
1283% hObject    handle to submenu_load_model (see GCBO)
1284% eventdata  reserved - to be defined in a future version of MATLAB
1285% handles    structure with handles and user data (see GUIDATA)
1286
1287
1288%--------------------------------------------------------------------------
1289function Untitled_1_Callback(hObject, eventdata, handles)
1290% hObject    handle to Untitled_1 (see GCBO)
1291% eventdata  reserved - to be defined in a future version of MATLAB
1292% handles    structure with handles and user data (see GUIDATA)
1293
1294
1295%--------------------------------------------------------------------------
1296function Untitled_4_Callback(hObject, eventdata, handles)
1297% hObject    handle to Untitled_4 (see GCBO)
1298% eventdata  reserved - to be defined in a future version of MATLAB
1299% handles    structure with handles and user data (see GUIDATA)
1300
1301
1302%--------------------------------------------------------------------------
1303function Untitled_7_Callback(hObject, eventdata, handles)
1304% hObject    handle to Untitled_7 (see GCBO)
1305% eventdata  reserved - to be defined in a future version of MATLAB
1306% handles    structure with handles and user data (see GUIDATA)
1307
1308
1309% --------------------------------------------------------------------
1310function submenu_dump_model_Callback(hObject, eventdata, handles)
1311% hObject    handle to submenu_dump_model (see GCBO)
1312% eventdata  reserved - to be defined in a future version of MATLAB
1313% handles    structure with handles and user data (see GUIDATA)
1314
1315% Get magnet AO
1316AOmagnet = getappdata(handles.figure1,'AOmagnet');
1317
1318fprintf('  DeviceName     Model   s(m)   phasex betax(m) etax(m) xcod(mm) phasez betaz(m) etaz(m) zcod(mm)\n')
1319
1320FamilyName = fieldnames(AOmagnet);
1321for k1 = 1:length(FamilyName)
1322    alias = AOmagnet.(FamilyName{k1});
1323    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1324        fprintf('%15s %6.2f %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f \n', ...
1325            alias.DeviceName{k2}, alias.ModelVal(k2), ...
1326            handles.spos(alias.AT.ATIndex(k2),1), handles.phase(alias.AT.ATIndex(k2),1), ...
1327            handles.beta(alias.AT.ATIndex(k2),1), handles.eta(alias.AT.ATIndex(k2),1), ...
1328            handles.cod(alias.AT.ATIndex(k2),1), ...
1329            handles.phase(alias.AT.ATIndex(k2),2), ...
1330            handles.beta(alias.AT.ATIndex(k2),2), handles.eta(alias.AT.ATIndex(k2),2), ...
1331            handles.cod(alias.AT.ATIndex(k2),2));
1332    end
1333end
1334
1335
1336%--------------------------------------------------------------------------
1337function submenu_dump_setpoint_Callback(hObject, eventdata, handles)
1338% hObject    handle to submenu_dump_setpoint (see GCBO)
1339% eventdata  reserved - to be defined in a future version of MATLAB
1340% handles    structure with handles and user data (see GUIDATA)
1341
1342% Get magnet AO
1343AOmagnet = getappdata(handles.figure1,'AOmagnet');
1344
1345fprintf('\n\n  DeviceName     TANGO\n')
1346
1347FamilyName = fieldnames(AOmagnet);
1348for k1 = 1:length(FamilyName)
1349    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1350        alias = AOmagnet.(FamilyName{k1});
1351        fprintf('%15s %6.2f \n', alias.DeviceName{k2}, ...
1352            alias.TangoVal(k2));
1353    end
1354end
1355
1356
1357%--------------------------------------------------------------------------
1358function submenu_dump_soleil_setpoint_Callback(hObject, eventdata, handles)
1359% hObject    handle to submenu_dump_soleil_setpoint (see GCBO)
1360% eventdata  reserved - to be defined in a future version of MATLAB
1361% handles    structure with handles and user data (see GUIDATA)
1362
1363fprintf('\n\n  DeviceName     Model  TANGO\n')
1364
1365% Get magnet AO
1366AOmagnet = getappdata(handles.figure1,'AOmagnet');
1367
1368FamilyName = fieldnames(AOmagnet);
1369for k1 = 1:length(FamilyName)
1370    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1371        alias = AOmagnet.(FamilyName{k1});
1372        fprintf('%15s %6.2f %6.2f\n', alias.DeviceName{k2}, ...
1373            alias.ModelVal(k2), alias.TangoVal(k2));
1374    end
1375end
1376
1377
1378% --------------------------------------------------------------------
1379function twiss_parameters_Callback(hObject, eventdata, handles)
1380% hObject    handle to twiss_parameters (see GCBO)
1381% eventdata  reserved - to be defined in a future version of MATLAB
1382% handles    structure with handles and user data (see GUIDATA)
1383
1384
1385% --------------------------------------------------------------------
1386function submenu_twissparameters_entry_Callback(hObject, eventdata, handles)
1387% hObject    handle to submenu_twissparameters_entry (see GCBO)
1388% eventdata  reserved - to be defined in a future version of MATLAB
1389% handles    structure with handles and user data (see GUIDATA)
1390
1391twiss_parameters_entry(handles)
1392
1393
1394% --- Executes during object creation, after setting all properties.
1395function figure1_CreateFcn(hObject, eventdata, handles)
1396% hObject    handle to figure1 (see GCBO)
1397% eventdata  reserved - to be defined in a future version of MATLAB
1398% handles    empty - handles not created until after all CreateFcns called
1399
1400
1401% --- Executes during object deletion, before destroying properties.
1402function figure1_DeleteFcn(hObject, eventdata, handles)
1403% hObject    handle to figure1 (see GCBO)
1404% eventdata  reserved - to be defined in a future version of MATLAB
1405% handles    structure with handles and user data (see GUIDATA)
1406
1407% --- Executes during object deletion, before destroying properties.
1408function sliderQP1L_DeleteFcn(hObject, eventdata, handles)
1409% hObject    handle to sliderQP1L (see GCBO)
1410% eventdata  reserved - to be defined in a future version of MATLAB
1411% handles    structure with handles and user data (see GUIDATA)
1412
1413
1414% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1415% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP1L.
1416function sliderQP1L_ButtonDownFcn(hObject, eventdata, handles)
1417% hObject    handle to sliderQP1L (see GCBO)
1418% eventdata  reserved - to be defined in a future version of MATLAB
1419% handles    structure with handles and user data (see GUIDATA)
1420
1421
1422% --- Executes on key press with focus on sliderQP1L and none of its controls.
1423function sliderQP1L_KeyPressFcn(hObject, eventdata, handles)
1424% hObject    handle to sliderQP1L (see GCBO)
1425% eventdata  structure with the following fields (see UICONTROL)
1426%       Key: name of the key that was pressed, in lower case
1427%       Character: character interpretation of the key(s) that was pressed
1428%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1429% handles    structure with handles and user data (see GUIDATA)
1430
1431
1432% --- Executes during object deletion, before destroying properties.
1433function sliderQP2L_DeleteFcn(hObject, eventdata, handles)
1434% hObject    handle to sliderQP2L (see GCBO)
1435% eventdata  reserved - to be defined in a future version of MATLAB
1436% handles    structure with handles and user data (see GUIDATA)
1437
1438
1439% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1440% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP2L.
1441function sliderQP2L_ButtonDownFcn(hObject, eventdata, handles)
1442% hObject    handle to sliderQP2L (see GCBO)
1443% eventdata  reserved - to be defined in a future version of MATLAB
1444% handles    structure with handles and user data (see GUIDATA)
1445
1446
1447% --- Executes on key press with focus on sliderQP2L and none of its controls.
1448function sliderQP2L_KeyPressFcn(hObject, eventdata, handles)
1449% hObject    handle to sliderQP2L (see GCBO)
1450% eventdata  structure with the following fields (see UICONTROL)
1451%       Key: name of the key that was pressed, in lower case
1452%       Character: character interpretation of the key(s) that was pressed
1453%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1454% handles    structure with handles and user data (see GUIDATA)
1455
1456
1457% --- Executes during object deletion, before destroying properties.
1458function sliderQP3L_DeleteFcn(hObject, eventdata, handles)
1459% hObject    handle to sliderQP3L (see GCBO)
1460% eventdata  reserved - to be defined in a future version of MATLAB
1461% handles    structure with handles and user data (see GUIDATA)
1462
1463
1464% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1465% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP3L.
1466function sliderQP3L_ButtonDownFcn(hObject, eventdata, handles)
1467% hObject    handle to sliderQP3L (see GCBO)
1468% eventdata  reserved - to be defined in a future version of MATLAB
1469% handles    structure with handles and user data (see GUIDATA)
1470
1471
1472% --- Executes on key press with focus on sliderQP3L and none of its controls.
1473function sliderQP3L_KeyPressFcn(hObject, eventdata, handles)
1474% hObject    handle to sliderQP3L (see GCBO)
1475% eventdata  structure with the following fields (see UICONTROL)
1476%       Key: name of the key that was pressed, in lower case
1477%       Character: character interpretation of the key(s) that was pressed
1478%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1479% handles    structure with handles and user data (see GUIDATA)
1480
1481
1482% --- Executes during object deletion, before destroying properties.
1483function sliderQP4L_DeleteFcn(hObject, eventdata, handles)
1484% hObject    handle to sliderQP4L (see GCBO)
1485% eventdata  reserved - to be defined in a future version of MATLAB
1486% handles    structure with handles and user data (see GUIDATA)
1487
1488
1489% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1490% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP4L.
1491function sliderQP4L_ButtonDownFcn(hObject, eventdata, handles)
1492% hObject    handle to sliderQP4L (see GCBO)
1493% eventdata  reserved - to be defined in a future version of MATLAB
1494% handles    structure with handles and user data (see GUIDATA)
1495
1496
1497% --- Executes on key press with focus on sliderQP4L and none of its controls.
1498function sliderQP4L_KeyPressFcn(hObject, eventdata, handles)
1499% hObject    handle to sliderQP4L (see GCBO)
1500% eventdata  structure with the following fields (see UICONTROL)
1501%       Key: name of the key that was pressed, in lower case
1502%       Character: character interpretation of the key(s) that was pressed
1503%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1504% handles    structure with handles and user data (see GUIDATA)
1505
1506
1507% --- Executes during object deletion, before destroying properties.
1508function sliderQP5L_DeleteFcn(hObject, eventdata, handles)
1509% hObject    handle to sliderQP5L (see GCBO)
1510% eventdata  reserved - to be defined in a future version of MATLAB
1511% handles    structure with handles and user data (see GUIDATA)
1512
1513
1514% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1515% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP5L.
1516function sliderQP5L_ButtonDownFcn(hObject, eventdata, handles)
1517% hObject    handle to sliderQP5L (see GCBO)
1518% eventdata  reserved - to be defined in a future version of MATLAB
1519% handles    structure with handles and user data (see GUIDATA)
1520
1521
1522% --- Executes on key press with focus on sliderQP5L and none of its controls.
1523function sliderQP5L_KeyPressFcn(hObject, eventdata, handles)
1524% hObject    handle to sliderQP5L (see GCBO)
1525% eventdata  structure with the following fields (see UICONTROL)
1526%       Key: name of the key that was pressed, in lower case
1527%       Character: character interpretation of the key(s) that was pressed
1528%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1529% handles    structure with handles and user data (see GUIDATA)
1530
1531
1532% --- Executes during object deletion, before destroying properties.
1533function sliderQP6L_DeleteFcn(hObject, eventdata, handles)
1534% hObject    handle to sliderQP6L (see GCBO)
1535% eventdata  reserved - to be defined in a future version of MATLAB
1536% handles    structure with handles and user data (see GUIDATA)
1537
1538
1539% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1540% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP6L.
1541function sliderQP6L_ButtonDownFcn(hObject, eventdata, handles)
1542% hObject    handle to sliderQP6L (see GCBO)
1543% eventdata  reserved - to be defined in a future version of MATLAB
1544% handles    structure with handles and user data (see GUIDATA)
1545
1546
1547% --- Executes on key press with focus on sliderQP6L and none of its controls.
1548function sliderQP6L_KeyPressFcn(hObject, eventdata, handles)
1549% hObject    handle to sliderQP6L (see GCBO)
1550% eventdata  structure with the following fields (see UICONTROL)
1551%       Key: name of the key that was pressed, in lower case
1552%       Character: character interpretation of the key(s) that was pressed
1553%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1554% handles    structure with handles and user data (see GUIDATA)
1555
1556
1557% --- Executes during object deletion, before destroying properties.
1558function sliderQP7L_DeleteFcn(hObject, eventdata, handles)
1559% hObject    handle to sliderQP7L (see GCBO)
1560% eventdata  reserved - to be defined in a future version of MATLAB
1561% handles    structure with handles and user data (see GUIDATA)
1562
1563
1564% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1565% --- Otherwise, executes on mouse press in 5 pixel border or over sliderQP7L.
1566function sliderQP7L_ButtonDownFcn(hObject, eventdata, handles)
1567% hObject    handle to sliderQP7L (see GCBO)
1568% eventdata  reserved - to be defined in a future version of MATLAB
1569% handles    structure with handles and user data (see GUIDATA)
1570
1571
1572% --- Executes on key press with focus on sliderQP7L and none of its controls.
1573function sliderQP7L_KeyPressFcn(hObject, eventdata, handles)
1574% hObject    handle to sliderQP7L (see GCBO)
1575% eventdata  structure with the following fields (see UICONTROL)
1576%       Key: name of the key that was pressed, in lower case
1577%       Character: character interpretation of the key(s) that was pressed
1578%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1579% handles    structure with handles and user data (see GUIDATA)
1580
1581
1582% --- Executes during object deletion, before destroying properties.
1583function editQP1L_DeleteFcn(hObject, eventdata, handles)
1584% hObject    handle to editQP1L (see GCBO)
1585% eventdata  reserved - to be defined in a future version of MATLAB
1586% handles    structure with handles and user data (see GUIDATA)
1587
1588
1589% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1590% --- Otherwise, executes on mouse press in 5 pixel border or over editQP1L.
1591function editQP1L_ButtonDownFcn(hObject, eventdata, handles)
1592% hObject    handle to editQP1L (see GCBO)
1593% eventdata  reserved - to be defined in a future version of MATLAB
1594% handles    structure with handles and user data (see GUIDATA)
1595
1596
1597% --- Executes on key press with focus on editQP1L and none of its controls.
1598function editQP1L_KeyPressFcn(hObject, eventdata, handles)
1599% hObject    handle to editQP1L (see GCBO)
1600% eventdata  structure with the following fields (see UICONTROL)
1601%       Key: name of the key that was pressed, in lower case
1602%       Character: character interpretation of the key(s) that was pressed
1603%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1604% handles    structure with handles and user data (see GUIDATA)
1605
1606
1607% --- Executes during object deletion, before destroying properties.
1608function editQP2L_DeleteFcn(hObject, eventdata, handles)
1609% hObject    handle to editQP2L (see GCBO)
1610% eventdata  reserved - to be defined in a future version of MATLAB
1611% handles    structure with handles and user data (see GUIDATA)
1612
1613
1614% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1615% --- Otherwise, executes on mouse press in 5 pixel border or over editQP2L.
1616function editQP2L_ButtonDownFcn(hObject, eventdata, handles)
1617% hObject    handle to editQP2L (see GCBO)
1618% eventdata  reserved - to be defined in a future version of MATLAB
1619% handles    structure with handles and user data (see GUIDATA)
1620
1621
1622% --- Executes on key press with focus on editQP2L and none of its controls.
1623function editQP2L_KeyPressFcn(hObject, eventdata, handles)
1624% hObject    handle to editQP2L (see GCBO)
1625% eventdata  structure with the following fields (see UICONTROL)
1626%       Key: name of the key that was pressed, in lower case
1627%       Character: character interpretation of the key(s) that was pressed
1628%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1629% handles    structure with handles and user data (see GUIDATA)
1630
1631
1632% --- Executes during object deletion, before destroying properties.
1633function editQP3L_DeleteFcn(hObject, eventdata, handles)
1634% hObject    handle to editQP3L (see GCBO)
1635% eventdata  reserved - to be defined in a future version of MATLAB
1636% handles    structure with handles and user data (see GUIDATA)
1637
1638
1639% --- If Enable == 'on', executes on mouse press in 5 pixel border.
1640% --- Otherwise, executes on mouse press in 5 pixel border or over editQP3L.
1641function editQP3L_ButtonDownFcn(hObject, eventdata, handles)
1642% hObject    handle to editQP3L (see GCBO)
1643% eventdata  reserved - to be defined in a future version of MATLAB
1644% handles    structure with handles and user data (see GUIDATA)
1645
1646
1647% --- Executes on key press with focus on editQP3L and none of its controls.
1648function editQP3L_KeyPressFcn(hObject, eventdata, handles)
1649% hObject    handle to editQP3L (see GCBO)
1650% eventdata  structure with the following fields (see UICONTROL)
1651%       Key: name of the key that was pressed, in lower case
1652%       Character: character interpretation of the key(s) that was pressed
1653%       Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
1654% handles    structure with handles and user data (see GUIDATA)
Note: See TracBrowser for help on using the repository browser.