source: MML/trunk/machine/SOLEIL/common/optics_LT1_LT2.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 49.0 KB
Line 
1function varargout = optics_LT1_LT2(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 09-Mar-2005 10:49:46
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_LT1_LT2_OpeningFcn, ...
32                   'gui_OutputFcn',  @optics_LT1_LT2_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_LT1_LT2_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 {'LT1'}
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       = [8.1 8.1];
73        twissdatain.alpha      = [0 0];
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', 'LT1 Optical functions');
80       
81    case {'LT2'}
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', 'LT2 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 LT1 and LT2 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)
112val_max = getmaxsp('QP');
113val_min = getminsp('QP');
114
115%% Number of sliders   
116handles.sliderNumber = 7;
117
118for k = 1:handles.sliderNumber,
119    name = strcat('sliderQP',num2str(k))
120    set(handles.(name),'Max',val_max(k),'Min',val_min(k));
121end
122
123
124%% liste de aimants a controler (menu deroulant)
125list = [AO.QP.CommonNames;...
126        AO.CH.CommonNames; ...
127        AO.CV.CommonNames
128        ];
129
130%% Automatic configuration for sliders
131for k = 1:handles.sliderNumber
132    name = ['popupmenu_bar' num2str(k)];
133    set(handles.(name),'String',list);
134    set(handles.(name),'Value',k);
135end
136
137%% graphe par defaut
138axes(handles.axes1);
139handles.xtype = 'spos';
140handles.ytype = 'beta';
141
142%% initialisation AT et IHM
143handles = restart(handles);
144
145%% Read Tango values
146%read_tango(handles);
147
148% UIWAIT makes optics_LT1_LT2 wait for user response (see UIRESUME)
149% uiwait(handles.figure1);
150set(0,'DefaultAxesXgrid','on','DefaultAxesYgrid','on');
151
152%% graphe symboles
153axes(handles.axes2);
154drawlattice(0,0.8);
155set(handles.axes2,'Xlim',[handles.spos(1) handles.spos(end)], ...
156    'XTick',[],'YTick',[]);
157
158
159% Update handles structure
160guidata(hObject, handles);
161
162%% -------------------------------------
163function handles = computeTwiss(handles)
164% update ATmodel
165% compute new twiss parameters
166%
167global THERING;
168
169%%% parameters at the entrance of the line
170% twissdatain.ElemIndex=1;
171% twissdatain.SPos=0;
172% twissdatain.ClosedOrbit=[1e-3 0 2e-3 0]'*0;
173% twissdatain.M44=eye(4);
174%
175% if isequal(isfield(twissdatain,'beta'),0)
176 
177 if handles.restart == 1
178     twissdatain = getappdata(handles.figure1,'twissdatain0');
179     handles.restart = 0;
180 else
181     twissdatain = getappdata(handles.figure1,'twissdatain');
182 end
183%     twissdatain.beta= [8.1 8.1];
184%     twissdatain.alpha= [0 0];
185% else
186%     twissdatain = getappdata(handles.figure1,'twissdatain')
187% end
188
189% twissdatain.mu= [0 0];
190% twissdatain.Dispersion= [0 0 0 0]';
191
192%%% get twiss paramaters
193TD = twissline(THERING,0.0,twissdatain,1:length(THERING),'chroma');
194
195handles.twissdatain = twissdatain;
196handles.beta  = cat(1,TD.beta);
197handles.cod   = cat(2,TD.ClosedOrbit)';
198handles.eta   = cat(2,TD.Dispersion)';
199handles.spos  = cat(1,TD.SPos);
200handles.phase = cat(1,TD.mu);
201
202setappdata(handles.figure1,'twissdatain',twissdatain);
203
204% --- Outputs from this function are returned to the command line.
205function varargout = optics_LT1_LT2_OutputFcn(hObject, eventdata, handles)
206% varargout  cell array for returning output args (see VARARGOUT);
207% hObject    handle to figure
208% eventdata  reserved - to be defined in a future version of MATLAB
209% handles    structure with handles and user data (see GUIDATA)
210
211% Get default command line output from handles structure
212varargout{1} = handles.output;
213
214% --- Executes during object creation, after setting all properties.
215function sliderQP1_CreateFcn(hObject, eventdata, handles)
216% hObject    handle to sliderQP1 (see GCBO)
217% eventdata  reserved - to be defined in a future version of MATLAB
218% handles    empty - handles not created until after all CreateFcns called
219
220% Hint: slider controls usually have a light gray background, change
221%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
222usewhitebg = 1;
223if usewhitebg
224    set(hObject,'BackgroundColor',[.9 .9 .9]);
225else
226    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
227end
228
229% --- Executes on slider movement.
230function sliderQP1_Callback(hObject, eventdata, handles)
231% hObject    handle to sliderQP1 (see GCBO)
232% eventdata  reserved - to be defined in a future version of MATLAB
233% handles    structure with handles and user data (see GUIDATA)
234
235% Hints: get(hObject,'Value') returns position of slider
236%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
237
238handles = setslider(hObject,handles);
239guidata(hObject, handles);
240
241% --- Executes during object creation, after setting all properties.
242function editQP1_CreateFcn(hObject, eventdata, handles)
243% hObject    handle to editQP1 (see GCBO)
244% eventdata  reserved - to be defined in a future version of MATLAB
245% handles    empty - handles not created until after all CreateFcns called
246
247% Hint: edit controls usually have a white background on Windows.
248%       See ISPC and COMPUTER.
249if ispc
250    set(hObject,'BackgroundColor','green');
251else
252    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
253end
254
255% --- Executes on slider movement.
256function editQP1_Callback(hObject, eventdata, handles)
257% hObject    handle to editQP1 (see GCBO)
258% eventdata  reserved - to be defined in a future version of MATLAB
259% handles    structure with handles and user data (see GUIDATA)
260
261% Hints: get(hObject,'String') returns contents of editQP1 as text
262%        str2double(get(hObject,'String')) returns contents of editQP1 as a double
263handles = setedit(handles);
264guidata(hObject, handles);
265
266% --- Executes during object creation, after setting all properties.
267function sliderQP2_CreateFcn(hObject, eventdata, handles)
268% hObject    handle to sliderQP2 (see GCBO)
269% eventdata  reserved - to be defined in a future version of MATLAB
270% handles    empty - handles not created until after all CreateFcns called
271
272% Hint: slider controls usually have a light gray background, change
273%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
274usewhitebg = 1;
275if usewhitebg
276    set(hObject,'BackgroundColor',[.9 .9 .9]);
277else
278    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
279end
280
281% --- Executes on slider movement.
282function sliderQP2_Callback(hObject, eventdata, handles)
283% hObject    handle to sliderQP2 (see GCBO)
284% eventdata  reserved - to be defined in a future version of MATLAB
285% handles    structure with handles and user data (see GUIDATA)
286
287% Hints: get(hObject,'Value') returns position of slider
288%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
289handles = setslider(hObject,handles);
290guidata(hObject, handles);
291
292% --- Executes during object creation, after setting all properties.
293function editQP2_CreateFcn(hObject, eventdata, handles)
294% hObject    handle to editQP2 (see GCBO)
295% eventdata  reserved - to be defined in a future version of MATLAB
296% handles    empty - handles not created until after all CreateFcns called
297
298% Hint: edit controls usually have a white background on Windows.
299%       See ISPC and COMPUTER.
300if ispc
301    set(hObject,'BackgroundColor','white');
302else
303    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
304end
305
306function editQP2_Callback(hObject, eventdata, handles)
307% hObject    handle to editQP2 (see GCBO)
308% eventdata  reserved - to be defined in a future version of MATLAB
309% handles    structure with handles and user data (see GUIDATA)
310
311% Hints: get(hObject,'String') returns contents of editQP2 as text
312%        str2double(get(hObject,'String')) returns contents of editQP2 as a double
313handles = setedit(handles);
314guidata(hObject, handles);
315
316% --- Executes during object creation, after setting all properties.
317function sliderQP3_CreateFcn(hObject, eventdata, handles)
318% hObject    handle to sliderQP3 (see GCBO)
319% eventdata  reserved - to be defined in a future version of MATLAB
320% handles    empty - handles not created until after all CreateFcns called
321
322% Hint: slider controls usually have a light gray background, change
323%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
324usewhitebg = 1;
325if usewhitebg
326    set(hObject,'BackgroundColor',[.9 .9 .9]);
327else
328    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
329end
330
331% --- Executes on slider movement.
332function sliderQP3_Callback(hObject, eventdata, handles)
333% hObject    handle to sliderQP3 (see GCBO)
334% eventdata  reserved - to be defined in a future version of MATLAB
335% handles    structure with handles and user data (see GUIDATA)
336
337% Hints: get(hObject,'Value') returns position of slider
338%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
339handles = setslider(hObject,handles);
340guidata(hObject, handles);
341
342
343% --- Executes during object creation, after setting all properties.
344function editQP3_CreateFcn(hObject, eventdata, handles)
345% hObject    handle to editQP3 (see GCBO)
346% eventdata  reserved - to be defined in a future version of MATLAB
347% handles    empty - handles not created until after all CreateFcns called
348
349% Hint: edit controls usually have a white background on Windows.
350%       See ISPC and COMPUTER.
351if ispc
352    set(hObject,'BackgroundColor','white');
353else
354    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
355end
356
357function editQP3_Callback(hObject, eventdata, handles)
358% hObject    handle to editQP3 (see GCBO)
359% eventdata  reserved - to be defined in a future version of MATLAB
360% handles    structure with handles and user data (see GUIDATA)
361
362% Hints: get(hObject,'String') returns contents of editQP3 as text
363%        str2double(get(hObject,'String')) returns contents of editQP3 as a double
364handles = setedit(handles);
365guidata(hObject, handles);
366
367% --- Executes during object creation, after setting all properties.
368function editQP4_CreateFcn(hObject, eventdata, handles)
369% hObject    handle to editQP4 (see GCBO)
370% eventdata  reserved - to be defined in a future version of MATLAB
371% handles    empty - handles not created until after all CreateFcns called
372
373% Hint: edit controls usually have a white background on Windows.
374%       See ISPC and COMPUTER.
375if ispc
376    set(hObject,'BackgroundColor','white');
377else
378    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
379end
380
381function editQP4_Callback(hObject, eventdata, handles)
382% hObject    handle to editQP4 (see GCBO)
383% eventdata  reserved - to be defined in a future version of MATLAB
384% handles    structure with handles and user data (see GUIDATA)
385
386% Hints: get(hObject,'String') returns contents of editQP4 as text
387%        str2double(get(hObject,'String')) returns contents of editQP4 as a double
388handles = setedit(handles);
389
390
391% --- Executes during object creation, after setting all properties.
392function sliderQP4_CreateFcn(hObject, eventdata, handles)
393% hObject    handle to sliderQP4 (see GCBO)
394% eventdata  reserved - to be defined in a future version of MATLAB
395% handles    empty - handles not created until after all CreateFcns called
396
397% Hint: slider controls usually have a light gray background, change
398%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
399usewhitebg = 1;
400if usewhitebg
401    set(hObject,'BackgroundColor',[.9 .9 .9]);
402else
403    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
404end
405
406
407% --- Executes on slider movement.
408function sliderQP4_Callback(hObject, eventdata, handles)
409% hObject    handle to sliderQP4 (see GCBO)
410% eventdata  reserved - to be defined in a future version of MATLAB
411% handles    structure with handles and user data (see GUIDATA)
412
413% Hints: get(hObject,'Value') returns position of slider
414%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
415handles = setslider(hObject,handles);
416guidata(hObject, handles);
417
418% --- Executes during object creation, after setting all properties.
419function editQP5_CreateFcn(hObject, eventdata, handles)
420% hObject    handle to editQP5 (see GCBO)
421% eventdata  reserved - to be defined in a future version of MATLAB
422% handles    empty - handles not created until after all CreateFcns called
423
424% Hint: edit controls usually have a white background on Windows.
425%       See ISPC and COMPUTER.
426if ispc
427    set(hObject,'BackgroundColor','white');
428else
429    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
430end
431
432
433function editQP5_Callback(hObject, eventdata, handles)
434% hObject    handle to editQP5 (see GCBO)
435% eventdata  reserved - to be defined in a future version of MATLAB
436% handles    structure with handles and user data (see GUIDATA)
437
438% Hints: get(hObject,'String') returns contents of editQP5 as text
439%        str2double(get(hObject,'String')) returns contents of editQP5 as a double
440handles = setedit(handles);
441guidata(hObject, handles);
442
443% --- Executes during object creation, after setting all properties.
444function sliderQP5_CreateFcn(hObject, eventdata, handles)
445% hObject    handle to sliderQP5 (see GCBO)
446% eventdata  reserved - to be defined in a future version of MATLAB
447% handles    empty - handles not created until after all CreateFcns called
448
449% Hint: slider controls usually have a light gray background, change
450%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
451usewhitebg = 1;
452if usewhitebg
453    set(hObject,'BackgroundColor',[.9 .9 .9]);
454else
455    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
456end
457
458% --- Executes on slider movement.
459function sliderQP5_Callback(hObject, eventdata, handles)
460% hObject    handle to sliderQP5 (see GCBO)
461% eventdata  reserved - to be defined in a future version of MATLAB
462% handles    structure with handles and user data (see GUIDATA)
463
464% Hints: get(hObject,'Value') returns position of slider
465%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
466handles = setslider(hObject,handles);
467guidata(hObject, handles);
468
469% --- Executes during object creation, after setting all properties.
470function sliderQP6_CreateFcn(hObject, eventdata, handles)
471% hObject    handle to sliderQP6 (see GCBO)
472% eventdata  reserved - to be defined in a future version of MATLAB
473% handles    empty - handles not created until after all CreateFcns called
474
475% Hint: slider controls usually have a light gray background, change
476%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
477usewhitebg = 1;
478if usewhitebg
479    set(hObject,'BackgroundColor',[.9 .9 .9]);
480else
481    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
482end
483
484% --- Executes on slider movement.
485function sliderQP6_Callback(hObject, eventdata, handles)
486% hObject    handle to sliderQP6 (see GCBO)
487% eventdata  reserved - to be defined in a future version of MATLAB
488% handles    structure with handles and user data (see GUIDATA)
489
490% Hints: get(hObject,'Value') returns position of slider
491%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
492handles = setslider(hObject,handles);
493guidata(hObject, handles);
494
495% --- Executes during object creation, after setting all properties.
496function editQP6_CreateFcn(hObject, eventdata, handles)
497% hObject    handle to editQP6 (see GCBO)
498% eventdata  reserved - to be defined in a future version of MATLAB
499% handles    empty - handles not created until after all CreateFcns called
500
501% Hint: edit controls usually have a white background on Windows.
502%       See ISPC and COMPUTER.
503if ispc
504    set(hObject,'BackgroundColor','white');
505else
506    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
507end
508
509function editQP6_Callback(hObject, eventdata, handles)
510% hObject    handle to editQP6 (see GCBO)
511% eventdata  reserved - to be defined in a future version of MATLAB
512% handles    structure with handles and user data (see GUIDATA)
513
514% Hints: get(hObject,'String') returns contents of editQP6 as text
515%        str2double(get(hObject,'String')) returns contents of editQP6 as a double
516handles = setedit(handles);
517guidata(hObject, handles);
518
519% --- Executes during object creation, after setting all properties.
520function editQP7_CreateFcn(hObject, eventdata, handles)
521% hObject    handle to editQP7 (see GCBO)
522% eventdata  reserved - to be defined in a future version of MATLAB
523% handles    empty - handles not created until after all CreateFcns called
524
525% Hint: edit controls usually have a white background on Windows.
526%       See ISPC and COMPUTER.
527if ispc
528    set(hObject,'BackgroundColor','white');
529else
530    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
531end
532
533function editQP7_Callback(hObject, eventdata, handles)
534% hObject    handle to editQP7 (see GCBO)
535% eventdata  reserved - to be defined in a future version of MATLAB
536% handles    structure with handles and user data (see GUIDATA)
537
538% Hints: get(hObject,'String') returns contents of editQP7 as text
539%        str2double(get(hObject,'String')) returns contents of editQP7 as a double
540handles = setedit(handles);
541
542
543% --- Executes during object creation, after setting all properties.
544function sliderQP7_CreateFcn(hObject, eventdata, handles)
545% hObject    handle to sliderQP7 (see GCBO)
546% eventdata  reserved - to be defined in a future version of MATLAB
547% handles    empty - handles not created until after all CreateFcns called
548
549% Hint: slider controls usually have a light gray background, change
550%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
551usewhitebg = 1;
552if usewhitebg
553    set(hObject,'BackgroundColor',[.9 .9 .9]);
554else
555    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
556end
557
558% --- Executes on slider movement.
559function sliderQP7_Callback(hObject, eventdata, handles)
560% hObject    handle to sliderQP7 (see GCBO)
561% eventdata  reserved - to be defined in a future version of MATLAB
562% handles    structure with handles and user data (see GUIDATA)
563
564% Hints: get(hObject,'Value') returns position of slider
565%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
566handles = setslider(hObject,handles);
567guidata(hObject, handles);
568
569%-----------------------------------------------------------------------
570function plot_axes(handles,quoi)
571%%% fonction generique
572
573axes(handles.axes1); cla; hold on;
574
575switch handles.xtype
576    case 'spos'
577        x=handles.(handles.xtype);
578    case 'phase'
579        x=handles.(handles.xtype); x = x(:,1);
580end
581
582switch quoi
583    case 'beta'
584        plot(x,handles.beta(:,1),'r.-');
585        plot(x,handles.beta(:,2),'b.-');
586        ylabel('\beta (m)');
587        %mat
588   %ylim([0 130]);
589       
590    case 'eta'       
591        plot(x,handles.eta(:,1),'r.-');
592        plot(x,handles.eta(:,3),'b.-');
593        ylabel('\eta (m)');
594    case 'cod'       
595        plot(x,handles.cod(:,1)*1e3,'r.-');
596        plot(x,handles.cod(:,3)*1e3,'b.-');
597        ylabel('cod (mm)');
598    case 'phase'       
599        plot(x,handles.phase(:,1),'r.-');
600        plot(x,handles.phase(:,2),'b.-');
601        ylabel('phase ');
602end
603axis([x(1) x(end) -inf inf]);
604datalabel on
605
606%--------------------------------------------------------------------------
607function handles = setslider(hObject, handles)
608%%% fonction generique pour un slider de type aimant
609
610AOmagnet = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
611%% extrait le numero
612tagstring = get(hObject,'Tag');
613num = tagstring(regexp(tagstring,'\d'));
614magnet0 = ['QP' num2str(num)];
615val =  get(hObject,'Value');
616str = num2str(val);
617set(handles.(['edit' magnet0]),'string',str);
618
619%% Cherche le nom de l'aimant
620h = handles.(['popupmenu_bar' num]);
621contents = get(h,'String');
622magnet = contents{get(h,'Value')};
623handles = setATmagnet(handles,magnet,val);
624
625AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val;
626
627% save data
628setappdata(handles.figure1,'AOmagnet',AOmagnet)
629
630%--------------------------------------------------------------------------
631function handles = setATmagnet(handles,magnet,val)
632% function handles = setATmagnet(handles,magnet,val)
633% set  val as new setvalue of element 'magnet'
634% Replot current graph
635
636AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO
637
638% set value to AT model
639setsp(common2family(magnet), val, common2dev(magnet),'Model');
640
641% Recompute twiss parameters
642handles = computeTwiss(handles);
643% Replot everything
644plot_axes(handles,handles.ytype);
645%mat
646%ylim([0 130]);
647
648%--------------------------------------------------------------------------
649function handles = setedit(handles)
650% function setedit(handles)
651% generic callback for an edit box
652
653AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO
654
655%% construction automatique du nom du slider
656val = str2double(get(gcbo,'String'));
657tagstring = get(gcbo,'Tag');
658num = tagstring(regexp(tagstring,'\d'));
659magnet0=['QP' num2str(num)];
660name = handles.(['slider' magnet0]);
661%% Cherche le nom de l'aimant
662h = handles.(['popupmenu_bar' num]);
663contents = get(h,'String');
664magnet = contents{get(h,'Value')};
665
666%%% Test si dans les limites
667if val<get(name,'Max') && val> get(name,'Min')
668  set(name,'Value',val);
669  handles = setATmagnet(handles,magnet,val);
670  AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val;
671else % message d'erreur
672  warndlg('Wrong value for K','Edit Box','Modal')
673  set(hObject,'String',num2str(get(name,'Value')));
674end
675
676% Save data
677setappdata(handles.figure1,'AOmagnet',AOmagnet);
678
679%---------------------------------
680function mutual_exclude(off)
681% function mutual_exclude(off)
682% fonction pour faire des radioboutons
683set(off,'Value',0);
684
685% --- Executes during object creation, after setting all properties.
686function popupmenu_y_CreateFcn(hObject, eventdata, handles)
687% hObject    handle to popupmenu_y (see GCBO)
688% eventdata  reserved - to be defined in a future version of MATLAB
689% handles    empty - handles not created until after all CreateFcns called
690
691% Hint: popupmenu controls usually have a white background on Windows.
692%       See ISPC and COMPUTER.
693if ispc
694    set(hObject,'BackgroundColor','white');
695else
696    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
697end
698
699
700% --- Executes on selection change in popupmenu_y.
701function popupmenu_y_Callback(hObject, eventdata, handles)
702% hObject    handle to popupmenu_y (see GCBO)
703% eventdata  reserved - to be defined in a future version of MATLAB
704% handles    structure with handles and user data (see GUIDATA)
705
706% Hints: contents = get(hObject,'String') returns popupmenu_y contents as cell array
707%        contents{get(hObject,'Value')} returns selected item from popupmenu_y
708contents = get(hObject,'String');
709plot_axes(handles, contents{get(hObject,'Value')});
710%mat
711     %ylim([0 130]);
712handles.ytype = contents{get(hObject,'Value')};       
713guidata(hObject, handles);
714
715% --- Executes during object creation, after setting all properties.
716function popupmenu_x_CreateFcn(hObject, eventdata, handles)
717% hObject    handle to popupmenu_x (see GCBO)
718% eventdata  reserved - to be defined in a future version of MATLAB
719% handles    empty - handles not created until after all CreateFcns called
720
721% Hint: popupmenu controls usually have a white background on Windows.
722%       See ISPC and COMPUTER.
723if ispc
724    set(hObject,'BackgroundColor','white');
725else
726    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
727end
728
729% --- Executes on selection change in popupmenu_x.
730function popupmenu_x_Callback(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    structure with handles and user data (see GUIDATA)
734
735% Hints: contents = get(hObject,'String') returns popupmenu_x contents as cell array
736%        contents{get(hObject,'Value')} returns selected item from popupmenu_x
737contents = get(hObject,'String');       
738handles.xtype = contents{get(hObject,'Value')};       
739guidata(hObject, handles);
740plot_axes(handles, handles.ytype);
741%mat
742      %ylim([0 130]);
743
744% --- Executes during object creation, after setting all properties.
745function popupmenu_plane_CreateFcn(hObject, eventdata, handles)
746% hObject    handle to popupmenu_plane (see GCBO)
747% eventdata  reserved - to be defined in a future version of MATLAB
748% handles    empty - handles not created until after all CreateFcns called
749
750% Hint: popupmenu controls usually have a white background on Windows.
751%       See ISPC and COMPUTER.
752if ispc
753    set(hObject,'BackgroundColor','white');
754else
755    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
756end
757
758
759% --- Executes on selection change in popupmenu_plane.
760function popupmenu_plane_Callback(hObject, eventdata, handles)
761% hObject    handle to popupmenu_plane (see GCBO)
762% eventdata  reserved - to be defined in a future version of MATLAB
763% handles    structure with handles and user data (see GUIDATA)
764
765% Hints: contents = get(hObject,'String') returns popupmenu_plane contents as cell array
766%        contents{get(hObject,'Value')} returns selected item from popupmenu_plane
767
768
769% --- Executes on button press in pushbutton_reload.
770function pushbutton_reload_Callback(hObject, eventdata, handles)
771% hObject    handle to pushbutton_reload (see GCBO)
772% eventdata  reserved - to be defined in a future version of MATLAB
773% handles    structure with handles and user data (see GUIDATA)
774
775handles = restart(handles);
776guidata(hObject,handles);
777
778%--------------------------------------------------------
779function handles = restart(handles)
780% function handles = restart(handles)
781% Reinitialise la maille et l'IHM
782
783AD = getad;
784run(AD.ATModel); %% Load lattice
785global THERING
786% MAT ET LAURENT : TEMPORAIRE
787%warning('66 MeV');
788%setenergymodel(0.066);
789
790%
791setappdata(handles.figure1, 'LT1', THERING);
792
793handles.restart = 1;
794handles         = computeTwiss(handles);
795
796plot_axes(handles,handles.ytype);
797%mat
798   
799%ylim([0 130]);
800
801handles.modelMagnetVal  = {'chModelVal', 'cvModelVal', ...
802    'quadrupoleModelVal', 'dipoleModelVal'};
803
804store_model_values(handles);
805
806% Relaod Accelerator Object
807AO  = getao;
808
809%% Initialise les sliders et editboxes
810for k = 1:handles.sliderNumber
811    name = ['popupmenu_bar' num2str(k)];
812    contents = get(handles.(name),'String');
813    magnet = contents{get(handles.(name),'Value')};
814   
815    Qname = ['QP' num2str(k)];   
816   
817    % Read AT values
818    val  = getam(common2family(magnet),common2dev(magnet),'Model');
819   
820    set(handles.(['slider' Qname]),'Value', val);
821    set(handles.(['edit' Qname]),'string', num2str(val));
822end
823
824
825% --- Executes during object creation, after setting all properties.
826function popupmenu_bar1_CreateFcn(hObject, eventdata, handles)
827% hObject    handle to popupmenu_bar1 (see GCBO)
828% eventdata  reserved - to be defined in a future version of MATLAB
829% handles    empty - handles not created until after all CreateFcns called
830
831% Hint: popupmenu controls usually have a white background on Windows.
832%       See ISPC and COMPUTER.
833if ispc
834    set(hObject,'BackgroundColor','white');
835else
836    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
837end
838
839
840% --- Executes on selection change in popupmenu_bar1.
841function popupmenu_bar1_Callback(hObject, eventdata, handles)
842% hObject    handle to popupmenu_bar1 (see GCBO)
843% eventdata  reserved - to be defined in a future version of MATLAB
844% handles    structure with handles and user data (see GUIDATA)
845
846% Hints: contents = get(hObject,'String') returns popupmenu_bar1 contents as cell array
847%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar1
848
849setbar(handles);
850
851%----------------------------------------------------------
852function setbar(handles)
853%% aimant selectionne
854contents = get(gcbo,'String');
855magnet = contents{get(gcbo,'Value')}
856
857%% mets a jour l'IHM pour cet aimant
858tagstring = get(gcbo,'Tag');
859num = tagstring(regexp(tagstring,'\d'));
860slidername = ['sliderQP' num];
861editboxname = ['editQP' num];
862
863AOmagnet  = getappdata(handles.figure1,'AOmagnet');
864
865switch magnet
866    case AOmagnet.CH.CommonNames
867        val_max = getmaxsp('CH');
868        for k = 1:7
869            name = strcat('sliderQP',num2str(k))
870            set(handles.(name),'Max',val_max);
871        end
872        val = AOmagnet.CH.ModelVal(str2double(magnet(end)));
873    case AOmagnet.CV.CommonNames
874        val = AOmagnet.CV.ModelVal(str2double(magnet(end)));
875    case AOmagnet.QP.CommonNames
876        val = AOmagnet.QP.ModelVal(str2double(magnet(end)));
877end
878
879str = num2str(val);
880set(handles.(slidername),'Value',val); % writes slider
881set(handles.(editboxname),'String',str); % writes editbox
882
883% --- Executes during object creation, after setting all properties.
884function popupmenu_bar2_CreateFcn(hObject, eventdata, handles)
885% hObject    handle to popupmenu_bar2 (see GCBO)
886% eventdata  reserved - to be defined in a future version of MATLAB
887% handles    empty - handles not created until after all CreateFcns called
888
889% Hint: popupmenu controls usually have a white background on Windows.
890%       See ISPC and COMPUTER.
891if ispc
892    set(hObject,'BackgroundColor','white');
893else
894    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
895end
896
897% --- Executes on selection change in popupmenu_bar2.
898function popupmenu_bar2_Callback(hObject, eventdata, handles)
899% hObject    handle to popupmenu_bar2 (see GCBO)
900% eventdata  reserved - to be defined in a future version of MATLAB
901% handles    structure with handles and user data (see GUIDATA)
902
903% Hints: contents = get(hObject,'String') returns popupmenu_bar2 contents as cell array
904%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar2
905setbar(handles);
906
907% --- Executes during object creation, after setting all properties.
908function popupmenu_bar3_CreateFcn(hObject, eventdata, handles)
909% hObject    handle to popupmenu_bar3 (see GCBO)
910% eventdata  reserved - to be defined in a future version of MATLAB
911% handles    empty - handles not created until after all CreateFcns called
912
913% Hint: popupmenu controls usually have a white background on Windows.
914%       See ISPC and COMPUTER.
915if ispc
916    set(hObject,'BackgroundColor','white');
917else
918    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
919end
920
921% --- Executes on selection change in popupmenu_bar3.
922function popupmenu_bar3_Callback(hObject, eventdata, handles)
923% hObject    handle to popupmenu_bar3 (see GCBO)
924% eventdata  reserved - to be defined in a future version of MATLAB
925% handles    structure with handles and user data (see GUIDATA)
926
927% Hints: contents = get(hObject,'String') returns popupmenu_bar3 contents as cell array
928%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar3
929setbar(handles);
930
931% --- Executes during object creation, after setting all properties.
932function popupmenu_bar4_CreateFcn(hObject, eventdata, handles)
933% hObject    handle to popupmenu_bar4 (see GCBO)
934% eventdata  reserved - to be defined in a future version of MATLAB
935% handles    empty - handles not created until after all CreateFcns called
936
937% Hint: popupmenu controls usually have a white background on Windows.
938%       See ISPC and COMPUTER.
939if ispc
940    set(hObject,'BackgroundColor','white');
941else
942    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
943end
944
945% --- Executes on selection change in popupmenu_bar4.
946function popupmenu_bar4_Callback(hObject, eventdata, handles)
947% hObject    handle to popupmenu_bar4 (see GCBO)
948% eventdata  reserved - to be defined in a future version of MATLAB
949% handles    structure with handles and user data (see GUIDATA)
950
951% Hints: contents = get(hObject,'String') returns popupmenu_bar4 contents as cell array
952%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar4
953setbar(handles);
954
955% --- Executes during object creation, after setting all properties.
956function popupmenu_bar5_CreateFcn(hObject, eventdata, handles)
957% hObject    handle to popupmenu_bar5 (see GCBO)
958% eventdata  reserved - to be defined in a future version of MATLAB
959% handles    empty - handles not created until after all CreateFcns called
960
961% Hint: popupmenu controls usually have a white background on Windows.
962%       See ISPC and COMPUTER.
963if ispc
964    set(hObject,'BackgroundColor','white');
965else
966    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
967end
968
969% --- Executes on selection change in popupmenu_bar5.
970function popupmenu_bar5_Callback(hObject, eventdata, handles)
971% hObject    handle to popupmenu_bar5 (see GCBO)
972% eventdata  reserved - to be defined in a future version of MATLAB
973% handles    structure with handles and user data (see GUIDATA)
974
975% Hints: contents = get(hObject,'String') returns popupmenu_bar5 contents as cell array
976%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar5
977setbar(handles);
978
979% --- Executes during object creation, after setting all properties.
980function popupmenu_bar6_CreateFcn(hObject, eventdata, handles)
981% hObject    handle to popupmenu_bar6 (see GCBO)
982% eventdata  reserved - to be defined in a future version of MATLAB
983% handles    empty - handles not created until after all CreateFcns called
984
985% Hint: popupmenu controls usually have a white background on Windows.
986%       See ISPC and COMPUTER.
987if ispc
988    set(hObject,'BackgroundColor','white');
989else
990    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
991end
992
993
994% --- Executes on selection change in popupmenu_bar6.
995function popupmenu_bar6_Callback(hObject, eventdata, handles)
996% hObject    handle to popupmenu_bar6 (see GCBO)
997% eventdata  reserved - to be defined in a future version of MATLAB
998% handles    structure with handles and user data (see GUIDATA)
999
1000% Hints: contents = get(hObject,'String') returns popupmenu_bar6 contents as cell array
1001%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar6
1002setbar(handles);
1003
1004% --- Executes during object creation, after setting all properties.
1005function popupmenu_bar7_CreateFcn(hObject, eventdata, handles)
1006% hObject    handle to popupmenu_bar7 (see GCBO)
1007% eventdata  reserved - to be defined in a future version of MATLAB
1008% handles    empty - handles not created until after all CreateFcns called
1009
1010% Hint: popupmenu controls usually have a white background on Windows.
1011%       See ISPC and COMPUTER.
1012if ispc
1013    set(hObject,'BackgroundColor','white');
1014else
1015    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1016end
1017
1018% --- Executes on selection change in popupmenu_bar7.
1019function popupmenu_bar7_Callback(hObject, eventdata, handles)
1020% hObject    handle to popupmenu_bar7 (see GCBO)
1021% eventdata  reserved - to be defined in a future version of MATLAB
1022% handles    structure with handles and user data (see GUIDATA)
1023
1024% Hints: contents = get(hObject,'String') returns popupmenu_bar7 contents as cell array
1025%        contents{get(hObject,'Value')} returns selected item from popupmenu_bar7
1026setbar(handles);
1027
1028
1029% --- Executes on button press in pushbutton_refresh.
1030function pushbutton_refresh_Callback(hObject, eventdata, handles)
1031% hObject    handle to pushbutton_refresh (see GCBO)
1032% eventdata  reserved - to be defined in a future version of MATLAB
1033% handles    structure with handles and user data (see GUIDATA)
1034
1035%--------------------------------------------------------------------------
1036function read_tango(handles)
1037% Reads Tango values for LT1.
1038
1039% Get magnet AO
1040AOmagnet = getappdata(handles.figure1,'AOmagnet');
1041FamilyName = fieldnames(AOmagnet);
1042
1043for k1 = 1:length(FamilyName)
1044        % get attribute readback value
1045        magnet = AOmagnet.(FamilyName{k1});
1046        AOmagnet.(FamilyName{k1}).TangoVal = ...
1047            getam(FamilyName{k1},'Online');
1048end
1049
1050% save data
1051setappdata(handles.figure1,'AOmagnet',AOmagnet)
1052
1053%--------------------------------------------------------------------------
1054function write_tango(handles);
1055%-- Writes Tango values
1056%% Ecriture courant aimant sur les devices serveurs
1057
1058% Get magnet AO
1059AOmagnet = getappdata(handles.figure1,'AOmagnet');
1060
1061FamilyName = fieldnames(AOmagnet);
1062for k1 = 1:length(FamilyName)
1063    magnet = AOmagnet.(FamilyName{k1});
1064    setsp(magnet, magnet.ModelVal,'Online');
1065end
1066
1067%--------------------------------------------------------------------------
1068function devicelist = get_device_name(machine,property,magnet)
1069% get device list from mapping read in tango database
1070
1071map        = tango_get_db_property(machine,property);
1072sep        = cell2mat(regexpi(map,'::','once'))-1;
1073devicelist = regexprep(map,[magnet '\d*::'],'')';
1074
1075% --- Executes during object creation, after setting all properties.
1076function pushbutton_reload_CreateFcn(hObject, eventdata, handles)
1077% hObject    handle to pushbutton_reload (see GCBO)
1078% eventdata  reserved - to be defined in a future version of MATLAB
1079% handles    empty - handles not created until after all CreateFcns called
1080
1081% --- Executes on button press in pushbutton_model2online.
1082function pushbutton_model2online_Callback(hObject, eventdata, handles)
1083% hObject    handle to pushbutton_model2online (see GCBO)
1084% eventdata  reserved - to be defined in a future version of MATLAB
1085% handles    structure with handles and user data (see GUIDATA)
1086
1087AOmagnet      = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
1088
1089user_response = questdlg('Do you want to write setvalues to LT1?');
1090switch user_response
1091    case{'No','Cancel'}
1092        return;
1093    case{'Yes'}
1094        FamilyName = fieldnames(AOmagnet);
1095        for k1 = 1:length(FamilyName)
1096            AOmagnet.(FamilyName{k1}).TangoVal = ...
1097                AOmagnet.(FamilyName{k1}).ModelVal;
1098        end
1099        write_tango(handles);
1100end
1101
1102% save data
1103setappdata(handles.figure1,'AOmagnet',AOmagnet)
1104
1105% --- Executes on button press in pushbutton_online2model.
1106function pushbutton_online2model_Callback(hObject, eventdata, handles)
1107% hObject    handle to pushbutton_online2model (see GCBO)
1108% eventdata  reserved - to be defined in a future version of MATLAB
1109% handles    structure with handles and user data (see GUIDATA)
1110
1111% Online values stored in model values except dipoles
1112user_response = questdlg('Do you want to read TANGO setvalues from LT1?');
1113switch user_response
1114    case{'No','Cancel'}
1115        return;
1116    case{'Yes'}
1117        read_tango(handles);
1118end
1119
1120AOmagnet    = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure
1121
1122FamilyName = fieldnames(AOmagnet);
1123for k1 = 1:length(FamilyName)   
1124        AOmagnet.(FamilyName{k1}).ModelVal = AOmagnet.(FamilyName{k1}).TangoVal;
1125end
1126       
1127%% Initialise les sliders et editboxes
1128for k = 1:handles.sliderNumber
1129    name = ['popupmenu_bar' num2str(k)];
1130    contents = get(handles.(name),'String');
1131    magnet = contents{get(handles.(name),'Value')};
1132   
1133    Qname = ['QP' num2str(k)];   
1134   
1135    switch magnet
1136        case AOmagnet.QP.CommonNames           
1137            val = AOmagnet.QP.TangoVal(str2double(magnet(end)));
1138        case AOmagnet.CH.CommonNames
1139            val = AOmagnet.CH.TangoVal(str2double(magnet(end)));
1140        case AOmagnet.CV.CommonNames
1141            val = AOmagnet.CV.TangoVal(str2double(magnet(end)));
1142    end
1143   
1144    set(handles.(['slider' Qname]),'Value', val);
1145    set(handles.(['edit' Qname]),'string', num2str(val));
1146end
1147
1148set_model_values(handles);
1149
1150handles = computeTwiss(handles);
1151plot_axes(handles,handles.ytype);
1152%mat
1153        %ylim([0 130]);
1154% Update handles structure
1155guidata(hObject, handles);
1156
1157%% Update date
1158set(handles.text_date,'String',datestr(now,0));
1159
1160%save data
1161setappdata(handles.figure1,'AOmagnet',AOmagnet);
1162
1163%--------------------------------------------------------------------------
1164function handles = init_handles(handles)
1165%% Inits structure storing all the magnet data
1166
1167%% AT model used
1168% global THERING;
1169
1170A1 = getao; % Load AO for the first time
1171AOmagnet = [];
1172list = findmemberof('Magnet');
1173for k = 1:length(list)
1174    AOmagnet.(list{k}) = A1.(list{k});
1175end
1176clear A1;
1177
1178%save data
1179setappdata(handles.figure1,'AOmagnet',AOmagnet);
1180
1181store_model_values(handles);
1182
1183%% Update time
1184set(handles.text_date,'String',datestr(now,0));
1185
1186%--------------------------------------------------------------------------
1187function store_model_values(handles)
1188%% Stores model values in AOmagnet
1189
1190AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure
1191
1192% Loop over magnet types
1193FamilyName = fieldnames(AOmagnet);
1194
1195for k1 = 1:length(FamilyName)
1196    AOmagnet.(FamilyName{k1}).ModelVal = getam(FamilyName{k1},'Model');
1197end
1198
1199setappdata(handles.figure1,'AOmagnet',AOmagnet);
1200
1201%--------------------------------------------------------------------------
1202function set_model_values(handles)
1203% Set Modelvalue into LT1 AT model
1204
1205AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure
1206
1207%% Set model values to AT
1208FamilyName = fieldnames(AOmagnet);
1209
1210for k1 = 1:length(FamilyName)
1211    magnet = AOmagnet.(FamilyName{k1});
1212    setsp(FamilyName{k1}, magnet.ModelVal,'Model');
1213end
1214
1215
1216%--------------------------------------------------------------------------
1217function submenu_print_setpoint_Callback(hObject, eventdata, handles)
1218% hObject    handle to submenu_print_setpoint (see GCBO)
1219% eventdata  reserved - to be defined in a future version of MATLAB
1220% handles    structure with handles and user data (see GUIDATA)
1221
1222
1223%--------------------------------------------------------------------------
1224function submenu_print_model_Callback(hObject, eventdata, handles)
1225% hObject    handle to submenu_print_model (see GCBO)
1226% eventdata  reserved - to be defined in a future version of MATLAB
1227% handles    structure with handles and user data (see GUIDATA)
1228
1229
1230% -------------------------------------------------------------------------
1231function submenu_save_setpoint_Callback(hObject, eventdata, handles)
1232% hObject    handle to submenu_save_setpoint (see GCBO)
1233% eventdata  reserved - to be defined in a future version of MATLAB
1234% handles    structure with handles and user data (see GUIDATA)
1235
1236
1237% -------------------------------------------------------------------------
1238function submenu_save_model_Callback(hObject, eventdata, handles)
1239% hObject    handle to submenu_save_model (see GCBO)
1240% eventdata  reserved - to be defined in a future version of MATLAB
1241% handles    structure with handles and user data (see GUIDATA)
1242
1243
1244% -------------------------------------------------------------------------
1245function submenu_load_setpoint_Callback(hObject, eventdata, handles)
1246% hObject    handle to submenu_load_setpoint (see GCBO)
1247% eventdata  reserved - to be defined in a future version of MATLAB
1248% handles    structure with handles and user data (see GUIDATA)
1249
1250
1251%--------------------------------------------------------------------------
1252function submenu_load_model_Callback(hObject, eventdata, handles)
1253% hObject    handle to submenu_load_model (see GCBO)
1254% eventdata  reserved - to be defined in a future version of MATLAB
1255% handles    structure with handles and user data (see GUIDATA)
1256
1257
1258%--------------------------------------------------------------------------
1259function Untitled_1_Callback(hObject, eventdata, handles)
1260% hObject    handle to Untitled_1 (see GCBO)
1261% eventdata  reserved - to be defined in a future version of MATLAB
1262% handles    structure with handles and user data (see GUIDATA)
1263
1264
1265%--------------------------------------------------------------------------
1266function Untitled_4_Callback(hObject, eventdata, handles)
1267% hObject    handle to Untitled_4 (see GCBO)
1268% eventdata  reserved - to be defined in a future version of MATLAB
1269% handles    structure with handles and user data (see GUIDATA)
1270
1271
1272%--------------------------------------------------------------------------
1273function Untitled_7_Callback(hObject, eventdata, handles)
1274% hObject    handle to Untitled_7 (see GCBO)
1275% eventdata  reserved - to be defined in a future version of MATLAB
1276% handles    structure with handles and user data (see GUIDATA)
1277
1278
1279% --------------------------------------------------------------------
1280function submenu_dump_model_Callback(hObject, eventdata, handles)
1281% hObject    handle to submenu_dump_model (see GCBO)
1282% eventdata  reserved - to be defined in a future version of MATLAB
1283% handles    structure with handles and user data (see GUIDATA)
1284
1285% Get magnet AO
1286AOmagnet = getappdata(handles.figure1,'AOmagnet');
1287
1288fprintf('  DeviceName     Model   s(m)   phasex betax(m) etax(m) xcod(mm) phasez betaz(m) etaz(m) zcod(mm)\n')
1289
1290FamilyName = fieldnames(AOmagnet);
1291for k1 = 1:length(FamilyName)
1292    alias = AOmagnet.(FamilyName{k1});
1293    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1294        fprintf('%15s %6.2f %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f  %6.2f \n', ...
1295            alias.DeviceName{k2}, alias.ModelVal(k2), ...
1296            handles.spos(alias.AT.ATIndex(k2),1), handles.phase(alias.AT.ATIndex(k2),1), ...
1297            handles.beta(alias.AT.ATIndex(k2),1), handles.eta(alias.AT.ATIndex(k2),1), ...
1298            handles.cod(alias.AT.ATIndex(k2),1), ...
1299            handles.phase(alias.AT.ATIndex(k2),2), ...
1300            handles.beta(alias.AT.ATIndex(k2),2), handles.eta(alias.AT.ATIndex(k2),2), ...
1301            handles.cod(alias.AT.ATIndex(k2),2));
1302    end
1303end
1304
1305
1306%--------------------------------------------------------------------------
1307function submenu_dump_setpoint_Callback(hObject, eventdata, handles)
1308% hObject    handle to submenu_dump_setpoint (see GCBO)
1309% eventdata  reserved - to be defined in a future version of MATLAB
1310% handles    structure with handles and user data (see GUIDATA)
1311
1312% Get magnet AO
1313AOmagnet = getappdata(handles.figure1,'AOmagnet');
1314
1315fprintf('\n\n  DeviceName     TANGO\n')
1316
1317FamilyName = fieldnames(AOmagnet);
1318for k1 = 1:length(FamilyName)
1319    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1320        alias = AOmagnet.(FamilyName{k1});
1321        fprintf('%15s %6.2f \n', alias.DeviceName{k2}, ...
1322            alias.TangoVal(k2));
1323    end
1324end
1325
1326
1327%--------------------------------------------------------------------------
1328function submenu_dump_soleil_setpoint_Callback(hObject, eventdata, handles)
1329% hObject    handle to submenu_dump_soleil_setpoint (see GCBO)
1330% eventdata  reserved - to be defined in a future version of MATLAB
1331% handles    structure with handles and user data (see GUIDATA)
1332
1333fprintf('\n\n  DeviceName     Model  TANGO\n')
1334
1335% Get magnet AO
1336AOmagnet = getappdata(handles.figure1,'AOmagnet');
1337
1338FamilyName = fieldnames(AOmagnet);
1339for k1 = 1:length(FamilyName)
1340    for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames)
1341        alias = AOmagnet.(FamilyName{k1});
1342        fprintf('%15s %6.2f %6.2f\n', alias.DeviceName{k2}, ...
1343            alias.ModelVal(k2), alias.TangoVal(k2));
1344    end
1345end
1346
1347
1348% --------------------------------------------------------------------
1349function twiss_parameters_Callback(hObject, eventdata, handles)
1350% hObject    handle to twiss_parameters (see GCBO)
1351% eventdata  reserved - to be defined in a future version of MATLAB
1352% handles    structure with handles and user data (see GUIDATA)
1353
1354
1355% --------------------------------------------------------------------
1356function submenu_twissparameters_entry_Callback(hObject, eventdata, handles)
1357% hObject    handle to submenu_twissparameters_entry (see GCBO)
1358% eventdata  reserved - to be defined in a future version of MATLAB
1359% handles    structure with handles and user data (see GUIDATA)
1360
1361twiss_parameters_entry(handles)
1362
1363
1364
Note: See TracBrowser for help on using the repository browser.