source: MML/trunk/machine/SOLEIL/LT1/emittance/emittance_v15.m @ 4

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

Initial import--MML version from SOLEIL@2013

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