source: MML/trunk/machine/SOLEIL/LT1/emittance/emittance_v16.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: 194.7 KB
Line 
1
2function varargout = emittance_v2(varargin)
3% EMITTANCE_V2 M-file for emittance_v2.fig
4%      EMITTANCE_V2, by itself, creates a new EMITTANCE_V2 or raises the existing
5%      singleton*.
6%
7%      H = EMITTANCE_V2 returns the handle to a new EMITTANCE_V2 or the handle to
8%      the existing singleton*.
9%
10%      EMITTANCE_V2('CALLBACK',hObject,eventData,handles,...) calls the local
11%      function named CALLBACK in EMITTANCE_V2.M with the given input arguments.
12%
13%      EMITTANCE_V2('Property','Value',...) creates a new EMITTANCE_V2 or raises the
14%      existing singleton*.  Starting from the left, property value pairs are
15%      applied to the GUI before emittance_v2_OpeningFunction gets called.  An
16%      unrecognized property name or invalid value makes property application
17%      stop.  All inputs are passed to emittance_v2_OpeningFcn via varargin.
18%
19
20%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
21%      instance to run (singleton)".
22%
23% See also: GUIDE, GUIDATA, GUIHANDLES
24
25% Edit the above text to modify the response to help emittance_v2
26
27% Last Modified by GUIDE v2.5 22-Jul-2005 14:22:55
28
29% Begin initialization code - DO NOT EDIT
30gui_Singleton = 1;
31gui_State = struct('gui_Name',       mfilename, ...
32                   'gui_Singleton',  gui_Singleton, ...
33                   'gui_OpeningFcn', @emittance_v2_OpeningFcn, ...
34                   'gui_OutputFcn',  @emittance_v2_OutputFcn, ...
35                   'gui_LayoutFcn',  [] , ...
36                   'gui_Callback',   []);
37if nargin & isstr(varargin{1})
38    gui_State.gui_Callback = str2func(varargin{1});
39end
40
41if nargout
42    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
43else
44    gui_mainfcn(gui_State, varargin{:});
45end
46% End initialization code - DO NOT EDIT
47
48% --- Executes just before emittance_v2 is made visible.
49function emittance_v2_OpeningFcn(hObject, eventdata, handles, varargin)
50% This function has no output args, see OutputFcn.
51% hObject    handle to figure
52% eventdata  reserved - to be defined in a future version of MATLAB
53% handles    structure with handles and user data (see GUIDATA)
54% varargin   command line arguments to emittance_v2 (see VARARGIN)
55
56% initialisation de l'ACCELERATOR_OBJECT
57LT1init
58
59% creation nouveau champ
60handles.output = hObject;
61handles.number_errors=0.;
62handles.nbsigmas=0;
63
64%essai
65%handles.nbremove=0;
66handles.nbrestore=0;
67
68val=0;
69faisc=[];
70st= struct([]);
71cellule=cell(1,1);
72%st2= struct([]);
73%st3=struct([]);
74handles.Sauver=struct([]);
75vect_colonne_noire=[];
76vect_ligne_noire=[];
77directory_principale='';
78directory_sauvegarde='';
79setappdata(handles.figure1,'tailles',faisc);
80setappdata(handles.figure1,'nbenregistrs',2);
81setappdata(handles.figure1,'ResultsData',st);
82setappdata(handles.figure1,'nbenregistrements',st);
83setappdata(handles.figure1,'Sauver',st);
84setappdata(handles.figure1,'Ecran',cellule);
85setappdata(handles.figure1,'largeur_option',val);
86setappdata(handles.figure1,'vect_colonne_noire',vect_colonne_noire);
87setappdata(handles.figure1,'vect_ligne_noire',vect_ligne_noire);
88setappdata(handles.figure1, 'G',0.043);
89% initialisation drapeau pour dialogue 'sauvegarde sur disque' ____
90setappdata(handles.figure1,'init_sauvegarde',val);
91% directory principale (dï¿œpend de l'utilisateur !!!)
92setappdata(handles.figure1,'directory_principale',directory_principale);
93setappdata(handles.figure1,'directory_sauvegarde',directory_sauvegarde);
94
95handles.nbenregistrs=getappdata(handles.figure1,'nbenregistrs')
96
97% Creates timer Infinite loop
98timer1=timer('StartDelay',1,...
99    'ExecutionMode','fixedRate','Period',.333,'TasksToExecute',Inf);
100timer1.TimerFcn = {@mycallback, hObject,eventdata, handles};
101setappdata(handles.figure1,'Timer',timer1);
102
103% button group sur l'image en continu
104h = uibuttongroup('visible','off','Position',[0.05 .9 .12 .08],...
105    'Title','Image','TitlePosition','centertop');
106u1 = uicontrol('Style','Radio','String','ON','Tag','radiobutton1',...
107    'pos',[2 .9 45 30],'parent',h,'HandleVisibility','off');
108u2 = uicontrol('Style','Radio','String','OFF','Tag','radiobutton2',...
109    'pos',[50 .9 45 30],'parent',h,'HandleVisibility','off');
110
111% set(h,'SelectionChangeFcn',@selcbk);
112set(h,'SelectionChangeFcn',...
113    {@uibuttongroup_SelectionChangeFcn,handles});
114
115set(h,'SelectedObject',u2);  % No selection
116set(h,'Visible','on');
117
118% positionne par défaut la lentille basse (plus de sensibilité pour les réglages)
119set(handles.Lenthaute_radiobutton7,'Value',0);
120set(handles.tata_radiobutton10,'Value',1);
121
122%% Set closing gui function
123set(handles.figure1,'CloseRequestFcn',{@Closinggui,timer1,handles.figure1});
124
125
126% Update handles structure
127guidata(hObject, handles);
128
129%%%if strcmp(get(hObject,'Visible'),'off')
130%%%    initialize_gui(hObject, handles);
131%%%end
132
133% UIWAIT makes emittance_v2 wait for user response (see UIRESUME)
134% uiwait(handles.figure1);
135
136
137% --- Outputs from this function are returned to the command line.
138function varargout = emittance_v2_OutputFcn(hObject, eventdata, handles)
139% varargout  cell array for returning output args (see VARARGOUT);
140% hObject    handle to figure
141% eventdata  reserved - to be defined in a future version of MATLAB
142% handles    structure with handles and user data (see GUIDATA)
143
144% Get default command line output from handles structure
145varargout{1} = handles.output;
146
147
148% % --- Executes during object creation, after setting all properties.
149
150initialize_gui(gcbf, handles);
151
152function initialize_gui(fig_handle, handles)
153
154
155%____________________________________________________________________
156% dï¿œfinir les alias pour les devices
157device_name.videograbber = 'lt1/dg/emit-vg';
158device_name.iris = 'lt1/dg/emit-iris';
159device_name.lentille_haute = 'lt1/dg/emit-l.haut';
160device_name.lentille_basse = 'lt1/dg/emit-l.bas';
161device_name.miroir = 'lt1/dg/emit-mc';
162device_name.backlight = 'lt1/dg/emit-bl';
163device_name.ecran = 'lt1/dg/emit-ecr';
164device_name.Q1 = 'lt1/AE/Q.1';
165device_name.Q2 = 'lt1/AE/Q.2';
166device_name.Q3 = 'lt1/AE/Q.3';
167device_name.Q4 = 'lt1/AE/Q.4';
168% test % device_name.H1 = 'lt1/AE/CH.1';
169% device_name.H2 = 'lt1/AE/CH.2';
170% device_name.V1 = 'lt1/AE/CV.1';
171setappdata(handles.figure1,'device_name',device_name);
172
173%____________________________________________________________________
174% directory de sauvegarde en attente
175
176%uibuttongroup
177%     prompt={'entrez votre directory de travail'};
178%     name='DIRECTORY PRINCIPALE';
179%     numlines=1;
180%     defaultanswer={'/home/PM/tordeux/matlab_test/'};
181%
182%     options.Resize='on';
183%     options.WindowStyle='normal';
184%     options.Interpreter='tex';
185%     nom=inputdlg(prompt,name,numlines,defaultanswer,options);
186%     if ~isempty(nom)
187%         setappdata(handles.figure1,'directory_principale',nom{:});
188%     end
189%
190%     directory_principale=getappdata(handles.figure1,'directory_principale');
191
192%DirectoryName = '/home/PM/nadolski/controlroom/measdata/LT1data/';
193directory_principale = getfamilydata('Directory','EMITData');
194phrase=strcat(directory_principale ,'?');
195set(handles.directory_sauvegarde_edit28,'String',phrase);
196setappdata(handles.figure1,'directory_principale',directory_principale);
197
198%____________________________________________________________________
199% inscrire les courants effectifs des aimants de la machine
200
201valQ1= (read_magnet(device_name.Q1));
202set(handles.Q1courant_edit,'String',sprintf('%3.2f',valQ1));
203resQ1 = str2double(get(handles.Q1courant_edit,'String'));
204setappdata(handles.figure1,'Q1courant',resQ1);
205
206valQ2= (read_magnet(device_name.Q2));
207set(handles.Q2courant_edit,'String',sprintf('%3.2f',valQ2));
208resQ2 = str2double(get(handles.Q2courant_edit,'String'));
209setappdata(handles.figure1,'Q2courant',resQ2);
210
211valQ3= (read_magnet(device_name.Q3));
212set(handles.Q3courant_edit,'String',sprintf('%3.2f',valQ3));
213resQ3 = str2double(get(handles.Q3courant_edit,'String'));
214setappdata(handles.figure1,'Q3courant',resQ3);
215
216valQ4= (read_magnet(device_name.Q4));
217set(handles.Q4courant_edit,'String',sprintf('%3.2f',valQ4));
218resQ4 = str2double(get(handles.Q4courant_edit,'String'));
219setappdata(handles.figure1,'Q4courant',resQ4);
220
221%test % valH1= (read_magnet(device_name.H1));
222% set(handles.H1courant_edit,'String',sprintf('%3.2f',valH1));
223% resH1 = str2double(get(handles.H1courant_edit,'String'));
224% setappdata(handles.figure1,'H1courant',resH1);
225%
226% valH2= (read_magnet(device_name.H2));
227% set(handles.H2courant_edit,'String',sprintf('%3.2f',valH2));
228% resH2 = str2double(get(handles.H2courant_edit,'String'));
229% setappdata(handles.figure1,'H2courant',resH2);
230%
231% valV1= (read_magnet(device_name.V1));
232% set(handles.V1courant_edit,'String',sprintf('%3.2f',valV1));
233% resV1 = str2double(get(handles.V1courant_edit,'String'));
234% setappdata(handles.figure1,'V1courant',resV1);
235
236%____________________________________________________________________
237% insrire une valeur par dï¿œfaut de calibration ???
238set(handles.G_edit12,'String',num2str(43));
239clear('figh');
240
241%____________________________________________________________________
242% mettre off le bouton calibration de l'image
243set([handles.calibOFF_radiobutton6],'Value',1);
244
245%____________________________________________________________________
246% exclure la possibilitᅵ de calibrer et de bouger les lentilles
247set([handles.Lenthaute_radiobutton7,handles.tata_radiobutton10,...
248 handles.ppp_pushbutton18,handles.pp_pushbutton19,handles.p_pushbutton20...
249 handles.mmm_pushbutton21,handles.mm_pushbutton22,handles.m_pushbutton23...
250 ,handles.backlight_popupmenu3,...
251 handles.Gmax_pushbutton26,handles.Gmoy_pushbutton27,handles.Gmin_pushbutton28,...
252 handles.qualite_edit23,handles.G_edit12,...
253    handles.pos1_edit29,handles.pos2_edit30...
254    handles.text45,handles.text39,handles.text26,handles.text41...
255    handles.calib_pushbutton7],'Enable','off')
256% handles.backlight_pushbutton24,handles.iris_pushbutton25,...
257
258%____________________________________________________________________
259% positionner le miroir HORS, eteindre le backlight
260% tango_command_inout('lt1/emit/mirror','Off');
261% tango_command_inout('lt1/emit/backlight','SetBrightness',uint16(0));
262tango_command_inout(device_name.miroir,'Off');
263tango_command_inout(device_name.backlight,'SetBrightness',uint16(0));
264%___________________________________________________________________
265% position des lentilles pour les differents grandissements, en nombre de pas
266setappdata(handles.figure1,'posl1Gmax',3000);
267setappdata(handles.figure1,'posl2Gmax',35130);
268setappdata(handles.figure1,'posl1Gmoy',8650);
269setappdata(handles.figure1,'posl2Gmoy',26500);
270setappdata(handles.figure1,'posl1Gmin',0);
271setappdata(handles.figure1,'posl2Gmin',3925);
272
273%____________________________________________________________________
274% positionner les voyants des butᅵes lentilles ᅵ leur valeur vraies
275
276%dev=device_name.lentille_haute;
277dev=device_name.lentille_haute;
278errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
279
280
281% errorstatus=21 dᅵcᅵlᅵration ou arrᅵt dᅵ ᅵ un limit switch sens +
282% errorstatus=3  limitswitch forward
283% errorstatus=22 dᅵcᅵlᅵration ou arrᅵt dᅵ ᅵ un limit switch sens -
284% errorstatus=4  limitswitch backward
285
286if (tango_error == -1)
287        %- handle error
288        tango_print_error_stack;
289        return;
290        errordlg('erreur tango !','Erreur');
291
292else
293        % cas ou l'axe est en butee backward (en haut)
294        if isequal(errorstatus,22)|isequal(errorstatus,4)
295            set(handles.LHBH_edit25,'BackgroundColor','red');
296        end
297        % cas ou l'axe est en butee forward (en bas)
298        if isequal(errorstatus,21)|isequal(errorstatus,3)
299            set(handles.LHBB_edit24,'BackgroundColor','red');
300        end
301
302end         
303
304
305dev=device_name.lentille_basse
306
307errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
308
309if (tango_error == -1)
310        %- handle error
311        tango_print_error_stack;
312        return;
313        errordlg('erreur tango !','Erreur');
314
315else
316        % cas ou l'axe est en butee backward (en haut)
317        if isequal(errorstatus,22)|isequal(errorstatus,4)
318            set(handles.LBBH_edit26,'BackgroundColor','red');
319        end
320        % cas ou l'axe est en butee forward (en bas)
321        if isequal(errorstatus,21)|isequal(errorstatus,3)
322            set(handles.LBBB_edit27,'BackgroundColor','red');
323        end
324end           
325
326
327%____________________________________________________________________
328% allumer en rouge le grandissement effectif
329
330posl1Gmax=getappdata(handles.figure1,'posl1Gmax');
331posl2Gmax=getappdata(handles.figure1,'posl2Gmax');
332posl1Gmoy=getappdata(handles.figure1,'posl1Gmoy');
333posl2Gmoy=getappdata(handles.figure1,'posl2Gmoy');
334posl1Gmin=getappdata(handles.figure1,'posl1Gmin');
335posl2Gmin=getappdata(handles.figure1,'posl2Gmin');
336
337
338dev1=device_name.lentille_haute;
339dev2=device_name.lentille_basse;
340
341str1=tango_read_attribute(dev1,'AxisCurrentPosition');
342str2=tango_read_attribute(dev2,'AxisCurrentPosition');
343position1=str1.value(1);
344position2=str2.value(1);
345
346set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
347set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
348set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
349
350if (tango_error == -1)
351        %- handle error
352        tango_print_error_stack;
353        return;
354        errordlg('erreur tango !','Erreur');
355
356else
357        % cas du grandissement max
358        if isequal(position1,posl1Gmax)&isequal(position2,posl2Gmax)
359            set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
360            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
361            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
362        end
363        % cas du grandissement moyen
364        if isequal(position1,posl1Gmoy)&isequal(position2,posl2Gmoy)
365            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
366            set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
367            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
368        end
369        % cas du grandissement min
370        if isequal(position1,posl1Gmin)&isequal(position2,posl2Gmin)
371            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
372            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
373            set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
374        end
375
376end           
377
378%________________________________________________________________________
379% ï¿œcrire les valeurs effectives de positions des lentilles
380
381pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
382set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
383pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
384set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
385
386
387%set(handles.nbacqu_edit13,'String',num2str(handles.nbenregistrs));
388%set(handles.nbacqu_edit13,'String',num2str(handles.nbenregistrs));
389
390% --- Executes during object creation, after setting all properties.
391function lent1_slider1_CreateFcn(hObject, eventdata, handles)
392% hObject    handle to lent1_slider1 (see GCBO)
393% eventdata  reserved - to be defined in a future version of MATLAB
394% handles    empty - handles not created until after all CreateFcns called
395
396% Hint: slider controls usually have a light gray background, change
397%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
398usewhitebg = 1;
399if usewhitebg
400    set(hObject,'BackgroundColor',[.9 .9 .9]);
401else
402    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
403end
404
405% du temps ou il y avait des sliders....
406%         % --- Executes on slider movement.
407%         function lent1_slider1_Callback(hObject, eventdata, handles)
408%         % hObject    handle to lent1_slider1 (see GCBO)
409%         % eventdata  reserved - to be defined in a future version of MATLAB
410%         % handles    structure with handles and user data (see GUIDATA)
411%
412%         % Hints: get(hObject,'Value') returns position of slider
413%         %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
414%
415%         set(handles.lent1_edit5,'String',...
416%             num2str(get(handles.lent1_slider1,'Value')));
417%
418%         % --- Executes during object creation, after setting all properties.
419%         function lent1_edit5_CreateFcn(hObject, eventdata, handles)
420%         % hObject    handle to lent1_edit5 (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.
426%         if ispc
427%             set(hObject,'BackgroundColor','white');
428%         else
429%             set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
430%         end
431
432
433%         function lent1_edit5_Callback(hObject, eventdata, handles)
434%         % hObject    handle to lent1_edit5 (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 lent1_edit5 as text
439%         %        str2double(get(hObject,'String')) returns contents of lent1_edit5 as a double
440%
441%
442%         val = str2double(get(handles.lent1_edit5,'String'));
443%         % Determine whether val is a number between 0 and 1
444%         if isnumeric(val) & length(val)==1 & ...
445%             val >= get(handles.lent1_slider1,'Min') & ...
446%             val <= get(handles.lent1_slider1,'Max')
447%             set(handles.lent1_slider1,'Value',val);
448%         else
449%         % Increment the error count, and display it
450%             handles.number_errors = handles.number_errors+1;
451%             guidata(hObject,handles); % store the changes
452%             set(handles.lent1_edit5,'String',...
453%             ['Caramba ',...
454%         %num2str(handles.number_errors),' Times']);
455%             '']);
456%         end
457%
458%
459%         % --- Executes during object creation, after setting all properties.
460%         function lent2_slider2_CreateFcn(hObject, eventdata, handles)
461%         % hObject    handle to lent2_slider2 (see GCBO)
462%         % eventdata  reserved - to be defined in a future version of MATLAB
463%         % handles    empty - handles not created until after all CreateFcns called
464%
465%         % Hint: slider controls usually have a light gray background, change
466%         %       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
467%         usewhitebg = 1;
468%         if usewhitebg
469%             set(hObject,'BackgroundColor',[.9 .9 .9]);
470%         else
471%             set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
472%         end
473%
474%
475%         % --- Executes on slider movement.
476%         function lent2_slider2_Callback(hObject, eventdata, handles)
477%         % hObject    handle to lent2_slider2 (see GCBO)
478%         % eventdata  reserved - to be defined in a future version of MATLAB
479%         % handles    structure with handles and user data (see GUIDATA)
480%
481%         % Hints: get(hObject,'Value') returns position of slider
482%         %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
483%
484%         set(handles.lent2_emitV_edit19,'String',...
485%             num2str(get(handles.lent2_slider2,'Value')));
486%
487%         % --- Executes during object creation, after setting all properties.
488%         function lent2_emitV_edit19_CreateFcn(hObject, eventdata, handles)
489%         % hObject    handle to lent2_emitV_edit19 (see GCBO)
490%         % eventdata  reserved - to be defined in a future version of MATLAB
491%         % handles    empty - handles not created until after all CreateFcns called
492%
493%         % Hint: edit controls usually have a white background on Windows.
494%         %       See ISPC and COMPUTER.
495%         if ispc
496%             set(hObject,'BackgroundColor','white');
497%         else
498%             set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
499%         end
500%
501%
502%
503%         function lent2_emitV_edit19_Callback(hObject, eventdata, handles)
504%         % hObject    handle to lent2_emitV_edit19 (see GCBO)
505%         % eventdata  reserved - to be defined in a future version of MATLAB
506%         % handles    structure with handles and user data (see GUIDATA)
507%
508%         % Hints: get(hObject,'String') returns contents of lent2_emitV_edit19 as text
509%         %        str2double(get(hObject,'String')) returns contents of lent2_emitV_edit19 as a double
510%
511%         val = str2double(get(handles.lent2_emitV_edit19,'String'));
512%         % Determine whether val is a number between 0 and 1
513%         if isnumeric(val) & length(val)==1 & ...
514%             val >= get(handles.lent2_slider2,'Min') & ...
515%             val <= get(handles.lent2_slider2,'Max')
516%             set(handles.lent2_slider2,'Value',val);
517%         else
518%         % Increment the error count, and display it
519%             handles.number_errors = handles.number_errors+1;
520%             guidata(hObject,handles); % store the changes
521%             set(handles.lent2_emitV_edit19,'String',...
522%             ['Zut ',...
523%         %num2str(handles.number_errors),'']);
524%             '']);
525%         end
526
527% --- Executes on button press in calib_pushbutton7.
528function calib_pushbutton7_Callback(hObject, eventdata, handles)
529% hObject    handle to calib_pushbutton7 (see GCBO)
530% eventdata  reserved - to be defined in a future version of MATLAB
531% handles    structure with handles and user data (see GUIDATA)
532
533
534% alias
535device_name=getappdata(handles.figure1,'device_name');
536dev=device_name.videograbber;
537
538tango_command_inout(dev,'Calibrate');
539%ATTENTION PEUT ETRE ATTRIBUTS  AVEC un SSSSS
540if isequal(tango_error,-1)
541   
542    %errordlg('erreur TANGO...','Error');
543    tango_print_error_stack;
544    diag = tango_error_stack;
545    errordlg(diag(1).desc);
546else   
547   
548    res=tango_read_attribute(dev,'calibration_quality');
549    % on teste la qualitï¿œ de la calibration  FACTEUR 996.0
550    % le 10 septembre MATLAB a pris lamain sur le code de NL pour le
551    % critï¿œre. attention ï¿œ 990 on est dans les choux
552    if res.value>996.0
553        val=sprintf('%3.2f',res.value);
554        set(handles.qualite_edit23,'String',val);
555        tango_read_attribute(dev,'x_magnification_factor');
556        val=sprintf('%2.1f',1000*ans.value);
557        set(handles.G_edit12,'String',val);
558        setappdata(handles.figure1, 'G',str2num(val)/1000)
559       
560        %dev='lt1/dg/emit-vg';
561        pause(1);
562        toto=tango_read_attribute(dev,'corrected_image');
563        figure(2);
564        imagesc(toto.value);
565        colormap(gray);
566
567    else
568        errordlg('la calibration a echouï¿œe ...','Error');
569    end
570   
571end
572
573
574
575
576% --- Executes during object creation, after setting all properties.
577function fit_popupmenu1_CreateFcn(hObject, eventdata, handles)
578% hObject    handle to fit_popupmenu1 (see GCBO)
579% eventdata  reserved - to be defined in a future version of MATLAB
580% handles    empty - handles not created until after all CreateFcns called
581
582% Hint: popupmenu controls usually have a white background on Windows.
583%       See ISPC and COMPUTER.
584if ispc
585    set(hObject,'BackgroundColor','white');
586else
587    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
588end
589
590
591% --- Executes on selection change in fit_popupmenu1.
592function fit_popupmenu1_Callback(hObject, eventdata, handles)
593% hObject    handle to fit_popupmenu1 (see GCBO)
594% eventdata  reserved - to be defined in a future version of MATLAB
595% handles    structure with handles and user data (see GUIDATA)
596
597% Hints: contents = get(hObject,'String') returns fit_popupmenu1 contents as cell array
598%        contents{get(hObject,'Value')} returns selected item from fit_popupmenu1
599
600val = get(hObject,'Value');
601switch val
602case 1
603    largeur_option=0;
604case 2
605    % fit par gaussienne
606    largeur_option=1;
607
608case 3
609    % vrai rms
610    largeur_option=2;
611   
612case 4
613    % rayon ï¿œ X %
614    largeur_option=3;
615end
616setappdata(handles.figure1,'largeur_option',largeur_option);
617
618% --- Executes on button press in mesure_pushbutton8.
619function mesure_pushbutton8_Callback(hObject, eventdata, handles)
620% hObject    handle to mesure_pushbutton8 (see GCBO)
621% eventdata  reserved - to be defined in a future version of MATLAB
622% handles    structure with handles and user data (see GUIDATA)
623
624%nbiterations=0;
625%nombre1=get(handles.fit_popupmenu1, 'String');
626
627popup_sel_index = get(handles.nbiter_popupmenu2, 'Value');
628nombre2=get(handles.nbiter_popupmenu2, 'String');
629Name = nombre2{popup_sel_index};
630nbiterat=str2num(Name(1));
631setappdata(handles.figure1, 'nbiterations',nbiterat);
632set(handles.nbiter_edit37,'String',Name(1));
633switch popup_sel_index
634    case 1
635         errordlg('selectionnez un nombre d''iterations','Error');
636             %error('Select a number of acquisitions'); %exprimez votre choix
637    case 2
638        %test de la pause : pause(10);
639        show1imagesgui_15(handles);     
640         
641    case 3
642         show5imagesgui_15(handles);   
643    case 4
644         show10imagesgui(handles);
645       
646end
647
648
649% --- Executes on button press in plot_pushbutton.
650function plot_pushbutton_Callback(hObject, eventdata, handles)
651% hObject    handle to plot_pushbutton (see GCBO)
652% eventdata  reserved - to be defined in a future version of MATLAB
653% handles    structure with handles and user data (see GUIDATA)
654
655handles.ResultsData=getappdata(handles.figure1,'ResultsData');
656handles.matrx=[];
657handles.matry=[];
658for ik=1:length(handles.ResultsData)
659    handles.matrx(ik,1)=handles.ResultsData(ik).Q4courant;
660    handles.matrx(ik,2)=handles.ResultsData(ik).LargeurH;
661    errorx(ik)=2*handles.ResultsData(ik).sigmaH;
662    handles.matry(ik,1)=handles.ResultsData(ik).Q4courant;
663    handles.matry(ik,2)=handles.ResultsData(ik).LargeurV;
664    errory(ik)=2*handles.ResultsData(ik).sigmaV;
665end
666
667clear('figure3');
668figure(3);
669toto1=handles.matrx(:,1)
670toto2=handles.matrx(:,2)
671
672%plot(handles.matrx(:,1),handles.matrx(:,2),'d')
673%%plot(handles.matry(:,1),handles.matry(:,2),'d')
674    % %'--rs','LineWidth',2,...
675    % %                'MarkerEdgeColor','k',...
676    % %                'MarkerFaceColor','g',...
677    %  %               'MarkerSize',8)
678    %
679    % 
680    % %%t=[4.298 3.5 3.9 4.6 5.1 5.6 6.2]';
681    % %%y=[2.3 13.5 7. 0.85 1.8 6.3 22.]';
682    % %plot(t,y,'+'),grid on
683X = [ones(size(handles.matrx(:,1)))  handles.matrx(:,1)  handles.matrx(:,1).^2];
684a=X\handles.matrx(:,2);
685Tmin=min(handles.matrx(:,1));
686Tmax=max(handles.matrx(:,1));
687T=[Tmin:0.1:Tmax]';
688Z = [ones(size(T))  T  T.^2]*a;
689hold on
690plot(T,Z,'r-',handles.matrx(:,1),handles.matrx(:,2),'ro'), grid on
691
692
693Y = [ones(size(handles.matry(:,1)))  handles.matry(:,1)  handles.matry(:,1).^2];
694a=Y\handles.matry(:,2);
695Tmin=min(handles.matry(:,1));
696Tmax=max(handles.matry(:,1));
697T=[Tmin:0.1:Tmax]';
698Z = [ones(size(T))  T  T.^2]*a;
699hold on
700plot(T,Z,'b-',handles.matry(:,1),handles.matry(:,2),'b+'), grid on
701
702% exemple de label des axes avec symboles grecs :
703xlabel('-\pi \leq \Theta \leq \pi')
704ylabel('sin(\Theta)')
705title('Plot of sin(\Theta)')
706text(-pi/4,sin(-pi/4),'\leftarrow sin(-\pi\div4)',...
707     'HorizontalAlignment','left')
708 
709% nos labels
710xlabel('Courant quadrupolaire (A)')
711ylabel('Largeur faisceau (mm2')
712title('Courbe de focalisation')
713
714% Q1courant de 1 ᅵ 10 A
715%T=[1:0.1:10]';
716%Y = [ones(size(T))  T  T.^2]*a;
717%%figure(1);
718%hold on
719%figure(4)
720%plot(T,Y,'-',handles.matrx(:,1),handles.matrx(:,2),'o'), grid on
721%hold on
722
723% barre d'erreur
724% hold on
725% errorbar(handles.matrx(:,1),handles.matrx(:,2),errorx)
726
727
728% --- Executes during object creation, after setting all properties.
729function Q1courant_edit_CreateFcn(hObject, eventdata, handles)
730% hObject    handle to Q1courant_edit (see GCBO)
731% eventdata  reserved - to be defined in a future version of MATLAB
732% handles    empty - handles not created until after all CreateFcns called
733
734% Hint: edit controls usually have a white background on Windows.
735%       See ISPC and COMPUTER.
736if ispc
737    set(hObject,'BackgroundColor','white');
738else
739    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
740end
741
742
743
744function Q1courant_edit_Callback(hObject, eventdata, handles)
745% hObject    handle to Q1courant_edit (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: get(hObject,'String') returns contents of Q1courant_edit as text
750%        str2double(get(hObject,'String')) returns contents of Q1courant_edit as a double
751
752
753ecriture('Q1',handles)
754
755
756
757function ecriture(aimant,handles)
758
759device_name = getappdata(handles.figure1,'device_name');
760Name = strcat(aimant,'courant_edit');
761res = str2double(get(handles.(Name),'String'));
762valmax=tango_get_attribute_config(device_name.(aimant),'current');
763
764if res > str2double(valmax.max_value)
765    set(handles.(Name),'BackgroundColor','red');
766    errordlg('Courant superieur ï¿œ valeur maximale !','ALARME');
767    guidata(gcbo,handles);
768    old = tango_read_attribute(device_name.(aimant),'current');
769    set(handles.(Name),'String',num2str(old.value(1)));
770    pause(2);
771    set(handles.(Name),'BackgroundColor','green');
772else
773    set(handles.(Name),'BackgroundColor','green');
774    Name2 =[aimant 'courant'];
775    setappdata(handles.figure1,Name2,res);
776    tango_write_attribute(device_name.(aimant),'current',res);
777end
778
779
780% --- Executes during object creation, after setting all properties.
781function H1courant_edit_CreateFcn(hObject, eventdata, handles)
782% hObject    handle to H1courant_edit (see GCBO)
783% eventdata  reserved - to be defined in a future version of MATLAB
784% handles    empty - handles not created until after all CreateFcns called
785
786% Hint: edit controls usually have a white background on Windows.
787%       See ISPC and COMPUTER.
788if ispc
789    set(hObject,'BackgroundColor','white');
790else
791    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
792end
793
794function H1courant_edit_Callback(hObject, eventdata, handles)
795% hObject    handle to H1courant_edit (see GCBO)
796% eventdata  reserved - to be defined in a future version of MATLAB
797% handles    structure with handles and user data (see GUIDATA)
798
799% Hints: get(hObject,'String') returns contents of H1courant_edit as text
800%        str2double(get(hObject,'String')) returns contents of H1courant_edit as a double
801
802ecriture('H1',handles)
803
804
805
806% --- Executes during object creation, after setting all properties.
807function V1courant_edit_CreateFcn(hObject, eventdata, handles)
808% hObject    handle to V1courant_edit (see GCBO)
809% eventdata  reserved - to be defined in a future version of MATLAB
810% handles    empty - handles not created until after all CreateFcns called
811
812
813% --------------------------------------------------------------------
814function V1courant_edit_Callback(hObject, eventdata, handles)
815% hObject    handle to V1courant_edit (see GCBO)
816% eventdata  reserved - to be defined in a future version of MATLAB
817% handles    structure with handles and user data (see GUIDATA)
818
819ecriture('V1',handles)
820
821
822% ------- lecture de valeurs dans les devices servers Tango ----------
823function Cour=read_magnet(dev)
824
825attr_val = tango_read_attribute(dev,'current');
826if (tango_error == -1)
827  %- handle error
828  tango_print_error_stack;
829  fprintf(1,'TracyServer Error %s\n',dev)
830  return;
831end
832Cour=attr_val.value(1);
833
834% --------------------------------------------------------------------
835% --- Executes during object creation, after setting all properties.
836function nbiter_popupmenu2_CreateFcn(hObject, eventdata, handles)
837% hObject    handle to nbiter_popupmenu2 (see GCBO)
838% eventdata  reserved - to be defined in a future version of MATLAB
839% handles    empty - handles not created until after all CreateFcns called
840
841% Hint: popupmenu controls usually have a white background on Windows.
842%       See ISPC and COMPUTER.
843if ispc
844    set(hObject,'BackgroundColor','white');
845else
846    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
847end
848
849set(hObject, 'String', {'Nbre iterations par acquisition','1 iteration par acquisition'...
850    ,'5 iterations par acquisition'...
851    });
852
853% --- Executes on selection change in nbiter_popupmenu2.
854function nbiter_popupmenu2_Callback(hObject, eventdata, handles)
855% hObject    handle to nbiter_popupmenu2 (see GCBO)
856% eventdata  reserved - to be defined in a future version of MATLAB
857% handles    structure with handles and user data (see GUIDATA)
858
859% Hints: contents = get(hObject,'String') returns nbiter_popupmenu2 contents as cell array
860%        contents{get(hObject,'Value')} returns selected item from nbiter_popupmenu2
861
862
863% % --- Executes on button press in camera_control_togglebutton.
864% function camera_control_togglebutton_Callback(hObject, eventdata, handles)
865% % hObject    handle to camera_control_togglebutton (see GCBO)
866% % eventdata  reserved - to be defined in a future version of MATLAB
867% % handles    structure with handles and user data (see GUIDATA)
868%
869% % Hint: get(hObject,'Value') returns toggle state of camera_control_togglebutton
870% button_state = get(hObject,'Value');
871% if button_state == get(hObject,'Max')
872%     % toggle button is pressed
873% elseif button_state == get(hObject,'Min')
874%     % toggle button is not pressed
875% end
876
877
878% ᅵ dᅵtruire
879%         % --- Executes on button press in camera_image_togglebutton.
880%         function camera_image_togglebutton_Callback(hObject, eventdata, handles)
881%         % hObject    handle to camera_image_togglebutton (see GCBO)
882%         % eventdata  reserved - to be defined in a future version of MATLAB
883%         % handles    structure with handles and user data (see GUIDATA)
884%
885%         % Hint: get(hObject,'Value') returns toggle state of camera_image_togglebutton
886%         button_state = get(hObject,'Value');
887%         if button_state == get(hObject,'Max')
888%             % toggle button is pressed
889%         elseif button_state == get(hObject,'Min')
890%             % toggle button is not pressed
891%         end
892%
893%         %camera_image(handles);
894%
895%
896%         %     name=['axes' num2str(1)];
897%         %    axes(handles.(name))
898%         % timer1 = timer('Period', 2,'TasksToExecute',
899%         % Inf,'ExecutionMode','fixedRate');
900%
901%         %     t=timer('StartDelay',1,'TimerFcn',@mycallback,...
902%         %     'ExecutionMode','fixedRate','Period',0.333,'TasksToExecute',10);
903%
904%         % timer1=timer('StartDelay',1,...
905%         %     'ExecutionMode','fixedRate','Period',0.333,'TasksToExecute',10);
906%         % timer1.TimerFcn = {@mycallback, hObject,eventdata, handles};
907%
908%         %figure(1);
909%         %axes(handles.axes1);
910%         timer1 = getappdata(handles.figure1,'Timer');
911%         start(timer1);
912
913%     % --- Executes on button press in imageOFF_radiobutton.
914%     function imageOFF_radiobutton_Callback(hObject, eventdata, handles)
915%     % hObject    handle to imageOFF_radiobutton (see GCBO)
916%     % eventdata  reserved - to be defined in a future version of MATLAB
917%     % handles    structure with handles and user data (see GUIDATA)
918%
919%     % Hint: get(hObject,'Value') returns toggle state of imageOFF_radiobutton
920%
921%     timer1 = getappdata(handles.figure1,'Timer');
922%     delete(timer1);
923
924
925% % function buttongroup(hObject, eventdata, handles)
926% % h = uibuttongroup('visible','off','Position',[0 .9 .1 .1]);
927% % u0 = uicontrol('Style','Radio','String','Option 1',...
928% %     'pos',[10 350 80 30],'parent',h,'HandleVisibility','off');
929% % u1 = uicontrol('Style','Radio','String','Option 2',...
930% %     'pos',[10 250 80 30],'parent',h,'HandleVisibility','off');
931% % u2 = uicontrol('Style','Radio','String','Option 3',...
932% %     'pos',[10 150 80 30],'parent',h,'HandleVisibility','off');
933% % set(h,'SelectionChangeFcn',@selcbk);
934% % set(h,'SelectedObject',[]);  % No selection
935% % set(h,'Visible','on');
936
937% function selcbk(source,eventdata)
938% disp(source);
939% disp('toto');
940% disp([eventdata.EventName,'  ',...
941%      get(eventdata.OldValue,'String'),'  ', ...
942%      get(eventdata.NewValue,'String')]);
943% disp(get(get(source,'SelectedObject'),'String'));
944
945function uibuttongroup_SelectionChangeFcn(hObject,eventdata,handles)
946% hObject    handle to uipanel1 (see GCBO)
947% eventdata  reserved - to be defined in a future version of MATLAB
948% handles    structure with handles and user data (see GUIDATA)
949
950timer1 = getappdata(handles.figure1,'Timer');
951switch get(get(hObject,'SelectedObject'),'Tag')  % Get Tag of selected object
952    case 'radiobutton1'
953        % code piece when radiobutton1 is selected goes here
954        disp('image video <-')
955        start(timer1);
956    case 'radiobutton2'
957        % code piece when radiobutton2 is selected goes here
958        disp('image video ->')
959        stop(timer1);
960end
961
962
963%     % --- Executes on button press in imageON_radiobutton.
964%     function imageON_radiobutton_Callback(hObject, eventdata, handles)
965%     % hObject    handle to imageON_radiobutton (see GCBO)
966%     % eventdata  reserved - to be defined in a future version of MATLAB
967%     % handles    structure with handles and user data (see GUIDATA)
968%
969%     % Hint: get(hObject,'Value') returns toggle state of imageON_radiobutton
970%
971%     timer1 = getappdata(handles.figure1,'Timer');
972%     start(timer1);
973
974
975function mutual_exclude(off)
976set(off,'Value',0)
977
978% --- Executes on button press in calibON_radiobutton5.
979function calibON_radiobutton5_Callback(hObject, eventdata, handles)
980% hObject    handle to calibON_radiobutton5 (see GCBO)
981% eventdata  reserved - to be defined in a future version of MATLAB
982% handles    structure with handles and user data (see GUIDATA)
983
984% Hint: get(hObject,'Value') returns toggle state of calibON_radiobutton5
985off = [handles.calibOFF_radiobutton6];
986mutual_exclude(off)
987
988% alias
989device_name = getappdata(handles.figure1,'device_name');
990
991% positionner le miroir EN, allumer le backlight
992tango_command_inout(device_name.miroir,'On');
993tango_command_inout(device_name.backlight,'SetBrightness',uint16(6));
994
995%____________________________________________________________________
996% positionner le popupmenu du backlight a la valeur effective
997lumiere=tango_command_inout(device_name.backlight,'GetBrightness');
998
999%- check error
1000if (tango_error == -1)
1001      %- handle error
1002      tango_print_error_stack;
1003      return;
1004else
1005    set(handles.backlight_popupmenu3,'Value',lumiere);
1006end
1007
1008%rendre la possibilitᅵ de calibrer et de bouger les lentilles
1009set([handles.Lenthaute_radiobutton7,handles.tata_radiobutton10,...
1010     handles.ppp_pushbutton18,handles.pp_pushbutton19,handles.p_pushbutton20...
1011     handles.mmm_pushbutton21,handles.mm_pushbutton22,handles.m_pushbutton23...
1012     handles.backlight_popupmenu3,...
1013     handles.Gmax_pushbutton26,handles.Gmoy_pushbutton27,handles.Gmin_pushbutton28,...
1014     handles.qualite_edit23,handles.G_edit12,...
1015     handles.pos1_edit29,handles.pos2_edit30...
1016     handles.text45,handles.text39,handles.text26,handles.text41...
1017        handles.calib_pushbutton7],'Enable','on')
1018% handles.backlight_pushbutton24,handles.iris_pushbutton25,...
1019
1020% --- Executes on button press in calibOFF_radiobutton6.
1021function calibOFF_radiobutton6_Callback(hObject, eventdata, handles)
1022% hObject    handle to calibOFF_radiobutton6 (see GCBO)
1023% eventdata  reserved - to be defined in a future version of MATLAB
1024% handles    structure with handles and user data (see GUIDATA)
1025
1026% Hint: get(hObject,'Value') returns toggle state of calibOFF_radiobutton6
1027off = [handles.calibON_radiobutton5];
1028mutual_exclude(off)
1029
1030% alias
1031
1032device_name = getappdata(handles.figure1,'device_name');
1033%getappdata(handles.figure1,'backlight');
1034
1035% positionner le miroir HORS, eteindre le backlight
1036tango_command_inout(device_name.miroir,'Off');
1037tango_command_inout(device_name.backlight,'SetBrightness',uint16(0));
1038
1039%% inserer l'écran YAG
1040%tango_command_inout(device_name.ecran,'Insert');
1041%fonction_error;
1042
1043%exclure la possibilitᅵ de calibrer et de bouger les lentilles
1044set([handles.Lenthaute_radiobutton7,handles.tata_radiobutton10,...
1045     handles.ppp_pushbutton18,handles.pp_pushbutton19,handles.p_pushbutton20...
1046     handles.mmm_pushbutton21,handles.mm_pushbutton22,handles.m_pushbutton23...
1047     handles.backlight_popupmenu3,...
1048     handles.Gmax_pushbutton26,handles.Gmoy_pushbutton27,handles.Gmin_pushbutton28,...
1049     handles.qualite_edit23,handles.G_edit12,...
1050        handles.pos1_edit29,handles.pos2_edit30...
1051        handles.text45,handles.text39,handles.text26,handles.text41...
1052        handles.calib_pushbutton7],'Enable','off')
1053%handles.backlight_pushbutton24,handles.iris_pushbutton25,...
1054
1055% --- Executes during object creation, after setting all properties.
1056function G_edit12_CreateFcn(hObject, eventdata, handles)
1057% hObject    handle to G_edit12 (see GCBO)
1058% eventdata  reserved - to be defined in a future version of MATLAB
1059% handles    empty - handles not created until after all CreateFcns called
1060
1061% Hint: edit controls usually have a white background on Windows.
1062%       See ISPC and COMPUTER.
1063if ispc
1064    set(hObject,'BackgroundColor','white');
1065else
1066    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1067end
1068
1069
1070
1071function G_edit12_Callback(hObject, eventdata, handles)
1072% hObject    handle to G_edit12 (see GCBO)
1073% eventdata  reserved - to be defined in a future version of MATLAB
1074% handles    structure with handles and user data (see GUIDATA)
1075
1076% Hints: get(hObject,'String') returns contents of G_edit12 as text
1077%        str2double(get(hObject,'String')) returns contents of G_edit12 as a double
1078
1079
1080
1081
1082
1083% ------------------------------------------------------------
1084% Callback for the Remove push button
1085% ------------------------------------------------------------
1086% --- Executes on button press in remove_pushbutton.
1087function remove_pushbutton_Callback(hObject, eventdata, handles)
1088% hObject    handle to remove_pushbutton (see GCBO)
1089% eventdata  reserved - to be defined in a future version of MATLAB
1090% handles    structure with handles and user data (see GUIDATA)
1091
1092% Callback of the uicontrol handles.RemoveButton.
1093%essai
1094%handles.nbremove=handles.nbremove+1
1095
1096currentVal = get(handles.listbox1,'Value')
1097resultsStr = get(handles.listbox1,'String')
1098numResults = size(resultsStr,1)
1099
1100
1101% Remove the data and list entry for the selected value
1102
1103handles.Ecran=getappdata(handles.figure1,'Ecran');
1104% handles.Sauver contient la structure du rᅵsultat ᅵ effacer
1105handles.Sauver=getappdata(handles.figure1,'Sauver');
1106if isequal( handles.Ecran,{[]})
1107    handles.Ecran= resultsStr(currentVal);
1108else
1109    handles.Ecran=[ handles.Ecran ; resultsStr(currentVal)];
1110end
1111resultsStr(currentVal) =[];
1112resultats=getappdata(handles.figure1,'ResultsData');
1113%%NumeroRemove=resultats(currentVal).RunNumber;
1114if isequal( handles.Sauver,struct([]))
1115    handles.Sauver=resultats(currentVal);
1116else
1117    handles.Sauver=[handles.Sauver  resultats(currentVal)];
1118end
1119
1120resultats(currentVal)=[];
1121setappdata(handles.figure1,'ResultsData',resultats);
1122handles.ResultsData = resultats;
1123
1124%essai
1125%restoreRes(handles.nbremove)=resultats(currentVal)
1126%handles.restore=handles.remove+1;
1127if ~isequal(numResults,1)
1128    set([handles.restaurer_pushbutton15],'Enable','on')
1129end
1130% If there are no other entries, disable the Remove and Plot button
1131% and change the list sting to <empty>
1132if isequal(numResults,1)
1133        resultsStr = {'<vide !!>'};
1134        currentVal = 1;
1135        set([handles.remove_pushbutton,handles.plot_pushbutton,...
1136        handles.restaurer_pushbutton15],'Enable','off')
1137end
1138
1139
1140
1141% Ensure that list box Value is valid, then reset Value and String
1142currentVal = min(currentVal,size(resultsStr,1));
1143set(handles.listbox1,'Value',currentVal,'String',resultsStr)
1144
1145% Store the new ResultsData
1146setappdata(handles.figure1,'Sauver',handles.Sauver);
1147setappdata(handles.figure1,'Ecran',handles.Ecran);
1148set(handles.nbacqu_edit13,'String', num2str(size(resultsStr,1)));
1149
1150% affiche le nombre de data utilisï¿œs dans le calcul d'ï¿œmittance
1151%%en attente   set(handles.nbacqu_edit13,'String',num2str(length(resultats)));
1152
1153guidata(hObject, handles);
1154
1155% --- Executes on button press in emittance_pushbutton12.
1156function emittance_pushbutton12_Callback(hObject, eventdata, handles)
1157% hObject    handle to emittance_pushbutton12 (see GCBO)
1158% eventdata  reserved - to be defined in a future version of MATLAB
1159% handles    structure with handles and user data (see GUIDATA)
1160% calcul d'emittance
1161
1162handles.ResultsData = getappdata(handles.figure1,'ResultsData');
1163largeur_option = getappdata(handles.figure1,'largeur_option');
1164
1165switch largeur_option
1166case 1
1167    % fit par gaussienne largeur_option = 1
1168    set(handles.type_edit36,'String','rms (fit)');
1169case 2
1170    % vrai rms largeur_option = 2
1171    set(handles.type_edit36,'String','vrai rms');
1172   
1173case 3
1174    % rayon ï¿œ X % largeur_option = 3
1175    set(handles.type_edit36,'String','à X %');
1176end
1177
1178
1179% les vecteurs sx et sy sont déjà les valeurs moyennᅵes sur nbiter iterations
1180for i=1:length(handles.ResultsData)
1181    sx(i) = handles.ResultsData(i).LargeurH;
1182    sy(i) = handles.ResultsData(i).LargeurV;
1183    I(i)= handles.ResultsData(i).Q4courant;
1184end
1185%%I = [1 2 3 4]
1186
1187% transformation courant - force quadrupolaire
1188% ï¿œtalonnage de Q7 (si on a le temps prï¿œfï¿œrez ï¿œtalonnage Q4, mais pas trop important)
1189% ATTENTION nᅵcessitᅵ de connaotre m'ᅵnergie de la ligne (he oui ce n'est
1190% pas simple) A RENTRER A LA MAIN DANS L'INTERFACE
1191res = get(handles.energie_edit38,'String');
1192if isequal(res,'ENERGIE')
1193    errordlg('vous n''avez pas rentré l''énergie de la ligne !','Attention');
1194    return
1195end
1196Energie = Str2num(get(handles.energie_edit38,'String'))*0.001;
1197%t = amp2k4LT1(I,[-1.49e-6 2.59e-5 -1.93e-4 4.98e-2 8.13e-4 ]/0.15 , 1,Energie)
1198%Family, Field, Amps, DeviceList, Energy, C, K2AmpScaleFactor
1199 t = amp2k4LT1('QP','SetPoint',I, [1 4], Energie,[-1.49e-6 2.59e-5 -1.93e-4 4.98e-2 8.13e-4 ]/0.15,1)
1200%t = hw2physics('QP','Setpoint',I,[1 4],Energie)';
1201%% tests !
1202%t=[4.298 3.5 3.9 4.6 5.1 5.6 6.2]';
1203%sx=[1.641  3.823 2.703 0.977 1.173 2.424 4.074];
1204%sy=[1.641  3.823 2.703 0.977 1.173 2.424 4.074];
1205
1206% constantes de la ligne de transfert
1207% valeur vérifiée sur 3D D Zerbib 11 février 2005
1208
1209Drift = [0.150 1.669 0.85415 2.400 0.950 3.79286];
1210%     % point 0 simulation barelattice_LT1 ï¿œ entrï¿œe Lmag Q1
1211%     drift1 = 1.669
1212%     % sortie Lmag Q1 entrï¿œe Lmag Q2
1213%     drift2 = 1.00415 - 0.150 = 0.85415
1214%     % sortie Lmag Q2 entrï¿œe Lmag Q3
1215%     drift3 = 2.550 - 0.150 = 2.400
1216%     % sortie Lmag Q3 entrï¿œe Lmag Q4
1217%     drift4 = 1.100 - 0.150 = 0.95
1218%     % sortie L magnï¿œtique Qpï¿œle - centre ï¿œmittance
1219%     drift5 = 3867,86 - 150/2 =  3792.86
1220setappdata(handles.figure1,'Drift',Drift)
1221Lq = Drift(1);
1222Ld = Drift(6);
1223Md = [1 Ld ; 0 1];
1224
1225% plan HORIZONTAL
1226%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1227% calcul des elements de la matrice de transport entre le Qpole et le point de mesure
1228
1229% tailles en unité standard
1230sx = sx * 0.001;
1231sx2=sx.*sx;
1232
1233Mx11=zeros(length(t),1);
1234Mx12=zeros(length(t),1);
1235for i = 1:length(t)
1236        clear('Mxq','Mxtransport')
1237        Mxq=[cos(Lq*sqrt(t(i)))  (1/sqrt(t(i)))*sin(Lq*sqrt(t(i))) ; ...
1238        -sqrt(t(i))*sin(Lq*sqrt(t(i)))  cos(Lq*sqrt(t(i)))];
1239        Mxtransport=Md*Mxq;
1240        Mx11(i)=Mxtransport(1,1);
1241        Mx12(i)=Mxtransport(1,2);
1242end
1243
1244% *********** methode Belbeoch **********************
1245A=Mx11.*Mx11;
1246B=Mx12.*Mx12;
1247F=2*Mx11.*Mx12 ;
1248   
1249Z=[A'*A A'*B A'*F ; B'*A B'*B B'*F ; ...
1250           F'*A F'*B F'*F];
1251H=[A'*sx2' ; B'*sx2' ; F'*sx2'];
1252   
1253twissx=Z\H;
1254% twissx(1) = sigma11(point origine) = Eps beta
1255% twissx(2) = sigma22(point origine) = Eps gamma
1256% twissx(3) = sigma12(point origine) = - Eps alpha
1257epsx = sqrt(twissx(1)*twissx(2)-twissx(3)*twissx(3));
1258% affichage de l'emittance en mm mrad
1259emittanceH = sprintf('%3.2f',epsx*1e6) ;
1260set(handles.emitH_edit18,'String',emittanceH);
1261setappdata(handles.figure1,'Twissx',twissx);
1262
1263% plan VERTICAL
1264%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1265% calcul des elements de la matrice de transport entre le Qpole et le point de mesure
1266
1267sy = sy * 1e-3;
1268sy2=sy.*sy;
1269
1270My11=zeros(length(t),1);
1271My12=zeros(length(t),1);
1272for i = 1:length(t)
1273        clear('Myq','Mytransport')
1274        Myq=[cosh(Lq*sqrt(t(i)))  (1/sqrt(t(i)))*sinh(Lq*sqrt(t(i))) ; ...
1275        sqrt(t(i))*sinh(Lq*sqrt(t(i)))  cosh(Lq*sqrt(t(i)))];
1276        Mytransport=Md*Myq;
1277        My11(i)=Mytransport(1,1);
1278        My12(i)=Mytransport(1,2);
1279end
1280
1281% *********** methode Belbeoch **********************
1282A=My11.*My11;
1283B=My12.*My12;
1284F=2*My11.*My12 ;
1285   
1286Z=[A'*A A'*B A'*F ; B'*A B'*B B'*F ; ...
1287           F'*A F'*B F'*F];
1288H=[A'*sy2' ; B'*sy2' ; F'*sy2'];
1289   
1290twissy=Z\H;
1291epsy = sqrt(twissy(1)*twissy(2)-twissy(3)*twissy(3));
1292emittanceV = sprintf('%3.2f',epsy*1e6) ;
1293set(handles.emitV_edit19,'String',emittanceV);
1294setappdata(handles.figure1,'Twissy',twissy);
1295
1296
1297
1298%         %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
1299%         % Mesure de l'emittance par fit "Belbeoch" et distribution normale des
1300%         % erreurs de mesures
1301%
1302%         % valeurs exactes gradient t
1303%         % valeurs exactes tailles de faisceau se
1304%         % pourc = pourcentage d'erreur maximum sur la mesure de taille
1305%         % Lq = Longueur du quadrupole
1306%         % Ld = longueur du drift Qpole - point de mesure
1307%         %---------------------------------------------------------
1308%         %
1309%
1310%         %cla(figure(1));
1311%
1312%         % methode de calcul
1313%         method = 'moyenne des acquisitions';
1314%         %method = 'moyenne des emittances'
1315%
1316%         % erreur sur les mesures de taille / nb d'iterations sur une mesure/ pour
1317%         % tester la validite de la methode : nb de tests
1318%         sigma = 0.35;
1319%         % ? nbiter=5;
1320%         nbiter=1;
1321%         nbtests=30000;
1322%
1323%         % valeurs exactes de forces quadrupolaires et tailles de faisceau
1324%         t=[4.298 3.5 3.9 4.6 5.1 5.6 6.2]';
1325%         se=[1.641  3.823 2.703 0.977 1.173 2.424 4.074];
1326%
1327%         % initialisations
1328%         % ? eps=zeros(nbiter,1);
1329%         eps=zeros(nbtests,1);
1330%         Lq=0.15;
1331%         Ld=3.8915;
1332%         Md=[1 Ld ; 0 1];
1333%         st2=zeros(nbiter,length(t));
1334%         meanst2=zeros(1,length(t));
1335%
1336%         nbcomplexes=0;
1337%         stdeps=1.;
1338%         g=0;
1339%         Z=zeros(3,3);
1340%
1341%
1342%         % calcul des elements de la matrice de transport entre le Qpole et le point
1343%         % de mesure
1344%         M11=zeros(length(t),1);
1345%         M12=zeros(length(t),1);
1346%         for i = 1:length(t)
1347%                 clear('Mq','Mtransport')
1348%                 Mq=[cos(Lq*sqrt(t(i)))  (1/sqrt(t(i)))*sin(Lq*sqrt(t(i))) ; ...
1349%                 -sqrt(t(i))*sin(Lq*sqrt(t(i)))  cos(Lq*sqrt(t(i)))];
1350%                 Mtransport=Md*Mq;
1351%                 M11(i)=Mtransport(1,1);
1352%                 M12(i)=Mtransport(1,2);
1353%         end
1354%
1355%
1356%         for j = 1:nbtests
1357%
1358%         % calcul de l'emittance avec moyenne prealable de chaque acquisition sur les nbiter
1359%         %iterations (5 dans le menu) (distribution normale dans cette simulation)
1360%         for i=1:length(t)
1361%             s=se(i)+sigma*se(i)*randn(nbiter,1);
1362%             s2=s.*s;
1363%             meanst2(i)=mean(s2);
1364%         end
1365%
1366%         % *********** methode Belbeoch **********************
1367%         A=M11.*M11;
1368%         B=M12.*M12;
1369%         F=2*M11.*M12 ;
1370%
1371%         Z=[A'*A A'*B A'*F ; B'*A B'*B B'*F ; ...
1372%                    F'*A F'*B F'*F];
1373%         H=[A'*meanst2' ; B'*meanst2' ; F'*meanst2'];
1374%
1375%         citer=Z\H;
1376%         eps(j)=sqrt(citer(1)*citer(2)-citer(3)*citer(3));
1377%         nbcomplexes = 1-isreal(eps(j)) + nbcomplexes;
1378%         if isequal(isreal(eps(j)),0)
1379%             epsilon(j) = 0;
1380%         else
1381%             epsilon(j) = eps(j);
1382%         end
1383%
1384%
1385%         % emittanceH=num2str(eps) ;   
1386%         % set(handles.emitH_edit18,'String',emittanceH);
1387%
1388%
1389%         end
1390%
1391%         moyenne = mean(epsilon)*length(eps)/(length(eps)-nbcomplexes);
1392%         for j=1:length(eps)
1393%             if isequal(epsilon(j),0)
1394%                 sepsilon(j) = moyenne;
1395%             else
1396%                 sepsilon(j) = epsilon(j);
1397%             end
1398%         end
1399%         standard = std(sepsilon)*sqrt(length(eps)/(length(eps)-nbcomplexes));
1400%         disp(['nbcomplexes=' sprintf('%0.5g',nbcomplexes) '  sigma tailles=' sprintf('%0.5g',sigma) ...
1401%                     '  nbiter=' sprintf('%0.5g',nbiter) ...
1402%                 '  nbtests=' sprintf('%0.5g',nbtests) '  meaneps=' ...
1403%                 sprintf('%0.5g',moyenne) '  stdeps=' sprintf('%0.5g',standard)] )
1404%         disp(' ')
1405%
1406%         %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
1407%
1408
1409
1410% --- Executes during object creation, after setting all properties.
1411function nbacqu_edit13_CreateFcn(hObject, eventdata, handles)
1412% hObject    handle to nbacqu_edit13 (see GCBO)
1413% eventdata  reserved - to be defined in a future version of MATLAB
1414% handles    empty - handles not created until after all CreateFcns called
1415
1416% Hint: edit controls usually have a white background on Windows.
1417%       See ISPC and COMPUTER.
1418if ispc
1419    set(hObject,'BackgroundColor','white');
1420else
1421    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1422end
1423
1424
1425
1426function nbacqu_edit13_Callback(hObject, eventdata, handles)
1427% hObject    handle to nbacqu_edit13 (see GCBO)
1428% eventdata  reserved - to be defined in a future version of MATLAB
1429% handles    structure with handles and user data (see GUIDATA)
1430
1431% Hints: get(hObject,'String') returns contents of nbacqu_edit13 as text
1432%        str2double(get(hObject,'String')) returns contents of nbacqu_edit13 as a double
1433
1434
1435% --- Executes during object creation, after setting all properties.
1436function edit14_CreateFcn(hObject, eventdata, handles)
1437% hObject    handle to edit14 (see GCBO)
1438% eventdata  reserved - to be defined in a future version of MATLAB
1439% handles    empty - handles not created until after all CreateFcns called
1440
1441% Hint: edit controls usually have a white background on Windows.
1442%       See ISPC and COMPUTER.
1443if ispc
1444    set(hObject,'BackgroundColor','white');
1445else
1446    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1447end
1448
1449
1450
1451function edit14_Callback(hObject, eventdata, handles)
1452% hObject    handle to edit14 (see GCBO)
1453% eventdata  reserved - to be defined in a future version of MATLAB
1454% handles    structure with handles and user data (see GUIDATA)
1455
1456% Hints: get(hObject,'String') returns contents of edit14 as text
1457%        str2double(get(hObject,'String')) returns contents of edit14 as a double
1458
1459
1460% --- Executes during object creation, after setting all properties.
1461function edit15_CreateFcn(hObject, eventdata, handles)
1462% hObject    handle to edit15 (see GCBO)
1463% eventdata  reserved - to be defined in a future version of MATLAB
1464% handles    empty - handles not created until after all CreateFcns called
1465
1466% Hint: edit controls usually have a white background on Windows.
1467%       See ISPC and COMPUTER.
1468if ispc
1469    set(hObject,'BackgroundColor','white');
1470else
1471    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1472end
1473
1474
1475
1476function edit15_Callback(hObject, eventdata, handles)
1477% hObject    handle to edit15 (see GCBO)
1478% eventdata  reserved - to be defined in a future version of MATLAB
1479% handles    structure with handles and user data (see GUIDATA)
1480
1481% Hints: get(hObject,'String') returns contents of edit15 as text
1482%        str2double(get(hObject,'String')) returns contents of edit15 as a double
1483
1484
1485% --- Executes during object creation, after setting all properties.
1486function edit16_CreateFcn(hObject, eventdata, handles)
1487% hObject    handle to edit16 (see GCBO)
1488% eventdata  reserved - to be defined in a future version of MATLAB
1489% handles    empty - handles not created until after all CreateFcns called
1490
1491% Hint: edit controls usually have a white background on Windows.
1492%       See ISPC and COMPUTER.
1493if ispc
1494    set(hObject,'BackgroundColor','white');
1495else
1496    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1497end
1498
1499
1500
1501function edit16_Callback(hObject, eventdata, handles)
1502% hObject    handle to edit16 (see GCBO)
1503% eventdata  reserved - to be defined in a future version of MATLAB
1504% handles    structure with handles and user data (see GUIDATA)
1505
1506% Hints: get(hObject,'String') returns contents of edit16 as text
1507%        str2double(get(hObject,'String')) returns contents of edit16 as a double
1508
1509
1510% --- Executes during object creation, after setting all properties.
1511function edit17_CreateFcn(hObject, eventdata, handles)
1512% hObject    handle to edit17 (see GCBO)
1513% eventdata  reserved - to be defined in a future version of MATLAB
1514% handles    empty - handles not created until after all CreateFcns called
1515
1516% Hint: edit controls usually have a white background on Windows.
1517%       See ISPC and COMPUTER.
1518if ispc
1519    set(hObject,'BackgroundColor','white');
1520else
1521    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1522end
1523
1524
1525
1526function edit17_Callback(hObject, eventdata, handles)
1527% hObject    handle to edit17 (see GCBO)
1528% eventdata  reserved - to be defined in a future version of MATLAB
1529% handles    structure with handles and user data (see GUIDATA)
1530
1531% Hints: get(hObject,'String') returns contents of edit17 as text
1532%        str2double(get(hObject,'String')) returns contents of edit17 as a double
1533
1534
1535% --- Executes during object creation, after setting all properties.
1536function emitH_edit18_CreateFcn(hObject, eventdata, handles)
1537% hObject    handle to emitH_edit18 (see GCBO)
1538% eventdata  reserved - to be defined in a future version of MATLAB
1539% handles    empty - handles not created until after all CreateFcns called
1540
1541% Hint: edit controls usually have a white background on Windows.
1542%       See ISPC and COMPUTER.
1543if ispc
1544    set(hObject,'BackgroundColor','white');
1545else
1546    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1547end
1548% emittance horizonale
1549
1550
1551
1552function emitH_edit18_Callback(hObject, eventdata, handles)
1553% hObject    handle to emitH_edit18 (see GCBO)
1554% eventdata  reserved - to be defined in a future version of MATLAB
1555% handles    structure with handles and user data (see GUIDATA)
1556
1557% Hints: get(hObject,'String') returns contents of emitH_edit18 as text
1558%        str2double(get(hObject,'String')) returns contents of emitH_edit18 as a double
1559
1560
1561% --- Executes during object creation, after setting all properties.
1562function emitV_edit19_CreateFcn(hObject, eventdata, handles)
1563% hObject    handle to emitV_edit19 (see GCBO)
1564% eventdata  reserved - to be defined in a future version of MATLAB
1565% handles    empty - handles not created until after all CreateFcns called
1566
1567% Hint: edit controls usually have a white background on Windows.
1568%       See ISPC and COMPUTER.
1569if ispc
1570    set(hObject,'BackgroundColor','white');
1571else
1572    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1573end
1574
1575
1576
1577function emitV_edit19_Callback(hObject, eventdata, handles)
1578% hObject    handle to emitV_edit19 (see GCBO)
1579% eventdata  reserved - to be defined in a future version of MATLAB
1580% handles    structure with handles and user data (see GUIDATA)
1581
1582% Hints: get(hObject,'String') returns contents of emitV_edit19 as text
1583%        str2double(get(hObject,'String')) returns contents of emitV_edit19 as a double
1584
1585
1586% --- Executes on button press in ellipseH_pushbutton13.
1587function ellipseH_pushbutton13_Callback(hObject, eventdata, handles)
1588% hObject    handle to ellipseH_pushbutton13 (see GCBO)
1589% eventdata  reserved - to be defined in a future version of MATLAB
1590% handles    structure with handles and user data (see GUIDATA)
1591
1592ellipseH_v16(handles)
1593
1594
1595% --- Executes when figure1 window is resized.
1596function figure1_ResizeFcn(hObject, eventdata, handles)
1597% hObject    handle to figure1 (see GCBO)
1598% eventdata  reserved - to be defined in a future version of MATLAB
1599% handles    structure with handles and user data (see GUIDATA)
1600
1601
1602% --- Executes during object creation, after setting all properties.
1603function listbox1_CreateFcn(hObject, eventdata, handles)
1604% hObject    handle to listbox1 (see GCBO)
1605% eventdata  reserved - to be defined in a future version of MATLAB
1606% handles    empty - handles not created until after all CreateFcns called
1607
1608% Hint: listbox controls usually have a white background on Windows.
1609%       See ISPC and COMPUTER.
1610if ispc
1611    set(hObject,'BackgroundColor','white');
1612else
1613    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1614end
1615
1616
1617% --- Executes on selection change in listbox1.
1618function listbox1_Callback(hObject, eventdata, handles)
1619% hObject    handle to listbox1 (see GCBO)
1620% eventdata  reserved - to be defined in a future version of MATLAB
1621% handles    structure with handles and user data (see GUIDATA)
1622
1623% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
1624%        contents{get(hObject,'Value')} returns selected item from listbox1
1625
1626
1627% --- Executes on button press in radiobutton7_bh_l1.
1628function Lenthaute_radiobutton7_Callback(hObject, eventdata, handles)
1629% hObject    handle to radiobutton7_bh_l1 (see GCBO)
1630% eventdata  reserved - to be defined in a future version of MATLAB
1631% handles    structure with handles and user data (see GUIDATA)
1632
1633% Hint: get(hObject,'Value') returns toggle state of Lenthaute_radiobutton7
1634autre = [handles.tata_radiobutton10];
1635mutual_exclude(autre)
1636
1637
1638
1639
1640% --- Executes on button press in radiobutton10_bh_l2.
1641function tata_radiobutton10_Callback(hObject, eventdata, handles)
1642% hObject    handle to radiobutton10_bh_l2 (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% Hint: get(hObject,'Value') returns toggle state of radiobutton10_bh_l2
1647autre = [handles.Lenthaute_radiobutton7];
1648mutual_exclude(autre)
1649
1650
1651
1652
1653
1654
1655% --- Executes on button press in restaurer_pushbutton15.
1656function restaurer_pushbutton15_Callback(hObject, eventdata, handles)
1657% hObject    handle to restaurer_pushbutton15 (see GCBO)
1658% eventdata  reserved - to be defined in a future version of MATLAB
1659% handles    structure with handles and user data (see GUIDATA)
1660
1661% Restore the data and list entry for the last deleted value       
1662ResultsStr = get(handles.listbox1,'String');
1663handles.Sauver=getappdata(handles.figure1,'Sauver');
1664handles.Ecran=getappdata(handles.figure1,'Ecran');
1665handles.ResultsData=getappdata(handles.figure1,'ResultsData');
1666
1667LastValue=length(handles.Sauver) ;
1668toto=handles.Sauver(LastValue);
1669titi=handles.Ecran(LastValue);
1670Numero=toto.RunNumber;
1671Nombre=length(handles.ResultsData);
1672reussite=0;
1673
1674if Numero>handles.ResultsData(Nombre).RunNumber
1675    handles.ResultsData=[handles.ResultsData toto];
1676    ResultsStr = [ResultsStr ; titi];
1677else
1678    i=0;     
1679    while isequal(reussite,0) & (i<(length(handles.ResultsData)))
1680            i=  i+1  ;
1681            if Numero>handles.ResultsData(Nombre-i+1).RunNumber
1682                handles.ResultsData=[handles.ResultsData(1:Nombre-i+1) toto handles.ResultsData(Nombre-i+2:end)];
1683                ResultsStr = [ResultsStr(1:Nombre-i+1) ; titi;ResultsStr(Nombre-i+2:end) ];
1684                reussite=reussite+1;
1685            end
1686       
1687    end
1688    if isequal(reussite,0) 
1689        handles.ResultsData=[toto handles.ResultsData];
1690        ResultsStr = [titi ; ResultsStr];
1691    end
1692   
1693end
1694
1695% Build the new results list string for the listbox
1696set(handles.listbox1,'String',ResultsStr);
1697
1698% Store the new ResultsData
1699handles.Sauver(LastValue)=[];
1700handles.Ecran(LastValue)=[];
1701setappdata(handles.figure1,'Sauver',handles.Sauver)
1702setappdata(handles.figure1,'Ecran',handles.Ecran)
1703setappdata(handles.figure1,'ResultsData',handles.ResultsData);
1704
1705% affiche le nombre de data utilisï¿œs dans le calcul d'ï¿œmittance
1706set(handles.nbacqu_edit13,'String', num2str(size(ResultsStr,1)));
1707
1708
1709% dï¿œsactiver le bouton restaurer si la liste est vide
1710if isequal(LastValue,1)
1711        set([handles.restaurer_pushbutton15],'Enable','off')   
1712end
1713guidata(hObject, handles);
1714
1715
1716% --- Executes on button press in mesuressfaisceau_pushbutton16.
1717function mesuressfaisceau_pushbutton16_Callback(hObject, eventdata, handles)
1718% hObject    handle to mesuressfaisceau_pushbutton16 (see GCBO)
1719% eventdata  reserved - to be defined in a future version of MATLAB
1720% handles    structure with handles and user data (see GUIDATA)
1721
1722% sauvegarde sur disque de l'ensemble des acquisitions avec et sans
1723% faisceau, proposee lorsque aucune acquisition avec faiseau n'est encore
1724% faite
1725entree=    getappdata(handles.figure1,'ResultsData');
1726directory_principale = getappdata(handles.figure1,'directory_principale');
1727if isequal(length(entree),0)
1728   
1729       %ouvrir le dossier pour l'enregistrement des profils
1730       prompt={'entrer un nom de rï¿œpertoire'};
1731       name='SAUVEGARDE SUR DISQUE';
1732       numlines=1;
1733       defaultanswer={strcat(datestr(clock,29),'_1')};
1734       options.Resize='on';
1735       options.WindowStyle='normal';
1736       options.Interpreter='tex';
1737       
1738       % on ne propose la boite de dialogue qu'une seule fois
1739       % ulterieurement, si on souhaite changer de directory de sauvegarde,
1740       % cela se fait interactivement dans le '   '
1741       val=getappdata(handles.figure1,'init_sauvegarde');
1742       directory_principale=getappdata(handles.figure1,'directory_principale');
1743       
1744       while isequal(val,0)
1745            directory=inputdlg(prompt,name,numlines,defaultanswer,options);
1746            % chemin=strcat('/home/PM/tordeux/matlab_test/',directory{:});
1747            %%directory_sauvegarde=strcat(directory_principale,directory{:});
1748            directory_sauvegarde=strcat(directory_principale,directory{:},'/');
1749            setappdata(handles.figure1,'directory_sauvegarde',directory_sauvegarde);
1750           
1751           
1752            % cas ou un nom de directory a ï¿œtï¿œ rentrï¿œ
1753            if ~isequal(directory,{})
1754                % cas ou la directory n'existe pas
1755                %%if ~isdir(strcat('/home/PM/tordeux/matlab_test/',directory{:}))
1756                if ~isdir(directory_sauvegarde)   
1757%                     mkdir(chemin)
1758%                     cd(chemin);
1759                    mkdir(directory_sauvegarde)
1760                    cd(directory_sauvegarde);
1761                   
1762                    setappdata(handles.figure1,'init_sauvegarde',1);
1763                    val=getappdata(handles.figure1,'init_sauvegarde');
1764                    set(handles.directory_sauvegarde_edit28,'String',directory_sauvegarde);
1765                   
1766                % cas ou la directory existe deja
1767                else   
1768                    button = questdlg('ce dossier existe ! voulez-vous continuer?','ATTENTION','oui','non','non') ;
1769                    if isequal(button,'oui')
1770                       
1771%                         cd(chemin);
1772                        cd(directory_sauvegarde); 
1773                       
1774                        setappdata(handles.figure1,'init_sauvegarde',1);
1775                        val=getappdata(handles.figure1,'init_sauvegarde');
1776                        set(handles.directory_sauvegarde_edit28,'String',directory_sauvegarde);
1777         
1778                    else
1779                        % retour ï¿œ la case dï¿œpart
1780                       
1781                    end
1782                end     
1783           
1784            % cas ou on a refusï¿œ de rentrer un nom de directory
1785            else
1786               
1787                errordlg('vous n''avez pas sï¿œlectionnï¿œ de directory de sauvegarde !','Attention');
1788               
1789                setappdata(handles.figure1,'init_sauvegarde',1);
1790                val=getappdata(handles.figure1,'init_sauvegarde');
1791            end
1792           
1793       end
1794
1795end
1796
1797
1798showsansfgui_15(handles);
1799
1800
1801%__________________________________________________________________________
1802% --- Executes on button press in Gmax_pushbutton26.
1803function Gmin_pushbutton28_Callback(hObject, eventdata, handles)
1804% hObject    handle to Gmax_pushbutton26 (see GCBO)
1805% eventdata  reserved - to be defined in a future version of MATLAB
1806% handles    structure with handles and user data (see GUIDATA)
1807
1808
1809
1810% alias
1811device_name = getappdata(handles.figure1,'device_name');
1812
1813% recuperer les valeurs de position des lentilles pour ce grandissement
1814posl1Gmin=getappdata(handles.figure1,'posl1Gmin');
1815posl2Gmin=getappdata(handles.figure1,'posl2Gmin');
1816
1817set(handles.Lenthaute_radiobutton7,'Value',0);
1818set(handles.tata_radiobutton10,'Value',0);
1819
1820% eteindre un voyant grandissement ᅵventuellement allumᅵ
1821set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
1822set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
1823set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
1824
1825dev=device_name.lentille_haute
1826
1827
1828errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
1829
1830if (tango_error == -1)
1831      %- handle error
1832      tango_print_error_stack;
1833      return;
1834      errordlg('erreur tango !','Erreur');
1835
1836else
1837    % cas ou l'axe n'est pas en butee backward (en haut)
1838    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
1839    % errorstatus=4  limitswitch backward
1840   
1841     if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
1842
1843        % si on est en butï¿œe basse forward on ï¿œteind le voyant
1844        if isequal(errorstatus,21)|isequal(errorstatus,3)
1845             set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
1846        end
1847         
1848        % aller en butee haute
1849        tango_command_inout(dev,'AxisBackward');
1850       
1851        % on attent que l'axe se mette en mouvement
1852        %temporisation_mvt_axis(dev);
1853        if (temporisation_mvt_axis(dev) == -1)
1854         % abort
1855        end
1856       
1857        % attendre la fin de la commande
1858        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
1859            set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
1860            pause(0.2);
1861            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
1862            pause(0.2);
1863            % on affiche la position de la lentille
1864            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
1865            set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
1866%             set(handles.Lenthaute_radiobutton7,'BackgroundColor','green')
1867%             pause(0.5);
1868        end
1869        % on affiche la position de la lentille
1870        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
1871        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
1872        %set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
1873    end
1874
1875    % % si le moteur n'est pas en butee ce n'est pas normal..
1876    % if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
1877    %     % probleme !
1878    %     errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
1879
1880    % indiquer la butee haute sur moteur 1 (lentille haute)
1881    set(handles.LHBH_edit25,'BackgroundColor','red');
1882   
1883    % definir la position 0
1884    tango_command_inout(dev,'AxisDefinePosition',0);
1885   
1886    % avancer du nombre de pas exact correspondant au grandissement : 0
1887   
1888    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
1889        set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
1890        pause(0.2);
1891        set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
1892        pause(0.2);
1893        % on affiche la position de la lentille
1894        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
1895        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
1896%         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
1897%         pause(0.5);
1898    end
1899   
1900    % on affiche la position de la lentille
1901    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
1902    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
1903   
1904    %set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
1905   
1906
1907end   
1908 
1909dev=device_name.lentille_basse
1910
1911errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
1912
1913if (tango_error == -1)
1914      %- handle error
1915      tango_print_error_stack;
1916      return;
1917      errordlg('erreur tango !','Erreur');
1918
1919else
1920    % cas ou l'axe n'est pas en butee backward (en haut)
1921    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
1922    % errorstatus=4  limitswitch backward
1923   
1924    if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
1925   
1926        % si on est en butï¿œe basse forward on ï¿œteind le voyant
1927        if isequal(errorstatus,21)|isequal(errorstatus,3)
1928             set(handles.LBBB_edit26,'BackgroundColor',[0.702 0.702 0.702]);
1929        end
1930       
1931        % aller en butee haute backward
1932        tango_command_inout(dev,'AxisBackward');
1933       
1934        % on attent que l'axe se mette en mouvement
1935        %temporisation_mvt_axis(dev);
1936        if (temporisation_mvt_axis(dev) == -1)
1937         % abort
1938        end
1939       
1940        % attendre la fin de la commande
1941        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
1942            set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
1943            pause(0.2);
1944            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
1945            pause(0.2);
1946            % on affiche la position de la lentille
1947            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
1948            set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
1949%             pause(0.2);
1950%             set(handles.tata_radiobutton10,'BackgroundColor','green');
1951%             pause(0.2);
1952%             set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
1953        end
1954        % on affiche la position de la lentille
1955        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
1956        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
1957        set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
1958        % set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
1959    end
1960   
1961    %     % si le moteur n'est pas en butee ce n'est pas normal..
1962    %     if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
1963    %         % probleme !
1964    %         errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
1965    %     else
1966
1967    % definir la position 0
1968    tango_command_inout(dev,'AxisDefinePosition',0);
1969    % on affiche la position de la lentille
1970    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
1971    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
1972   
1973    % eteindre le voyant rouge butee backward s'il est allumï¿œ
1974    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
1975   
1976    % avancer du nombre de pas exact correspondant au grandissement
1977    tango_command_inout(dev,'AxisGoToPosition',posl2Gmin);
1978     
1979    % on attent que l'axe se mette en mouvement
1980    %temporisation_mvt_axis(dev);
1981    if (temporisation_mvt_axis(dev) == -1)
1982         % abort
1983    end
1984       
1985    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
1986        set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
1987        pause(0.2);
1988        set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
1989        pause(0.2);
1990        % on affiche la position de la lentille
1991        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
1992        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
1993%         pause(0.2);
1994%         set(handles.tata_radiobutton10,'BackgroundColor','green');
1995%         pause(0.2);
1996%         set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
1997    end
1998 
1999    % on affiche la position de la lentille
2000    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2001    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2002        % ï¿œteindre le vert
2003        %set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2004       
2005
2006end   
2007
2008% allumer le voyant rouge Gmin
2009pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition')
2010pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition')
2011test1 = test_position(pos1.value(1),posl1Gmin,5);
2012test2 = test_position(pos2.value(1),posl2Gmin,5);
2013if test1 == 1&test2==1
2014    set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
2015end
2016
2017%__________________________________________________________________________
2018% --- Executes on button press in Gmoy_pushbutton27.
2019function Gmoy_pushbutton27_Callback(hObject, eventdata, handles)
2020% hObject    handle to Gmoy_pushbutton27 (see GCBO)
2021% eventdata  reserved - to be defined in a future version of MATLAB
2022% handles    structure with handles and user data (see GUIDATA)
2023
2024% recuperer les valeurs de position des lentilles pour ce grandissement
2025posl1Gmoy=getappdata(handles.figure1,'posl1Gmoy');
2026posl2Gmoy=getappdata(handles.figure1,'posl2Gmoy');
2027device_name = getappdata(handles.figure1,'device_name');
2028
2029set(handles.Lenthaute_radiobutton7,'Value',0);
2030set(handles.tata_radiobutton10,'Value',0);
2031
2032% eteindre un voyant grandissement ᅵventuellement allumᅵ
2033set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2034set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2035set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2036
2037dev=device_name.lentille_haute
2038
2039errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2040
2041if (tango_error == -1)
2042      %- handle error
2043      tango_print_error_stack;
2044      return;
2045      errordlg('erreur tango !','Erreur');
2046
2047else
2048    % cas ou l'axe n'est pas en butee backward (en haut)
2049    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
2050    % errorstatus=4  limitswitch backward
2051   
2052     if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
2053
2054        % si on est en butï¿œe basse forward on ï¿œteind le voyant
2055        if isequal(errorstatus,21)|isequal(errorstatus,3)
2056             set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
2057        end
2058         
2059        % aller en butee haute
2060        tango_command_inout(dev,'AxisBackward');
2061       
2062        % on attent que l'axe se mette en mouvement
2063        if (temporisation_mvt_axis(dev) == -1)
2064         % abort
2065        end
2066       
2067        % attendre la fin de la commande
2068        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2069            set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2070            pause(0.2);
2071            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2072            pause(0.2);
2073            % on affiche la position de la lentille
2074            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2075            set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2076%             set(handles.Lenthaute_radiobutton7,'BackgroundColor','green')
2077%             pause(0.5);
2078        end
2079        % on affiche la position de la lentille
2080        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2081        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2082%             set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2083    end
2084
2085    % % si le moteur n'est pas en butee ce n'est pas normal..
2086    % if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
2087    %     % probleme !
2088    %     errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
2089
2090    % indiquer la butee haute sur moteur 1 (lentille haute)
2091    set(handles.LHBH_edit25,'BackgroundColor','red');
2092   
2093    % definir la position 0
2094    tango_command_inout(dev,'AxisDefinePosition',0);
2095    fonction_error
2096    % on affiche la position de la lentille
2097    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2098    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2099   
2100    status0 =  tango_command_inout(dev,'AxisGetMotionStatus')
2101    % avancer du nombre de pas exact correspondant au grandissement moyen :
2102    tango_command_inout(dev,'AxisGoToPosition',posl1Gmoy);
2103    fonction_error
2104    % eteindre le voyant butï¿œe haute
2105    set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2106   
2107    % on attent que l'axe se mette en mouvement
2108    %temporisation_mvt_axis(dev);
2109    if (temporisation_mvt_axis(dev) == -1)
2110        error =  tango_command_inout(dev,'AxisGetMotionStatus')
2111        disp('lentille haute')
2112        % abort
2113    end
2114   
2115    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2116        set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2117        pause(0.2);
2118        set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2119        pause(0.2);
2120        % on affiche la position de la lentille
2121        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2122        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2123%         pause(0.2);
2124%         set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2125%         pause(0.2);
2126%         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
2127    end
2128   
2129    % on affiche la position de la lentille
2130    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2131    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2132    set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2133   
2134end   
2135 
2136dev=device_name.lentille_basse
2137
2138errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2139
2140if (tango_error == -1)
2141      %- handle error
2142      tango_print_error_stack;
2143      return;
2144      errordlg('erreur tango !','Erreur');
2145
2146else
2147    % cas ou l'axe n'est pas en butee backward (en haut)
2148    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
2149    % errorstatus=4  limitswitch backward
2150   
2151    if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
2152   
2153        % si on est en butï¿œe basse forward on ï¿œteind le voyant
2154        if isequal(errorstatus,21)|isequal(errorstatus,3)
2155             set(handles.LBBB_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2156        end
2157       
2158        % aller en butee haute backward
2159        tango_command_inout(dev,'AxisBackward');
2160       
2161        % on attent que l'axe se mette en mouvement
2162        %temporisation_mvt_axis(dev);
2163        if (temporisation_mvt_axis(dev) == -1)
2164         % abort
2165         disp('moy : abort')
2166        end
2167
2168        % au cas oï¿œ la butï¿œe haute est allumï¿œe on l'ï¿œteint
2169        set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2170       
2171        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2172            set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2173            pause(0.2);
2174            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2175            pause(0.2);
2176            % on affiche la position de la lentille
2177            %pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2178            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2179            %set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2180            set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2181%             pause(0.2);
2182%             set(handles.tata_radiobutton10,'BackgroundColor','green');
2183%             pause(0.2);
2184%             set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2185        end
2186       
2187        % set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2188    end
2189   
2190    %     % si le moteur n'est pas en butee ce n'est pas normal..
2191    %     if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
2192    %         % probleme !
2193    %         errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
2194    %     else
2195
2196    % definir la position 0
2197    tango_command_inout(dev,'AxisDefinePosition',0);
2198    fonction_error;
2199   
2200    % on affiche la position de la lentille
2201    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2202    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2203
2204    % eteindre le voyant rouge butee backward s'il est allumï¿œ
2205    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2206
2207    % avancer du nombre de pas exact correspondant au grandissement
2208    tango_command_inout(dev,'AxisGoToPosition',posl2Gmoy);
2209   
2210    % on attent que l'axe se mette en mouvement
2211    if (temporisation_mvt_axis(dev) == -1)
2212        error =  tango_command_inout(dev,'AxisGetMotionStatus')
2213        % abort
2214    end
2215
2216    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2217        set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2218        pause(0.2);
2219        set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2220        pause(0.2);
2221        % on affiche la position de la lentille
2222        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2223        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2224    end
2225   
2226    % on affiche la position de la lentille
2227    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2228    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2229%         % ï¿œteindre le vert
2230%         set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2231   
2232
2233end   
2234
2235% allumer le voyant rouge Gmoy
2236pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition')
2237pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition')
2238test1 = test_position(pos1.value(1),posl1Gmoy,5);
2239test2 = test_position(pos2.value(1),posl2Gmoy,5);
2240if test1 == 1&test2==1
2241    set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2242end
2243
2244%__________________________________________________________________________
2245% --- Executes on button press in Gmin_pushbutton28.
2246function Gmax_pushbutton26_Callback(hObject, eventdata, handles)
2247% hObject    handle to Gmin_pushbutton28 (see GCBO)
2248% eventdata  reserved - to be defined in a future version of MATLAB
2249% handles    structure with handles and user data (see GUIDATA)
2250
2251% recuperer les valeurs de positions des lentilles pour ce grandissement
2252posl1Gmax=getappdata(handles.figure1,'posl1Gmax');
2253posl2Gmax=getappdata(handles.figure1,'posl2Gmax');
2254device_name = getappdata(handles.figure1,'device_name');
2255
2256set(handles.Lenthaute_radiobutton7,'Value',0);
2257set(handles.tata_radiobutton10,'Value',0);
2258
2259% eteindre un voyant grandissement ᅵventuellement allumᅵ
2260
2261set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2262set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2263set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2264
2265
2266
2267dev=device_name.lentille_haute
2268
2269errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2270
2271if (tango_error == -1)
2272      %- handle error
2273      tango_print_error_stack;
2274      return;
2275      errordlg('erreur tango !','Erreur');
2276
2277else
2278    % cas ou l'axe n'est pas en butee backward (en haut)
2279    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
2280    % errorstatus=4  limitswitch backward
2281   
2282     if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
2283
2284        % si on est en butï¿œe basse forward on ï¿œteind le voyant
2285        if isequal(errorstatus,21)|isequal(errorstatus,3)
2286             set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
2287        end
2288         
2289        % aller en butee haute
2290        tango_command_inout(dev,'AxisBackward');
2291       
2292        % on attent que l'axe se mette en mouvement
2293        %temporisation_mvt_axis(dev);
2294        if (temporisation_mvt_axis(dev) == -1)
2295         % abort
2296        end
2297       
2298        % attendre la fin de la commande
2299        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2300            set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2301            pause(0.2);
2302            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2303            pause(0.2);
2304            % on affiche la position de la lentille
2305            pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2306            set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2307%             pause(0.2);
2308%             set(handles.Lenthaute_radiobutton7,'BackgroundColor','green')
2309%             pause(0.2);
2310%             set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702])
2311        end
2312        % on affiche la position de la lentille
2313        pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2314        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2315            %set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2316    end
2317
2318    % % si le moteur n'est pas en butee ce n'est pas normal..
2319    % if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
2320    %     % probleme !
2321    %     errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
2322
2323    % indiquer la butee haute sur moteur 1 (lentille haute)
2324    set(handles.LHBH_edit25,'BackgroundColor','red');
2325   
2326    % definir la position 0
2327    tango_command_inout(dev,'AxisDefinePosition',0);
2328    % on affiche la position de la lentille
2329    pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2330    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2331   
2332    % avancer du nombre de pas exact correspondant au grandissement max :
2333    tango_command_inout(dev,'AxisGoToPosition',posl1Gmax);
2334    % eteindre le voyant butï¿œe haute
2335    set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2336         
2337    % on attent que l'axe se mette en mouvement
2338    %temporisation_mvt_axis(dev);
2339    if (temporisation_mvt_axis(dev) == -1)
2340         % abort
2341    end
2342   
2343    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2344        set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2345        pause(0.2);
2346        set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2347        pause(0.2);
2348        % on affiche la position de la lentille
2349        pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2350        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2351%         pause(0.2);
2352%         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green')
2353%         pause(0.2);
2354%         set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702])
2355    end
2356    % on affiche la position de la lentille
2357    pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2358    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2359        %set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2360   
2361   
2362end   
2363 
2364dev=device_name.lentille_basse
2365
2366errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2367
2368if (tango_error == -1)
2369      %- handle error
2370      tango_print_error_stack;
2371      return;
2372      errordlg('erreur tango !','Erreur');
2373
2374else
2375    % cas ou l'axe n'est pas en butee backward (en haut)
2376    % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens -
2377    % errorstatus=4  limitswitch backward
2378   
2379    if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
2380   
2381        % si on est en butï¿œe basse forward on ï¿œteind le voyant
2382        if isequal(errorstatus,21)|isequal(errorstatus,3)
2383             set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
2384        end
2385       
2386        % aller en butee haute backward
2387        tango_command_inout(dev,'AxisBackward');
2388       
2389        % on attent que l'axe se mette en mouvement
2390        %temporisation_mvt_axis(dev);
2391        if (temporisation_mvt_axis(dev) == -1)
2392         % abort
2393        end
2394           
2395        % attendre la fin de la commande
2396            % set(handles.tata_radiobutton10,'BackgroundColor','green');
2397        while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2398            set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2399            pause(0.2);
2400            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2401            pause(0.2);
2402            % on affiche la position de la lentille
2403            pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2404            set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2405%             pause(0.2);
2406%             set(handles.tata_radiobutton10,'BackgroundColor','green');
2407%             pause(0.2);
2408%             set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2409        end
2410        % on affiche la position de la lentille
2411        pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2412        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2413            %set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2414            % set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2415    end
2416   
2417    %     % si le moteur n'est pas en butee ce n'est pas normal..
2418    %     if ~isequal(tango_command_inout(dev,'AxisGetMotionStatus'),-1)
2419    %         % probleme !
2420    %         errordlg('bizzare, vous n''etes pas en butï¿œe...?!','Erreur');
2421    %     else
2422
2423    % definir la position 0
2424    tango_command_inout(dev,'AxisDefinePosition',0);
2425    % on affiche la position de la lentille
2426    pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2427    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2428   
2429    % eteindre le voyant rouge butee backward s'il est allumï¿œ
2430    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2431   
2432    % avancer du nombre de pas exact correspondant au grandissement MAX ...
2433    tango_command_inout(dev,'AxisGoToPosition',posl2Gmax);
2434   
2435    % on attent que l'axe se mette en mouvement
2436    %temporisation_mvt_axis(dev);
2437    if (temporisation_mvt_axis(dev) == -1)
2438         % abort
2439    end
2440           
2441    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2442        set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2443        pause(0.2);
2444        set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2445        pause(0.2);
2446        % on affiche la position de la lentille
2447        pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2448        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2449%         pause(0.2);
2450%         set(handles.tata_radiobutton10,'BackgroundColor','green');
2451%         pause(0.2);
2452%         set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2453    end
2454    % on affiche la position de la lentille
2455    pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
2456    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2457    %     % ï¿œteindre le vert
2458    %     set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2459
2460end   
2461
2462% allumer le voyant Gmax en rouge
2463pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition')
2464pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition')
2465test1 = test_position(pos1.value(1),posl1Gmax,5);
2466test2 = test_position(pos2.value(1),posl2Gmax,5);
2467if test1 == 1&test2==1
2468    set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2469end
2470
2471%__________________________________________________________________________
2472% --- Executes on button press in ppp_pushbutton18.
2473function ppp_pushbutton18_Callback(hObject, eventdata, handles)
2474% hObject    handle to ppp_pushbutton18 (see GCBO)
2475% eventdata  reserved - to be defined in a future version of MATLAB
2476% handles    structure with handles and user data (see GUIDATA)
2477
2478logdev1=get(handles.Lenthaute_radiobutton7,'Value');
2479logdev2=get(handles.tata_radiobutton10,'Value');
2480posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
2481posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
2482posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
2483posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
2484posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
2485posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
2486device_name = getappdata(handles.figure1,'device_name');
2487
2488if isequal(logdev1,0)&isequal(logdev2,0)
2489    errordlg('selectionnez une lentille','ATTENTION');
2490else
2491    if isequal(logdev1,1)
2492        dev=device_name.lentille_haute;
2493        nbpas=5000;
2494    else
2495        dev=device_name.lentille_basse;
2496        nbpas=10000;
2497    end
2498   
2499    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2500
2501    if (tango_error == -1)
2502        %- handle error
2503        tango_print_error_stack;
2504        return;
2505        errordlg('erreur tango !','Erreur');
2506
2507    else
2508        % cas ou l'axe n'est pas en butee forward (en bas)
2509        % errorstatus=21 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
2510        % errorstatus=3  limitswitch forward
2511
2512        if ~isequal(errorstatus,21)&~isequal(errorstatus,3)
2513 
2514            % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
2515            if isequal(errorstatus,22)|isequal(errorstatus,4)
2516                if isequal(logdev1,1)
2517                    set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2518                else
2519                    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2520                end
2521            end
2522           
2523            % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
2524            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2525            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2526            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2527           
2528            % on descend vers la butï¿œe forward
2529            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
2530       
2531            % temporisation :
2532            %temporisation_mvt_axis(dev);
2533            if (temporisation_mvt_axis(dev) == -1)
2534                % abort
2535            end
2536 
2537            while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2538               
2539                if isequal(logdev1,1)
2540                   
2541                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
2542                    % on affiche la position de la lentille
2543                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2544                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2545                    pause(0.2);
2546                    drawnow;
2547                else
2548                   
2549                    set(handles.tata_radiobutton10,'BackgroundColor','green');
2550                    % on affiche la position de la lentille
2551                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2552                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2553                    pause(0.2);
2554                    drawnow;
2555                   
2556                end
2557                %pause(0.5);
2558            end
2559           
2560            pause(0.5);
2561            % on ï¿œteind le vert ï¿œ la fin du mouvement
2562            % on ï¿œcrit une derniï¿œre fois la position de la lentille
2563            if isequal(logdev1,1)
2564                set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2565                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2566                set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2567
2568            else
2569                set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2570                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2571                set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2572            end
2573           
2574            % si on est arrivï¿œ en butï¿œe forward on allume le voyant
2575            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2576            if isequal(errorstatus,21)|isequal(errorstatus,3)
2577                if isequal(logdev1,1)
2578                    set(handles.LHBB_edit24,'BackgroundColor','red');
2579                else
2580                    set(handles.LBBB_edit27,'BackgroundColor','red');
2581                end
2582            end
2583           
2584            % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
2585     
2586            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2587            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2588            if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
2589                set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2590            elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
2591                set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2592            elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
2593                set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
2594            end
2595           
2596        else
2597            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
2598        end
2599    end
2600end
2601
2602%
2603%
2604% logdev1=get(handles.Lenthaute_radiobutton7,'Value');
2605% logdev2=get(handles.tata_radiobutton10,'Value');
2606% posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
2607% posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
2608% posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
2609% posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
2610% posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
2611% posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
2612%
2613% if isequal(logdev1,0)&isequal(logdev2,0)
2614%     errordlg('selectionnez une lentille','ATTENTION');
2615% else
2616%     if isequal(logdev1,1)
2617%         dev=device_name.lentille_haute;
2618%         nbpas=5000;
2619%     else
2620%         dev=device_name.lentille_basse;
2621%         nbpas=10000;
2622%     end
2623%     
2624%     errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2625%
2626%     if (tango_error == -1)
2627%         %- handle error
2628%         tango_print_error_stack;
2629%         return;
2630%         errordlg('erreur tango !','Erreur');
2631%
2632%     else
2633%         % cas ou l'axe n'est pas en butee forward (en bas)
2634%         % errorstatus=21 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
2635%         % errorstatus=3  limitswitch forward
2636%
2637%         if ~isequal(errorstatus,21)&~isequal(errorstatus,3)
2638
2639%             % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
2640%             if isequal(errorstatus,22)|isequal(errorstatus,4)
2641%                 if isequal(logdev1,1)
2642%                     set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2643%                 else
2644%                     set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2645%                 end
2646%             end
2647%             
2648%             % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
2649%             set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2650%             set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2651%             set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2652%             
2653%             
2654%             % on descend vers la butï¿œe forward
2655%             tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
2656%         
2657%             % temporisation :
2658%             pause(0.2);
2659%             while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2660%                 if isequal(logdev1,1)
2661%                     set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
2662%                 else
2663%                     set(handles.tata_radiobutton10,'BackgroundColor','green');
2664%                 end
2665%                 pause(0.5);
2666%             end
2667%             
2668%             % on ï¿œteind le vert ï¿œ la fin du mouvement
2669%             if isequal(logdev1,1)
2670%                 set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2671%             else
2672%                 set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2673%             end
2674%             
2675%             % si on est arrivï¿œ en butï¿œe forward on allume le voyant
2676%             errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2677%             if isequal(errorstatus,21)|isequal(errorstatus,3)
2678%                 if isequal(logdev1,1)
2679%                     set(handles.LHBB_edit24,'BackgroundColor','red');
2680%                 else
2681%                     set(handles.LBBB_edit27,'BackgroundColor','red');
2682%                 end
2683%             end
2684%             
2685%             % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
2686%       
2687%             pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2688%             pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2689%             if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
2690%                 set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2691%             elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
2692%                 set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2693%             elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
2694%                 set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
2695%             end
2696%             
2697%         else
2698%             errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
2699%         end
2700%     end
2701% end
2702%
2703
2704
2705
2706% --- Executes on button press in pp_pushbutton19.
2707function pp_pushbutton19_Callback(hObject, eventdata, handles)
2708% hObject    handle to pp_pushbutton19 (see GCBO)
2709% eventdata  reserved - to be defined in a future version of MATLAB
2710% handles    structure with handles and user data (see GUIDATA)
2711
2712logdev1=get(handles.Lenthaute_radiobutton7,'Value');
2713logdev2=get(handles.tata_radiobutton10,'Value');
2714posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
2715posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
2716posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
2717posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
2718posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
2719posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
2720device_name = getappdata(handles.figure1,'device_name');
2721
2722if isequal(logdev1,0)&isequal(logdev2,0)
2723    errordlg('selectionnez une lentille','ATTENTION');
2724else
2725    if isequal(logdev1,1)
2726        dev=device_name.lentille_haute;
2727        nbpas=500;
2728    else
2729        dev=device_name.lentille_basse;
2730        nbpas=1000;
2731    end
2732   
2733    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2734
2735    if (tango_error == -1)
2736        %- handle error
2737        tango_print_error_stack;
2738        return;
2739        errordlg('erreur tango !','Erreur');
2740
2741    else
2742        % cas ou l'axe n'est pas en butee forward (en bas)
2743        % errorstatus=21 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
2744        % errorstatus=3  limitswitch forward
2745
2746        if ~isequal(errorstatus,21)&~isequal(errorstatus,3)
2747 
2748            % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
2749            if isequal(errorstatus,22)|isequal(errorstatus,4)
2750                if isequal(logdev1,1)
2751                    set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2752                else
2753                    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2754                end
2755            end
2756           
2757            % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
2758            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2759            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2760            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2761           
2762            % on descend vers la butï¿œe forward
2763            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
2764       
2765            % temporisation :
2766            %temporisation_mvt_axis(dev);
2767            if (temporisation_mvt_axis(dev) == -1)
2768                % abort
2769            end
2770 
2771            while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2772               
2773                if isequal(logdev1,1)
2774                   
2775                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
2776                    % on affiche la position de la lentille
2777                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2778                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2779                    pause(0.2);
2780                    drawnow;
2781                else
2782                   
2783                    set(handles.tata_radiobutton10,'BackgroundColor','green');
2784                    % on affiche la position de la lentille
2785                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2786                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2787                    pause(0.2);
2788                    drawnow;
2789                   
2790                end
2791                %pause(0.5);
2792            end
2793           
2794            pause(0.5);
2795            % on ï¿œteind le vert ï¿œ la fin du mouvement
2796            % on ï¿œcrit une derniï¿œre fois la position de la lentille
2797            if isequal(logdev1,1)
2798                set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2799                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2800                set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2801
2802            else
2803                set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2804                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2805                set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2806            end
2807           
2808            % si on est arrivï¿œ en butï¿œe forward on allume le voyant
2809            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2810            if isequal(errorstatus,21)|isequal(errorstatus,3)
2811                if isequal(logdev1,1)
2812                    set(handles.LHBB_edit24,'BackgroundColor','red');
2813                else
2814                    set(handles.LBBB_edit27,'BackgroundColor','red');
2815                end
2816            end
2817           
2818            % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
2819     
2820            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2821            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2822            if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
2823                set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2824            elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
2825                set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2826            elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
2827                set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
2828            end
2829           
2830        else
2831            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
2832        end
2833    end
2834end
2835
2836
2837
2838
2839% --- Executes on button press in p_pushbutton20.
2840function p_pushbutton20_Callback(hObject, eventdata, handles)
2841% hObject    handle to p_pushbutton20 (see GCBO)
2842% eventdata  reserved - to be defined in a future version of MATLAB
2843% handles    structure with handles and user data (see GUIDATA)
2844
2845logdev1=get(handles.Lenthaute_radiobutton7,'Value');
2846logdev2=get(handles.tata_radiobutton10,'Value');
2847posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
2848posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
2849posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
2850posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
2851posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
2852posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
2853device_name = getappdata(handles.figure1,'device_name');
2854
2855if isequal(logdev1,0)&isequal(logdev2,0)
2856    errordlg('selectionnez une lentille','ATTENTION');
2857else
2858    if isequal(logdev1,1)
2859        dev=device_name.lentille_haute;
2860        nbpas=50;
2861    else
2862        dev=device_name.lentille_basse;
2863        nbpas=100;
2864    end
2865   
2866    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2867
2868    if (tango_error == -1)
2869        %- handle error
2870        tango_print_error_stack;
2871        return;
2872        errordlg('erreur tango !','Erreur');
2873
2874    else
2875        % cas ou l'axe n'est pas en butee forward (en bas)
2876        % errorstatus=21 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
2877        % errorstatus=3  limitswitch forward
2878
2879        if ~isequal(errorstatus,21)&~isequal(errorstatus,3)
2880 
2881            % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
2882            if isequal(errorstatus,22)|isequal(errorstatus,4)
2883                if isequal(logdev1,1)
2884                    set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
2885                else
2886                    set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
2887                end
2888            end
2889           
2890            % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
2891            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
2892            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
2893            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
2894           
2895           
2896            % on descend vers la butï¿œe forward
2897            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
2898       
2899            % temporisation :
2900            %temporisation_mvt_axis(dev);
2901            if (temporisation_mvt_axis(dev) == -1)
2902                % abort
2903            end
2904           
2905            %pause(0.2);
2906            while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
2907                if isequal(logdev1,1)
2908                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
2909                    % on affiche la position de la lentille
2910                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2911                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2912                else
2913                    set(handles.tata_radiobutton10,'BackgroundColor','green');
2914                    % on affiche la position de la lentille
2915                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2916                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2917                end
2918               
2919            end
2920           
2921            pause(0.5);
2922            % on ï¿œteind le vert ï¿œ la fin du mouvement
2923            % on ï¿œcrit une derniï¿œre fois la position de la lentille
2924           
2925            if isequal(logdev1,1)
2926                set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
2927                % on affiche la position de la lentille
2928                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2929                set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
2930               
2931            else
2932                set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
2933                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2934                set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
2935               
2936            end
2937           
2938            % si on est arrivï¿œ en butï¿œe forward on allume le voyant
2939           
2940            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2941            if isequal(errorstatus,21)|isequal(errorstatus,3)
2942                if isequal(logdev1,1)
2943                    set(handles.LHBB_edit24,'BackgroundColor','red');
2944                   
2945                else
2946                    set(handles.LBBB_edit27,'BackgroundColor','red');
2947
2948                end
2949            end
2950           
2951            % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
2952     
2953            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
2954            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
2955            if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
2956                set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
2957            elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
2958                set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
2959            elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
2960                set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
2961            end
2962           
2963        else
2964            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
2965        end
2966    end
2967end
2968
2969% --- Executes on button press in m_pushbutton23.
2970function mmm_pushbutton21_Callback(hObject, eventdata, handles)
2971% hObject    handle to m_pushbutton23 (see GCBO)
2972% eventdata  reserved - to be defined in a future version of MATLAB
2973% handles    structure with handles and user data (see GUIDATA)
2974
2975logdev1=get(handles.Lenthaute_radiobutton7,'Value');
2976logdev2=get(handles.tata_radiobutton10,'Value');
2977posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
2978posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
2979posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
2980posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
2981posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
2982posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
2983device_name = getappdata(handles.figure1,'device_name');
2984
2985if isequal(logdev1,0)&isequal(logdev2,0)
2986    errordlg('selectionnez une lentille','ATTENTION');
2987else
2988    if isequal(logdev1,1)
2989        dev=device_name.lentille_haute;
2990        nbpas=-5000;
2991    else
2992        dev=device_name.lentille_basse;
2993        nbpas=-10000;
2994    end
2995   
2996    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
2997
2998    if (tango_error == -1)
2999        %- handle error
3000        tango_print_error_stack;
3001        return;
3002        errordlg('erreur tango !','Erreur');
3003
3004    else
3005        % cas ou l'axe n'est pas en butee backward (en haut)
3006        % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
3007        % errorstatus=4  limitswitch forward
3008
3009        if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
3010 
3011            % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
3012            if isequal(errorstatus,21)|isequal(errorstatus,3)
3013                if isequal(logdev1,1)
3014                    set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
3015                else
3016                    set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
3017                end
3018            end
3019           
3020             % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
3021            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
3022            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
3023            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
3024           
3025           
3026            % on monte vers la butï¿œe backward
3027            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
3028            if (tango_error == -1)
3029                %- handle error
3030                tango_print_error_stack;
3031                return;
3032                errordlg('erreur tango !','Erreur');
3033
3034            else
3035           
3036                % temporisation :
3037                %temporisation_mvt_axis(dev);
3038                if (temporisation_mvt_axis(dev) == -1)
3039                    % abort
3040                end
3041
3042                if isequal(logdev1,1)
3043                   
3044                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3045                    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3046                        % on affiche la position de la lentille
3047                        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3048                        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3049                        pause(0.2);
3050                        drawnow;
3051                    end
3052                   
3053                else
3054                   
3055                    set(handles.tata_radiobutton10,'BackgroundColor','green');
3056                    while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3057                        % on affiche la position de la lentille
3058                        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3059                        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3060                        pause(0.2);
3061                        drawnow;
3062                    end
3063                   
3064                end
3065%                 while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3066%                     disp('dans la boucle tant que mvt')
3067%                     if isequal(logdev1,1)
3068%                         disp('je dois afficher le vert')
3069%                         pause(0.1);
3070%                         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3071%                         % on affiche la position de la lentille
3072%                         pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3073%                         %pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3074%                         set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3075%                         %set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3076%                     else
3077%                         set(handles.tata_radiobutton10,'BackgroundColor','green');
3078%                         % on affiche la position de la lentille
3079%                         %pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3080%                         pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3081%                         %set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3082%                         set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3083%
3084%                     end
3085%                 end
3086
3087                pause(0.5);
3088                % on ï¿œteind le vert ï¿œ la fin du mouvement
3089                % on ï¿œcrit une derniï¿œre fois la position de la lentille
3090
3091                if isequal(logdev1,1)
3092                    set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
3093                    % on affiche la position de la lentille
3094                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3095                    %pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3096                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3097                    %set(handles.pos2_edit30,'String',num2str(pos2.value(1)
3098                    %));
3099
3100                else
3101                    set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
3102                    %pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3103                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3104                    %set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3105                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3106
3107                end
3108
3109                % si on est arrivï¿œ en butï¿œe backward on allume le voyant
3110                errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3111                if isequal(errorstatus,22)|isequal(errorstatus,4)
3112                    if isequal(logdev1,1)
3113                        set(handles.LHBH_edit25,'BackgroundColor','red');
3114                    else
3115                        set(handles.LBBH_edit26,'BackgroundColor','red');
3116                    end
3117                end
3118
3119                % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
3120
3121                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3122                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3123                if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
3124                    set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
3125                elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
3126                    set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
3127                elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
3128                    set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
3129                end
3130            end
3131        else
3132            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
3133        end
3134    end
3135end
3136
3137
3138
3139
3140%     % --- Executes on button press in mmm_pushbutton21.
3141%     function mmm_pushbutton21_Callback(hObject, eventdata, handles)
3142%     % hObject    handle to mmm_pushbutton21 (see GCBO)
3143%     % eventdata  reserved - to be defined in a future version of MATLAB
3144%     % handles    structure with handles and user data (see GUIDATA)
3145%
3146%     logdev1=get(handles.Lenthaute_radiobutton7,'Value');
3147%     logdev2=get(handles.tata_radiobutton10,'Value');
3148%     posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
3149%     posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
3150%     posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
3151%     posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
3152%     posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
3153%     posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
3154%
3155%     if isequal(logdev1,0)&isequal(logdev2,0)
3156%         errordlg('selectionnez une lentille','ATTENTION');
3157%     else
3158%         if isequal(logdev1,1)
3159%             dev=device_name.lentille_haute;
3160%             nbpas=-5000;
3161%         else
3162%             dev=device_name.lentille_basse;
3163%             nbpas=-10000;
3164%         end
3165%
3166%         errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3167%
3168%         if (tango_error == -1)
3169%             %- handle error
3170%             tango_print_error_stack;
3171%             return;
3172%             errordlg('erreur tango !','Erreur');
3173%
3174%         else
3175%             % cas ou l'axe n'est pas en butee backward (en haut)
3176%             % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
3177%             % errorstatus=4  limitswitch forward
3178%
3179%             if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
3180%
3181%                 % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
3182%                 if isequal(errorstatus,21)|isequal(errorstatus,3)
3183%                     if isequal(logdev1,1)
3184%                         set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
3185%                     else
3186%                         set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
3187%                     end
3188%                 end
3189%
3190%                 % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
3191%                 set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
3192%                 set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
3193%                 set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
3194%
3195%                 % on monte vers la butï¿œe backward
3196%                 tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
3197%
3198%                 % temporisation :
3199%                 pause(0.2);
3200%                 while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3201%                     if isequal(logdev1,1)
3202%                         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3203%                     else
3204%                         set(handles.tata_radiobutton10,'BackgroundColor','green');
3205%                     end
3206%                     pause(0.5);
3207%                 end
3208%
3209%                 % on ï¿œteind le vert ï¿œ la fin du mouvement
3210%                 if isequal(logdev1,1)
3211%                     set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
3212%                 else
3213%                     set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
3214%                 end
3215%
3216%                 % si on est arrivï¿œ en butï¿œe backward on allume le voyant
3217%                 errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3218%                 if isequal(errorstatus,22)|isequal(errorstatus,4)
3219%                     if isequal(logdev1,1)
3220%                         set(handles.LHBH_edit25,'BackgroundColor','red');
3221%                     else
3222%                         set(handles.LBBH_edit26,'BackgroundColor','red');
3223%                     end
3224%                 end
3225%
3226%                 % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
3227%
3228%                 pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3229%                 pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3230%                 if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
3231%                     set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
3232%                 elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
3233%                     set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
3234%                 elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
3235%                     set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
3236%                 end
3237%
3238%
3239%             else
3240%                 errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
3241%             end
3242%         end
3243%     end
3244
3245% --- Executes on button press in m_pushbutton23.
3246function mm_pushbutton22_Callback(hObject, eventdata, handles)
3247% hObject    handle to m_pushbutton23 (see GCBO)
3248% eventdata  reserved - to be defined in a future version of MATLAB
3249% handles    structure with handles and user data (see GUIDATA)
3250
3251logdev1=get(handles.Lenthaute_radiobutton7,'Value');
3252logdev2=get(handles.tata_radiobutton10,'Value');
3253posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
3254posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
3255posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
3256posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
3257posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
3258posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
3259device_name = getappdata(handles.figure1,'device_name');
3260
3261if isequal(logdev1,0)&isequal(logdev2,0)
3262    errordlg('selectionnez une lentille','ATTENTION');
3263else
3264    if isequal(logdev1,1)
3265        dev=device_name.lentille_haute;
3266        nbpas=-500;
3267    else
3268        dev=device_name.lentille_basse;
3269        nbpas=-1000;
3270    end
3271   
3272    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3273
3274    if (tango_error == -1)
3275        %- handle error
3276        tango_print_error_stack;
3277        return;
3278        errordlg('erreur tango !','Erreur');
3279
3280    else
3281        % cas ou l'axe n'est pas en butee backward (en haut)
3282        % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
3283        % errorstatus=4  limitswitch forward
3284
3285        if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
3286 
3287            % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
3288            if isequal(errorstatus,21)|isequal(errorstatus,3)
3289                if isequal(logdev1,1)
3290                    set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
3291                else
3292                    set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
3293                end
3294            end
3295           
3296             % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
3297            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
3298            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
3299            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
3300           
3301           
3302            % on monte vers la butï¿œe backward
3303            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
3304            if (tango_error == -1)
3305                %- handle error
3306                tango_print_error_stack;
3307                return;
3308                errordlg('erreur tango !','Erreur');
3309
3310            else
3311           
3312                % temporisation :
3313                %temporisation_mvt_axis(dev);
3314                if (temporisation_mvt_axis(dev) == -1)
3315                    % abort
3316                end
3317
3318                while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3319                   
3320                    if isequal(logdev1,1)
3321                        set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3322                        % on affiche la position de la lentille
3323                        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3324                        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3325                        pause(0.2);
3326                        drawnow;
3327                       
3328                    else
3329                       
3330                        set(handles.tata_radiobutton10,'BackgroundColor','green');
3331                        % on affiche la position de la lentille
3332                        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3333                        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3334                        pause(0.2);
3335                        drawnow;
3336
3337                    end
3338                end
3339
3340                pause(0.5);
3341                % on ï¿œteind le vert ï¿œ la fin du mouvement
3342                % on ï¿œcrit une derniï¿œre fois la position de la lentille
3343
3344                if isequal(logdev1,1)
3345                    set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
3346                    % on affiche la position de la lentille
3347                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3348                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3349
3350                else
3351                    set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
3352                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3353                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3354
3355                end
3356
3357                % si on est arrivï¿œ en butï¿œe backward on allume le voyant
3358                errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3359                if isequal(errorstatus,22)|isequal(errorstatus,4)
3360                    if isequal(logdev1,1)
3361                        set(handles.LHBH_edit25,'BackgroundColor','red');
3362                    else
3363                        set(handles.LBBH_edit26,'BackgroundColor','red');
3364                    end
3365                end
3366
3367                % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
3368
3369                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3370                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3371                if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
3372                    set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
3373                elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
3374                    set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
3375                elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
3376                    set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
3377                end
3378            end
3379        else
3380            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
3381        end
3382    end
3383end
3384
3385%
3386%
3387%     % --- Executes on button press in mm_pushbutton22.
3388%     function mm_pushbutton22_Callback(hObject, eventdata, handles)
3389%     % hObject    handle to mm_pushbutton22 (see GCBO)
3390%     % eventdata  reserved - to be defined in a future version of MATLAB
3391%     % handles    structure with handles and user data (see GUIDATA)
3392%
3393%
3394%     logdev1=get(handles.Lenthaute_radiobutton7,'Value');
3395%     logdev2=get(handles.tata_radiobutton10,'Value');
3396%     posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
3397%     posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
3398%     posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
3399%     posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
3400%     posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
3401%     posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
3402%
3403%     if isequal(logdev1,0)&isequal(logdev2,0)
3404%         errordlg('selectionnez une lentille','ATTENTION');
3405%     else
3406%         if isequal(logdev1,1)
3407%             dev=device_name.lentille_haute;
3408%             nbpas=-500;
3409%         else
3410%             dev=device_name.lentille_basse;
3411%             nbpas=-1000;
3412%         end
3413%
3414%         errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3415%
3416%         if (tango_error == -1)
3417%             %- handle error
3418%             tango_print_error_stack;
3419%             return;
3420%             errordlg('erreur tango !','Erreur');
3421%
3422%         else
3423%             % cas ou l'axe n'est pas en butee backward (en haut)
3424%             % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
3425%             % errorstatus=4  limitswitch forward
3426%
3427%             if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
3428%
3429%                 % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
3430%                 if isequal(errorstatus,21)|isequal(errorstatus,3)
3431%                     if isequal(logdev1,1)
3432%                         set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
3433%                     else
3434%                         set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
3435%                     end
3436%                 end
3437%
3438%                 % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
3439%                 set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
3440%                 set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
3441%                 set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
3442%
3443%                 % on monte vers la butï¿œe backward
3444%                 tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
3445%                 if (tango_error == -1)
3446%                     %- handle error
3447%                     tango_print_error_stack;
3448%                     return;
3449%                     errordlg('erreur tango !','Erreur');
3450%
3451%                 else
3452%
3453%                 % temporisation :
3454%                 pause(0.2);
3455%                 while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3456%                     if isequal(logdev1,1)
3457%                         set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3458%                     else
3459%                         set(handles.tata_radiobutton10,'BackgroundColor','green');
3460%                     end
3461%                     pause(0.5);
3462%                 end
3463%
3464%                 % on ï¿œteind le vert ï¿œ la fin du mouvement
3465%                 if isequal(logdev1,1)
3466%                     set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
3467%                 else
3468%                     set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
3469%                 end
3470%
3471%                 % si on est arrivï¿œ en butï¿œe backward on allume le voyant
3472%                 errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3473%                 if isequal(errorstatus,22)|isequal(errorstatus,4)
3474%                     if isequal(logdev1,1)
3475%                         set(handles.LHBH_edit25,'BackgroundColor','red');
3476%                     else
3477%                         set(handles.LBBH_edit26,'BackgroundColor','red');
3478%                     end
3479%                 end
3480%
3481%                 % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
3482%
3483%                 pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3484%                 pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3485%                 if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
3486%                     set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
3487%                 elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
3488%                     set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
3489%                 elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
3490%                     set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
3491%                 end
3492%
3493%                 end
3494%             else
3495%                 errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
3496%             end
3497%         end
3498%     end
3499
3500
3501% --- Executes on button press in m_pushbutton23.
3502function m_pushbutton23_Callback(hObject, eventdata, handles)
3503% hObject    handle to m_pushbutton23 (see GCBO)
3504% eventdata  reserved - to be defined in a future version of MATLAB
3505% handles    structure with handles and user data (see GUIDATA)
3506
3507logdev1=get(handles.Lenthaute_radiobutton7,'Value');
3508logdev2=get(handles.tata_radiobutton10,'Value');
3509posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
3510posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
3511posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
3512posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
3513posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
3514posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
3515device_name = getappdata(handles.figure1,'device_name');
3516
3517if isequal(logdev1,0)&isequal(logdev2,0)
3518    errordlg('selectionnez une lentille','ATTENTION');
3519else
3520    if isequal(logdev1,1)
3521        dev=device_name.lentille_haute;
3522        nbpas=-50;
3523    else
3524        dev=device_name.lentille_basse;
3525        nbpas=-100;
3526    end
3527   
3528    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3529
3530    if (tango_error == -1)
3531        %- handle error
3532        tango_print_error_stack;
3533        return;
3534        errordlg('erreur tango !','Erreur');
3535
3536    else
3537        % cas ou l'axe n'est pas en butee backward (en haut)
3538        % errorstatus=22 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
3539        % errorstatus=4  limitswitch forward
3540
3541        if ~isequal(errorstatus,22)&~isequal(errorstatus,4)
3542 
3543            % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
3544            if isequal(errorstatus,21)|isequal(errorstatus,3)
3545                if isequal(logdev1,1)
3546                    set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
3547                else
3548                    set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
3549                end
3550            end
3551           
3552             % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
3553            set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
3554            set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
3555            set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
3556           
3557           
3558            % on monte vers la butï¿œe backward
3559            tango_command_inout(dev,'AxisGoToRelativePosition',nbpas);
3560            if (tango_error == -1)
3561                %- handle error
3562                tango_print_error_stack;
3563                return;
3564                errordlg('erreur tango !','Erreur');
3565
3566            else
3567           
3568                % temporisation :
3569                %temporisation_mvt_axis(dev);
3570                if (temporisation_mvt_axis(dev) == -1)
3571                    % abort
3572                end
3573               
3574                while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
3575                    if isequal(logdev1,1)
3576                        set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
3577                        % on affiche la position de la lentille
3578                        pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3579                        set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3580                    else
3581                        set(handles.tata_radiobutton10,'BackgroundColor','green');
3582                        % on affiche la position de la lentille
3583                        pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3584                        set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3585
3586                    end
3587                end
3588
3589                pause(0.5);
3590                % on ï¿œteind le vert ï¿œ la fin du mouvement
3591                % on ï¿œcrit une derniï¿œre fois la position de la lentille
3592
3593                if isequal(logdev1,1)
3594                    set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
3595                    % on affiche la position de la lentille
3596                    pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3597                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
3598
3599                else
3600                    set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
3601                    pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3602                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
3603
3604                end
3605
3606                % si on est arrivï¿œ en butï¿œe backward on allume le voyant
3607                errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3608                if isequal(errorstatus,22)|isequal(errorstatus,4)
3609                    if isequal(logdev1,1)
3610                        set(handles.LHBH_edit25,'BackgroundColor','red');
3611                    else
3612                        set(handles.LBBH_edit26,'BackgroundColor','red');
3613                    end
3614                end
3615
3616                % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
3617
3618                pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
3619                pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
3620                if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
3621                    set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
3622                elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
3623                    set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
3624                elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
3625                    set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
3626                end
3627            end
3628        else
3629            errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
3630        end
3631    end
3632end
3633
3634
3635%         % --- Executes on button press in backlight_pushbutton24.
3636%         function backlight_pushbutton24_Callback(hObject, eventdata, handles)
3637%         % hObject    handle to backlight_pushbutton24 (see GCBO)
3638%         % eventdata  reserved - to be defined in a future version of MATLAB
3639%         % handles    structure with handles and user data (see GUIDATA)
3640%
3641%         prompt={'entrer une intensitï¿œ * entier entre 0 et 10'};
3642%         name='backlight';
3643%         numlines=1;
3644%         lumiere=tango_command_inout('lt1/emit/backlight','GetBrightness');
3645%         %- check error
3646%         if (tango_error == -1)
3647%               %- handle error
3648%               tango_print_error_stack;
3649%               return;
3650%         else
3651%             defaultanswer={num2str(lumiere)};
3652%         end
3653%         options.Resize='on';
3654%         options.WindowStyle='normal';
3655%         options.Interpreter='tex';
3656%         intensite=inputdlg(prompt,name,numlines,defaultanswer,options);
3657%         if ~isempty(intensite)
3658%             tango_command_inout('lt1/emit/backlight','SetBrightness',uint16(str2num(intensite{:})));
3659%         end
3660%
3661%     % --- Executes on button press in iris_pushbutton25.
3662%     function iris_pushbutton25_Callback(hObject, eventdata, handles)
3663%     % hObject    handle to iris_pushbutton25 (see GCBO)
3664%     % eventdata  reserved - to be defined in a future version of MATLAB
3665%     % handles    structure with handles and user data (see GUIDATA)
3666%
3667%     %      %entrer les deux variables vitesse et intensite pour l'iris
3668%     %        prompt={'entrer la vitesse - valeur entre 1 et 3','entrer l''intensite - valeur entre 1 et 10'};
3669%     %        name='IRIS';
3670%     %        numlines=1;
3671%     %        defaultanswer={'3','10'};
3672%     %        options.Resize='on';
3673%     %        options.WindowStyle='normal';
3674%     %        options.Interpreter='tex';
3675%     %        val=0;
3676%     %     %     while isequal(val,0)
3677%     %         choix=inputdlg(prompt,name,numlines,defaultanswer,options);
3678%     %     %         if ~isequal(directory,{})
3679%     %     %             if ~isdir(strcat('/home/PM/tordeux/matlab_test/',directory{:}))
3680%     %     %                 mkdir /home/PM/tordeux/matlab_test/directory;
3681%     %     %                 val=1;
3682%     %     %             else   
3683%     %     %                 button = questdlg('ce dossier existe ! voulez-vous continuer?','ATTENTION','oui','non','non') 
3684%     %     %                 if isequal(button,'oui')
3685%     %     %                     val=1;
3686%     %     %                 end
3687%     %     %             end     
3688%     %     %         else
3689%     %     %             %avoir deja creï¿œ une directory de secours pour si on a fait "cancel"..
3690%     %     %             directory={'secours'};
3691%     %     %             val=1;
3692%     %     %         end
3693%     %     %     end
3694%
3695%     IRIS(handles);
3696%
3697
3698
3699function qualite_edit23_Callback(hObject, eventdata, handles)
3700% hObject    handle to qualite_edit23 (see GCBO)
3701% eventdata  reserved - to be defined in a future version of MATLAB
3702% handles    structure with handles and user data (see GUIDATA)
3703
3704% Hints: get(hObject,'String') returns contents of qualite_edit23 as text
3705%        str2double(get(hObject,'String')) returns contents of qualite_edit23 as a double
3706
3707
3708% --- Executes during object creation, after setting all properties.
3709function qualite_edit23_CreateFcn(hObject, eventdata, handles)
3710% hObject    handle to qualite_edit23 (see GCBO)
3711% eventdata  reserved - to be defined in a future version of MATLAB
3712% handles    empty - handles not created until after all CreateFcns called
3713
3714% Hint: edit controls usually have a white background on Windows.
3715%       See ISPC and COMPUTER.
3716if ispc
3717    set(hObject,'BackgroundColor','white');
3718else
3719    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3720end
3721
3722
3723
3724function LHBB_edit24_Callback(hObject, eventdata, handles)
3725% hObject    handle to LHBB_edit24 (see GCBO)
3726% eventdata  reserved - to be defined in a future version of MATLAB
3727% handles    structure with handles and user data (see GUIDATA)
3728
3729% Hints: get(hObject,'String') returns contents of LHBB_edit24 as text
3730%        str2double(get(hObject,'String')) returns contents of LHBB_edit24 as a double
3731
3732
3733% --- Executes during object creation, after setting all properties.
3734function LHBB_edit24_CreateFcn(hObject, eventdata, handles)
3735% hObject    handle to LHBB_edit24 (see GCBO)
3736% eventdata  reserved - to be defined in a future version of MATLAB
3737% handles    empty - handles not created until after all CreateFcns called
3738
3739% Hint: edit controls usually have a white background on Windows.
3740%       See ISPC and COMPUTER.
3741if ispc
3742    set(hObject,'BackgroundColor','white');
3743else
3744    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3745end
3746
3747
3748
3749function LHBH_edit25_Callback(hObject, eventdata, handles)
3750% hObject    handle to LHBH_edit25 (see GCBO)
3751% eventdata  reserved - to be defined in a future version of MATLAB
3752% handles    structure with handles and user data (see GUIDATA)
3753
3754% Hints: get(hObject,'String') returns contents of LHBH_edit25 as text
3755%        str2double(get(hObject,'String')) returns contents of LHBH_edit25 as a double
3756
3757
3758% --- Executes during object creation, after setting all properties.
3759function LHBH_edit25_CreateFcn(hObject, eventdata, handles)
3760% hObject    handle to LHBH_edit25 (see GCBO)
3761% eventdata  reserved - to be defined in a future version of MATLAB
3762% handles    empty - handles not created until after all CreateFcns called
3763
3764% Hint: edit controls usually have a white background on Windows.
3765%       See ISPC and COMPUTER.
3766if ispc
3767    set(hObject,'BackgroundColor','white');
3768else
3769    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3770end
3771
3772
3773
3774function LBBH_edit26_Callback(hObject, eventdata, handles)
3775% hObject    handle to LBBH_edit26 (see GCBO)
3776% eventdata  reserved - to be defined in a future version of MATLAB
3777% handles    structure with handles and user data (see GUIDATA)
3778
3779% Hints: get(hObject,'String') returns contents of LBBH_edit26 as text
3780%        str2double(get(hObject,'String')) returns contents of LBBH_edit26 as a double
3781
3782
3783% --- Executes during object creation, after setting all properties.
3784function LBBH_edit26_CreateFcn(hObject, eventdata, handles)
3785% hObject    handle to LBBH_edit26 (see GCBO)
3786% eventdata  reserved - to be defined in a future version of MATLAB
3787% handles    empty - handles not created until after all CreateFcns called
3788
3789% Hint: edit controls usually have a white background on Windows.
3790%       See ISPC and COMPUTER.
3791if ispc
3792    set(hObject,'BackgroundColor','white');
3793else
3794    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3795end
3796
3797
3798
3799function LBBB_edit27_Callback(hObject, eventdata, handles)
3800% hObject    handle to LBBB_edit27 (see GCBO)
3801% eventdata  reserved - to be defined in a future version of MATLAB
3802% handles    structure with handles and user data (see GUIDATA)
3803
3804% Hints: get(hObject,'String') returns contents of LBBB_edit27 as text
3805%        str2double(get(hObject,'String')) returns contents of LBBB_edit27 as a double
3806
3807
3808% --- Executes during object creation, after setting all properties.
3809function LBBB_edit27_CreateFcn(hObject, eventdata, handles)
3810% hObject    handle to LBBB_edit27 (see GCBO)
3811% eventdata  reserved - to be defined in a future version of MATLAB
3812% handles    empty - handles not created until after all CreateFcns called
3813
3814% Hint: edit controls usually have a white background on Windows.
3815%       See ISPC and COMPUTER.
3816if ispc
3817    set(hObject,'BackgroundColor','white');
3818else
3819    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3820end
3821
3822
3823% --- Executes on button press in fondGmax_pushbutton29.
3824function fondGmax_pushbutton29_Callback(hObject, eventdata, handles)
3825% hObject    handle to fondGmax_pushbutton29 (see GCBO)
3826% eventdata  reserved - to be defined in a future version of MATLAB
3827% handles    structure with handles and user data (see GUIDATA)
3828
3829
3830% --- Executes on button press in fondGmoy_pushbutton30.
3831function fondGmoy_pushbutton30_Callback(hObject, eventdata, handles)
3832% hObject    handle to fondGmoy_pushbutton30 (see GCBO)
3833% eventdata  reserved - to be defined in a future version of MATLAB
3834% handles    structure with handles and user data (see GUIDATA)
3835
3836
3837% --- Executes on button press in fondGmin_pushbutton31.
3838function fondGmin_pushbutton31_Callback(hObject, eventdata, handles)
3839% hObject    handle to fondGmin_pushbutton31 (see GCBO)
3840% eventdata  reserved - to be defined in a future version of MATLAB
3841% handles    structure with handles and user data (see GUIDATA)
3842
3843
3844
3845function directory_sauvegarde_edit28_Callback(hObject, eventdata, handles)
3846% hObject    handle to directory_sauvegarde_edit28 (see GCBO)
3847% eventdata  reserved - to be defined in a future version of MATLAB
3848% handles    structure with handles and user data (see GUIDATA)
3849
3850% Hints: get(hObject,'String') returns contents of directory_sauvegarde_edit28 as text
3851%        str2double(get(hObject,'String')) returns contents of directory_sauvegarde_edit28 as a double
3852
3853
3854% % directory principale (dï¿œpend de l'utilisateur !!!)
3855% setappdata(handles.figure1,'directory_principale',directory_principale);
3856%
3857% % directory de sauvegarde en attente
3858% setappdata(handles.figure1,'directory_principale','/home/PM/tordeux/matlab_test/');
3859% directory_principale=getappdata(handles.figure1,'directory_principale');
3860% phrase=strcat(directory_principale,'?');
3861
3862directory_sauvegarde=get(handles.directory_sauvegarde_edit28,'String');
3863setappdata(handles.figure1,'directory_sauvegarde',directory_sauvegarde);
3864
3865% cas ou la directory n'existe pas
3866%if ~isdir(strcat('/home/PM/tordeux/matlab_test/',directory{:}))
3867if  ~isdir(   directory_sauvegarde)
3868%                     mkdir(chemin)
3869%                     cd(chemin);
3870    mkdir(directory_sauvegarde)
3871    cd(directory_sauvegarde);
3872
3873    %setappdata(handles.figure1,'init_sauvegarde',1);
3874    %val=getappdata(handles.figure1,'init_sauvegarde');
3875    %set(handles.directory_sauvegarde_edit28,'String',directory_sauvegarde);
3876    setappdata(handles.figure1,'directory_sauvegarde',directory_sauvegarde);
3877
3878% cas ou la directory existe deja
3879else   
3880    button = questdlg('ce dossier existe ! voulez-vous continuer?','ATTENTION','oui','non','non') ;
3881    if isequal(button,'oui')
3882
3883%                         cd(chemin);
3884        cd(directory_sauvegarde); 
3885
3886        %setappdata(handles.figure1,'init_sauvegarde',1);
3887        %val=getappdata(handles.figure1,'init_sauvegarde');
3888        %set(handles.directory_sauvegarde_edit28,'String',directory_sauvegarde);
3889        setappdata(handles.figure1,'directory_sauvegarde',directory_sauvegarde);
3890
3891    else
3892        % retour ï¿œ la case dï¿œpart
3893
3894    end
3895end     
3896
3897
3898
3899% --- Executes during object creation, after setting all properties.
3900function directory_sauvegarde_edit28_CreateFcn(hObject, eventdata, handles)
3901% hObject    handle to directory_sauvegarde_edit28 (see GCBO)
3902% eventdata  reserved - to be defined in a future version of MATLAB
3903% handles    empty - handles not created until after all CreateFcns called
3904
3905% Hint: edit controls usually have a white background on Windows.
3906%       See ISPC and COMPUTER.
3907if ispc
3908    set(hObject,'BackgroundColor','white');
3909else
3910    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3911end
3912
3913
3914% --- Executes on selection change in backlight_popupmenu3.
3915function backlight_popupmenu3_Callback(hObject, eventdata, handles)
3916% hObject    handle to backlight_popupmenu3 (see GCBO)
3917% eventdata  reserved - to be defined in a future version of MATLAB
3918% handles    structure with handles and user data (see GUIDATA)
3919
3920% Hints: contents = get(hObject,'String') returns backlight_popupmenu3 contents as cell array
3921%        contents{get(hObject,'Value')} returns selected item from backlight_popupmenu3
3922
3923%alias
3924device_name = getappdata(handles.figure1,'device_name');
3925dev = device_name.backlight;
3926
3927val = get(hObject,'Value');
3928switch val
3929case 1
3930tango_command_inout(dev,'SetBrightness',uint16(0));   
3931case 2
3932tango_command_inout(dev,'SetBrightness',uint16(1)); 
3933case 3
3934tango_command_inout(dev,'SetBrightness',uint16(2)); 
3935case 4
3936tango_command_inout(dev,'SetBrightness',uint16(3)); 
3937case 5
3938tango_command_inout(dev,'SetBrightness',uint16(4)); 
3939case 6
3940tango_command_inout(dev,'SetBrightness',uint16(5)); 
3941case 7
3942tango_command_inout(dev,'SetBrightness',uint16(6)); 
3943case 8
3944tango_command_inout(dev,'SetBrightness',uint16(7)); 
3945case 9
3946tango_command_inout(dev,'SetBrightness',uint16(8)); 
3947case 10
3948tango_command_inout(dev,'SetBrightness',uint16(9)); 
3949case 11
3950tango_command_inout(dev,'SetBrightness',uint16(10)); 
3951
3952end
3953
3954% --- Executes during object creation, after setting all properties.
3955function backlight_popupmenu3_CreateFcn(hObject, eventdata, handles)
3956% hObject    handle to backlight_popupmenu3 (see GCBO)
3957% eventdata  reserved - to be defined in a future version of MATLAB
3958% handles    empty - handles not created until after all CreateFcns called
3959
3960% Hint: popupmenu controls usually have a white background on Windows.
3961%       See ISPC and COMPUTER.
3962if ispc
3963    set(hObject,'BackgroundColor','white');
3964else
3965    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
3966end
3967
3968set(hObject, 'String', {'0','1','2','3','4','5','6',...
3969    '7','8','9','10',...
3970    });
3971
3972
3973function pos1_edit29_Callback(hObject, eventdata, handles)
3974% hObject    handle to pos1_edit29 (see GCBO)
3975% eventdata  reserved - to be defined in a future version of MATLAB
3976% handles    structure with handles and user data (see GUIDATA)
3977
3978% Hints: get(hObject,'String') returns contents of pos1_edit29 as text
3979%        str2double(get(hObject,'String')) returns contents of pos1_edit29 as a double
3980
3981% encore ᅵ faire !!
3982
3983
3984% posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
3985% posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
3986% posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
3987% posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
3988% posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
3989% posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
3990% device_name = getappdata(handles.figure1,'device_name');
3991%     
3992% numeropas = get(handles.pos1_edit29,'String');
3993% errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
3994%
3995% if (tango_error == -1)
3996%     %- handle error
3997%     tango_print_error_stack;
3998%     return;
3999%     errordlg('erreur tango !','Erreur');
4000%
4001% else
4002%         % cas ou l'axe n'est pas en butee forward (en bas)
4003%         % errorstatus=21 dï¿œcï¿œlï¿œration ou arrï¿œt dï¿œ ï¿œ un limit switch sens +
4004%         % errorstatus=3  limitswitch forward
4005%
4006%         if ~isequal(errorstatus,21)&~isequal(errorstatus,3)
4007
4008%             % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
4009%             if isequal(errorstatus,22)|isequal(errorstatus,4)
4010%                 if isequal(logdev1,1)
4011%                     set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
4012%                 else
4013%                     set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
4014%                 end
4015%             end
4016%             
4017%             % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
4018%             set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
4019%             set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
4020%             set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
4021%             
4022%             
4023%             % on bouge
4024%             tango_command_inout(dev,'AxisGoToPosition',numeropas);
4025%         
4026%             % temporisation :
4027%             temporisation_mvt_axis(dev);
4028%             
4029%             while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
4030%                 
4031%                 set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
4032%                 % on affiche la position de la lentille
4033%                 pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
4034%                 set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4035%
4036%             end
4037%             
4038%             pause(0.5);
4039%             % on ï¿œteind le vert ï¿œ la fin du mouvement
4040%             % on ï¿œcrit une derniï¿œre fois la position de la lentille
4041
4042%                 set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
4043%                 % on affiche la position de la lentille
4044%                 pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
4045%                 set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4046%                             
4047%             % si on est arrivï¿œ en butï¿œe forward on allume le voyant
4048%             
4049%             errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4050%             if isequal(errorstatus,21)|isequal(errorstatus,3)
4051%                 if isequal(logdev1,1)
4052%                     set(handles.LHBB_edit24,'BackgroundColor','red');
4053%                     
4054%                 else
4055%                     set(handles.LBBB_edit27,'BackgroundColor','red');
4056%
4057%                 end
4058%             end
4059%             
4060%             % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
4061%       
4062%             pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
4063%             pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
4064%             if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
4065%                 set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
4066%             elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
4067%                 set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
4068%             elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
4069%                 set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
4070%             end
4071%             
4072%         else
4073%             errordlg('dï¿œjï¿œ en butee ou erreur','ATTENTION');
4074%         end
4075%     end
4076% end
4077%
4078
4079% --- Executes during object creation, after setting all properties.
4080function pos1_edit29_CreateFcn(hObject, eventdata, handles)
4081% hObject    handle to pos1_edit29 (see GCBO)
4082% eventdata  reserved - to be defined in a future version of MATLAB
4083% handles    empty - handles not created until after all CreateFcns called
4084
4085% Hint: edit controls usually have a white background on Windows.
4086%       See ISPC and COMPUTER.
4087if ispc
4088    set(hObject,'BackgroundColor','white');
4089else
4090    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
4091end
4092
4093
4094
4095function pos2_edit30_Callback(hObject, eventdata, handles)
4096% hObject    handle to pos2_edit30 (see GCBO)
4097% eventdata  reserved - to be defined in a future version of MATLAB
4098% handles    structure with handles and user data (see GUIDATA)
4099
4100% Hints: get(hObject,'String') returns contents of pos2_edit30 as text
4101%        str2double(get(hObject,'String')) returns contents of pos2_edit30 as a double
4102
4103
4104% --- Executes during object creation, after setting all properties.
4105function pos2_edit30_CreateFcn(hObject, eventdata, handles)
4106% hObject    handle to pos2_edit30 (see GCBO)
4107% eventdata  reserved - to be defined in a future version of MATLAB
4108% handles    empty - handles not created until after all CreateFcns called
4109
4110% Hint: edit controls usually have a white background on Windows.
4111%       See ISPC and COMPUTER.
4112if ispc
4113    set(hObject,'BackgroundColor','white');
4114else
4115    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
4116end
4117
4118
4119% --- Executes on button press in F_iris_pushbutton32.
4120function F_iris_pushbutton32_Callback(hObject, eventdata, handles)
4121% hObject    handle to F_iris_pushbutton32 (see GCBO)
4122% eventdata  reserved - to be defined in a future version of MATLAB
4123% handles    structure with handles and user data (see GUIDATA)
4124
4125device_name = getappdata(handles.figure1,'device_name');
4126dev = device_name.iris
4127type = 'CloseX';
4128vitesse = '1';
4129click = '5';
4130commandename=strcat(type,vitesse);
4131tango_command_inout(dev,commandename,int32(str2num(click)));
4132
4133
4134% --- Executes on button press in FF_iris_pushbutton33.
4135function FF_iris_pushbutton33_Callback(hObject, eventdata, handles)
4136% hObject    handle to FF_iris_pushbutton33 (see GCBO)
4137% eventdata  reserved - to be defined in a future version of MATLAB
4138% handles    structure with handles and user data (see GUIDATA)
4139
4140device_name = getappdata(handles.figure1,'device_name');
4141dev = device_name.iris
4142type = 'CloseX';
4143vitesse = '2';
4144click = '5';
4145commandename=strcat(type,vitesse);
4146tango_command_inout(dev,commandename,int32(str2num(click)));
4147
4148
4149% --- Executes on button press in FFF_iris_pushbutton34.
4150function FFF_iris_pushbutton34_Callback(hObject, eventdata, handles)
4151% hObject    handle to FFF_iris_pushbutton34 (see GCBO)
4152% eventdata  reserved - to be defined in a future version of MATLAB
4153% handles    structure with handles and user data (see GUIDATA)
4154
4155device_name = getappdata(handles.figure1,'device_name');
4156dev = device_name.iris
4157type = 'CloseX';
4158vitesse = '3';
4159click = '5';
4160commandename=strcat(type,vitesse);
4161tango_command_inout(dev,commandename,int32(str2num(click)));
4162
4163
4164% --- Executes on button press in O_iris_pushbutton35.
4165function O_iris_pushbutton35_Callback(hObject, eventdata, handles)
4166% hObject    handle to O_iris_pushbutton35 (see GCBO)
4167% eventdata  reserved - to be defined in a future version of MATLAB
4168% handles    structure with handles and user data (see GUIDATA)
4169
4170device_name = getappdata(handles.figure1,'device_name');
4171dev = device_name.iris
4172type = 'OpenX';
4173vitesse = '1';
4174click = '5';
4175commandename=strcat(type,vitesse);
4176tango_command_inout(dev,commandename,int32(str2num(click)));
4177
4178
4179% --- Executes on button press in OO_iris_pushbutton36.
4180function OO_iris_pushbutton36_Callback(hObject, eventdata, handles)
4181% hObject    handle to OO_iris_pushbutton36 (see GCBO)
4182% eventdata  reserved - to be defined in a future version of MATLAB
4183% handles    structure with handles and user data (see GUIDATA)
4184
4185device_name = getappdata(handles.figure1,'device_name');
4186dev = device_name.iris
4187type = 'OpenX';
4188vitesse = '2';
4189click = '5';
4190commandename=strcat(type,vitesse);
4191tango_command_inout(dev,commandename,int32(str2num(click)));
4192
4193
4194% --- Executes on button press in OOO_iris_pushbutton38.
4195function OOO_iris_pushbutton38_Callback(hObject, eventdata, handles)
4196% hObject    handle to OOO_iris_pushbutton38 (see GCBO)
4197% eventdata  reserved - to be defined in a future version of MATLAB
4198% handles    structure with handles and user data (see GUIDATA)
4199
4200device_name = getappdata(handles.figure1,'device_name');
4201dev = device_name.iris
4202type = 'OpenX';
4203vitesse = '3';
4204click = '5';
4205commandename=strcat(type,vitesse);
4206tango_command_inout(dev,commandename,int32(str2num(click)));
4207
4208
4209%% What to do before closing the application
4210function Closinggui(obj, event, handles, figure1)
4211
4212%device_name = getappdata(handles.figure1,'device_name');
4213
4214% Get default command line output from handles structure
4215answer = questdlg('Fermer Emittance ?',...
4216    'Exit Programme Emittance',...
4217    'Yes','No','Yes');
4218
4219switch answer
4220    case 'Yes'           
4221        delete(handles); %Delete Timer       
4222        delete(figure1); %Close gui
4223        %% extraire l'écran YAG
4224        %tango_command_inout(device_name.ecran,'Extract');
4225        %fonction_error;
4226    otherwise
4227        disp('Closing aborted')
4228end
4229
4230
4231
4232function Q2courant_edit_Callback(hObject, eventdata, handles)
4233% hObject    handle to Q2courant_edit (see GCBO)
4234% eventdata  reserved - to be defined in a future version of MATLAB
4235% handles    structure with handles and user data (see GUIDATA)
4236
4237% Hints: get(hObject,'String') returns contents of Q2courant_edit as text
4238%        str2double(get(hObject,'String')) returns contents of Q2courant_edit as a double
4239
4240
4241ecriture('Q2',handles)
4242
4243
4244% --- Executes during object creation, after setting all properties.
4245function Q2courant_edit_CreateFcn(hObject, eventdata, handles)
4246% hObject    handle to Q2courant_edit (see GCBO)
4247% eventdata  reserved - to be defined in a future version of MATLAB
4248% handles    empty - handles not created until after all CreateFcns called
4249
4250% Hint: edit controls usually have a white background on Windows.
4251%       See ISPC and COMPUTER.
4252if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4253    set(hObject,'BackgroundColor','white');
4254end
4255
4256
4257
4258function H2courant_edit_Callback(hObject, eventdata, handles)
4259% hObject    handle to H2courant_edit (see GCBO)
4260% eventdata  reserved - to be defined in a future version of MATLAB
4261% handles    structure with handles and user data (see GUIDATA)
4262
4263% Hints: get(hObject,'String') returns contents of H2courant_edit as text
4264%        str2double(get(hObject,'String')) returns contents of H2courant_edit as a double
4265
4266ecriture('H2',handles)
4267
4268
4269% --- Executes during object creation, after setting all properties.
4270function H2courant_edit_CreateFcn(hObject, eventdata, handles)
4271% hObject    handle to H2courant_edit (see GCBO)
4272% eventdata  reserved - to be defined in a future version of MATLAB
4273% handles    empty - handles not created until after all CreateFcns called
4274
4275% Hint: edit controls usually have a white background on Windows.
4276%       See ISPC and COMPUTER.
4277if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4278    set(hObject,'BackgroundColor','white');
4279end
4280
4281
4282
4283function edit33_Callback(hObject, eventdata, handles)
4284% hObject    handle to edit33 (see GCBO)
4285% eventdata  reserved - to be defined in a future version of MATLAB
4286% handles    structure with handles and user data (see GUIDATA)
4287
4288% Hints: get(hObject,'String') returns contents of edit33 as text
4289%        str2double(get(hObject,'String')) returns contents of edit33 as a double
4290
4291
4292% --- Executes during object creation, after setting all properties.
4293function edit33_CreateFcn(hObject, eventdata, handles)
4294% hObject    handle to edit33 (see GCBO)
4295% eventdata  reserved - to be defined in a future version of MATLAB
4296% handles    empty - handles not created until after all CreateFcns called
4297
4298% Hint: edit controls usually have a white background on Windows.
4299%       See ISPC and COMPUTER.
4300if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4301    set(hObject,'BackgroundColor','white');
4302end
4303
4304
4305
4306function Q3courant_edit_Callback(hObject, eventdata, handles)
4307% hObject    handle to Q3courant_edit (see GCBO)
4308% eventdata  reserved - to be defined in a future version of MATLAB
4309% handles    structure with handles and user data (see GUIDATA)
4310
4311% Hints: get(hObject,'String') returns contents of Q3courant_edit as text
4312%        str2double(get(hObject,'String')) returns contents of Q3courant_edit as a double
4313
4314ecriture('Q3',handles)
4315
4316
4317
4318% --- Executes during object creation, after setting all properties.
4319function Q3courant_edit_CreateFcn(hObject, eventdata, handles)
4320% hObject    handle to Q3courant_edit (see GCBO)
4321% eventdata  reserved - to be defined in a future version of MATLAB
4322% handles    empty - handles not created until after all CreateFcns called
4323
4324% Hint: edit controls usually have a white background on Windows.
4325%       See ISPC and COMPUTER.
4326if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4327    set(hObject,'BackgroundColor','white');
4328end
4329
4330
4331
4332function Q4courant_edit_Callback(hObject, eventdata, handles)
4333% hObject    handle to Q4courant_edit (see GCBO)
4334% eventdata  reserved - to be defined in a future version of MATLAB
4335% handles    structure with handles and user data (see GUIDATA)
4336
4337% Hints: get(hObject,'String') returns contents of Q4courant_edit as text
4338%        str2double(get(hObject,'String')) returns contents of Q4courant_edit as a double
4339
4340ecriture('Q4',handles)
4341
4342
4343
4344% --- Executes during object creation, after setting all properties.
4345function Q4courant_edit_CreateFcn(hObject, eventdata, handles)
4346% hObject    handle to Q4courant_edit (see GCBO)
4347% eventdata  reserved - to be defined in a future version of MATLAB
4348% handles    empty - handles not created until after all CreateFcns called
4349
4350% Hint: edit controls usually have a white background on Windows.
4351%       See ISPC and COMPUTER.
4352if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4353    set(hObject,'BackgroundColor','white');
4354end
4355
4356
4357
4358function type_edit36_Callback(hObject, eventdata, handles)
4359% hObject    handle to type_edit36 (see GCBO)
4360% eventdata  reserved - to be defined in a future version of MATLAB
4361% handles    structure with handles and user data (see GUIDATA)
4362
4363% Hints: get(hObject,'String') returns contents of type_edit36 as text
4364%        str2double(get(hObject,'String')) returns contents of type_edit36 as a double
4365
4366
4367% --- Executes during object creation, after setting all properties.
4368function type_edit36_CreateFcn(hObject, eventdata, handles)
4369% hObject    handle to type_edit36 (see GCBO)
4370% eventdata  reserved - to be defined in a future version of MATLAB
4371% handles    empty - handles not created until after all CreateFcns called
4372
4373% Hint: edit controls usually have a white background on Windows.
4374%       See ISPC and COMPUTER.
4375if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4376    set(hObject,'BackgroundColor','white');
4377end
4378
4379
4380
4381function nbiter_edit37_Callback(hObject, eventdata, handles)
4382% hObject    handle to nbiter_edit37 (see GCBO)
4383% eventdata  reserved - to be defined in a future version of MATLAB
4384% handles    structure with handles and user data (see GUIDATA)
4385
4386% Hints: get(hObject,'String') returns contents of nbiter_edit37 as text
4387%        str2double(get(hObject,'String')) returns contents of nbiter_edit37 as a double
4388
4389
4390% --- Executes during object creation, after setting all properties.
4391function nbiter_edit37_CreateFcn(hObject, eventdata, handles)
4392% hObject    handle to nbiter_edit37 (see GCBO)
4393% eventdata  reserved - to be defined in a future version of MATLAB
4394% handles    empty - handles not created until after all CreateFcns called
4395
4396% Hint: edit controls usually have a white background on Windows.
4397%       See ISPC and COMPUTER.
4398if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4399    set(hObject,'BackgroundColor','white');
4400end
4401
4402
4403
4404function energie_edit38_Callback(hObject, eventdata, handles)
4405% hObject    handle to energie_edit38 (see GCBO)
4406% eventdata  reserved - to be defined in a future version of MATLAB
4407% handles    structure with handles and user data (see GUIDATA)
4408
4409% Hints: get(hObject,'String') returns contents of energie_edit38 as text
4410%        str2double(get(hObject,'String')) returns contents of energie_edit38 as a double
4411
4412
4413% --- Executes during object creation, after setting all properties.
4414function energie_edit38_CreateFcn(hObject, eventdata, handles)
4415% hObject    handle to energie_edit38 (see GCBO)
4416% eventdata  reserved - to be defined in a future version of MATLAB
4417% handles    empty - handles not created until after all CreateFcns called
4418
4419% Hint: edit controls usually have a white background on Windows.
4420%       See ISPC and COMPUTER.
4421if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4422    set(hObject,'BackgroundColor','white');
4423end
4424
4425% --- Executes on button press in imprimer_pushbutton7.
4426function imprimer_pushbutton17_Callback(hObject, eventdata, handles)
4427% hObject    handle to imprimer_pushbutton17 (see GCBO)
4428% eventdata  reserved - to be defined in a future version of MATLAB
4429% handles    structure with handles and user data (see GUIDATA)
4430
4431% Determine file and directory name
4432FileName = '1';
4433
4434DirectoryName = getappdata(handles.figure1,'directory_sauvegarde');
4435
4436% Append date_Time to FileName
4437%FileName = sprintf('%s_%s', 'tableau', FileName);
4438FileName = sprintf( '%s_%s','tableau', FileName);
4439
4440%FileName = appendtimestamp(FileName, clock);
4441[FileName, DirectoryName] = uiputfile('*','Save Lattice to ...', [DirectoryName FileName]);
4442if FileName == 0
4443    fprintf('   File not saved (getmachineconfig)\n');
4444    return;
4445end
4446
4447% Save all data in structure to file
4448DirStart = pwd;
4449[DirectoryName, DirectoryErrorFlag] = gotodirectory(DirectoryName); 
4450
4451ResultsStr = get(handles.listbox1,'String');
4452
4453try
4454    save(FileName,'ResultsStr')
4455    %save(FileName,'ResultsStr','-ascii')
4456    %save -ascii mydata.dat
4457catch
4458    cd(DirStart);
4459    return
4460end
4461cd(DirStart);
4462
4463
4464
4465
4466% --- Executes during object creation, after setting all properties.
4467function imprimer_pushbutton17_CreateFcn(hObject, eventdata, handles)
4468% hObject    handle to imprimer_pushbutton17 (see GCBO)
4469% eventdata  reserved - to be defined in a future version of MATLAB
4470% handles    empty - handles not created until after all CreateFcns called
4471
4472% Hint: edit controls usually have a white background on Windows.
4473%       See ISPC and COMPUTER.
4474
4475
4476% --- Executes on selection change in camera_controle_popupmenu4.
4477function camera_controle_popupmenu4_Callback(hObject, eventdata, handles)
4478% hObject    handle to camera_controle_popupmenu4 (see GCBO)
4479% eventdata  reserved - to be defined in a future version of MATLAB
4480% handles    structure with handles and user data (see GUIDATA)
4481
4482% Hints: contents = get(hObject,'String') returns camera_controle_popupmenu4 contents as cell array
4483%        contents{get(hObject,'Value')} returns selected item from camera_controle_popupmenu4
4484
4485device_name = getappdata(handles.figure1,'device_name');
4486dev = device_name.videograbber;
4487
4488val = get(hObject,'Value');
4489switch val
4490   
4491case 2
4492tango_command_inout(dev,'AutoAdjustRefLevels'); 
4493disp('AutoAdjustRefLevels')
4494case 3
4495tango_command_inout(dev,'EnableCorrectedImage'); 
4496case 4
4497tango_command_inout(dev,'EnableCorrectedProfiles'); 
4498case 5
4499tango_command_inout(dev,'EnableProfiles'); 
4500case 6
4501tango_command_inout(dev,'DisableCorrectedImage'); 
4502case 7
4503tango_command_inout(dev,'DisableCorrectedProfiles'); 
4504case 8
4505tango_command_inout(dev,'DisableProfiles');
4506
4507case 9
4508tango_command_inout(dev,'GetExposureTime');
4509% on donne la possibilité de modifier le exposuretime
4510res = tango_command_inout(dev,'GetExposureTime');
4511prompt={'ExposureTime'};
4512name='GetExposureTime';
4513numlines=1;
4514defaultanswer={num2str(res)};
4515options.Resize='on';
4516options.WindowStyle='normal';
4517options.Interpreter='tex';
4518time = inputdlg(prompt,name,numlines,defaultanswer,options);
4519tango_command_inout(dev,'SetExposureTime',str2num(time{:}));
4520
4521case 10
4522% on donne la possibilité de modifier le shutterdelay
4523res = tango_command_inout(dev,'GetShutterDelay');
4524prompt={'ShutterDelay'};
4525name='GetShutterDelay';
4526numlines=1;
4527defaultanswer={num2str(res)};
4528options.Resize='on';
4529options.WindowStyle='normal';
4530options.Interpreter='tex';
4531delay = inputdlg(prompt,name,numlines,defaultanswer,options);
4532tango_command_inout(dev,'SetShutterDelay',str2num(delay{:}));
4533
4534case 11
4535res = tango_command_inout(dev,'State');
4536errordlg(res,'State');
4537case 12
4538res = tango_command_inout(dev,'Status');
4539errordlg(res,'Status');
4540end
4541
4542
4543% --- Executes during object creation, after setting all properties.
4544function camera_controle_popupmenu4_CreateFcn(hObject, eventdata, handles)
4545% hObject    handle to camera_controle_popupmenu4 (see GCBO)
4546% eventdata  reserved - to be defined in a future version of MATLAB
4547% handles    empty - handles not created until after all CreateFcns called
4548
4549% Hint: popupmenu controls usually have a white background on Windows.
4550%       See ISPC and COMPUTER.
4551if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4552    set(hObject,'BackgroundColor','white');
4553end
4554
4555
4556% --- Executes on selection change in controle_lentilles_popupmenu5.
4557function controle_lentilles_popupmenu5_Callback(hObject, eventdata, handles)
4558% hObject    handle to controle_lentilles_popupmenu5 (see GCBO)
4559% eventdata  reserved - to be defined in a future version of MATLAB
4560% handles    structure with handles and user data (see GUIDATA)
4561
4562% Hints: contents = get(hObject,'String') returns controle_lentilles_popupmenu5 contents as cell array
4563%        contents{get(hObject,'Value')} returns selected item from controle_lentilles_popupmenu5
4564
4565
4566device_name = getappdata(handles.figure1,'device_name');
4567logdev1=get(handles.Lenthaute_radiobutton7,'Value');
4568logdev2=get(handles.tata_radiobutton10,'Value');
4569posl1Gmax = getappdata(handles.figure1,'posl1Gmax');
4570posl2Gmax = getappdata(handles.figure1,'posl2Gmax');
4571posl1Gmoy = getappdata(handles.figure1,'posl1Gmoy');
4572posl2Gmoy = getappdata(handles.figure1,'posl2Gmoy');
4573posl1Gmin = getappdata(handles.figure1,'posl1Gmin');
4574posl2Gmin = getappdata(handles.figure1,'posl2Gmin');
4575device_name = getappdata(handles.figure1,'device_name');
4576
4577if isequal(logdev1,0)&isequal(logdev2,0)
4578    errordlg('selectionnez une lentille','ATTENTION');
4579else
4580    if isequal(logdev1,1)
4581        dev=device_name.lentille_haute;       
4582    else
4583        dev=device_name.lentille_basse;     
4584    end
4585   
4586    errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4587
4588    if (tango_error == -1)
4589        %- handle error
4590        tango_print_error_stack;
4591        return;
4592        errordlg('erreur tango !','Erreur');
4593
4594    else
4595       
4596        val = get(hObject,'Value');
4597        switch val
4598
4599        case 2
4600        prompt={'Entrez une position'};
4601        name='AxisDefinePosition';
4602        numlines=1;
4603        defaultanswer={ num2str(0) };
4604        options.Resize='on';
4605        options.WindowStyle='normal';
4606        options.Interpreter='tex';
4607        toto = inputdlg(prompt,name,numlines,defaultanswer,options);
4608        if ~isequal(toto,{})
4609            tango_command_inout(dev,'AxisDefinePosition',str2num(toto{:}));
4610            fonction_error;
4611           
4612            if isequal(logdev1,1)
4613                    % on affiche la position de la lentille
4614                    pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4615                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4616            else
4617                    % on affiche la position de la lentille
4618                    pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4619                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
4620            end
4621           
4622        end
4623
4624        case 3
4625        res = tango_command_inout(dev,'AxisGetErrorStatus'); 
4626        errordlg(num2str(res),'AxisGetErrorStatus');
4627
4628        case 4
4629        res = tango_command_inout(dev,'AxisGetMotionStatus'); 
4630        errordlg(num2str(res),'AxisGetMotionStatus');
4631
4632        case 5
4633        prompt={'Entrez une position de destination'};
4634        name='AxisGoToPosition';
4635        numlines=1;
4636        defaultanswer={ num2str(0) };
4637        options.Resize='on';
4638        options.WindowStyle='normal';
4639        options.Interpreter='tex';
4640        toto = inputdlg(prompt,name,numlines,defaultanswer,options);
4641        if ~isequal(toto,{})
4642           
4643            posref=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4644            fonction_error;
4645           
4646            if str2num(toto{:})>posref.value
4647                % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
4648                set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
4649                set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
4650                set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
4651               
4652                % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
4653                if isequal(errorstatus,22)|isequal(errorstatus,4)
4654                    if isequal(logdev1,1)
4655                        set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
4656                    else
4657                        set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
4658                    end
4659                end
4660               
4661            elseif str2num(toto{:})<posref.value
4662               
4663                % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
4664                set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
4665                set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
4666                set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
4667               
4668                % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
4669                if isequal(errorstatus,21)|isequal(errorstatus,3)
4670                    if isequal(logdev1,1)
4671                        set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
4672                    else
4673                        set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
4674                    end
4675                end
4676               
4677            else
4678                return;
4679            end
4680           
4681            % on déplace l'axe jusqu'à la position demandée
4682            tango_command_inout(dev,'AxisGoToPosition',str2num(toto{:}));
4683            % on attent que l'axe se mette en mouvement
4684            if (temporisation_mvt_axis(dev) == -1)
4685             % abort
4686            end
4687
4688            % attendre la fin de la commande en clignotant
4689            while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
4690                if isequal(logdev1,1)
4691                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
4692                    % on affiche la position de la lentille
4693                    pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4694                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4695                else
4696                    set(handles.tata_radiobutton10,'BackgroundColor','green');
4697                    % on affiche la position de la lentille
4698                    pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4699                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
4700                end
4701            end
4702
4703            pause(0.5);
4704            % on ï¿œteind le vert ï¿œ la fin du mouvement
4705            % on ï¿œcrit une derniï¿œre fois la position de la lentille
4706
4707            if isequal(logdev1,1)
4708                set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
4709                % on affiche la position de la lentille
4710                pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4711                set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4712
4713            else
4714                set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
4715                pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4716                set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
4717
4718            end
4719       
4720            % si on est arrivï¿œ en butï¿œe forward on allume le voyant 
4721            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4722            fonction_error;
4723            if isequal(errorstatus,21)|isequal(errorstatus,3)
4724                if isequal(logdev1,1)
4725                    set(handles.LHBB_edit24,'BackgroundColor','red');
4726                else
4727                    set(handles.LBBB_edit27,'BackgroundColor','red');
4728                end
4729            end
4730
4731            % si on est arrivï¿œ en butï¿œe backward on allume le voyant 
4732            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4733            if isequal(errorstatus,22)|isequal(errorstatus,4)
4734                if isequal(logdev1,1)
4735                    set(handles.LHBH_edit25,'BackgroundColor','red');
4736                else
4737                    set(handles.LBBH_edit26,'BackgroundColor','red');
4738                end
4739            end
4740
4741            % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
4742            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
4743            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
4744            if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
4745                set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
4746            elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
4747                set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
4748            elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
4749                set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
4750            end
4751        end
4752       
4753        case 6
4754        prompt={'Entrez une position relative de destination'};
4755        name='AxisGoToRelativePosition';
4756        numlines=1;
4757        defaultanswer={ num2str(0) };
4758        options.Resize='on';
4759        options.WindowStyle='normal';
4760        options.Interpreter='tex';
4761        toto = inputdlg(prompt,name,numlines,defaultanswer,options);
4762        if ~isequal(toto,{})
4763           
4764            posref=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4765            fonction_error;
4766           
4767            if str2num(toto{:})>0
4768                % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
4769                set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
4770                set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
4771                set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
4772               
4773                % si on ï¿œtait en butï¿œe backward, on ï¿œteind le voyant
4774                if isequal(errorstatus,22)|isequal(errorstatus,4)
4775                    if isequal(logdev1,1)
4776                        set(handles.LHBH_edit25,'BackgroundColor',[0.702 0.702 0.702]);
4777                    else
4778                        set(handles.LBBH_edit26,'BackgroundColor',[0.702 0.702 0.702]);
4779                    end
4780                end
4781               
4782            elseif str2num(toto{:})<0
4783               
4784                % pour le cas oï¿œ on ï¿œtait dans les conditions d'un grandissement, ï¿œteindre tous les voyants rouges grandissements
4785                set(handles.fondGmax_pushbutton29,'BackgroundColor',[0.979 1.0 0.822]);
4786                set(handles.fondGmoy_pushbutton30,'BackgroundColor',[0.979 1.0 0.822]);
4787                set(handles.fondGmin_pushbutton31,'BackgroundColor',[0.979 1.0 0.822]);
4788               
4789                % si on ï¿œtait en butï¿œe forward, on ï¿œteind le voyant
4790                if isequal(errorstatus,21)|isequal(errorstatus,3)
4791                    if isequal(logdev1,1)
4792                        set(handles.LHBB_edit24,'BackgroundColor',[0.702 0.702 0.702]);
4793                    else
4794                        set(handles.LBBB_edit27,'BackgroundColor',[0.702 0.702 0.702]);
4795                    end
4796                end
4797               
4798            else
4799                return;
4800            end
4801           
4802            % on déplace l'axe jusqu'à la position demandée
4803            tango_command_inout(dev,'AxisGoToRelativePosition',str2num(toto{:}));
4804            % on attent que l'axe se mette en mouvement
4805            if (temporisation_mvt_axis(dev) == -1)
4806             % abort
4807            end
4808
4809            % attendre la fin de la commande en clignotant
4810            while isequal(tango_command_inout(dev,'AxisGetMotionStatus'),1)
4811                if isequal(logdev1,1)
4812                    set(handles.Lenthaute_radiobutton7,'BackgroundColor','green');
4813                    % on affiche la position de la lentille
4814                    pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4815                    set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4816                else
4817                    set(handles.tata_radiobutton10,'BackgroundColor','green');
4818                    % on affiche la position de la lentille
4819                    pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4820                    set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
4821                end
4822            end
4823
4824            pause(0.5);
4825            % on ï¿œteind le vert ï¿œ la fin du mouvement
4826            % on ï¿œcrit une derniï¿œre fois la position de la lentille
4827
4828            if isequal(logdev1,1)
4829                set(handles.Lenthaute_radiobutton7,'BackgroundColor',[0.702 0.702 0.702]);
4830                % on affiche la position de la lentille
4831                pos1=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4832                set(handles.pos1_edit29,'String',num2str(pos1.value(1)));
4833
4834            else
4835                set(handles.tata_radiobutton10,'BackgroundColor',[0.702 0.702 0.702]);
4836                pos2=tango_read_attribute(dev,'AxisCurrentMotorPosition');
4837                set(handles.pos2_edit30,'String',num2str(pos2.value(1)));
4838
4839            end
4840       
4841            % si on est arrivï¿œ en butï¿œe forward on allume le voyant 
4842            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4843            fonction_error;
4844            if isequal(errorstatus,21)|isequal(errorstatus,3)
4845                if isequal(logdev1,1)
4846                    set(handles.LHBB_edit24,'BackgroundColor','red');
4847                else
4848                    set(handles.LBBB_edit27,'BackgroundColor','red');
4849                end
4850            end
4851
4852            % si on est arrivï¿œ en butï¿œe backward on allume le voyant 
4853            errorstatus=tango_command_inout(dev,'AxisGetErrorStatus');
4854            if isequal(errorstatus,22)|isequal(errorstatus,4)
4855                if isequal(logdev1,1)
4856                    set(handles.LHBH_edit25,'BackgroundColor','red');
4857                else
4858                    set(handles.LBBH_edit26,'BackgroundColor','red');
4859                end
4860            end
4861
4862            % si on est sur une position dï¿œterminï¿œe d'un grandissement, allumer en rouge celui-ci
4863            pos1=tango_read_attribute(device_name.lentille_haute,'AxisCurrentMotorPosition');
4864            pos2=tango_read_attribute(device_name.lentille_basse,'AxisCurrentMotorPosition');
4865            if isequal(pos1.value(1),posl1Gmax)&isequal(pos2.value(1),posl2Gmax)
4866                set(handles.fondGmax_pushbutton29,'BackgroundColor','red');
4867            elseif isequal(pos1.value(1),posl1Gmoy)&isequal(pos2.value(1),posl2Gmoy)
4868                set(handles.fondGmoy_pushbutton30,'BackgroundColor','red');
4869            elseif isequal(pos1.value(1),posl1Gmin)&isequal(pos2.value(1),posl2Gmin)
4870                set(handles.fondGmin_pushbutton31,'BackgroundColor','red');
4871            end
4872        end
4873       
4874       
4875        case 11
4876        res = tango_command_inout(dev,'State');
4877        errordlg(res,'State');
4878        case 12
4879        res = tango_command_inout(dev,'Status');
4880        errordlg(res,'Status');
4881       
4882        end
4883    end
4884end
4885           
4886   
4887
4888
4889
4890% --- Executes during object creation, after setting all properties.
4891function controle_lentilles_popupmenu5_CreateFcn(hObject, eventdata, handles)
4892% hObject    handle to controle_lentilles_popupmenu5 (see GCBO)
4893% eventdata  reserved - to be defined in a future version of MATLAB
4894% handles    empty - handles not created until after all CreateFcns called
4895
4896% Hint: popupmenu controls usually have a white background on Windows.
4897%       See ISPC and COMPUTER.
4898if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4899    set(hObject,'BackgroundColor','white');
4900end
4901
4902
4903% --- Executes on button press in emitV_pushbutton39.
4904function emitV_pushbutton39_Callback(hObject, eventdata, handles)
4905% hObject    handle to emitV_pushbutton39 (see GCBO)
4906% eventdata  reserved - to be defined in a future version of MATLAB
4907% handles    structure with handles and user data (see GUIDATA)
4908
4909
4910% --- Executes on button press in ellipseV_pushbutton40.
4911function ellipseV_pushbutton40_Callback(hObject, eventdata, handles)
4912% hObject    handle to ellipseV_pushbutton40 (see GCBO)
4913% eventdata  reserved - to be defined in a future version of MATLAB
4914% handles    structure with handles and user data (see GUIDATA)
4915
4916ellipseV_v16(handles)
Note: See TracBrowser for help on using the repository browser.