source: MML/trunk/machine/SOLEIL/Booster/applications/ACtune.m @ 17

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

To have a stable version on the server.

  • Property svn:executable set to *
File size: 27.6 KB
Line 
1function varargout = ACtune(varargin)
2% ACTUNE M-file for ACtune.fig
3%      ACTUNE, by itself, creates a new ACTUNE or raises the existing
4%      singleton*.
5%
6%      H = ACTUNE returns the handle to a new ACTUNE or the handle to
7%      the existing singleton*.
8%
9%      ACTUNE('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in ACTUNE.M with the given input arguments.
11%
12%      ACTUNE('Property','Value',...) creates a new ACTUNE or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before ACtune_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to ACtune_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 ACtune
24
25% Last Modified by GUIDE v2.5 27-Apr-2006 14:46:15
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', @ACtune_OpeningFcn, ...
32                   'gui_OutputFcn',  @ACtune_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 ACtune is made visible.
48function ACtune_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 ACtune (see VARARGIN)
54
55% Choose default command line output for ACtune
56handles.output = hObject;
57
58if ~strcmp(getfamilydata('SubMachine'),'Booster')
59    error('Load Booster first');
60end
61
62m1   =[1.1931   -0.1543 ; -0.2537    1.2602 ] ;
63acqf=200.*18.48/2*sin(18.48*.020);
64acqd=150.*18.48/2*sin(18.48*.020);
65r =110/2750;
66% dtune = M *  QFoffset  QDoffset  QFcur  QDcur  delayQF  delay QD  (A et seconde)
67M = [m1(1,1) m1(1,2)  r*m1(1,1) r*m1(1,2) -acqf*m1(1,1) -acqd*m1(1,2); ...
68     m1(2,1) m1(2,2)  r*m1(2,1) r*m1(2,2) -acqf*m1(2,1) -acqd*m1(2,2); ...
69     r*m1(1,1) r*m1(1,2) r*m1(1,1) r*m1(1,2) 0         0           ; ...
70     r*m1(2,1) r*m1(2,2) r*m1(2,1) r*m1(2,2) 0         0           ; ...
71     m1(1,1) m1(1,2)  r*m1(1,1) r*m1(1,2) acqf*m1(1,1) acqd*m1(1,2); ...
72     m1(2,1) m1(2,2)  r*m1(2,1) r*m1(2,2) acqf*m1(2,1) acqd*m1(2,2)];
73 
74handles.M=M;
75% alim
76    boo.DIPcurrent=readattribute('BOO/AE/D.1/current'        ,'Setpoint');
77    boo.DIPoffset =readattribute('BOO/AE/D.1/waveformOffset' ,'Setpoint');
78    boo.QFcurrent=readattribute('BOO/AE/QF/current'          ,'Setpoint');
79    boo.QFpoffset =readattribute('BOO/AE/QF/waveformOffset'  ,'Setpoint');
80    boo.QDcurrent=readattribute('BOO/AE/QD/current'          ,'Setpoint');
81    boo.QDpoffset =readattribute('BOO/AE/QD/waveformOffset'  ,'Setpoint');
82    boo.SFcurrent=readattribute('BOO/AE/SF/current'          ,'Setpoint');
83    boo.SFpoffset =readattribute('BOO/AE/SF/waveformOffset'  ,'Setpoint');
84    boo.SDcurrent=readattribute('BOO/AE/SD/current'          ,'Setpoint');
85    boo.SDpoffset =readattribute('BOO/AE/SD/waveformOffset'  ,'Setpoint');
86% synchro
87    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'dpTimeDelay');
88    boo.DIPdelay=temp.value(1);
89    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'qfTimeDelay');
90    boo.QFdelay=temp.value(1);
91    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'qdTimeDelay');
92    boo.QDdelay=temp.value(1);
93handles.boo=boo;
94
95
96
97% Update handles structure
98guidata(hObject, handles);
99
100
101% UIWAIT makes ACtune wait for user response (see UIRESUME)
102% uiwait(handles.figure1);
103
104
105% --- Outputs from this function are returned to the command line.
106function varargout = ACtune_OutputFcn(hObject, eventdata, handles)
107% varargout  cell array for returning output args (see VARARGOUT);
108% hObject    handle to figure
109% eventdata  reserved - to be defined in a future version of MATLAB
110% handles    structure with handles and user data (see GUIDATA)
111
112% Get default command line output from handles structure
113varargout{1} = handles.output;
114
115
116
117function x_inj_Callback(hObject, eventdata, handles)
118% hObject    handle to x_inj (see GCBO)
119% eventdata  reserved - to be defined in a future version of MATLAB
120% handles    structure with handles and user data (see GUIDATA)
121
122% Hints: get(hObject,'String') returns contents of x_inj as text
123%        str2double(get(hObject,'String')) returns contents of x_inj as a double
124
125
126% --- Executes during object creation, after setting all properties.
127function x_inj_CreateFcn(hObject, eventdata, handles)
128% hObject    handle to x_inj (see GCBO)
129% eventdata  reserved - to be defined in a future version of MATLAB
130% handles    empty - handles not created until after all CreateFcns called
131
132% Hint: edit controls usually have a white background on Windows.
133%       See ISPC and COMPUTER.
134if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
135    set(hObject,'BackgroundColor','white');
136end
137
138
139
140function x_ext_Callback(hObject, eventdata, handles)
141% hObject    handle to x_ext (see GCBO)
142% eventdata  reserved - to be defined in a future version of MATLAB
143% handles    structure with handles and user data (see GUIDATA)
144
145% Hints: get(hObject,'String') returns contents of x_ext as text
146%        str2double(get(hObject,'String')) returns contents of x_ext as a double
147
148
149% --- Executes during object creation, after setting all properties.
150function x_ext_CreateFcn(hObject, eventdata, handles)
151% hObject    handle to x_ext (see GCBO)
152% eventdata  reserved - to be defined in a future version of MATLAB
153% handles    empty - handles not created until after all CreateFcns called
154
155% Hint: edit controls usually have a white background on Windows.
156%       See ISPC and COMPUTER.
157if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
158    set(hObject,'BackgroundColor','white');
159end
160
161
162
163function x_retour_Callback(hObject, eventdata, handles)
164% hObject    handle to x_retour (see GCBO)
165% eventdata  reserved - to be defined in a future version of MATLAB
166% handles    structure with handles and user data (see GUIDATA)
167
168% Hints: get(hObject,'String') returns contents of x_retour as text
169%        str2double(get(hObject,'String')) returns contents of x_retour as a double
170
171
172% --- Executes during object creation, after setting all properties.
173function x_retour_CreateFcn(hObject, eventdata, handles)
174% hObject    handle to x_retour (see GCBO)
175% eventdata  reserved - to be defined in a future version of MATLAB
176% handles    empty - handles not created until after all CreateFcns called
177
178% Hint: edit controls usually have a white background on Windows.
179%       See ISPC and COMPUTER.
180if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
181    set(hObject,'BackgroundColor','white');
182end
183
184
185% --- Executes on button press in button_x_inj_plus.
186function button_x_inj_plus_Callback(hObject, eventdata, handles)
187% hObject    handle to button_x_inj_plus (see GCBO)
188% eventdata  reserved - to be defined in a future version of MATLAB
189% handles    structure with handles and user data (see GUIDATA)
190
191tune =str2double(get(handles.x_inj,'String'));
192tune=tune+0.05;
193set(handles.x_inj,'String',num2str(tune));
194
195% --- Executes on button press in button_x_ext_plus.
196function button_x_ext_plus_Callback(hObject, eventdata, handles)
197% hObject    handle to button_x_ext_plus (see GCBO)
198% eventdata  reserved - to be defined in a future version of MATLAB
199% handles    structure with handles and user data (see GUIDATA)
200
201tune =str2double(get(handles.x_ext,'String'));
202tune=tune+0.05;
203set(handles.x_ext,'String',num2str(tune));
204
205% --- Executes on button press in button_x_retour_plus.
206function button_x_retour_plus_Callback(hObject, eventdata, handles)
207% hObject    handle to button_x_retour_plus (see GCBO)
208% eventdata  reserved - to be defined in a future version of MATLAB
209% handles    structure with handles and user data (see GUIDATA)
210tune =str2double(get(handles.x_retour,'String'));
211tune=tune+0.05;
212set(handles.x_retour,'String',num2str(tune));
213
214% --- Executes on button press in button_x_inj_moins.
215function button_x_inj_moins_Callback(hObject, eventdata, handles)
216% hObject    handle to button_x_inj_moins (see GCBO)
217% eventdata  reserved - to be defined in a future version of MATLAB
218% handles    structure with handles and user data (see GUIDATA)
219tune =str2double(get(handles.x_inj,'String'));
220tune=tune-0.05;
221set(handles.x_inj,'String',num2str(tune));
222
223% --- Executes on button press in button_x_ext_moins.
224function button_x_ext_moins_Callback(hObject, eventdata, handles)
225% hObject    handle to button_x_ext_moins (see GCBO)
226% eventdata  reserved - to be defined in a future version of MATLAB
227% handles    structure with handles and user data (see GUIDATA)
228tune =str2double(get(handles.x_ext,'String'));
229tune=tune-0.05;
230set(handles.x_ext,'String',num2str(tune));
231
232% --- Executes on button press in button_x_retour_moins.
233function button_x_retour_moins_Callback(hObject, eventdata, handles)
234% hObject    handle to button_x_retour_moins (see GCBO)
235% eventdata  reserved - to be defined in a future version of MATLAB
236% handles    structure with handles and user data (see GUIDATA)
237
238tune =str2double(get(handles.x_retour,'String'));
239tune=tune-0.05;
240set(handles.x_retour,'String',num2str(tune));
241
242
243% --- Executes on button press in button_x_plus.
244function button_x_plus_Callback(hObject, eventdata, handles)
245% hObject    handle to button_x_plus (see GCBO)
246% eventdata  reserved - to be defined in a future version of MATLAB
247% handles    structure with handles and user data (see GUIDATA)
248
249tune =str2double(get(handles.x_inj,'String'));
250tune=tune+0.05;
251set(handles.x_inj,'String',num2str(tune));
252tune =str2double(get(handles.x_ext,'String'));
253tune=tune+0.05;
254set(handles.x_ext,'String',num2str(tune));
255tune =str2double(get(handles.x_retour,'String'));
256tune=tune+0.05;
257set(handles.x_retour,'String',num2str(tune));
258
259% --- Executes on button press in button_x_zero.
260function button_x_zero_Callback(hObject, eventdata, handles)
261% hObject    handle to button_x_zero (see GCBO)
262% eventdata  reserved - to be defined in a future version of MATLAB
263% handles    structure with handles and user data (see GUIDATA)
264
265tune=0;
266set(handles.x_inj,'String',num2str(tune));
267set(handles.x_ext,'String',num2str(tune));
268set(handles.x_retour,'String',num2str(tune));
269
270% --- Executes on button press in button_x_moins.
271function button_x_moins_Callback(hObject, eventdata, handles)
272% hObject    handle to button_x_moins (see GCBO)
273% eventdata  reserved - to be defined in a future version of MATLAB
274% handles    structure with handles and user data (see GUIDATA)
275
276tune =str2double(get(handles.x_inj,'String'));
277tune=tune-0.05;
278set(handles.x_inj,'String',num2str(tune));
279tune =str2double(get(handles.x_ext,'String'));
280tune=tune-0.05;
281set(handles.x_ext,'String',num2str(tune));
282tune =str2double(get(handles.x_retour,'String'));
283tune=tune-0.05;
284set(handles.x_retour,'String',num2str(tune));
285
286
287
288function z_inj_Callback(hObject, eventdata, handles)
289% hObject    handle to z_inj (see GCBO)
290% eventdata  reserved - to be defined in a future version of MATLAB
291% handles    structure with handles and user data (see GUIDATA)
292
293% Hints: get(hObject,'String') returns contents of z_inj as text
294%        str2double(get(hObject,'String')) returns contents of z_inj as a double
295
296
297% --- Executes during object creation, after setting all properties.
298function z_inj_CreateFcn(hObject, eventdata, handles)
299% hObject    handle to z_inj (see GCBO)
300% eventdata  reserved - to be defined in a future version of MATLAB
301% handles    empty - handles not created until after all CreateFcns called
302
303% Hint: edit controls usually have a white background on Windows.
304%       See ISPC and COMPUTER.
305if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
306    set(hObject,'BackgroundColor','white');
307end
308
309
310
311function z_ext_Callback(hObject, eventdata, handles)
312% hObject    handle to z_ext (see GCBO)
313% eventdata  reserved - to be defined in a future version of MATLAB
314% handles    structure with handles and user data (see GUIDATA)
315
316% Hints: get(hObject,'String') returns contents of z_ext as text
317%        str2double(get(hObject,'String')) returns contents of z_ext as a double
318
319
320% --- Executes during object creation, after setting all properties.
321function z_ext_CreateFcn(hObject, eventdata, handles)
322% hObject    handle to z_ext (see GCBO)
323% eventdata  reserved - to be defined in a future version of MATLAB
324% handles    empty - handles not created until after all CreateFcns called
325
326% Hint: edit controls usually have a white background on Windows.
327%       See ISPC and COMPUTER.
328if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
329    set(hObject,'BackgroundColor','white');
330end
331
332
333% --- Executes on button press in button_z_inj_plus.
334function button_z_inj_plus_Callback(hObject, eventdata, handles)
335% hObject    handle to button_z_inj_plus (see GCBO)
336% eventdata  reserved - to be defined in a future version of MATLAB
337% handles    structure with handles and user data (see GUIDATA)
338tune =str2double(get(handles.z_inj,'String'));
339tune=tune+0.05;
340set(handles.z_inj,'String',num2str(tune));
341
342% --- Executes on button press in button_z_ext_plus.
343function button_z_ext_plus_Callback(hObject, eventdata, handles)
344% hObject    handle to button_z_ext_plus (see GCBO)
345% eventdata  reserved - to be defined in a future version of MATLAB
346% handles    structure with handles and user data (see GUIDATA)
347tune =str2double(get(handles.z_ext,'String'));
348tune=tune+0.05;
349set(handles.z_ext,'String',num2str(tune));
350
351
352% --- Executes on button press in pushbutton15.
353function pushbutton15_Callback(hObject, eventdata, handles)
354% hObject    handle to pushbutton15 (see GCBO)
355% eventdata  reserved - to be defined in a future version of MATLAB
356% handles    structure with handles and user data (see GUIDATA)
357
358
359% --- Executes on button press in button_z_inj_moins.
360function button_z_inj_moins_Callback(hObject, eventdata, handles)
361% hObject    handle to button_z_inj_moins (see GCBO)
362% eventdata  reserved - to be defined in a future version of MATLAB
363% handles    structure with handles and user data (see GUIDATA)
364tune =str2double(get(handles.z_inj,'String'));
365tune=tune-0.05;
366set(handles.z_inj,'String',num2str(tune));
367
368% --- Executes on button press in button_z_ext_moins.
369function button_z_ext_moins_Callback(hObject, eventdata, handles)
370% hObject    handle to button_z_ext_moins (see GCBO)
371% eventdata  reserved - to be defined in a future version of MATLAB
372% handles    structure with handles and user data (see GUIDATA)
373tune =str2double(get(handles.z_ext,'String'));
374tune=tune-0.05;
375set(handles.z_ext,'String',num2str(tune));
376
377% --- Executes on button press in button_z_retour_moins.
378function button_z_retour_moins_Callback(hObject, eventdata, handles)
379% hObject    handle to button_z_retour_moins (see GCBO)
380% eventdata  reserved - to be defined in a future version of MATLAB
381% handles    structure with handles and user data (see GUIDATA)
382tune =str2double(get(handles.z_retour,'String'));
383tune=tune-0.05;
384set(handles.z_retour,'String',num2str(tune));
385
386function z_retour_Callback(hObject, eventdata, handles)
387% hObject    handle to z_retour (see GCBO)
388% eventdata  reserved - to be defined in a future version of MATLAB
389% handles    structure with handles and user data (see GUIDATA)
390
391% Hints: get(hObject,'String') returns contents of z_retour as text
392%        str2double(get(hObject,'String')) returns contents of z_retour as a double
393
394
395% --- Executes during object creation, after setting all properties.
396function z_retour_CreateFcn(hObject, eventdata, handles)
397% hObject    handle to z_retour (see GCBO)
398% eventdata  reserved - to be defined in a future version of MATLAB
399% handles    empty - handles not created until after all CreateFcns called
400
401% Hint: edit controls usually have a white background on Windows.
402%       See ISPC and COMPUTER.
403if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
404    set(hObject,'BackgroundColor','white');
405end
406
407
408% --- Executes on button press in button_z_plus.
409function button_z_plus_Callback(hObject, eventdata, handles)
410% hObject    handle to button_z_plus (see GCBO)
411% eventdata  reserved - to be defined in a future version of MATLAB
412% handles    structure with handles and user data (see GUIDATA)
413tune =str2double(get(handles.z_inj,'String'));
414tune=tune+0.05;
415set(handles.z_inj,'String',num2str(tune));
416tune =str2double(get(handles.z_ext,'String'));
417tune=tune+0.05;
418set(handles.z_ext,'String',num2str(tune));
419tune =str2double(get(handles.z_retour,'String'));
420tune=tune+0.05;
421set(handles.z_retour,'String',num2str(tune));
422
423% --- Executes on button press in button_z_zero.
424function button_z_zero_Callback(hObject, eventdata, handles)
425% hObject    handle to button_z_zero (see GCBO)
426% eventdata  reserved - to be defined in a future version of MATLAB
427% handles    structure with handles and user data (see GUIDATA)
428
429tune=0;
430set(handles.z_inj,'String',num2str(tune));
431set(handles.z_ext,'String',num2str(tune));
432set(handles.z_retour,'String',num2str(tune));
433
434% --- Executes on button press in button_z_moins.
435function button_z_moins_Callback(hObject, eventdata, handles)
436% hObject    handle to button_z_moins (see GCBO)
437% eventdata  reserved - to be defined in a future version of MATLAB
438% handles    structure with handles and user data (see GUIDATA)
439tune =str2double(get(handles.z_inj,'String'));
440tune=tune-0.05;
441set(handles.z_inj,'String',num2str(tune));
442tune =str2double(get(handles.z_ext,'String'));
443tune=tune-0.05;
444set(handles.z_ext,'String',num2str(tune));
445tune =str2double(get(handles.z_retour,'String'));
446tune=tune-0.05;
447set(handles.z_retour,'String',num2str(tune));
448
449% --- Executes on button press in button_z_retour_plus.
450function button_z_retour_plus_Callback(hObject, eventdata, handles)
451% hObject    handle to button_z_retour_plus (see GCBO)
452% eventdata  reserved - to be defined in a future version of MATLAB
453% handles    structure with handles and user data (see GUIDATA)
454tune =str2double(get(handles.z_retour,'String'));
455tune=tune+0.05;
456set(handles.z_retour,'String',num2str(tune));
457
458
459
460% --- Executes on button press in button_apply.
461function button_apply_Callback(hObject, eventdata, handles)
462% hObject    handle to button_apply (see GCBO)
463% eventdata  reserved - to be defined in a future version of MATLAB
464% handles    structure with handles and user data (see GUIDATA)
465
466xinj=str2double(get(handles.x_inj,'String'));
467xext=str2double(get(handles.x_ext,'String')) ;
468xretour=str2double(get(handles.x_retour,'String')) ;
469zinj=str2double(get(handles.z_inj,'String'));
470zext=str2double(get(handles.z_ext,'String')) ;
471zretour=str2double(get(handles.z_retour,'String')) ;
472
473tunex=[ xinj         xext       xretour];
474tunez=[ zinj         zext       zretour];
475%              x       z
476dtune_inj = [tunex(1)   tunez(1)];         % dnu H  et dnu V  injection   110 MeV
477dtune_ext = [tunex(2)   tunez(2)];         % dnu H  et dnu V  extraction 2750 MeV
478dtune_dow = [tunex(3)   tunez(3)];         % dnu H  et dnu V  retour      110 MeV
479dtune     = [dtune_inj dtune_ext dtune_dow];
480%
481M=handles.M;sol=inv(M)*dtune';
482
483fprintf('  ************************** \n')
484fprintf('   OFFSET  QF = %g  A \n',sol(1) )
485fprintf('   OFFSET  QD = %g  A \n',sol(2) )
486fprintf('   CURRENT QF = %g  A \n',sol(3) )
487fprintf('   CURRENT QD = %g  A \n',sol(4) )
488fprintf('   DELAY   QF = %g  µs \n',sol(5)*1e+06 )
489fprintf('   DELAY   QD = %g  µs \n ',sol(6)*1e+06 )
490
491% read setpoint values
492button_load_setpoint_Callback(hObject, eventdata, handles);
493boo=handles.boo;
494
495% add delta current on the solution
496if (sol(1)<50) & (sol(2)<50)
497   
498    boo.QFpoffset=boo.QFpoffset + sol(1);
499    boo.QDpoffset=boo.QDpoffset + sol(2);
500    boo.QFcurrent=boo.QFcurrent + sol(3);
501    boo.QDcurrent=boo.QDcurrent + sol(4);
502   
503    boo.QFdelay  = boo.QFdelay  + sol(5)*1e+06;
504    boo.QDdelay  = boo.QDdelay  + sol(6)*1e+06;
505    handles.boo=boo;
506    guidata(hObject, handles);
507   
508end
509
510% apply solution
511button_load_file_Callback(hObject, eventdata, handles);
512
513
514ok=1;
515
516if (ok==1)
517
518
519
520
521% model pour affichage
522Grf = 0.0465 +0.015;            % gradient remanent  T/m
523Grd = 0.0490 +0.0093;           % gradient remanent  T/m
524af  = 0.0520 ;                  % G/I   T/m/A
525ad  = 0.0517;
526Br = 0.0020 ;                   % Champ remanent T
527b  = 0.0013516 ;                % B/I  T/A
528rho=12.3759 ;                   % rayon dipole
529brhom = 9.17 ; 
530deltaf=-0.00005 ;
531deltad=-0.00005 ;
532
533load 'current_ttf' time Df1 Df2 Dqf Dqd;
534n=length(Df1);
535dt=0.0001/6; %step temp 16 ï¿œs
536
537
538
539%% model
540Iqf0 = boo.QFcurrent;    Iqfc = boo.QFpoffset;         
541Iqd0 = boo.QDcurrent;    Iqdc = boo.QDpoffset ;           
542Id0  = boo.DIPcurrent;   Ibc  = boo.DIPoffset ;
543delf=deltaf + (boo.DIPdelay-boo.QFdelay)*1e-06 ; % 0.0002 -sol(5)         % avance si positif
544deld=deltad + (boo.DIPdelay-boo.QDdelay)*1e-06 ; % 0.0001 -sol(6)
545
546
547%courant en manipe 09-04-06
548% Iqf0 =201.65 +sol(3);    Iqfc = -0.617 +sol(1);         
549% Iqd0 =162.43 +sol(4);   Iqdc = -0.700  +sol(2) ;           
550% Id0  =545;       Ibc  = -0.01 ;
551% delf=deltaf + 0.0002 -sol(5) ;             % avance si positif
552% deld=deltad + 0.0001 -sol(6);
553
554
555
556
557% calcul dï¿œcalage table pour dï¿œlai
558clear qf qd
559k1=int16(delf/dt);
560if (k1>0)
561   qf=[Dqf(k1+1:n); Dqf(1:k1)];
562else
563   qf=[Dqf(n+k1:n); Dqf(1:n+k1-1)];
564end
565k1=int16(deld/dt);
566if (k1>0)
567   qd=[Dqd(k1+1:n); Dqd(1:k1)];
568else
569   qd=[Dqd(n+k1:n); Dqd(1:n+k1-1)];
570end
571Dqf1=qf;
572Dqd1=qd;
573
574clear Id Iqf Iqd
575Id =Id0*(Df1+Df2)*(-28)/553.6 +Ibc;
576Iqf=Iqf0*Dqf1*(-25)/201.3 + Iqfc;
577Iqd=Iqd0*Dqd1*(-25)/151.04 + Iqdc;
578
579clear pf pd p0 rf rd
580pf=Grf + af*(Iqf);
581pd=Grd + ad*(Iqd);
582p0=Br +  b.*(Id);
583rf=pf./(p0*rho);
584rd=pd./(p0*rho);
585
586table=(31 +  [0 10 20 30 100 148 200 270 280 293 ]);
587
588ntable=int16(table*1e-03/dt);
589
590
591global THERING
592clear dnux dnuz tt
593%switch2sim
594QFI = findcells(THERING,'FamName','QPF');
595QDI = findcells(THERING,'FamName','QPD');
596i=0;
597for k=1:length(table)
598   n1=ntable(k);
599   KQF=rf(n1);
600   KQD=-rd(n1);
601   THERING = setcellstruct(THERING,'K',QFI,KQF);
602   THERING = setcellstruct(THERING,'K',QDI,KQD);
603   THERING = setcellstruct(THERING,'PolynomB',QFI, KQF,2);
604   THERING = setcellstruct(THERING,'PolynomB',QDI, KQD,2);
605   [TD, tune] = twissring(THERING,0,1:(length(THERING)+1));
606   dnux(k)=tune(1);dnuz(k)=tune(2);
607end
608n1=ntable(1);
609n2=ntable(6);          %                 ntable(length(ntable));
610fprintf('\n');
611fprintf(' Tune à l injection        %g   %g: \n', dnux(1), dnuz(1))
612fprintf(' Courant à l injection     %g   %g  %g: \n', (Id(n1)),(Iqf(n1)),(Iqd(n1)))
613fprintf(' Courant à la redescente   %g   %g  %g: \n', (Id(n2)),(Iqf(n2)),(Iqd(n2)))
614fprintf('\n');fprintf('\n');
615
616axes(handles.axes1)
617plot(table,dnux-6, '-or',table , dnuz-4,'-ob');
618legend('X','Z')
619xlim([0 340]); ylim([0.5 1]);
620xlabel('Time (ms)'); ylabel('Tune');
621grid on
622
623end
624
625function comment_Callback(hObject, eventdata, handles)
626% hObject    handle to comment (see GCBO)
627% eventdata  reserved - to be defined in a future version of MATLAB
628% handles    structure with handles and user data (see GUIDATA)
629
630% Hints: get(hObject,'String') returns contents of comment as text
631%        str2double(get(hObject,'String')) returns contents of comment as a double
632
633
634% --- Executes during object creation, after setting all properties.
635function comment_CreateFcn(hObject, eventdata, handles)
636% hObject    handle to comment (see GCBO)
637% eventdata  reserved - to be defined in a future version of MATLAB
638% handles    empty - handles not created until after all CreateFcns called
639
640% Hint: edit controls usually have a white background on Windows.
641%       See ISPC and COMPUTER.
642if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
643    set(hObject,'BackgroundColor','white');
644end
645
646
647% --- Executes on button press in button_save.
648function button_save_Callback(hObject, eventdata, handles)
649% hObject    handle to button_save (see GCBO)
650% eventdata  reserved - to be defined in a future version of MATLAB
651% handles    structure with handles and user data (see GUIDATA)
652
653legend=get(handles.comment,'String');
654Directory =  [getfamilydata('Directory','DataRoot') 'Datatemp'];
655pwdold = pwd;
656cd(Directory);
657save_param(legend)
658cd(pwdold);
659
660% --- Executes on button press in button_load_file.
661function button_load_file_Callback(hObject, eventdata, handles)
662% hObject    handle to button_load_file (see GCBO)
663% eventdata  reserved - to be defined in a future version of MATLAB
664% handles    structure with handles and user data (see GUIDATA)
665
666boo=handles.boo;
667boo
668tout=0.5;
669%Alim
670    writeattribute('BOO/AE/dipole/current',boo.DIPcurrent);
671    writeattribute('BOO/AE/QF/current',boo.QFcurrent);
672    writeattribute('BOO/AE/QD/current',boo.QDcurrent);
673    writeattribute('BOO/AE/SF/current',boo.SFcurrent);
674    writeattribute('BOO/AE/SD/current',boo.SDcurrent);
675    writeattribute('BOO/AE/dipole/waveformOffset',boo.DIPoffset);
676    writeattribute('BOO/AE/QF/waveformOffset',boo.QFpoffset);
677    writeattribute('BOO/AE/QD/waveformOffset',boo.QDpoffset);
678    writeattribute('BOO/AE/SF/waveformOffset',boo.SFpoffset);
679    writeattribute('BOO/AE/SD/waveformOffset',boo.SDpoffset);
680%timing
681    tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'dpTimeDelay',boo.DIPdelay);pause(tout);
682    tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'qfTimeDelay',boo.QFdelay);pause(tout);
683    tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'qdTimeDelay',boo.QDdelay);pause(tout);
684    tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'sfTimeDelay',boo.DIPdelay);pause(tout);
685    tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'sdTimeDelay',boo.DIPdelay);pause(tout);
686
687
688% --- Executes on button press in button_openfile.
689function button_openfile_Callback(hObject, eventdata, handles)
690% hObject    handle to button_openfile (see GCBO)
691% eventdata  reserved - to be defined in a future version of MATLAB
692% handles    structure with handles and user data (see GUIDATA)
693
694Directory =  [getfamilydata('Directory','DataRoot') 'Datatemp'];
695pwdold = pwd;
696cd(Directory);
697[FileName,PathName] = uigetfile('*.mat','Select the setpoint file');
698load(FileName, 'boo');
699handles.boo=boo;
700set(handles.comment,'String',boo.comment);
701guidata(hObject, handles);
702cd(pwdold);
703
704% --- Executes on button press in button_load_setpoint.
705function button_load_setpoint_Callback(hObject, eventdata, handles)
706% hObject    handle to button_load_setpoint (see GCBO)
707% eventdata  reserved - to be defined in a future version of MATLAB
708% handles    structure with handles and user data (see GUIDATA)
709% alim
710    boo.DIPcurrent=readattribute('BOO/AE/D.1/current'        ,'Setpoint');
711    boo.DIPoffset =readattribute('BOO/AE/D.1/waveformOffset' ,'Setpoint');
712    boo.QFcurrent=readattribute('BOO/AE/QF/current'          ,'Setpoint');
713    boo.QFpoffset =readattribute('BOO/AE/QF/waveformOffset'  ,'Setpoint');
714    boo.QDcurrent=readattribute('BOO/AE/QD/current'          ,'Setpoint');
715    boo.QDpoffset =readattribute('BOO/AE/QD/waveformOffset'  ,'Setpoint');
716    boo.SFcurrent=readattribute('BOO/AE/SF/current'          ,'Setpoint');
717    boo.SFpoffset =readattribute('BOO/AE/SF/waveformOffset'  ,'Setpoint');
718    boo.SDcurrent=readattribute('BOO/AE/SD/current'          ,'Setpoint');
719    boo.SDpoffset =readattribute('BOO/AE/SD/waveformOffset'  ,'Setpoint');
720% synchro
721    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'dpTimeDelay');
722    boo.DIPdelay=temp.value(1);
723    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'qfTimeDelay');
724    boo.QFdelay=temp.value(1);
725    temp=tango_read_attribute2('BOO/SY/LOCAL.ALIM.1', 'qdTimeDelay');
726    boo.QDdelay=temp.value(1);
727   
728handles.boo=boo;
729boo
730guidata(hObject, handles);
Note: See TracBrowser for help on using the repository browser.