source: MML/trunk/machine/SOLEIL/StorageRing/couplage/couplage.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 17.8 KB
Line 
1function varargout = couplage(varargin)
2% COUPLAGE M-file for couplage.fig
3%      COUPLAGE, by itself, creates a new COUPLAGE or raises the existing
4%      singleton*.
5%
6%      H = COUPLAGE returns the handle to a new COUPLAGE or the handle to
7%      the existing singleton*.
8%
9%      COUPLAGE('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in COUPLAGE.M with the given input arguments.
11%
12%      COUPLAGE('Property','Value',...) creates a new COUPLAGE or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before couplage_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to couplage_OpeningFcn via varargin.
17%
18%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19%      instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22
23% Edit the above text to modify the response to help couplage
24
25% Last Modified by GUIDE v2.5 03-Jan-2012 15:41:28
26
27% Begin initialization code - DO NOT EDIT
28gui_Singleton = 1;
29gui_State = struct('gui_Name',       mfilename, ...
30                   'gui_Singleton',  gui_Singleton, ...
31                   'gui_OpeningFcn', @couplage_OpeningFcn, ...
32                   'gui_OutputFcn',  @couplage_OutputFcn, ...
33                   'gui_LayoutFcn',  [] , ...
34                   'gui_Callback',   []);
35if nargin && ischar(varargin{1})
36    gui_State.gui_Callback = str2func(varargin{1});
37end
38
39if nargout
40    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41else
42    gui_mainfcn(gui_State, varargin{:});
43end
44% End initialization code - DO NOT EDIT
45
46
47% --- Executes just before couplage is made visible.
48function couplage_OpeningFcn(hObject, eventdata, handles, varargin)
49% This function has no output args, see OutputFcn.
50% hObject    handle to figure
51% eventdata  reserved - to be defined in a future version of MATLAB
52% handles    structure with handles and user data (see GUIDATA)
53% varargin   command line arguments to couplage (see VARARGIN)
54
55% Choose default command line output for couplage
56handles.output = hObject;
57
58%%%%%%%%%%%%%%%%%%%%%%%%%
59k0 = uibuttongroup('visible','on','Position',[0.03 0.63 .95 .16],...
60    'Title','','TitlePosition','lefttop','FontSize',14,...
61    'BackgroundColor',[.651 0.855 0.924]);
62
63%%%%%%%%%%%%%%%%%%%%%%%%%
64%[.651 0.855 0.924]); % couleur bleu layette
65k1 = uibuttongroup('visible','on','Position',[0.01 0.01 .98 .60],...
66    'Title','','TitlePosition','lefttop','FontSize',14,...
67    'BackgroundColor',[.5 0.5 1]);
68
69%%%%%%%%%%%%%%%%%%%%%%%%%
70%[0.03 0.05 .95 .48]
71g0 = uibuttongroup('visible','on','Position',[0.03 0.02 .95 .21],...
72    'Title','','TitlePosition','lefttop','FontSize',14,...
73    'BackgroundColor',[.5 0.5 1]);
74
75h1 = uicontrol('Style','Radio','String','  diaphonie DIAG','Tag','radiobutton1',...
76    'pos',[50 80 150 20],'parent',g0,'HandleVisibility','off','FontSize',14,...
77    'BackgroundColor',[.5 0.5 1]);
78h2 = uicontrol('Style','Radio','String','  diaphonie LOCO','Tag','radiobutton2','FontSize',14,...
79    'pos',[300. 80 150 20],'parent',g0,'HandleVisibility','off',...
80    'BackgroundColor',[.5 0.5 1]);
81set(g0,'SelectedObject',h2);  % No selection
82set(g0,'Visible','on');
83set(g0,'SelectionChangeFcn',...
84    {@uibuttongroup_SelectionChangeFcn_diaphonie,handles});
85setappdata(handles.figure1,'Diaphonie','LOCO'); % LOCO par défaut
86
87%%%%%%%%%%%%%%%%%%%%%%%%%
88%[0.03 0.05 .45 .18]
89g2 = uibuttongroup('visible','on','Position',[0.33 0.30 .65 .28],...
90    'Title','','TitlePosition','lefttop','FontSize',14,...
91    'BackgroundColor',[.5 0.5 1]);
92
93
94q2 = uicontrol('Style','Radio','String','  à partir d''une mesure de couplage','Tag','radiobutton1','FontSize',14,...
95    'pos',[15. 120 280 20],'parent',g2,'HandleVisibility','off',...
96    'BackgroundColor',[.5 0.5 1]);
97q3 = uicontrol('Style','Radio','String','  par un jeu de correcteurs QT connu','Tag','radiobutton2','FontSize',14,...
98    'pos',[15 55 350 20],'parent',g2,'HandleVisibility','off',...
99    'BackgroundColor',[.5 0.5 1]);
100q1 = uicontrol('Style','Radio','String','  en superposant un jeu de correcteurs QT connu','Tag','radiobutton3',...
101     'pos',[15 16 380 20],'parent',g2,'HandleVisibility','off','FontSize',14,...
102     'BackgroundColor',[.5 0.5 1]);
103set(g2,'SelectedObject',q3);  % No selection
104set(handles.edit_poids,'Enable','Off')
105set(handles.edit_nbvp,'Enable','Off')
106set(g2,'Visible','on');
107set(g2,'SelectionChangeFcn',...
108    {@uibuttongroup_SelectionChangeFcn_correction,handles});
109setappdata(handles.figure1,'Correction','jeu'); % un jeu connu par défaut
110
111%%%%%%%%%%%%%%%%%%%%%%%%%
112g = uibuttongroup('visible','off','Position',[0.658 0.8 .32 .17],...
113    'Title','Sélection mode','TitlePosition','centertop','FontSize',14,...
114    'BackgroundColor',[.651 0.855 0.924]);
115v1 = uicontrol('Style','Radio','String','  Online','Tag','radiobutton1',...
116    'pos',[10 30 80 20],'parent',g,'HandleVisibility','off','FontSize',14,...
117    'BackgroundColor',[.651 0.855 0.924]);
118v2 = uicontrol('Style','Radio','String','  Model','Tag','radiobutton2','FontSize',14,...
119    'pos',[110. 30 80 20],'parent',g,'HandleVisibility','off',...
120    'BackgroundColor',[.651 0.855 0.924]);
121set(g,'SelectedObject',v2);  % No selection
122set(g,'Visible','on');
123set(g,'SelectionChangeFcn',...
124    {@uibuttongroup_SelectionChangeFcn,handles});
125setappdata(handles.figure1,'Mode','Model'); % Model par défaut
126
127%% paramÚtres par défaut de la mesure et de la correction du couplage
128
129M.Param1 = 0.2;  % Delta I corr H = 0.2 A
130M.Param2 = 4;    % Pause aprÚs consigne delta I = 4 secondes
131setappdata(handles.figure1,'M',M);
132
133S.Param1 = 1e3;
134S.Param2 = 32;
135S.Param3 = 100 ; % ParamÚtres par défaut de la correction
136% Param1 : poids Dz
137% Param2 : nb de valeurs propres de la matrice efficacite QT
138% Param3 : pourcentage de correction appliqué
139setappdata(handles.figure1,'S',S);
140
141% Update handles structure
142guidata(hObject, handles);
143
144% UIWAIT makes couplage wait for user response (see UIRESUME)
145% uiwait(handles.figure1);
146
147
148% --- Outputs from this function are returned to the command line.
149function varargout = couplage_OutputFcn(hObject, eventdata, handles)
150% varargout  cell array for returning output args (see VARARGOUT);
151% hObject    handle to figure
152% eventdata  reserved - to be defined in a future version of MATLAB
153% handles    structure with handles and user data (see GUIDATA)
154
155% Get default command line output from handles structure
156varargout{1} = handles.output;
157
158
159% --- Executes on button press in pushbutton_mesure.
160function pushbutton_mesure_Callback(hObject, eventdata, handles)
161% hObject    handle to pushbutton_mesure (see GCBO)
162% eventdata  reserved - to be defined in a future version of MATLAB
163% handles    structure with handles and user data (see GUIDATA)
164
165M = getappdata(handles.figure1,'M');
166Mode = getappdata(handles.figure1,'Mode');
167setskewcorrection(Mode,'Archive','Measurement','NoCorrection',handles) %[M.Param1 M.Param2])
168
169% --- Executes on button press in pushbutton_correction.
170function pushbutton_correction_Callback(hObject, eventdata, handles)
171% hObject    handle to pushbutton_correction (see GCBO)
172% eventdata  reserved - to be defined in a future version of MATLAB
173% handles    structure with handles and user data (see GUIDATA)
174
175type_corr = getappdata(handles.figure1,'Correction');
176Mode = getappdata(handles.figure1,'Mode');
177
178if strcmp(type_corr,'fichier')
179   
180    S = getappdata(handles.figure1,'S');
181   
182    setskewcorrection(Mode,'Archive','NoMeasurement','Correction',handles) %[S.Param1 S.Param2 S.Param3])
183   
184else
185   
186    DirectoryName = getfamilydata('Directory', 'Coupling');
187    if isempty(DirectoryName)
188        %             DirectoryName = [getfamilydata('Directory','DataRoot'), 'Response', filesep, 'BPM', filesep];
189    else
190        % Make sure default directory exists
191        DirStart = pwd;
192        [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
193        cd(DirStart);
194    end
195        %[FileName, DirectoryName] = uigetfile('*.mat', 'Select a Skew corrector list ("Save" starts measurement)', [DirectoryName FileName]);
196
197    [FileName, DirectoryName] = uigetfile('*.mat', 'Select a Skew corrector list ("Save" starts measurement)',DirectoryName);
198    if FileName == 0
199        ArchiveFlag = 0;
200        disp('   Skew correction canceled.');
201        return
202    end
203    FileName = [DirectoryName, FileName];
204   
205    S = load(FileName);
206    Sparam = getappdata(handles.figure1,'S'); % on va cherche le pourcentage d'aplication
207    pourcentage = Sparam.Param3;
208
209    if strcmp(type_corr,'jeu')
210        setsp('QT',pourcentage*1e-2*S.Deltaskewquad,Mode);
211    elseif strcmp(type_corr,'superposition')
212        stepsp('QT',pourcentage*1e-2*S.Deltaskewquad,Mode);
213    else
214        disp('pb avec les options !')
215    end
216    disp('Skew correction applied');
217    disp(FileName)
218    disp(['Pourcentage applied = ' num2str(pourcentage) '%' ])
219end
220
221function edit_poids_Callback(hObject, eventdata, handles)
222% hObject    handle to edit_poids (see GCBO)
223% eventdata  reserved - to be defined in a future version of MATLAB
224% handles    structure with handles and user data (see GUIDATA)
225
226% Hints: get(hObject,'String') returns contents of edit_poids as text
227%        str2double(get(hObject,'String')) returns contents of edit_poids as a double
228
229S.Param1 = str2double(get(hObject,'String'));
230S.Param2 = str2double(get(handles.edit_nbvp,'String'));
231S.Param3 = str2double(get(handles.edit_pourcentage,'String'));
232%% sauvegarde de la structure S
233setappdata(handles.figure1,'S',S);
234
235% --- Executes during object creation, after setting all properties.
236function edit_poids_CreateFcn(hObject, eventdata, handles)
237% hObject    handle to edit_poids (see GCBO)
238% eventdata  reserved - to be defined in a future version of MATLAB
239% handles    empty - handles not created until after all CreateFcns called
240
241% Hint: edit controls usually have a white background on Windows.
242%       See ISPC and COMPUTER.
243if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
244    set(hObject,'BackgroundColor','white');
245end
246
247
248
249function edit_nbvp_Callback(hObject, eventdata, handles)
250% hObject    handle to edit_nbvp (see GCBO)
251% eventdata  reserved - to be defined in a future version of MATLAB
252% handles    structure with handles and user data (see GUIDATA)
253
254% Hints: get(hObject,'String') returns contents of edit_nbvp as text
255%        str2double(get(hObject,'String')) returns contents of edit_nbvp as a double
256
257S.Param1 = str2double(get(handles.edit_poids,'String'));
258S.Param2 = str2double(get(hObject,'String'));
259S.Param3 = str2double(get(handles.edit_pourcentage,'String'));
260%% sauvegarde de la structure S
261setappdata(handles.figure1,'S',S);
262
263% --- Executes during object creation, after setting all properties.
264function edit_nbvp_CreateFcn(hObject, eventdata, handles)
265% hObject    handle to edit_nbvp (see GCBO)
266% eventdata  reserved - to be defined in a future version of MATLAB
267% handles    empty - handles not created until after all CreateFcns called
268
269% Hint: edit controls usually have a white background on Windows.
270%       See ISPC and COMPUTER.
271if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
272    set(hObject,'BackgroundColor','white');
273end
274
275
276
277function edit_pourcentage_Callback(hObject, eventdata, handles)
278% hObject    handle to edit_pourcentage (see GCBO)
279% eventdata  reserved - to be defined in a future version of MATLAB
280% handles    structure with handles and user data (see GUIDATA)
281
282% Hints: get(hObject,'String') returns contents of edit_pourcentage as text
283%        str2double(get(hObject,'String')) returns contents of edit_pourcentage as a double
284S.Param1 = str2double(get(handles.edit_poids,'String'));
285S.Param2 = str2double(get(handles.edit_nbvp,'String'));
286S.Param3 = str2double(get(hObject,'String'));
287%% sauvegarde de la structure S
288setappdata(handles.figure1,'S',S);
289
290% --- Executes during object creation, after setting all properties.
291function edit_pourcentage_CreateFcn(hObject, eventdata, handles)
292% hObject    handle to edit_pourcentage (see GCBO)
293% eventdata  reserved - to be defined in a future version of MATLAB
294% handles    empty - handles not created until after all CreateFcns called
295
296% Hint: edit controls usually have a white background on Windows.
297%       See ISPC and COMPUTER.
298if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
299    set(hObject,'BackgroundColor','white');
300end
301
302
303% --- Executes on button press in pushbutton_nbvp.
304function pushbutton_nbvp_Callback(hObject, eventdata, handles)
305% hObject    handle to pushbutton_nbvp (see GCBO)
306% eventdata  reserved - to be defined in a future version of MATLAB
307% handles    structure with handles and user data (see GUIDATA)
308
309function uibuttongroup_SelectionChangeFcn(hObject,eventdata,handles)
310% hObject    handle to uipanel1 (see GCBO)
311% eventdata  reserved - to be defined in a future version of MATLAB
312% handles    structure with handles and user data (see GUIDATA)
313
314switch get(get(hObject,'SelectedObject'),'Tag')  % Get Tag of selected object
315    case 'radiobutton1'
316        % code piece when radiobutton1 is selected goes here
317        %handles.energie = 'min';
318        setappdata(handles.figure1,'Mode','Online'); %
319
320
321    case 'radiobutton2'
322        % code piece when radiobutton2 is selected goes here
323        %handles.energie = 'max';
324        setappdata(handles.figure1,'Mode','Model'); %
325end
326
327function uibuttongroup_SelectionChangeFcn_diaphonie(hObject,eventdata,handles)
328% hObject    handle to uipanel1 (see GCBO)
329% eventdata  reserved - to be defined in a future version of MATLAB
330% handles    structure with handles and user data (see GUIDATA)
331
332switch get(get(hObject,'SelectedObject'),'Tag')  % Get Tag of selected object
333    case 'radiobutton1'
334        % code piece when radiobutton1 is selected goes here
335        %handles.energie = 'min';
336        setappdata(handles.figure1,'Diaphonie','DIAG'); %
337
338
339    case 'radiobutton2'
340        % code piece when radiobutton2 is selected goes here
341        %handles.energie = 'max';
342        setappdata(handles.figure1,'Diaphonie','LOCO'); %
343end
344
345function uibuttongroup_SelectionChangeFcn_correction(hObject,eventdata,handles)
346% hObject    handle to uipanel1 (see GCBO)
347% eventdata  reserved - to be defined in a future version of MATLAB
348% handles    structure with handles and user data (see GUIDATA)
349
350switch get(get(hObject,'SelectedObject'),'Tag')  % Get Tag of selected object
351%     case 'radiobutton1'
352%         % code piece when radiobutton1 is selected goes here
353%         %handles.energie = 'min';
354%         setappdata(handles.figure1,'Correction','actuel'); %       
355
356    case 'radiobutton1'
357        % code piece when radiobutton1 is selected goes here
358        setappdata(handles.figure1,'Correction','fichier'); %
359        set(handles.edit_poids,'Enable','On')
360        set(handles.edit_nbvp,'Enable','On')
361
362    case 'radiobutton2'
363        % code piece when radiobutton2 is selected goes here
364        %handles.energie = 'max';
365        setappdata(handles.figure1,'Correction','jeu'); %
366        set(handles.edit_poids,'Enable','Off')
367        set(handles.edit_nbvp,'Enable','Off')
368       
369    case 'radiobutton3'
370        % code piece when radiobutton2 is selected goes here
371        %handles.energie = 'max';
372        setappdata(handles.figure1,'Correction','superposition'); %
373        set(handles.edit_poids,'Enable','Off')
374        set(handles.edit_nbvp,'Enable','Off')
375       
376end
377
378function edit_deltaIcorr_Callback(hObject, eventdata, handles)
379% hObject    handle to edit_deltaIcorr (see GCBO)
380% eventdata  reserved - to be defined in a future version of MATLAB
381% handles    structure with handles and user data (see GUIDATA)
382
383% Hints: get(hObject,'String') returns contents of edit_deltaIcorr as text
384%        str2double(get(hObject,'String')) returns contents of edit_deltaIcorr as a double
385M.Param1 = str2double(get(handles.edit_deltaIcorr,'String'));
386M.Param2 = str2double(get(handles.edit_pause,'String'));
387%% sauvegarde de la structure M
388setappdata(handles.figure1,'M',M);
389
390% --- Executes during object creation, after setting all properties.
391function edit_deltaIcorr_CreateFcn(hObject, eventdata, handles)
392% hObject    handle to edit_deltaIcorr (see GCBO)
393% eventdata  reserved - to be defined in a future version of MATLAB
394% handles    empty - handles not created until after all CreateFcns called
395
396% Hint: edit controls usually have a white background on Windows.
397%       See ISPC and COMPUTER.
398if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
399    set(hObject,'BackgroundColor','white');
400end
401
402
403
404function edit_pause_Callback(hObject, eventdata, handles)
405% hObject    handle to edit_pause (see GCBO)
406% eventdata  reserved - to be defined in a future version of MATLAB
407% handles    structure with handles and user data (see GUIDATA)
408
409% Hints: get(hObject,'String') returns contents of edit_pause as text
410%        str2double(get(hObject,'String')) returns contents of edit_pause as a double
411
412M.Param1 = str2double(get(handles.edit_deltaIcorr,'String'));
413M.Param2 = str2double(get(handles.edit_pause,'String'));
414%% sauvegarde de la structure M
415setappdata(handles.figure1,'M',M);
416
417
418% --- Executes during object creation, after setting all properties.
419function edit_pause_CreateFcn(hObject, eventdata, handles)
420% hObject    handle to edit_pause (see GCBO)
421% eventdata  reserved - to be defined in a future version of MATLAB
422% handles    empty - handles not created until after all CreateFcns called
423
424% Hint: edit controls usually have a white background on Windows.
425%       See ISPC and COMPUTER.
426if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
427    set(hObject,'BackgroundColor','white');
428end
429
430
431% --- Executes on button press in pushbutton_RAZ_QT.
432function pushbutton_RAZ_QT_Callback(hObject, eventdata, handles)
433% hObject    handle to pushbutton_RAZ_QT (see GCBO)
434% eventdata  reserved - to be defined in a future version of MATLAB
435% handles    structure with handles and user data (see GUIDATA)
436
437setsp('QT',0)
Note: See TracBrowser for help on using the repository browser.