source: MML/trunk/machine/SOLEIL/common/synchro/synchro_injecteur8_rafale.m

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

To have a stable version on the server.

  • Property svn:executable set to *
File size: 156.5 KB
Line 
1function varargout = synchro_injecteur8_rafale(varargin)
2% SYNCHRO_INJECTEUR8_RAFALE M-file for synchro_injecteur8_rafale.fig
3%      SYNCHRO_INJECTEUR8_RAFALE, by itself, creates a new SYNCHRO_INJECTEUR8_RAFALE or raises the existing
4%      singleton*.
5%
6%      H = SYNCHRO_INJECTEUR8_RAFALE returns the handle to a new SYNCHRO_INJECTEUR8_RAFALE or the handle to
7%      the existing singleton*.
8%
9%      SYNCHRO_INJECTEUR8_RAFALE('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in SYNCHRO_INJECTEUR8_RAFALE.M with the given input arguments.
11%
12%      SYNCHRO_INJECTEUR8_RAFALE('Property','Value',...) creates a new SYNCHRO_INJECTEUR8_RAFALE or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before synchro_injecteur8_rafale_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to synchro_injecteur8_rafale_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% For the compiler
24%#function aoinit setao setoperationalmode
25%#function boosterinit
26%#function magnetcoefficients
27%
28
29% Edit the above text to modify the response to help synchro_injecteur8_rafale
30
31% Last Modified by GUIDE v2.5 23-Aug-2011 10:05:25
32
33% Begin initialization code - DO NOT EDIT
34gui_Singleton = 1;
35gui_State = struct('gui_Name',       mfilename, ...
36                   'gui_Singleton',  gui_Singleton, ...
37                   'gui_OpeningFcn', @synchro_injecteur8_rafale_OpeningFcn, ...
38                   'gui_OutputFcn',  @synchro_injecteur8_rafale_OutputFcn, ...
39                   'gui_LayoutFcn',  [] , ...
40                   'gui_Callback',   []);
41if nargin && ischar(varargin{1})
42    gui_State.gui_Callback = str2func(varargin{1});
43end
44
45if nargout
46    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
47else
48    gui_mainfcn(gui_State, varargin{:});
49end
50% End initialization code - DO NOT EDIT
51
52
53% --- Executes just before synchro_injecteur8_rafale is made visible.
54function synchro_injecteur8_rafale_OpeningFcn(hObject, eventdata, handles, varargin)
55% This function has no output args, see OutputFcn.
56% hObject    handle to figure
57% eventdata  reserved - to be defined in a future version of MATLAB
58% handles    structure with handles and user data (see GUIDATA)
59% varargin   command line arguments to synchro_injecteur8_rafale (see VARARGIN)
60
61% Choose default command line output for synchro_injecteur8_rafale
62handles.output = hObject;
63
64% list les devices annexe pour etat
65fprintf('Liste devices annexes \n');
66% name={'ANS-C03/DG/DCCT','LT1/DG/MC','BOO-C01/DG/DCCT',...
67%     'ANS/DG/PUB-FillingMode', 'ANS/FC/INJ_COND'};
68name={'ANS/DG/DCCT-CTRL','LT1/DG/MC','BOO-C01/DG/DCCT',...
69    'ANS/DG/PUB-FillingMode', 'ANS/FC/INJ_COND'};
70for i=1:4
71    try
72        txt=tango_command_inout2(name{2},'State');
73        %temp=tango_read_attribute(name{i},'State');
74        %temp=tango_read_attribute(name{i},'Status');txt=temp.value;
75    catch
76        txt='bug_device';
77    end
78    fprintf('%s   :   %s \n',name{i},txt);
79end
80
81% Added by Laurent
82if isdeployed
83    cd(getenv('MLROOT'));
84    setpathsoleil('Booster');
85end
86% End
87
88% Directories
89%Directory='/home/matlabML/measdata/SOLEIL/Boosterdata/Datatemp'; % ALEX
90Directory =  [getfamilydata('Directory','DataRoot') '../Boosterdata/Datatemp']; % Laurent
91handles.Directory=Directory;  % for saved data
92
93%FileName = fullfile+31.555cxxccx(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
94% DirName ='/home/matlabML/machine/SOLEIL/common/synchro/'; % ALEX
95DirName = getfamilydata('Directory', 'Synchro'); % Laurent
96handles.DirName=DirName;      % for offset & table
97
98% Charge les offset
99FileName = [DirName 'synchro_offset_lin'];
100fprintf('Laurent:%s\n', FileName');
101load(FileName, 'inj_offset' , 'ext_offset', 'lin_fin');
102set(handles.inj_offset,'String',num2str(inj_offset));
103set(handles.ext_offset,'String',num2str(ext_offset));
104set(handles.lin_canon_spm_fin,'String',num2str(lin_fin));
105% Periode linac fin
106handles.lin_fin_step=0.090;                   % En ns  (90 ps)
107handles.one_bunch=2.84/handles.lin_fin_step;  % Nombre de pas pour sauter un paquet
108
109% Periode du trigger par defaut = 10 s
110handles.periode = 10;
111set(handles.periode_edit,'String',num2str(handles.periode));
112set(handles.edit_Ncycle,'String',num2str(1));
113set(handles.edit_Ncoup,'String',1.0);
114
115%Memorise les délais spare et soft initiaux
116temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprStepDelay');
117clk1=temp.value(1);
118temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay');
119clk2=temp.value(1);
120
121%Stocke les sauts pour les 4 quarts mode LPM
122jump=int32([0 39 26 13]);
123handles.clk_spare  =jump +  int32(clk1);
124handles.clk_soft=jump  + int32(clk2);
125handles.quart=1;
126
127% Table initiale sur paquet 1
128bunch=[1];
129[dtour,dpaquet]=bucketnumber(bunch);
130offset_linac=lin_fin/handles.lin_fin_step;
131bjump=handles.one_bunch;
132dpaquet=dpaquet*bjump+offset_linac;
133handles.table=int32([length(bunch) dtour dpaquet]);
134handles.table0=handles.table;
135handles.bunch=bunch;
136
137handles.mode = 'Mode=???';
138set(handles.edit_filling_relecture_tables,'Enable','off');
139set(handles.edit_filling_relecture_bunch,'Enable','off');
140
141% Verifie le mode selectionné en SPM ou LPM
142% Verifie le mode central selectionné  : rafale ou continue
143% Verifie le mode selectionné en SPM : 1 2 ou 3 paquets
144% Verifie le mode d'injection selectionné : soft ou 3Hz
145test_modes(handles);
146
147
148% Choix des events
149handles.event0 =int32(0);
150handles.event00=int32(100);  %Spéciale EP
151
152% Cache le tableau des délais BPM
153set(handles.panel_bpm,'Visible','off');
154set(handles.uipanel_kicker_machine,'Visible','off');
155
156% text affichage
157handles.txt_inj=  ' INJECTION AUTOMATIQUE EN COURS '; % txt injection auto en cours
158handles.txt_noinj=' INJECTION INTERDITE ';            % txt injection non autorise (Grp fonctionnement)
159
160% Publisher - fonctionnement (gere sur injection en boucle)
161tango_write_attribute2('ANS/DG/PUB-FillingMode','mode_auto',uint8(0))         % flag injection auto
162tango_write_attribute2('ANS/DG/PUB-FillingMode','courant_consigne',uint8(0))  % flag courant consigne atteint
163 
164% tango parser ANS/FC/INJ_COND
165% temp=tango_read_attribute2('ANS/FC/INJ_COND', 'COND_INJ');
166% handles.cond_inj=temp.value;   % 0 no injection,  1 injection
167% try temp=tango_read_attribute2('ANS/FC/INJ_COND', 'COND_INJ'); % 0 no injection,  1 injection
168% val=temp.value; catch val=1 ; end ; if val~=0 ; val=1; end;
169% handles.cond_inj=val;
170
171
172% Fonction timer pour injection en boucle
173% Creates timer Infinite loop
174timer2=timer('StartDelay',1,...
175    'ExecutionMode','fixedRate','Period',3,'TasksToExecute',Inf);
176timer2.TimerFcn = {@fonction_alex2, hObject,eventdata, handles};
177setappdata(handles.figure1,'Timer2',timer2);
178
179% Creates timer Infinite loop
180timer1=timer('StartDelay',1,...
181    'ExecutionMode','fixedRate','Period',handles.periode,'TasksToExecute',Inf);
182timer1.TimerFcn = {@fonction_alex1, hObject,eventdata, handles};
183setappdata(handles.figure1,'Timer1',timer1);
184
185% button group sur on/off timer du trigger
186h = uibuttongroup('visible','off','Position',[0.7275 0.72 0.125 0.145],...
187    'Title','','TitlePosition','centertop',...
188    'BackgroundColor',[1 0.3 0 ]);
189u1 = uicontrol('Style','Radio','String',' OFF','Tag','radiobutton1',...
190    'pos',[05 85 55 25],'parent',h,'HandleVisibility','off',...
191    'BackgroundColor',[1 0.3 0  ]);
192u2 = uicontrol('Style','Radio','String',' Laps :','Tag','radiobutton2',...
193    'pos',[05 45 55 25],'parent',h,'HandleVisibility','off',...
194    'BackgroundColor',[1 0.3 0 ]);
195u3 = uicontrol('Style','Radio','String',' Imin :','Tag','radiobutton3',...
196    'pos',[05 05 55 25],'parent',h,'HandleVisibility','off',...
197    'BackgroundColor',[1 0.3 0 ]);
198
199set(h,'SelectionChangeFcn',...
200    {@uibuttongroup_SelectionChangeFcn,handles});
201
202handles.off = u1;
203handles.on1 = u2;
204handles.on2 = u3;
205
206set(h,'SelectedObject',u1);
207set(h,'Visible','on');
208
209%% Set closing gui function
210set(handles.figure1,'CloseRequestFcn',{@Closinggui,timer1,handles.figure1});
211set(handles.figure1,'CloseRequestFcn',{@Closinggui,timer2,handles.figure1});
212
213
214% Update handles structure
215guidata(hObject, handles);
216
217% UIWAIT makes synchro_injecteur8_rafale wait for user response (see UIRESUME)
218% uiwait(handles.figure1);
219
220
221% --- Outputs from this function are returned to the command line.
222function varargout = synchro_injecteur8_rafale_OutputFcn(hObject, eventdata, handles)
223% varargout  cell array for returning output args (see VARARGOUT);
224% hObject    handle to figure
225% eventdata  reserved - to be defined in a future version of MATLAB
226% handles    structure with handles and user data (see GUIDATA)
227
228% Get default command line output from handles structure
229varargout{1} = handles.output;
230
231
232
233function boo_alim_dipole_Callback(hObject, eventdata, handles)
234% hObject    handle to boo_alim_dipole (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
238% Hints: get(hObject,'String') returns contents of boo_alim_dipole as text
239%        str2double(get(hObject,'String')) returns contents of boo_alim_dipole as a double
240%h=gcf
241delay=str2double(get(hObject,'String'));
242tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'dpTimeDelay',delay);
243
244% --- Executes during object creation, after setting all properties.
245function boo_alim_dipole_CreateFcn(hObject, eventdata, handles)
246% hObject    handle to boo_alim_dipole (see GCBO)
247% eventdata  reserved - to be defined in a future version of MATLAB
248% handles    empty - handles not created until after all CreateFcns called
249
250% Hint: edit controls usually have a white background on Windows.
251%       See ISPC and COMPUTER.
252if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
253    set(hObject,'BackgroundColor','white');
254end
255
256
257function boo_alim_qf_Callback(hObject, eventdata, handles)
258% hObject    handle to boo_alim_qf (see GCBO)
259% eventdata  reserved - to be defined in a future version of MATLAB
260% handles    structure with handles and user data (see GUIDATA)
261
262% Hints: get(hObject,'String') returns contents of boo_alim_qf as text
263%        str2double(get(hObject,'String')) returns contents of boo_alim_qf as a double
264
265delay=str2double(get(hObject,'String'));
266tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'qfTimeDelay',delay);
267
268% --- Executes during object creation, after setting all properties.
269function boo_alim_qf_CreateFcn(hObject, eventdata, handles)
270% hObject    handle to boo_alim_qf (see GCBO)
271% eventdata  reserved - to be defined in a future version of MATLAB
272% handles    empty - handles not created until after all CreateFcns called
273
274% Hint: edit controls usually have a white background on Windows.
275%       See ISPC and COMPUTER.
276if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
277    set(hObject,'BackgroundColor','white');
278end
279
280
281
282function boo_alim_qd_Callback(hObject, eventdata, handles)
283% hObject    handle to boo_alim_qd (see GCBO)
284% eventdata  reserved - to be defined in a future version of MATLAB
285% handles    structure with handles and user data (see GUIDATA)
286
287% Hints: get(hObject,'String') returns contents of boo_alim_qd as text
288%        str2double(get(hObject,'String')) returns contents of boo_alim_qd as a double
289
290delay=str2double(get(hObject,'String'));
291tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'qdTimeDelay',delay);
292
293% --- Executes during object creation, after setting all properties.
294function boo_alim_qd_CreateFcn(hObject, eventdata, handles)
295% hObject    handle to boo_alim_qd (see GCBO)
296% eventdata  reserved - to be defined in a future version of MATLAB
297% handles    empty - handles not created until after all CreateFcns called
298
299% Hint: edit controls usually have a white background on Windows.
300%       See ISPC and COMPUTER.
301if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
302    set(hObject,'BackgroundColor','white');
303end
304
305
306
307function boo_alim_sf_Callback(hObject, eventdata, handles)
308% hObject    handle to boo_alim_sf (see GCBO)
309% eventdata  reserved - to be defined in a future version of MATLAB
310% handles    structure with handles and user data (see GUIDATA)
311
312% Hints: get(hObject,'String') returns contents of boo_alim_sf as text
313%        str2double(get(hObject,'String')) returns contents of boo_alim_sf as a double
314
315delay=str2double(get(hObject,'String'));
316tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'sfTimeDelay',delay);
317
318% --- Executes during object creation, after setting all properties.
319function boo_alim_sf_CreateFcn(hObject, eventdata, handles)
320% hObject    handle to boo_alim_sf (see GCBO)
321% eventdata  reserved - to be defined in a future version of MATLAB
322% handles    empty - handles not created until after all CreateFcns called
323
324% Hint: edit controls usually have a white background on Windows.
325%       See ISPC and COMPUTER.
326if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
327    set(hObject,'BackgroundColor','white');
328end
329
330
331
332function boo_alim_sd_Callback(hObject, eventdata, handles)
333% hObject    handle to boo_alim_sd (see GCBO)
334% eventdata  reserved - to be defined in a future version of MATLAB
335% handles    structure with handles and user data (see GUIDATA)
336
337% Hints: get(hObject,'String') returns contents of boo_alim_sd as text
338%        str2double(get(hObject,'String')) returns contents of boo_alim_sd as a double
339
340delay=str2double(get(hObject,'String'));
341tango_write_attribute2('BOO/SY/LOCAL.ALIM.1', 'sdTimeDelay',delay);
342
343
344% --- Executes during object creation, after setting all properties.
345function boo_alim_sd_CreateFcn(hObject, eventdata, handles)
346% hObject    handle to boo_alim_sd (see GCBO)
347% eventdata  reserved - to be defined in a future version of MATLAB
348% handles    empty - handles not created until after all CreateFcns called
349
350% Hint: edit controls usually have a white background on Windows.
351%       See ISPC and COMPUTER.
352if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
353    set(hObject,'BackgroundColor','white');
354end
355
356
357
358function boo_rf_Callback(hObject, eventdata, handles)
359% hObject    handle to boo_rf (see GCBO)
360% eventdata  reserved - to be defined in a future version of MATLAB
361% handles    structure with handles and user data (see GUIDATA)
362
363% Hints: get(hObject,'String') returns contents of boo_rf as text
364%        str2double(get(hObject,'String')) returns contents of boo_rf as a double
365
366delay=str2double(get(hObject,'String'));
367tango_write_attribute2('BOO/SY/LOCAL.RF.1', 'rfTimeDelay',delay);
368
369% --- Executes during object creation, after setting all properties.
370function boo_rf_CreateFcn(hObject, eventdata, handles)
371% hObject    handle to boo_rf (see GCBO)
372% eventdata  reserved - to be defined in a future version of MATLAB
373% handles    empty - handles not created until after all CreateFcns called
374
375% Hint: edit controls usually have a white background on Windows.
376%       See ISPC and COMPUTER.
377if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
378    set(hObject,'BackgroundColor','white');
379end
380
381
382
383function lin_canon_lpm_Callback(hObject, eventdata, handles)
384% hObject    handle to lin_alim_canon_lpm (see GCBO)
385% eventdata  reserved - to be defined in a future version of MATLAB
386% handles    structure with handles and user data (see GUIDATA)
387
388% Hints: get(hObject,'String') returns contents of lin_alim_canon_lpm as text
389%        str2double(get(hObject,'String')) returns contents of lin_alim_canon_lpm as a double
390
391inj_offset=str2double(get(handles.inj_offset,'String'));
392delay=str2double(get(hObject,'String'))+inj_offset;
393tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmTimeDelay',delay);
394
395
396% --- Executes during object creation, after setting all properties.
397function lin_canon_lpm_CreateFcn(hObject, eventdata, handles)
398% hObject    handle to lin_alim_canon_lpm (see GCBO)
399% eventdata  reserved - to be defined in a future version of MATLAB
400% handles    empty - handles not created until after all CreateFcns called
401
402% Hint: edit controls usually have a white background on Windows.
403%       See ISPC and COMPUTER.
404if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
405    set(hObject,'BackgroundColor','white');
406end
407
408
409
410function lt1_emittance_Callback(hObject, eventdata, handles)
411% hObject    handle to lt1_emittance (see GCBO)
412% eventdata  reserved - to be defined in a future version of MATLAB
413% handles    structure with handles and user data (see GUIDATA)
414
415% Hints: get(hObject,'String') returns contents of lt1_emittance as text
416%        str2double(get(hObject,'String')) returns contents of lt1_emittance as a double
417inj_offset=str2double(get(handles.inj_offset,'String'));
418delay=str2double(get(hObject,'String'))+inj_offset;
419tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'emittanceTimeDelay',delay);
420
421% --- Executes during object creation, after setting all properties.
422function lt1_emittance_CreateFcn(hObject, eventdata, handles)
423% hObject    handle to lt1_emittance (see GCBO)
424% eventdata  reserved - to be defined in a future version of MATLAB
425% handles    empty - handles not created until after all CreateFcns called
426
427% Hint: edit controls usually have a white background on Windows.
428%       See ISPC and COMPUTER.
429if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
430    set(hObject,'BackgroundColor','white');
431end
432
433
434
435function lt1_MC1_Callback(hObject, eventdata, handles)
436% hObject    handle to lt1_MC1 (see GCBO)
437% eventdata  reserved - to be defined in a future version of MATLAB
438% handles    structure with handles and user data (see GUIDATA)
439
440% Hints: get(hObject,'String') returns contents of lt1_MC1 as text
441%        str2double(get(hObject,'String')) returns contents of lt1_MC1 as a double
442inj_offset=str2double(get(handles.inj_offset,'String'));
443delay=str2double(get(hObject,'String'))+inj_offset;
444tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'mc.1TimeDelay',delay);
445
446% --- Executes during object creation, after setting all properties.
447function lt1_MC1_CreateFcn(hObject, eventdata, handles)
448% hObject    handle to lt1_MC1 (see GCBO)
449% eventdata  reserved - to be defined in a future version of MATLAB
450% handles    empty - handles not created until after all CreateFcns called
451
452% Hint: edit controls usually have a white background on Windows.
453%       See ISPC and COMPUTER.
454if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
455    set(hObject,'BackgroundColor','white');
456end
457
458
459
460function lt1_MC2_Callback(hObject, eventdata, handles)
461% hObject    handle to lt1_MC2 (see GCBO)
462% eventdata  reserved - to be defined in a future version of MATLAB
463% handles    structure with handles and user data (see GUIDATA)
464
465% Hints: get(hObject,'String') returns contents of lt1_MC2 as text
466%        str2double(get(hObject,'String')) returns contents of lt1_MC2 as a double
467inj_offset=str2double(get(handles.inj_offset,'String'));
468delay=str2double(get(hObject,'String'))+inj_offset;
469tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'mc.2TimeDelay',delay);
470
471% --- Executes during object creation, after setting all properties.
472function lt1_MC2_CreateFcn(hObject, eventdata, handles)
473% hObject    handle to lt1_MC2 (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: edit controls usually have a white background on Windows.
478%       See ISPC and COMPUTER.
479if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
480    set(hObject,'BackgroundColor','white');
481end
482
483
484
485function lt1_osc_Callback(hObject, eventdata, handles)
486% hObject    handle to lt1_osc (see GCBO)
487% eventdata  reserved - to be defined in a future version of MATLAB
488% handles    structure with handles and user data (see GUIDATA)
489
490% Hints: get(hObject,'String') returns contents of lt1_osc as text
491%        str2double(get(hObject,'String')) returns contents of lt1_osc as a double
492inj_offset=str2double(get(handles.inj_offset,'String'));
493delay=str2double(get(hObject,'String'))+inj_offset;
494tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'oscTimeDelay',delay);
495
496
497% --- Executes during object creation, after setting all properties.
498function lt1_osc_CreateFcn(hObject, eventdata, handles)
499% hObject    handle to lt1_osc (see GCBO)
500% eventdata  reserved - to be defined in a future version of MATLAB
501% handles    empty - handles not created until after all CreateFcns called
502
503% Hint: edit controls usually have a white background on Windows.
504%       See ISPC and COMPUTER.
505if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
506    set(hObject,'BackgroundColor','white');
507end
508
509
510
511function sdc1_Callback(hObject, eventdata, handles)
512% hObject    handle to sdc1 (see GCBO)
513% eventdata  reserved - to be defined in a future version of MATLAB
514% handles    structure with handles and user data (see GUIDATA)
515
516% Hints: get(hObject,'String') returns contents of sdc1 as text
517%        str2double(get(hObject,'String')) returns contents of sdc1 as a double
518inj_offset=str2double(get(handles.inj_offset,'String'));
519delay=str2double(get(hObject,'String'))+inj_offset;
520tango_write_attribute2('ANS/SY/LOCAL.SDC.1', 'oscTimeDelay',delay);
521
522% --- Executes during object creation, after setting all properties.
523function sdc1_CreateFcn(hObject, eventdata, handles)
524% hObject    handle to sdc1 (see GCBO)
525% eventdata  reserved - to be defined in a future version of MATLAB
526% handles    empty - handles not created until after all CreateFcns called
527
528% Hint: edit controls usually have a white background on Windows.
529%       See ISPC and COMPUTER.
530if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
531    set(hObject,'BackgroundColor','white');
532end
533
534
535
536function boo_inj_septum_Callback(hObject, eventdata, handles)
537% hObject    handle to boo_inj_septum (see GCBO)
538% eventdata  reserved - to be defined in a future version of MATLAB
539% handles    structure with handles and user data (see GUIDATA)
540
541% Hints: get(hObject,'String') returns contents of boo_inj_septum as text
542%        str2double(get(hObject,'String')) returns contents of boo_inj_septum as a double
543inj_offset=str2double(get(handles.inj_offset,'String'));
544delay=str2double(get(hObject,'String'))+inj_offset;
545tango_write_attribute2('BOO/SY/LOCAL.Binj.1', 'sep-p.trigTimeDelay',delay);
546
547% --- Executes during object creation, after setting all properties.
548function boo_inj_septum_CreateFcn(hObject, eventdata, handles)
549% hObject    handle to boo_inj_septum (see GCBO)
550% eventdata  reserved - to be defined in a future version of MATLAB
551% handles    empty - handles not created until after all CreateFcns called
552
553% Hint: edit controls usually have a white background on Windows.
554%       See ISPC and COMPUTER.
555if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
556    set(hObject,'BackgroundColor','white');
557end
558
559
560
561function boo_inj_kicker_Callback(hObject, eventdata, handles)
562% hObject    handle to boo_inj_kicker (see GCBO)
563% eventdata  reserved - to be defined in a future version of MATLAB
564% handles    structure with handles and user data (see GUIDATA)
565
566% Hints: get(hObject,'String') returns contents of boo_inj_kicker as text
567%        str2double(get(hObject,'String')) returns contents of boo_inj_kicker as a double
568inj_offset=str2double(get(handles.inj_offset,'String'));
569delay=str2double(get(hObject,'String'))+inj_offset;
570tango_write_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigTimeDelay',delay);
571
572% --- Executes during object creation, after setting all properties.
573function boo_inj_kicker_CreateFcn(hObject, eventdata, handles)
574% hObject    handle to boo_inj_kicker (see GCBO)
575% eventdata  reserved - to be defined in a future version of MATLAB
576% handles    empty - handles not created until after all CreateFcns called
577
578% Hint: edit controls usually have a white background on Windows.
579%       See ISPC and COMPUTER.
580if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
581    set(hObject,'BackgroundColor','white');
582end
583
584
585
586function boo_bpm_Callback(hObject, eventdata, handles)
587% hObject    handle to boo_bpm (see GCBO)
588% eventdata  reserved - to be defined in a future version of MATLAB
589% handles    structure with handles and user data (see GUIDATA)
590
591% Hints: get(hObject,'String') returns contents of boo_bpm as text
592%        str2double(get(hObject,'String')) returns contents of boo_bpm as a double
593
594inj_offset=str2double(get(handles.inj_offset,'String'));
595delay=str2double(get(hObject,'String'))+inj_offset;
596tango_write_attribute2('BOO/SY/LOCAL.DG.1', 'bpm-bta.trigTimeDelay',delay);
597tango_write_attribute2('BOO/SY/LOCAL.DG.1', 'bpm-btd.trigTimeDelay',delay);
598tango_write_attribute2('BOO/SY/LOCAL.DG.2', 'bpm-btb.trigTimeDelay',delay);
599tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'bpm-btc.trigTimeDelay',delay);
600
601
602% --- Executes during object creation, after setting all properties.
603function boo_bpm_CreateFcn(hObject, eventdata, handles)
604% hObject    handle to boo_bpm (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: edit controls usually have a white background on Windows.
609%       See ISPC and COMPUTER.
610if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
611    set(hObject,'BackgroundColor','white');
612end
613
614
615
616function boo_nod_Callback(hObject, eventdata, handles)
617% hObject    handle to boo_nod (see GCBO)
618% eventdata  reserved - to be defined in a future version of MATLAB
619% handles    structure with handles and user data (see GUIDATA)
620
621% Hints: get(hObject,'String') returns contents of boo_nod as text
622%        str2double(get(hObject,'String')) returns contents of boo_nod as a double
623inj_offset=str2double(get(handles.inj_offset,'String'));
624delay=str2double(get(hObject,'String'))+inj_offset;
625tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'bpm-onde.trigTimeDelay',delay);
626
627% --- Executes during object creation, after setting all properties.
628function boo_nod_CreateFcn(hObject, eventdata, handles)
629% hObject    handle to boo_nod (see GCBO)
630% eventdata  reserved - to be defined in a future version of MATLAB
631% handles    empty - handles not created until after all CreateFcns called
632
633% Hint: edit controls usually have a white background on Windows.
634%       See ISPC and COMPUTER.
635if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
636    set(hObject,'BackgroundColor','white');
637end
638
639
640
641function boo_dcct_Callback(hObject, eventdata, handles)
642% hObject    handle to boo_dcct (see GCBO)
643% eventdata  reserved - to be defined in a future version of MATLAB
644% handles    structure with handles and user data (see GUIDATA)
645
646% Hints: get(hObject,'String') returns contents of boo_dcct as text
647%        str2double(get(hObject,'String')) returns contents of boo_dcct as a double
648inj_offset=str2double(get(handles.inj_offset,'String'));
649delay=str2double(get(hObject,'String'))+inj_offset;
650tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'dcct-booTimeDelay',delay);
651
652% --- Executes during object creation, after setting all properties.
653function boo_dcct_CreateFcn(hObject, eventdata, handles)
654% hObject    handle to boo_dcct (see GCBO)
655% eventdata  reserved - to be defined in a future version of MATLAB
656% handles    empty - handles not created until after all CreateFcns called
657
658% Hint: edit controls usually have a white background on Windows.
659%       See ISPC and COMPUTER.
660if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
661    set(hObject,'BackgroundColor','white');
662end
663
664
665
666function lin_canon_spm_fin_Callback(hObject, eventdata, handles)
667% hObject    handle to lin_alim_canon_spm_fin (see GCBO)
668% eventdata  reserved - to be defined in a future version of MATLAB
669% handles    structure with handles and user data (see GUIDATA)
670
671% Hints: get(hObject,'String') returns contents of lin_alim_canon_spm_fin as text
672%        str2double(get(hObject,'String')) returns contents of lin_alim_canon_spm_fin as a double
673
674inj_offset=str2double(get(handles.inj_offset,'String'));
675ext_offset=str2double(get(handles.ext_offset,'String'));
676lin_fin   =str2double(get(handles.lin_canon_spm_fin,'String'));
677
678%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
679FileName = [handles.DirName 'synchro_offset_lin'];
680save(FileName, 'inj_offset' , 'ext_offset', 'lin_fin');
681
682% --- Executes during object creation, after setting all properties.
683function lin_canon_spm_fin_CreateFcn(hObject, eventdata, handles)
684% hObject    handle to lin_alim_canon_spm_fin (see GCBO)
685% eventdata  reserved - to be defined in a future version of MATLAB
686% handles    empty - handles not created until after all CreateFcns called
687
688% Hint: edit controls usually have a white background on Windows.
689%       See ISPC and COMPUTER.
690if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
691    set(hObject,'BackgroundColor','white');
692end
693
694
695
696function central_spare_Callback(hObject, eventdata, handles)
697% hObject    handle to central_spare (see GCBO)
698% eventdata  reserved - to be defined in a future version of MATLAB
699% handles    structure with handles and user data (see GUIDATA)
700
701% Hints: get(hObject,'String') returns contents of central_spare as text
702%        str2double(get(hObject,'String')) returns contents of central_spare as a double
703
704delay=str2double(get(hObject,'String'));
705tango_write_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay',delay);
706
707%status soft checked on linac
708temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent');
709if (temp.value(1)==2)
710   %
711elseif (temp.value(1)==5)
712    dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
713    inj_offset=str2double(get(handles.inj_offset,'String'));
714    dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
715    delay=dt.value(1)-dt1.value(1)+inj_offset;
716    tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
717    temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay');
718    set(handles.lin_modulateur,'String',num2str(temp.value(1)-inj_offset));
719end
720
721% --- Executes during object creation, after setting all properties.
722function central_spare_CreateFcn(hObject, eventdata, handles)
723% hObject    handle to central_spare (see GCBO)
724% eventdata  reserved - to be defined in a future version of MATLAB
725% handles    empty - handles not created until after all CreateFcns called
726
727% Hint: edit controls usually have a white background on Windows.
728%       See ISPC and COMPUTER.
729if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
730    set(hObject,'BackgroundColor','white');
731end
732
733
734
735function central_inj_Callback(hObject, eventdata, handles)
736% hObject    handle to central_inj (see GCBO)
737% eventdata  reserved - to be defined in a future version of MATLAB
738% handles    structure with handles and user data (see GUIDATA)
739
740% Hints: get(hObject,'String') returns contents of central_inj as text
741%        str2double(get(hObject,'String')) returns contents of central_inj as a double
742
743delay=str2double(get(hObject,'String'));
744tango_write_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay',delay);
745
746% --- Executes during object creation, after setting all properties.
747function central_inj_CreateFcn(hObject, eventdata, handles)
748% hObject    handle to central_inj (see GCBO)
749% eventdata  reserved - to be defined in a future version of MATLAB
750% handles    empty - handles not created until after all CreateFcns called
751
752% Hint: edit controls usually have a white background on Windows.
753%       See ISPC and COMPUTER.
754if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
755    set(hObject,'BackgroundColor','white');
756end
757
758
759
760
761function central_soft_Callback(hObject, eventdata, handles)
762% hObject    handle to central_soft (see GCBO)
763% eventdata  reserved - to be defined in a future version of MATLAB
764% handles    structure with handles and user data (see GUIDATA)
765
766% Hints: get(hObject,'String') returns contents of central_soft as text
767%        str2double(get(hObject,'String')) returns contents of central_soft as a double
768
769delay=str2double(get(hObject,'String'));
770tango_write_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay',delay);
771
772% temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay');
773% clkinj=int32(temp.value(1)+5*52);
774% clkext=int32(temp.value(1)/52+10);
775% tango_write_attribute2('ANS/SY/CENTRAL', 'TInjStepDelay',clkinj);
776% tango_write_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue',clkext);
777%
778% %status soft checked on linac
779% temp=tango_read_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareEvent');
780% if (temp.value(1)==2)
781%    %
782% elseif (temp.value(1)==1)
783%     dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
784%     inj_offset=str2double(get(handles.inj_offset,'String'));
785%     dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
786%     delay=dt.value(1)-dt1.value(1)+inj_offset;
787%     tango_write_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
788%     temp=tango_read_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay');
789%     set(handles.lin_alim_modulateur,'String',num2str(temp.value(1)-inj_offset));
790% end
791
792% --- Executes during object creation, after setting all properties.
793function central_soft_CreateFcn(hObject, eventdata, handles)
794% hObject    handle to central_soft (see GCBO)
795% eventdata  reserved - to be defined in a future version of MATLAB
796% handles    empty - handles not created until after all CreateFcns called
797
798% Hint: edit controls usually have a white background on Windows.
799%       See ISPC and COMPUTER.
800if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
801    set(hObject,'BackgroundColor','white');
802end
803
804
805% --- Executes on button press in button_acquisition_nooffset.
806function button_acquisition_nooffset_Callback(hObject, eventdata, handles)
807% hObject    handle to button_acquisition_nooffset (see GCBO)
808% eventdata  reserved - to be defined in a future version of MATLAB
809% handles    structure with handles and user data (see GUIDATA)
810
811test_modes(handles);
812
813
814set(handles.inj_offset,'Enable','off');
815set(handles.sdc1,'Enable','off');
816set(handles.lin_canon_lpm,'Enable','off');
817set(handles.lin_canon_spm,'Enable','off');
818set(handles.lin_canon_spm_fin,'Enable','off');
819set(handles.lin_alim,'Enable','off');
820set(handles.boo_bpm,'Enable','off');
821set(handles.lt1_emittance,'Enable','off');
822set(handles.lt1_MC1,'Enable','off');
823set(handles.lt1_MC2,'Enable','off');
824set(handles.lt1_osc,'Enable','off');
825set(handles.boo_dcct,'Enable','off');
826set(handles.boo_nod,'Enable','off');
827set(handles.boo_inj_septum,'Enable','off');
828set(handles.boo_inj_kicker,'Enable','off');
829set(handles.boo_alim_dipole,'Enable','off');
830set(handles.boo_alim_qf,'Enable','off');
831set(handles.boo_alim_qd,'Enable','off');
832set(handles.boo_alim_sf,'Enable','off');
833set(handles.boo_alim_sd,'Enable','off');
834set(handles.boo_alim_cp,'Enable','off');
835set(handles.boo_rf,'Enable','off');
836set(handles.boo_mrsv,'Enable','off');
837set(handles.lin_modulateur,'Enable','off');
838set(handles.ext_offset,'Enable','off');
839set(handles.boo_ext_dof,'Enable','off');
840set(handles.boo_ext_sept_p,'Enable','off');
841set(handles.boo_ext_sept_a,'Enable','off');
842set(handles.boo_ext_kicker,'Enable','off');
843set(handles.sdc2,'Enable','off');
844set(handles.lt2_emittance,'Enable','off');
845set(handles.lt2_osc,'Enable','off');
846set(handles.lt2_bpm,'Enable','off');
847set(handles.ans_inj_k1,'Enable','off');
848set(handles.ans_inj_k2,'Enable','off');
849set(handles.ans_inj_k3,'Enable','off');
850set(handles.ans_inj_k4,'Enable','off');
851set(handles.ans_inj_sept_p,'Enable','off');
852set(handles.ans_inj_sept_a,'Enable','off');
853set(handles.ans_fbt,'Enable','off');
854set(handles.ans_dcct,'Enable','off');
855set(handles.ans_nod,'Enable','off');
856set(handles.ans_bpm_c01,'Enable','off');
857set(handles.ans_bpm_c02,'Enable','off');
858set(handles.ans_bpm_c03,'Enable','off');
859set(handles.ans_bpm_c04,'Enable','off');
860set(handles.ans_bpm_c05,'Enable','off');
861set(handles.ans_bpm_c06,'Enable','off');
862set(handles.ans_bpm_c07,'Enable','off');
863set(handles.ans_bpm_c08,'Enable','off');
864set(handles.ans_bpm_c09,'Enable','off');
865set(handles.ans_bpm_c10,'Enable','off');
866set(handles.ans_bpm_c11,'Enable','off');
867set(handles.ans_bpm_c12,'Enable','off');
868set(handles.ans_bpm_c13,'Enable','off');
869set(handles.ans_bpm_c14,'Enable','off');
870set(handles.ans_bpm_c15,'Enable','off');
871set(handles.ans_bpm_c16,'Enable','off');
872
873get_synchro_delay_nooffset(handles)
874n=1;
875
876temp=tango_read_attribute2('LT1/SY/LOCAL.DG.1', 'libre.1TimeDelay');
877try txt=num2str(temp.value(n)); catch txt='Bug device' ; end
878set(handles.lin_alim,'String',txt);
879
880temp=tango_read_attribute2('BOO/SY/LOCAL.DG.3', 'emittanceTimeDelay');
881try ;txt=num2str(temp.value(n)); catch txt=bug_device ; end
882set(handles.boo_mrsv,'String',txt);
883
884temp=tango_read_attribute2('ANS-C14/SY/LOCAL.DG.1', 'perteTimeDelay');
885try ;txt=num2str(temp.value(n)); catch txt=bug_device ; end
886set(handles.ans_nod,'String',txt);
887
888
889%status soft checked on linac
890temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent');
891if (temp.value(n)==2)
892    %set(handles.soft_button,'Value',0);
893elseif (temp.value(n)==5)
894    %set(handles.soft_button,'Value',1);
895end
896
897%status tables
898temp=tango_read_attribute('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue');
899offset=temp.value(1)*52;
900temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TablesCurrentDepth');
901n=temp.value;
902temp=tango_read_attribute2('ANS/SY/CENTRAL', 'ExtractionDelayTable');
903table=temp.value(1:n)-offset;
904set(handles.edit_filling_relecture_tables,'String',['T=' , num2str(table)]); 
905
906
907
908% --- Executes on button press in button_acquisition_delay.
909function button_acquisition_delay_Callback(hObject, eventdata, handles)
910% hObject    handle to button_acquisition_delay (see GCBO)
911% eventdata  reserved - to be defined in a future version of MATLAB
912% handles    structure with handles and user data (see GUIDATA)
913bug_device='Bug device';
914
915test_modes(handles);
916
917set(handles.inj_offset,'Enable','on');
918set(handles.sdc1,'Enable','on');
919set(handles.lin_canon_lpm,'Enable','on');
920set(handles.lin_canon_spm,'Enable','on');
921set(handles.lin_canon_spm_fin,'Enable','on');
922set(handles.lin_alim,'Enable','on');
923set(handles.boo_bpm,'Enable','on');
924set(handles.lt1_emittance,'Enable','on');
925set(handles.lt1_MC1,'Enable','on');
926set(handles.lt1_MC2,'Enable','on');
927set(handles.lt1_osc,'Enable','on');
928set(handles.boo_dcct,'Enable','on');
929set(handles.boo_nod,'Enable','on');
930set(handles.boo_inj_septum,'Enable','on');
931set(handles.boo_inj_kicker,'Enable','on');
932set(handles.boo_alim_dipole,'Enable','on');
933set(handles.boo_alim_qf,'Enable','on');
934set(handles.boo_alim_qd,'Enable','on');
935set(handles.boo_alim_sf,'Enable','on');
936set(handles.boo_alim_sd,'Enable','on');
937set(handles.boo_alim_cp,'Enable','on');
938set(handles.boo_rf,'Enable','on');
939set(handles.boo_mrsv,'Enable','on');
940set(handles.lin_modulateur,'Enable','on');
941set(handles.ext_offset,'Enable','on');
942set(handles.boo_ext_dof,'Enable','on');
943set(handles.boo_ext_sept_p,'Enable','on');
944set(handles.boo_ext_sept_a,'Enable','on');
945set(handles.boo_ext_kicker,'Enable','on');
946set(handles.sdc2,'Enable','on');
947set(handles.lt2_emittance,'Enable','on');
948set(handles.lt2_osc,'Enable','on');
949set(handles.lt2_bpm,'Enable','on');
950set(handles.ans_inj_k1,'Enable','on');
951set(handles.ans_inj_k2,'Enable','on');
952set(handles.ans_inj_k3,'Enable','on');
953set(handles.ans_inj_k4,'Enable','on');
954set(handles.ans_inj_sept_p,'Enable','on');
955set(handles.ans_inj_sept_a,'Enable','on');
956set(handles.ans_fbt,'Enable','on');
957set(handles.ans_dcct,'Enable','on');
958set(handles.ans_nod,'Enable','on');
959set(handles.ans_bpm_c01,'Enable','on');
960set(handles.ans_bpm_c02,'Enable','on');
961set(handles.ans_bpm_c03,'Enable','on');
962set(handles.ans_bpm_c04,'Enable','on');
963set(handles.ans_bpm_c05,'Enable','on');
964set(handles.ans_bpm_c06,'Enable','on');
965set(handles.ans_bpm_c07,'Enable','on');
966set(handles.ans_bpm_c08,'Enable','on');
967set(handles.ans_bpm_c09,'Enable','on');
968set(handles.ans_bpm_c10,'Enable','on');
969set(handles.ans_bpm_c11,'Enable','on');
970set(handles.ans_bpm_c12,'Enable','on');
971set(handles.ans_bpm_c13,'Enable','on');
972set(handles.ans_bpm_c14,'Enable','on');
973set(handles.ans_bpm_c15,'Enable','on');
974set(handles.ans_bpm_c16,'Enable','on');
975set(handles.ans_k_pc,'Enable','on');
976set(handles.ans_k_h,'Enable','on');
977set(handles.ans_k_v,'Enable','on');
978
979
980%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
981FileName = [handles.DirName 'synchro_offset_lin'];
982load(FileName, 'inj_offset' , 'ext_offset', 'lin_fin');
983set(handles.inj_offset,'String',num2str(inj_offset));
984set(handles.ext_offset,'String',num2str(ext_offset));
985set(handles.lin_canon_spm_fin,'String',num2str(lin_fin));
986
987get_synchro_delay(handles)
988n=1;
989ext_offset=str2double(get(handles.ext_offset,'String'));
990temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TPcTimeDelay');
991set(handles.central_pc,'String',num2str(temp.value(n)));
992
993temp=tango_read_attribute2('LT1/SY/LOCAL.DG.1', 'libre.1TimeDelay');
994try txt=num2str(temp.value(n)); catch txt='Bug device' ; end
995set(handles.lin_alim,'String',txt);
996
997temp=tango_read_attribute2('BOO/SY/LOCAL.DG.3', 'emittanceTimeDelay');
998try ;txt=num2str(temp.value(n)-ext_offset); catch txt=bug_device ; end
999set(handles.boo_mrsv,'String',txt);
1000
1001temp=tango_read_attribute2('ANS-C08/SY/LOCAL.DG.1', 'bpm.pmTimeDelay');
1002try ;txt=num2str(temp.value(n)-ext_offset); catch txt=bug_device ; end
1003set(handles.ans_nod,'String',txt);
1004
1005
1006%status soft checked on linac
1007temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent');
1008if (temp.value(n)==2)
1009    %set(handles.soft_button,'Value',0);
1010elseif (temp.value(n)==5)
1011    %set(handles.uipanel_mode,'String','Mode Soft');
1012end
1013
1014%status tables
1015%temp=tango_read_attribute('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue');
1016%offset=temp.value(1)*52;
1017offset_linac=10*lin_fin;
1018temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TablesCurrentDepth');
1019n=temp.value;
1020temp=tango_read_attribute2('ANS/SY/CENTRAL', 'ExtractionDelayTable');
1021table_ext=temp.value(1:n); %-offset_ext;
1022temp=tango_read_attribute2('ANS/SY/CENTRAL', 'LinacDelayTable');
1023table_linac=(temp.value(1:n)-offset_linac)/28;
1024table=[];
1025for i=1:n
1026    table=[table ' ' '(' num2str([table_ext(i)])  ' '  num2str([table_linac(i)]) ')'];
1027end
1028set(handles.edit_filling_relecture_tables,'String',[num2str(table)]);
1029set(handles.edit_filling_relecture_bunch, 'String','??');
1030
1031
1032
1033% --- Executes on button press in button_injection_soft.
1034function button_injection_soft_Callback(hObject, eventdata, handles)
1035% hObject    handle to button_injection_soft (see GCBO)
1036% eventdata  reserved - to be defined in a future version of MATLAB
1037% handles    structure with handles and user data (see GUIDATA)
1038
1039% verifie si inj autorisé
1040% try temp=tango_read_attribute2('ANS/FC/INJ_COND', 'COND_INJ'); % 0 no injection,  1 injection
1041% val=temp.value; catch val=1 ; end ; if val~=0 ; val=1; end;
1042%
1043% if (val==1)
1044%     
1045%     tic
1046%    [r1,r2]=fire_injection(handles);
1047%     toc
1048% else
1049%     % pas d'injection, tir non autorise
1050%     fprintf('%s\n','Gap U20  < limite    dans ANS/EI/GAP_U20_SECURITY');
1051% end
1052
1053[r1,r2]=fire_injection(handles);
1054
1055% check synchro booster
1056%flag=0 : OK
1057%falg=1 : mauvais delais
1058[flag]=check_boo_synchro;
1059if flag==1 && r1> 20
1060    set(handles.central_inj,'Backgroundcolor', [1 0 0]); % KO
1061else
1062    set(handles.central_inj,'Backgroundcolor', [1 1 1]); % OK
1063end
1064
1065% % Warning mauvais rendement booster
1066% if r1 < 90
1067%     set(handles.edit_rboo,'Backgroundcolor', [1 0 0]); % KO
1068%     set(handles.edit_rboo,'Foregroundcolor', [0 0 0]);
1069% else
1070%     set(handles.edit_rboo,'Backgroundcolor', [1 1 1]); % OK
1071%     set(handles.edit_rboo,'Foregroundcolor', [1 0 0]);
1072% end
1073
1074%
1075test_modes(handles);
1076
1077function periode_edit_Callback(hObject, eventdata, handles)
1078% hObject    handle to periode_edit (see GCBO)
1079% eventdata  reserved - to be defined in a future version of MATLAB
1080% handles    structure with handles and user data (see GUIDATA)
1081
1082% Hints: get(hObject,'String') returns contents of periode_edit as text
1083%        str2double(get(hObject,'String')) returns contents of periode_edit as a double
1084
1085val_multishot = get(handles.on1,'Value');
1086
1087if val_multishot
1088    errordlg('positionner le trigger a OFF !','Attention');
1089    return
1090else
1091    periode = str2double(get(hObject,'String'));
1092
1093    % change timer Infinite loop
1094    timer1=timer('StartDelay',1,...
1095        'ExecutionMode','fixedRate','Period',periode,'TasksToExecute',Inf);
1096    timer1.TimerFcn = {@fonction_alex1, hObject,eventdata, handles};
1097    setappdata(handles.figure1,'Timer1',timer1);
1098
1099    % Update handles structure
1100    guidata(hObject, handles);
1101   
1102    %getappdata(handles.figure1,'Timer1')
1103   
1104end
1105
1106
1107
1108% --- Executes during object creation, after setting all properties.
1109function periode_edit_CreateFcn(hObject, eventdata, handles)
1110% hObject    handle to periode_edit (see GCBO)
1111% eventdata  reserved - to be defined in a future version of MATLAB
1112% handles    empty - handles not created until after all CreateFcns called
1113
1114% Hint: edit controls usually have a white background on Windows.
1115%       See ISPC and COMPUTER.
1116if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1117    set(hObject,'BackgroundColor','white');
1118end
1119
1120function uibuttongroup_SelectionChangeFcn(hObject,eventdata,handles)
1121% hObject    handle to uipanel1 (see GCBO)
1122% eventdata  reserved - to be defined in a future version of MATLAB
1123% handles    structure with handles and user data (see GUIDATA)
1124
1125%handles = guidata(gcbo);
1126timer1 = getappdata(handles.figure1,'Timer1');
1127timer2 = getappdata(handles.figure1,'Timer2');
1128
1129%txt1=' INJECTION EN COURS ';
1130
1131switch get(get(hObject,'SelectedObject'),'Tag')  % Get Tag of selected object
1132    case 'radiobutton1'
1133        % stop du trigger
1134        stop(timer1);
1135        stop(timer2);
1136        set(handles.uipanel6,'Backgroundcolor', [1 0.3 0]);
1137        test_modes(handles);
1138        tango_write_attribute2('ANS/DG/PUB-FillingMode','mode_auto',uint8(0))
1139        tango_write_attribute2('ANS/DG/PUB-FillingMode','courant_consigne',uint8(0))
1140    case 'radiobutton2'
1141        % démarrage  du trigger 1
1142        start(timer1);
1143        set(handles.edit_modes,'String',handles.txt_inj);
1144        tango_write_attribute2('ANS/DG/PUB-FillingMode','mode_auto',uint8(1))
1145    case 'radiobutton3'
1146        % démarrage du trigger 2 
1147        temp=tango_read_attribute2('ANS/DG/DCCT-CTRL','current');anscur=temp.value;
1148        if (anscur>1.)
1149           start(timer2);     
1150           set(handles.edit_modes,'String',handles.txt_inj);
1151           tango_write_attribute2('ANS/DG/PUB-FillingMode','mode_auto',uint8(1))
1152        else
1153            % ne fait rien, en cas de perte faisceau
1154        end
1155end
1156
1157
1158function fonction_alex1(arg1,arg2,hObject,eventdata,handles)
1159% hObject    handle to uipanel1 (see GCBO)
1160% eventdata  reserved - to be defined in a future version of MATLAB
1161% handles    structure with handles and user data (see GUIDATA)set(handles.boo_alim_sd,'Enable','on');
1162
1163color=get(handles.uipanel6,'Backgroundcolor');
1164if color==[1 0.3 0]
1165    set(handles.uipanel6,'Backgroundcolor', [1 0.3 1]);
1166elseif color==[1 0.3 1]
1167    set(handles.uipanel6,'Backgroundcolor', [1 0.3 0]);
1168end
1169
1170button_injection_soft_Callback(hObject,eventdata,handles)
1171
1172
1173function fonction_alex2(arg1,arg2,hObject,eventdata,handles)
1174% hObject    handle to uipanel1 (see GCBO)
1175% eventdata  reserved - to be defined in a future version of MATLAB
1176% handles    structure with handles and user data (see GUIDATA)
1177
1178
1179temp=tango_read_attribute2('ANS/DG/DCCT-CTRL','current');anscur=temp.value;
1180set(handles.edit_courant_total,'String', num2str(anscur,'%5.2f'));
1181Imin=str2double(get(handles.edit_Imin,'String'));
1182
1183color=get(handles.uipanel6,'Backgroundcolor');
1184if color==[1 0.3 0]
1185    set(handles.uipanel6,'Backgroundcolor', [1 0.3 1]);
1186elseif color==[1 0.3 1]
1187    set(handles.uipanel6,'Backgroundcolor', [1 0.3 0]);
1188end
1189
1190
1191if     (anscur>Imin)
1192    %on attend
1193    %fprintf('Cur = %g \n',anscur)
1194    tango_write_attribute2('ANS/DG/PUB-FillingMode','courant_consigne',uint8(1))
1195else
1196    %inject le cycle en cours
1197    %fprintf('Cur = %g : Injection \n',anscur)
1198    %set(handles.uipanel6,'Backgroundcolor', [1 1 0]);
1199    button_injection_soft_Callback(hObject, eventdata, handles)
1200end
1201
1202
1203
1204%% What to do before closing the application
1205function Closinggui(obj, event, handles, figure1)
1206
1207% Get default command line output from handles structure
1208answer = questdlg('Fermer softsynchro ?',...
1209    'Exit softsynchro',...
1210    'Yes','No','Yes');
1211
1212switch answer
1213    case 'Yes'           
1214        delete(handles); %Delete Timer       
1215        delete(figure1); %Close gui
1216    otherwise
1217        disp('Closing aborted')
1218end
1219
1220
1221
1222% --- Executes on button press in button_softmoins.
1223function button_softmoins_Callback(hObject, eventdata, handles)
1224% hObject    handle to button_softmoins (see GCBO)
1225% eventdata  reserved - to be defined in a future version of MATLAB
1226% handles    structure with handles and user data (see GUIDATA)
1227tt=0.6;
1228
1229temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay');
1230step=temp.value(1)-52;
1231tango_write_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay',step);
1232pause(2*tt)
1233
1234%status soft checked on linac
1235temp=tango_read_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigEvent');
1236if (temp.value(1)==2)
1237    pause(tt)
1238    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1239    set(handles.central_soft,'String',num2str(temp.value(1)));
1240elseif (temp.value(1)==5)
1241    dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1242    inj_offset=str2double(get(handles.inj_offset,'String'));
1243    dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
1244    delay=dt.value(1)-dt1.value(1)+inj_offset;
1245    tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1246
1247    pause(tt)
1248    % read again for possible delay
1249    temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay');
1250    set(handles.lin_modulateur,'String',num2str(temp.value(1)-inj_offset));
1251    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1252    set(handles.central_soft,'String',num2str(temp.value(1)));
1253end
1254
1255
1256
1257% --- Executes on button press in button_softplus.
1258function button_softplus_Callback(hObject, eventdata, handles)
1259% hObject    handle to button_softplus (see GCBO)
1260% eventdata  reserved - to be defined in a future version of MATLAB
1261% handles    structure with handles and user data (see GUIDATA)
1262tt=0.6;
1263
1264temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay');
1265step=temp.value(1)+52;
1266tango_write_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay',step);
1267pause(2*tt)
1268
1269%status soft checked on linac
1270temp=tango_read_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigEvent');
1271if (temp.value(1)==2)
1272    pause(tt)
1273    % read again for possible delay
1274    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1275    set(handles.central_soft,'String',num2str(temp.value(1)));
1276elseif (temp.value(1)==5)
1277    dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1278    inj_offset=str2double(get(handles.inj_offset,'String'));
1279    dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
1280    delay=dt.value(1)-dt1.value(1)+inj_offset;
1281    tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1282
1283    pause(tt)
1284    % read again for possible delay
1285    temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay');
1286    set(handles.lin_modulateur,'String',num2str(temp.value(1)-inj_offset));
1287    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftTimeDelay');
1288    set(handles.central_soft,'String',num2str(temp.value(1)));
1289end
1290
1291
1292
1293% --- Executes on button press in button_injmoins.
1294function button_injmoins_Callback(hObject, eventdata, handles)
1295% hObject    handle to button_injmoins (see GCBO)
1296% eventdata  reserved - to be defined in a future version of MATLAB
1297% handles    structure with handles and user data (see GUIDATA)
1298tt=0.6;
1299
1300temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjStepDelay');
1301step=temp.value(1)-52;
1302tango_write_attribute2('ANS/SY/CENTRAL', 'TInjStepDelay',step);
1303pause(2*tt)
1304
1305%status soft checked on linac
1306temp=tango_read_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigEvent');
1307if (temp.value(1)==5)
1308    pause(tt)
1309    % read again for possible delay
1310    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1311    set(handles.central_inj,'String',num2str(temp.value(1)));
1312elseif (temp.value(1)==2)
1313%    commented With address spare = 2
1314%     dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1315%     inj_offset=str2double(get(handles.inj_offset,'String'));
1316%     dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
1317%     delay=dt.value(1)-dt1.value(1)+inj_offset;
1318%     tango_write_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1319%
1320%     pause(tt)
1321%     % read again for possible delay
1322%     temp=tango_read_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay');
1323%     set(handles.lin_alim_modulateur,'String',num2str(temp.value(1)-inj_offset));
1324     temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1325     set(handles.central_inj,'String',num2str(temp.value(1)));
1326end
1327
1328
1329% --- Executes on button press in button_injplus.
1330function button_injplus_Callback(hObject, eventdata, handles)
1331% hObject    handle to button_injplus (see GCBO)
1332% eventdata  reserved - to be defined in a future version of MATLAB
1333% handles    structure with handles and user data (see GUIDATA)
1334tt=0.6;
1335set(handles.boo_alim_sd,'Enable','on');
1336temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjStepDelay');
1337step=temp.value(1)+52;
1338tango_write_attribute2('ANS/SY/CENTRAL', 'TInjStepDelay',step);
1339pause(2*tt)
1340
1341%status soft checked on linac
1342temp=tango_read_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigEvent');
1343if (temp.value(1)==5)
1344    pause(tt)
1345    % read again for possible delay
1346    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1347    set(handles.central_inj,'String',num2str(temp.value(1)));
1348elseif (temp.value(1)==2)
1349%    commented With address spare = 2
1350%     dt=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1351%     inj_offset=str2double(get(handles.inj_offset,'String'));
1352%     dt1=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprTimeDelay');
1353%     delay=dt.value(1)-dt1.value(1)+inj_offset;
1354%     tango_write_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1355%
1356%     pause(tt)
1357%     % read again for possible delay
1358%     temp=tango_read_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareTimeDelay');
1359%     set(handles.lin_alim_modulateur,'String',num2str(temp.value(1)-inj_offset));
1360     temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TInjTimeDelay');
1361     set(handles.central_inj,'String',num2str(temp.value(1)));
1362end
1363
1364
1365
1366
1367
1368
1369function boo_ext_sept_p_Callback(hObject, eventdata, handles)
1370% hObject    handle to boo_ext_sept_p (see GCBO)
1371% eventdata  reserved - to be defined in a future version of MATLAB
1372% handles    structure with handles and user data (see GUIDATA)
1373
1374% Hints: get(hObject,'String') returns contents of boo_ext_sept_p as text
1375%        str2double(get(hObject,'String')) returns contents of boo_ext_sept_p as a double
1376ext_offset=str2double(get(handles.ext_offset,'String'));
1377delay=str2double(get(hObject,'String'))+ext_offset;
1378tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-p.trigTimeDelay',delay);
1379
1380% --- Executes during object creation, after setting all properties.
1381function boo_ext_sept_p_CreateFcn(hObject, eventdata, handles)
1382% hObject    handle to boo_ext_sept_p (see GCBO)
1383% eventdata  reserved - to be defined in a future version of MATLAB
1384% handles    empty - handles not created until after all CreateFcns called
1385
1386% Hint: edit controls usually have a white background on Windows.
1387%       See ISPC and COMPUTER.
1388if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1389    set(hObject,'BackgroundColor','white');
1390end
1391
1392
1393function boo_ext_dof_Callback(hObject, eventdata, handles)
1394% hObject    handle to boo_ext_dof (see GCBO)
1395% eventdata  reserved - to be defined in a future version of MATLAB
1396% handles    structure with handles and user data (see GUIDATA)
1397
1398% Hints: get(hObject,'String') returns contents of boo_ext_dof as text
1399%        str2double(get(hObject,'String')) returns contents of boo_ext_dof as a double
1400ext_offset=str2double(get(handles.ext_offset,'String'));
1401delay=str2double(get(hObject,'String'))+ext_offset;
1402tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'dof.trigTimeDelay',delay);
1403
1404% --- Executes during object creation, after setting all properties.
1405function boo_ext_dof_CreateFcn(hObject, eventdata, handles)
1406% hObject    handle to boo_ext_dof (see GCBO)
1407% eventdata  reserved - to be defined in a future version of MATset(handles.boo_alim_sd,'Enable','on');LAB
1408% handles    empty - handles not created until after all CreateFcns called
1409
1410% Hint: edit controls usually have a white background on Windows.
1411%       See ISPC and COMPUTER.
1412if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1413    set(hObject,'BackgroundColor','white');
1414end
1415
1416
1417function boo_ext_sept_a_Callback(hObject, eventdata, handles)
1418% hObject    handle to boo_ext_sept_a (see GCBO)
1419% eventdata  reserved - to be defined in a future version of MATLAB
1420% handles    structure with handles and user data (see GUIDATA)
1421
1422% Hints: get(hObject,'String') returns contents of boo_ext_sept_a as text
1423%        str2double(get(hObject,'String')) returns contents of boo_ext_sept_a as a double
1424ext_offset=str2double(get(handles.ext_offset,'String'));
1425delay=str2double(get(hObject,'String'))+ext_offset;
1426tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigTimeDelay',delay);
1427
1428% --- Executes during object creation, after setting all properties.
1429function boo_ext_sept_a_CreateFcn(hObject, eventdata, handles)
1430% hObject    handle to boo_ext_sept_a (see GCBO)
1431% eventdata  reserved - to be defined in a future version of MATLAB
1432% handles    empty - handles not created until after all CreateFcns called
1433
1434% Hint: edit controls usually have a white background on Windows.
1435%       See ISPC and COMPUTER.
1436if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1437    set(hObject,'BackgroundColor','white');
1438end
1439
1440
1441
1442function boo_ext_kicker_Callback(hObject, eventdata, handles)
1443% hObject    handle to boo_ext_kicker (see GCBO)set(handles.boo_alim_sd,'Enable','on');
1444% eventdata  reserved - to be defined in a future version of MATLAB
1445% handles    structure with handles and user data (see GUIDATA)
1446
1447% Hints: get(hObject,'String') returns contents of boo_ext_kicker as text
1448%        str2double(get(hObject,'String')) returns contents of boo_ext_kicker as a double
1449ext_offset=str2double(get(handles.ext_offset,'String'));
1450delay=str2double(get(hObject,'String'))+ext_offset;
1451tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'k.trigTimeDelay',delay);
1452
1453
1454% --- Executes during object creation, after setting all properties.
1455function boo_ext_kicker_CreateFcn(hObject, eventdata, handles)
1456% hObject    handle to boo_ext_kicker (see GCBO)
1457% eventdata  reserved - to be defined in a future version of MATLAB
1458% handles    empty - handles not created until after all CreateFcns called
1459
1460% Hint: edit controls usually have a white background on Windows.
1461%       See ISPC and COMPUTER.
1462if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1463    set(hObject,'BackgroundColor','white');
1464end
1465
1466
1467
1468function ans_inj_sept_p_Callback(hObject, eventdata, handles)
1469% hObject    handle to ans_inj_sept_p (see GCBO)
1470% eventdata  reserved - to be defined in a future version of MATLAB
1471% handles    structure with handles and user data (see GUIDATA)
1472
1473% Hints: get(hObject,'String') returns contents of ans_inj_sept_p as text
1474%        str2double(get(hObject,'String')) returns contents of ans_inj_sept_p as a double
1475
1476ext_offset=str2double(get(handles.ext_offset,'String'));
1477delay=str2double(get(hObject,'String'))+ext_offset;
1478tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-p.trigTimeDelay',delay);
1479
1480% --- Executes during object creation, after setting all properties.
1481function ans_inj_sept_p_CreateFcn(hObject, eventdata, handles)
1482% hObject    handle to ans_inj_sept_p (see GCBO)
1483% eventdata  reserved - to be defined in a future version of MATLAB
1484% handles    empty - handles not created until after all CreateFcns called
1485
1486% Hint: edit controls usually have a white background on Windows.
1487%       See ISPC and COMPUTER.
1488if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1489    set(hObject,'BackgroundColor','white');
1490end
1491
1492
1493
1494function ans_inj_sept_a_Callback(hObject, eventdata, handles)
1495% hObject    handle to ans_inj_sept_a (see GCBO)
1496% eventdata  reserved - to be defined in a future version of MATLAB
1497% handles    structure with handles and user data (see GUIDATA)
1498
1499% Hints: get(hObject,'String') returns contents of ans_inj_sept_a as text
1500%        str2double(get(hObject,'String')) returns contents of ans_inj_sept_a as a double
1501
1502ext_offset=str2double(get(handles.ext_offset,'String'));
1503delay=str2double(get(hObject,'String'))+ext_offset;
1504tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigTimeDelay',delay);
1505
1506% --- Executes during object creation, after setting all properties.
1507function ans_inj_sept_a_CreateFcn(hObject, eventdata, handles)
1508% hObject    handle to ans_inj_sept_a (see GCBO)
1509% eventdata  reserved - to be defined in a future version of MATLAB
1510% handles    empty - handles not created until after all CreateFcns called
1511
1512% Hint: edit controls usually have a white background on Windows.
1513%       See ISPC and COMPUTER.
1514if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1515    set(hObject,'BackgroundColor','white');
1516end
1517
1518
1519
1520function ans_inj_k1_Callback(hObject, eventdata, handles)
1521% hObject    handle to ans_inj_k1 (see GCBO)
1522% eventdata  reserved - to be defined in a future version of MATLAB
1523% handles    structure with handles and user data (see GUIDATA)
1524
1525% Hints: get(hObject,'String') returns contents of ans_inj_k1 as text
1526%        str2double(get(hObject,'String')) returns contents of ans_inj_k1 as a double
1527
1528ext_offset=str2double(get(handles.ext_offset,'String'));
1529delay=str2double(get(hObject,'String'))+ext_offset;
1530tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k1.trigTimeDelay',delay);
1531
1532
1533
1534% --- Executes during object creation, after setting all properties.
1535function ans_inj_k1_CreateFcn(hObject, eventdata, handles)
1536% hObject    handle to ans_inj_k1 (see GCBO)
1537% eventdata  reserved - to be defined in a future version of MATLAB
1538% handles    empty - handles not created until after all CreateFcns called
1539
1540% Hint: edit controls usually have a white background on Windows.
1541%       See ISPC and COMPUTER.
1542if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1543    set(hObject,'BackgroundColor','white');
1544end
1545
1546
1547
1548function ans_inj_k2_Callback(hObject, eventdata, handles)
1549% hObject    handle to ans_inj_k2 (see GCBO)
1550% eventdata  reserved - to be defined in a future version of MATLAB
1551% handles    structure with handles and user data (see GUIDATA)
1552
1553% Hints: get(hObject,'String') returns contents of ans_inj_k2 as text
1554%        str2double(get(hObject,'String')) returns contents of ans_inj_k2 as a double
1555
1556ext_offset=str2double(get(handles.ext_offset,'String'));
1557delay=str2double(get(hObject,'String'))+ext_offset;
1558tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k2.trigTimeDelay',delay);
1559
1560% --- Executes during object creation, after setting all properties.
1561function ans_inj_k2_CreateFcn(hObject, eventdata, handles)
1562% hObject    handle to ans_inj_k2 (see GCBO)
1563% eventdata  reserved - to be defined in a future version of MATset(handles.boo_alim_sd,'Enable','on');LAB
1564% handles    empty - handles not created until after all CreateFcns called
1565
1566% Hint: edit controls usually have a white background on Windows.
1567%       See ISPC and COMPUTER.
1568if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1569    set(hObject,'BackgroundColor','white');
1570end
1571
1572
1573
1574function ans_inj_k3_Callback(hObject, eventdata, handles)
1575% hObject    handle to ans_inj_k3 (see GCBO)
1576% eventdata  reserved - to be defined in a future version of MATLAB
1577% handles    structure with handles and user data (see GUIDATA)
1578
1579% Hints: get(hObject,'String') returns contents of ans_inj_k3 as text
1580%        str2double(get(hObject,'String')) returns contents of ans_inj_k3 as a double
1581
1582ext_offset=str2double(get(handles.ext_offset,'String'));
1583delay=str2double(get(hObject,'String'))+ext_offset;
1584tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k3.trigTimeDelay',delay);
1585
1586% --- Executes during object creation, after setting all properties.
1587function ans_inj_k3_CreateFcn(hObject, eventdata, handles)
1588% hObject    handle to ans_inj_k3 (see GCBO)
1589% eventdata  reserved - to be defined in a future version of MATLAB
1590% handles    empty - handles not created until after all CreateFcns called
1591
1592% Hint: edit controls usually have a white background on Windows.
1593%       See ISPC and COMPUTER.
1594if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1595    set(hObject,'BackgroundColor','white');
1596end
1597
1598
1599
1600function ans_inj_k4_Callback(hObject, eventdata, handles)
1601% hObject    handle to ans_inj_k4 (see GCBO)
1602% eventdata  reserved - to be defined in a future version of MATLAB
1603% handles    structure with handles and user data (see GUIDATA)
1604
1605% Hints: get(hObject,'String') returns contents of ans_inj_k4 as text
1606%        str2double(get(hObject,'String')) returns contents of ans_inj_k4 as a double
1607
1608ext_offset=str2double(get(handles.ext_offset,'String'));
1609delay=str2double(get(hObject,'String'))+ext_offset;
1610tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k4.trigTimeDelay',delay);
1611
1612% --- Executes during object creation, after setting all properties.
1613function ans_inj_k4_CreateFcn(hObject, eventdata, handles)
1614% hObject    handle to ans_inj_k4 (see GCBO)
1615% eventdata  reserved - to be defined in a future version of MATLAB
1616% handles    empty - handles not created until after all CreateFcns called
1617
1618% Hint: edit controls usually have a white background on Windows.
1619%       See ISPC and COMPUTER.
1620if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1621    set(hObject,'BackgroundColor','white');
1622end
1623
1624
1625
1626function ans_dcct_Callback(hObject, eventdata, handles)
1627% hObject    handle to ans_dcct (see GCBO)
1628% eventdata  reserved - to be defined in a future version of MATLAB
1629% handles    structure with handles and user data (see GUIDATA)
1630
1631% Hints: get(hObject,'String') returns contents of ans_dcct as text
1632%        str2double(get(hObject,'String')) returns contents of ans_dcct as a double
1633
1634ext_offset=str2double(get(handles.ext_offset,'String'));
1635delay=str2double(get(hObject,'String'))+ext_offset;
1636tango_write_attribute2('ANS-C14/SY/LOCAL.DG.1', 'perteTimeDelay',delay);
1637
1638
1639% --- Executes during object creation, after setting all properties.
1640function ans_dcct_CreateFcn(hObject, eventdata, handles)
1641% hObject    handle to ans_dcct (see GCBO)
1642% eventdata  reserved - to be defined in a future version of MATLAB
1643% handles    empty - handles not created until after all CreateFcns called
1644
1645% Hint: edit controls usually have a white background on Windows.
1646%       See ISPC and COMPUTER.
1647if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1648    set(hObject,'BackgroundColor','white');
1649end
1650
1651
1652
1653function ans_fbt_Callback(hObject, eventdata, handles)
1654% hObject    handle to ans_fbt (see GCBO)
1655% eventdata  reserved - to be defined in a future version of MATLAB
1656% handles    structure with handles and user data (see GUIDATA)
1657
1658% Hints: get(hObject,'String') returns contents of ans_fbt as text
1659%        str2double(get(hObject,'String')) returns contents of ans_fbt as a double
1660
1661ext_offset=str2double(get(handles.ext_offset,'String'));
1662delay=str2double(get(hObject,'String'))+ext_offset;
1663tango_write_attribute2('ANS-C07/SY/LOCAL.DG.1', 'libre.1TimeDelay',delay);
1664
1665
1666% --- Executes during object creation, after setting all properties.
1667function ans_fbt_CreateFcn(hObject, eventdata, handles)
1668% hObject    handle to ans_fbt (see GCBO)
1669% eventdata  reserved - to be defined in a future version of MATLAB
1670% handles    empty - handles not created until after all CreateFcns called
1671
1672% Hint: edit controls usually have a white background on Windows.
1673%       See ISPC and COMPUTER.
1674if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1675    set(hObject,'BackgroundColor','white');
1676end
1677
1678
1679
1680function central_ext_Callback(hObject, eventdata, handles)
1681% hObject    handle to central_ext (see GCBO)
1682% eventdata  reserved - to be defined in a future version of MATLAB
1683% handles    structure with handles and user data (see GUIDATA)
1684
1685% Hints: get(hObject,'String') returns contents of central_ext as text
1686%        str2double(get(hObject,'String')) returns contents of central_ext as a double
1687%'ANS/SY/CENTRAL', 'ExtractionOffsetTimeValue'
1688
1689delay=str2double(get(hObject,'String'));
1690tango_write_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetTimeValue',delay);
1691
1692% --- Executes during object creation, after setting all properties.
1693function central_ext_CreateFcn(hObject, eventdata, handles)
1694% hObject    handle to central_ext (see GCBO)
1695% eventdata  reserved - to be defined in a future version of MATLAB
1696% handles    empty - handles not created until after all CreateFcns called
1697
1698% Hint: edit controls usually have a white background on Windows.
1699%       See ISPC and COMPUTER.
1700if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1701    set(hObject,'BackgroundColor','white');
1702end
1703
1704
1705
1706function central_soft1_Callback(hObject, eventdata, handles)
1707% hObject    handle to central_soft (see GCBO)
1708% eventdata  reserved - to be defined in a future version of MATLAB
1709% handles    structure with handles and user data (see GUIDATA)
1710
1711% Hints: get(hObject,'String') returns contents of central_soft as text
1712%        str2double(get(hObject,'String')) returns contents of central_soft as a double
1713
1714
1715
1716% --- Executes during object creation, after setting all properties.
1717function central_soft1_CreateFcn(hObject, eventdata, handles)
1718% hObject    handle to central_soft (see GCBO)
1719% eventdata  reserved - to be defined in a future version of MATLAB
1720% handles    empty - handles not created until after all CreateFcns called
1721
1722% Hint: edit controls usually have a white background on Windows.
1723%       See ISPC and COMPUTER.
1724if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1725    set(hObject,'BackgroundColor','white');
1726end
1727
1728
1729% --- Executes on button press in button_extmoins.
1730function button_extmoins_Callback(hObject, eventdata, handles)
1731% hObject    handle to button_extmoins (see GCBO)
1732% eventdata  reserved - to be defined in a future version of MATLAB
1733% handles    structure with handles and user data (see GUIDATA)
1734
1735dclk=10;
1736temp=tango_read_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue');
1737step=temp.value(1)-dclk;
1738tango_write_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue',int32(step));
1739temp=tango_read_attribute2('ANS/SY/CENTRAL','ExtractionOffsetTimeValue');
1740set(handles.central_ext,'String',num2str(temp.value(1)));
1741
1742% on fait suivre les septa actif
1743% temp=tango_read_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigStepDelay');boo=temp.value(1);
1744% tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigStepDelay',double(boo-dclk*52*184/2));
1745% temp=tango_read_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigStepDelay');ans=temp.value(1);
1746% tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigStepDelay',double(ans-dclk*52*184/2))
1747
1748% --- Executes on button press in button_extplus.
1749function button_extplus_Callback(hObject, eventdata, handles)
1750% hObject    handle to button_extplus (see GCBO)
1751% eventdata  reserved - to be defined in a future version of MATLAB
1752% handles    structure with handles and user data (see GUIDATA)
1753
1754dclk=10;
1755temp=tango_read_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue');
1756step=temp.value(1)+dclk;
1757tango_write_attribute2('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue',int32(step));
1758temp=tango_read_attribute2('ANS/SY/CENTRAL','ExtractionOffsetTimeValue');
1759set(handles.central_ext,'String',num2str(temp.value(1)));
1760
1761% on fait suivre les septa actif
1762% temp=tango_read_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigStepDelay');boo=temp.value(1);
1763% tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigStepDelay',double(boo+dclk*52*184/2));
1764% temp=tango_read_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigStepDelay');ans=temp.value(1);
1765% tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigStepDelay',double(ans+dclk*52*184/2))
1766
1767function sdc2_Callback(hObject, eventdata, handles)
1768% hObject    handle to sdc2 (see GCBO)
1769% eventdata  reserved - to be defined in a future version of MATLAB
1770% handles    structure with handles and user data (see GUIDATA)
1771
1772% Hints: get(hObject,'String') returns contents of sdc2 as text
1773%        str2double(get(hObject,'String')) returns contents of sdc2 as a double
1774ext_offset=str2double(get(handles.ext_offset,'String'));
1775delay=str2double(get(hObject,'String'))+ext_offset;
1776tango_write_attribute2('ANS/SY/LOCAL.SDC.1', 'spareTimeDelay',delay);
1777
1778% --- Executes during object creation, after setting all properties.
1779function sdc2_CreateFcn(hObject, eventdata, handles)
1780% hObject    handle to sdc2 (see GCBO)
1781% eventdata  reserved - to be defined in a future version of MATLAB
1782% handles    empty - handles not created until after all CreateFcns called
1783
1784% Hint: edit controls usually have a white background on Windows.
1785%       See ISPC and COMPUTER.
1786if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1787    set(hObject,'BackgroundColor','white');
1788end
1789
1790
1791
1792function lt2_emittance_Callback(hObject, eventdata, handles)
1793% hObject    handle to lt2_emittance (see GCBO)
1794% eventdata  reserved - to be defined in a future version of MATLAB
1795% handles    structure with handles and user data (see GUIDATA)
1796
1797% Hints: get(hObject,'String') returns contents of lt2_emittance as text
1798%        str2double(get(hObject,'String')) returns contents of lt2_emittance as a double
1799ext_offset=str2double(get(handles.ext_offset,'String'));
1800delay=str2double(get(hObject,'String'))+ext_offset;
1801tango_write_attribute2('LT2/SY/LOCAL.DG.1', 'mrsvTimeDelay',delay);
1802tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'emittanceTimeDelay',delay);
1803
1804
1805% --- Executes during object creation, after setting all properties.
1806function lt2_emittance_CreateFcn(hObject, eventdata, handles)
1807% hObject    handle to lt2_emittance (see GCBO)
1808% eventdata  reserved - to be defined in a future version of MATLAB
1809% handles    empty - handles not created until after all CreateFcns called
1810
1811% Hint: edit controls usually have a white background on Windows.
1812%       See ISPC and COMPUTER.
1813if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1814    set(hObject,'BackgroundColor','white');
1815end
1816
1817
1818
1819function lt2_bpm_Callback(hObject, eventdata, handles)
1820% hObject    handle to lt2_bpm (see GCBO)
1821% eventdata  reserved - to be defined in a future version of MATLAB
1822% handles    structure with handles and user data (see GUIDATA)
1823
1824% Hints: get(hObject,'String') returns contents of lt2_bpm as text
1825%        str2double(get(hObject,'String')) returns contents of lt2_bpm as a double
1826ext_offset=str2double(get(handles.ext_offset,'String'));
1827delay=str2double(get(hObject,'String'))+ext_offset;
1828tango_write_attribute2('LT2/SY/LOCAL.DG.2', 'bpm.trigTimeDelay',delay);
1829
1830% --- Executes during object creation, after setting all properties.
1831function lt2_bpm_CreateFcn(hObject, eventdata, handles)
1832% hObject    handle to lt2_bpm (see GCBO)
1833% eventdata  reserved - to be defined in a future version of MATLAB
1834% handles    empty - handles not created until after all CreateFcns called
1835
1836% Hint: edit controls usually have a white background on Windows.
1837%       See ISPC and COMPUTER.
1838if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1839    set(hObject,'BackgroundColor','white');
1840end
1841
1842
1843
1844function lt2_osc_Callback(hObject, eventdata, handles)
1845% hObject    handle to lt2_osc (see GCBO)
1846% eventdata  reserved - to be defined in a future version of MATLAB
1847% handles    structure with handles and user data (see GUIDATA)
1848
1849% Hints: get(hObject,'String') returns contents of lt2_osc as text
1850%        str2double(get(hObject,'String')) returns contents of lt2_osc as a double
1851ext_offset=str2double(get(handles.ext_offset,'String'));
1852delay=str2double(get(hObject,'String'))+ext_offset;
1853tango_write_attribute2('LT2/SY/LOCAL.DG.1', 'osc-fctTimeDelay',delay);
1854
1855% --- Executes during object creation, after setting all properties.
1856function lt2_osc_CreateFcn(hObject, eventdata, handles)
1857% hObject    handle to lt2_osc (see GCBO)
1858% eventdata  reserved - to be defined in a future version of MATLAB
1859% handles    empty - handles not created until after all CreateFcns called
1860
1861% Hint: edit controls usually have a white background on Windows.
1862%       See ISPC and COMPUTER.
1863if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1864    set(hObject,'BackgroundColor','white');
1865end
1866
1867
1868
1869function lin_modulateur_Callback(hObject, eventdata, handles)
1870% hObject    handle to lin_alim_modulateur (see GCBO)
1871% eventdata  reserved - to be defined in a future version of MATLAB
1872% handles    structure with handles and user data (see GUIDATA)
1873
1874% Hints: get(hObject,'String') returns contents of lin_alim_modulateur as text
1875%        str2double(get(hObject,'String')) returns contents of lin_alim_modulateur as a double
1876inj_offset=str2double(get(handles.inj_offset,'String'));
1877delay=str2double(get(hObject,'String'))+inj_offset;
1878tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1879
1880% --- Executes during object creation, after setting all properties.
1881function lin_modulateur_CreateFcn(hObject, eventdata, handles)
1882% hObject    handle to lin_alim_modulateur (see GCBO)
1883% eventdata  reserved - to be defined in a future version of MATLAB
1884% handles    empty - handles not created until after all CreateFcns called
1885
1886% Hint: edit controls usually have a white background on Windows.
1887%       See ISPC and COMPUTER.
1888if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1889    set(hObject,'BackgroundColor','white');
1890end
1891
1892
1893
1894function inj_offset_Callback(hObject, eventdata, handles)
1895% hObject    handle to inj_offset (see GCBO)
1896% eventdata  reserved - to be defined in a future version of MATLAB
1897% handles    structure with handles and user data (see GUIDATA)
1898
1899% Hints: get(hObject,'String') returns contents of inj_offset as text
1900%        str2double(get(hObject,'String')) returns contents of inj_offset as a double
1901
1902inj_offset=str2double(get(hObject,'String'));
1903ext_offset=str2double(get(handles.ext_offset,'String'));
1904lin_fin   =str2double(get(handles.lin_canon_spm_fin,'String'));
1905%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
1906FileName = [handles.DirName 'synchro_offset_lin'];
1907save(FileName, 'inj_offset' , 'ext_offset', 'lin_fin')
1908
1909%lin_alim
1910delay=str2double(get(handles.lin_canon_lpm,'String'))+inj_offset;
1911tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmTimeDelay',delay);
1912
1913delay=str2double(get(handles.lin_canon_spm,'String'))+inj_offset;
1914tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacTimeDelay',delay);
1915
1916delay=str2double(get(handles.lin_modulateur,'String'))+inj_offset;
1917tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'spareTimeDelay',delay);
1918
1919delay=str2double(get(handles.sdc1,'String'))+inj_offset;
1920tango_write_attribute2('ANS/SY/LOCAL.SDC.1', 'oscTimeDelay',delay);
1921
1922
1923% LT1
1924delay=str2double(get(handles.lt1_MC2,'String'))+inj_offset;
1925tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'mc.2TimeDelay',delay);
1926
1927delay=str2double(get(handles.lt1_MC1,'String'))+inj_offset;
1928tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'mc.1TimeDelay',delay);
1929
1930delay=str2double(get(handles.lt1_emittance,'String'))+inj_offset;
1931tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'emittanceTimeDelay',delay);
1932
1933delay=str2double(get(handles.lt1_osc,'String'))+inj_offset;
1934tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'oscTimeDelay',delay);
1935
1936
1937% BOO
1938delay=str2double(get(handles.boo_inj_septum,'String'))+inj_offset;
1939tango_write_attribute2('BOO/SY/LOCAL.Binj.1', 'sep-p.trigTimeDelay',delay);
1940
1941delay=str2double(get(handles.boo_inj_kicker,'String'))+inj_offset;
1942tango_write_attribute2('BOO/SY/LOCAL.Binj.1', 'k.trigTimeDelay',delay);
1943
1944delay=str2double(get(handles.boo_bpm,'String'))+inj_offset;
1945tango_write_attribute2('BOO/SY/LOCAL.DG.1', 'bpm-bta.trigTimeDelay',delay);
1946tango_write_attribute2('BOO/SY/LOCAL.DG.1', 'bpm-btd.trigTimeDelay',delay);
1947tango_write_attribute2('BOO/SY/LOCAL.DG.2', 'bpm-btb.trigTimeDelay',delay);
1948tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'bpm-btc.trigTimeDelay',delay);
1949
1950
1951delay=str2double(get(handles.boo_nod,'String'))+inj_offset;
1952tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'bpm-onde.trigTimeDelay',delay);
1953
1954% delay=str2double(get(handles.boo_dcct,'String'))+inj_offset;
1955% tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'dcct-booTimeDelay',delay);
1956
1957
1958
1959% --- Executes during object creation, after setting all properties.
1960function inj_offset_CreateFcn(hObject, eventdata, handles)
1961% hObject    handle to inj_offset (see GCBO)
1962% eventdata  reserved - to be defined in a future version of MATLAB
1963% handles    empty - handles not created until after all CreateFcns called
1964
1965% Hint: edit controls usually have a white background on Windows.
1966%       See ISPC and COMPUTER.
1967if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1968    set(hObject,'BackgroundColor','white');
1969end
1970
1971
1972
1973function ext_offset_Callback(hObject, eventdata, handles)
1974% hObject    handle to ext_offset (see GCBO)
1975% eventdata  reserved - to be defined in a future version of MATLAB
1976% handles    structure with handles and user data (see GUIDATA)
1977
1978% Hints: get(hObject,'String') returns contents of ext_offset as text
1979%        str2double(get(hObject,'String')) returns contents of ext_offset as a double
1980
1981ext_offset=str2double(get(hObject,'String'));
1982inj_offset=str2double(get(handles.inj_offset,'String'));
1983lin_fin   =str2double(get(handles.lin_canon_spm_fin,'String'));
1984
1985%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
1986FileName = [handles.DirName 'synchro_offset_lin'];
1987save(FileName, 'inj_offset' , 'ext_offset', 'lin_fin');
1988
1989
1990%BOO
1991delay=str2double(get(handles.boo_ext_dof,'String'))+ext_offset;
1992tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'dof.trigTimeDelay',delay);
1993
1994delay=str2double(get(handles.boo_ext_sept_p,'String'))+ext_offset;
1995tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-p.trigTimeDelay',delay);
1996
1997delay=str2double(get(handles.boo_ext_sept_a,'String'))+ext_offset;
1998tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'sep-a.trigTimeDelay',delay);
1999
2000delay=str2double(get(handles.boo_ext_kicker,'String'))+ext_offset;
2001tango_write_attribute2('BOO/SY/LOCAL.Bext.1', 'k.trigTimeDelay',delay);
2002
2003delay=str2double(get(handles.sdc2,'String'))+ext_offset;
2004tango_write_attribute2('ANS/SY/LOCAL.SDC.1', 'spareTimeDelay',delay);
2005
2006%LT2
2007delay=str2double(get(handles.lt2_bpm,'String'))+ext_offset;
2008tango_write_attribute2('LT2/SY/LOCAL.DG.2', 'bpm.trigTimeDelay',delay);
2009
2010delay=str2double(get(handles.lt2_osc,'String'))+ext_offset;
2011tango_write_attribute2('LT2/SY/LOCAL.DG.1', 'osc-fctTimeDelay',delay);
2012
2013delay=str2double(get(handles.lt2_emittance,'String'))+ext_offset;
2014tango_write_attribute2('LT2/SY/LOCAL.DG.1', 'mrsvTimeDelay',delay);
2015
2016%ANS
2017
2018delay=str2double(get(handles.ans_inj_sept_a,'String'))+ext_offset;
2019tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-a.trigTimeDelay',delay);
2020
2021delay=str2double(get(handles.ans_inj_sept_p,'String'))+ext_offset;
2022tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.2', 'sep-p.trigTimeDelay',delay);
2023
2024delay=str2double(get(handles.ans_inj_k1,'String'))+ext_offset;
2025tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k1.trigTimeDelay',delay);
2026
2027delay=str2double(get(handles.ans_inj_k2,'String'))+ext_offset;
2028tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k2.trigTimeDelay',delay);
2029
2030delay=str2double(get(handles.ans_inj_k3,'String'))+ext_offset;
2031tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k3.trigTimeDelay',delay);
2032
2033delay=str2double(get(handles.ans_inj_k4,'String'))+ext_offset;
2034tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k4.trigTimeDelay',delay);
2035
2036
2037
2038% --- Executes during object creation, after setting all properties.
2039function ext_offset_CreateFcn(hObject, eventdata, handles)
2040% hObject    handle to ext_offset (see GCBO)
2041% eventdata  reserved - to be defined in a future version of MATLAB
2042% handles    empty - handles not created until after all CreateFcns called
2043
2044% Hint: edit controls usually have a white background on Windows.
2045%       See ISPC and COMPUTER.
2046if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2047    set(hObject,'BackgroundColor','white');
2048end
2049
2050
2051% --- Executes on button press in button_acquisition_address.
2052function button_acquisition_address_Callback(hObject, eventdata, handles)
2053% hObject    handle to button_acquisition_address (see GCBO)
2054% eventdata  reserved - to be defined in a future version of MATLAB
2055% handles    structure with handles and user data (see GUIDATA)
2056
2057test_modes(handles);
2058
2059
2060set(handles.inj_offset,'Enable','off');
2061set(handles.sdc1,'Enable','off');
2062set(handles.lin_canon_lpm,'Enable','off');
2063set(handles.lin_canon_spm,'Enable','off');
2064set(handles.lin_canon_spm_fin,'Enable','off');
2065set(handles.lin_alim,'Enable','off');
2066set(handles.boo_bpm,'Enable','off');
2067set(handles.lt1_emittance,'Enable','off');
2068set(handles.lt1_MC1,'Enable','off');
2069set(handles.lt1_MC2,'Enable','off');
2070set(handles.lt1_osc,'Enable','off');
2071set(handles.boo_dcct,'Enable','off');
2072set(handles.boo_nod,'Enable','off');
2073set(handles.boo_inj_septum,'Enable','off');
2074set(handles.boo_inj_kicker,'Enable','off');
2075set(handles.boo_alim_dipole,'Enable','off');
2076set(handles.boo_alim_qf,'Enable','off');
2077set(handles.boo_alim_qd,'Enable','off');
2078set(handles.boo_alim_sf,'Enable','off');
2079set(handles.boo_alim_sd,'Enable','off');
2080set(handles.boo_alim_cp,'Enable','off');
2081set(handles.boo_rf,'Enable','off');
2082set(handles.boo_mrsv,'Enable','off');
2083set(handles.lin_modulateur,'Enable','off');
2084set(handles.ext_offset,'Enable','off');
2085set(handles.boo_ext_dof,'Enable','off');
2086set(handles.boo_ext_sept_p,'Enable','off');
2087set(handles.boo_ext_sept_a,'Enable','off');
2088set(handles.boo_ext_kicker,'Enable','off');
2089set(handles.sdc2,'Enable','off');
2090set(handles.lt2_emittance,'Enable','off');
2091set(handles.lt2_osc,'Enable','off');
2092set(handles.lt2_bpm,'Enable','off');
2093set(handles.ans_inj_k1,'Enable','off');
2094set(handles.ans_inj_k2,'Enable','off');
2095set(handles.ans_inj_k3,'Enable','off');
2096set(handles.ans_inj_k4,'Enable','off');
2097set(handles.ans_inj_sept_p,'Enable','off');
2098set(handles.ans_inj_sept_a,'Enable','off');
2099set(handles.ans_fbt,'Enable','off');
2100set(handles.ans_dcct,'Enable','off');
2101set(handles.ans_nod,'Enable','off');
2102set(handles.ans_bpm_c01,'Enable','off');
2103set(handles.ans_bpm_c02,'Enable','off');
2104set(handles.ans_bpm_c03,'Enable','off');
2105set(handles.ans_bpm_c04,'Enable','off');
2106set(handles.ans_bpm_c05,'Enable','off');
2107set(handles.ans_bpm_c06,'Enable','off');
2108set(handles.ans_bpm_c07,'Enable','off');
2109set(handles.ans_bpm_c08,'Enable','off');
2110set(handles.ans_bpm_c09,'Enable','off');
2111set(handles.ans_bpm_c10,'Enable','off');
2112set(handles.ans_bpm_c11,'Enable','off');
2113set(handles.ans_bpm_c12,'Enable','off');
2114set(handles.ans_bpm_c13,'Enable','off');
2115set(handles.ans_bpm_c14,'Enable','off');
2116set(handles.ans_bpm_c15,'Enable','off');
2117set(handles.ans_bpm_c16,'Enable','off');
2118
2119
2120%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'synchro_offset_lin_alim');
2121FileName = [handles.DirName 'synchro_offset_lin'];
2122load(FileName, 'inj_offset' , 'ext_offset', 'lin_fin');
2123set(handles.inj_offset,'String',num2str(inj_offset));
2124set(handles.ext_offset,'String',num2str(ext_offset));
2125set(handles.lin_canon_spm_fin,'String',num2str(lin_fin));
2126
2127get_synchro_address(handles)
2128n=1;
2129temp=tango_read_attribute2('LT1/SY/LOCAL.DG.1', 'libre.1Event');
2130try txt=num2str(temp.value(n)); catch txt='Bug device' ; end
2131set(handles.lin_alim,'String',txt);
2132
2133temp=tango_read_attribute2('BOO/SY/LOCAL.DG.3', 'emittanceEvent');
2134try ;txt=num2str(temp.value(n)); catch txt=bug_device ; end
2135set(handles.boo_mrsv,'String',txt);
2136
2137temp=tango_read_attribute2('ANS-C08/SY/LOCAL.DG.1', 'bpm.pmEvent');
2138try ;txt=num2str(temp.value(n)); catch txt=bug_device ; end
2139set(handles.ans_nod,'String',txt);
2140set(handles.boo_alim_sd,'Enable','off');
2141
2142% --- Executes on button press in button_offinj_moins.
2143function button_offinj_moins_Callback(hObject, eventdata, handles)
2144% hObject    handle to button_offinj_moins (see GCBO)
2145% eventdata  reserved - to be defined in a future version of MATLAB
2146% handles    structure with handles and user data (see GUIDATA)
2147
2148temp=str2double(get(handles.inj_offset,'String'));
2149step=temp-52*0.52243;
2150set(handles.inj_offset,'String',step);
2151inj_offset_Callback(handles.inj_offset, eventdata, handles);
2152
2153% --- Executes on button press in button_offinj_plus.
2154function button_offinj_plus_Callback(hObject, eventdata, handles)
2155% hObject    handle to button_offinj_plus (see GCBO)
2156% eventdata  reserved - to be defined in a future version of MATLAB
2157% handles    structure with handles and user data (see GUIDATA)
2158
2159temp=str2double(get(handles.inj_offset,'String'));
2160step=temp+52*0.52243;
2161set(handles.inj_offset,'String',step);
2162inj_offset_Callback(handles.inj_offset, eventdata, handles);
2163
2164% --- Executes on button press in button_offext_moins.
2165function button_offext_moins_Callback(hObject, eventdata, handles)
2166% hObject    handle to button_offext_moins (see GCBO)
2167% eventdata  reserved - to be defined in a future version of MATLAB
2168% handles    structure with handles and user data (see GUIDATA)
2169
2170temp=str2double(get(handles.ext_offset,'String'));
2171step=temp-52*0.52243;
2172set(handles.ext_offset,'String',step);
2173ext_offset_Callback(handles.ext_offset, eventdata, handles);
2174
2175% --- Executes on button press in button_offext_plus.
2176function button_offext_plus_Callback(hObject, eventdata, handles)
2177% hObject    handle to button_offext_plus (see GCBO)
2178% eventdata  reserved - to be defined in a future version of MATLAB
2179% handles    structure with handles and user data (see GUIDATA)
2180
2181temp=str2double(get(handles.ext_offset,'String'));
2182step=temp+52*0.52243;
2183set(handles.ext_offset,'String',step);
2184ext_offset_Callback(handles.ext_offset, eventdata, handles);
2185
2186
2187% --- Executes on button press in button_bpm.
2188function button_bpm_Callback(hObject, eventdata, handles)
2189% hObject    handle to button_bpm (see GCBO)
2190% eventdata  reserved - to be defined in a future version of MATLAB
2191% handles    structure with handles and user data (see GUIDATA)
2192
2193% Hint: get(hObject,'Value') returns toggle state of button_bpm
2194
2195bpm=get(hObject,'Value');
2196
2197if (bpm==0)
2198   set(handles.panel_bpm,'Visible','off');
2199elseif (bpm==1)
2200    set(handles.panel_bpm,'Visible','on');
2201end
2202
2203
2204
2205function ans_bpm_c01_Callback(hObject, eventdata, handles)
2206% hObject    handle to ans_bpm_c01 (see GCBO)
2207% eventdata  reserved - to be defined in a future version of MATLAB
2208% handles    structure with handles and user data (see GUIDATA)
2209
2210% Hints: get(hObject,'String') returns contents of ans_bpm_c01 as text
2211%        str2double(get(hObject,'String')) returns contents of ans_bpm_c01 as a double
2212
2213ext_offset=str2double(get(handles.ext_offset,'String'));
2214delay=str2double(get(hObject,'String'))+ext_offset;
2215tango_write_attribute2('ANS-C01/SY/LOCAL.DG.2', 'bpm.trigTimeDelay',delay);
2216
2217% --- Executes during object creation, after setting all properties.
2218function ans_bpm_c01_CreateFcn(hObject, eventdata, handles)
2219% hObject    handle to ans_bpm_c01 (see GCBO)
2220% eventdata  reserved - to be defined in a future version of MATLAB
2221% handles    empty - handles not created until after all CreateFcns called
2222
2223% Hint: edit controls usually have a white background on Windows.
2224%       See ISPC and COMPUTER.
2225if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2226    set(hObject,'BackgroundColor','white');
2227end
2228
2229
2230function ans_bpm_c02_Callback(hObject, eventdata, handles)
2231% hObject    handle to ans_bpm_c02 (see GCBO)
2232% eventdata  reserved - to be defined in a future version of MATLAB
2233% handles    structure with handles and user data (see GUIDATA)
2234
2235% Hints: get(hObject,'String') returns contents of ans_bpm_c02 as text
2236%        str2double(get(hObject,'String')) returns contents of ans_bpm_c02 as a double
2237ext_offset=str2double(get(handles.ext_offset,'String'));
2238delay=str2double(get(hObject,'String'))+ext_offset;
2239tango_write_attribute2('ANS-C02/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2240
2241
2242% --- Executes during object creation, after setting all properties.
2243function ans_bpm_c02_CreateFcn(hObject, eventdata, handles)
2244% hObject    handle to ans_bpm_c02 (see GCBO)
2245% eventdata  reserved - to be defined in a future version of MATLAB
2246% handles    empty - handles not created until after all CreateFcns called
2247
2248% Hint: edit controls usually have a white background on Windows.
2249%       See ISPC and COMPUTER.
2250if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2251    set(hObject,'BackgroundColor','white');
2252end
2253
2254
2255
2256function ans_bpm_c03_Callback(hObject, eventdata, handles)
2257% hObject    handle to ans_bpm_c03 (see GCBO)
2258% eventdata  reserved - to be defined in a future version of MATLAB
2259% handles    structure with handles and user data (see GUIDATA)
2260
2261% Hints: get(hObject,'String') returns contents of ans_bpm_c03 as text
2262%        str2double(get(hObject,'String')) returns contents of ans_bpm_c03 as a double
2263ext_offset=str2double(get(handles.ext_offset,'String'));
2264delay=str2double(get(hObject,'String'))+ext_offset;
2265tango_write_attribute2('ANS-C03/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2266
2267
2268% --- Executes during object creation, after setting all properties.
2269function ans_bpm_c03_CreateFcn(hObject, eventdata, handles)
2270% hObject    handle to ans_bpm_c03 (see GCBO)
2271% eventdata  reserved - to be defined in a future version of MATLAB
2272% handles    empty - handles not created until after all CreateFcns called
2273
2274% Hint: edit controls usually have a white background on Windows.
2275%       See ISPC and COMPUTER.
2276if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2277    set(hObject,'BackgroundColor','white');
2278end
2279
2280
2281
2282function ans_bpm_c04_Callback(hObject, eventdata, handles)
2283% hObject    handle to ans_bpm_c04 (see GCBO)
2284% eventdata  reserved - to be defined in a future version of MATLAB
2285% handles    structure with handles and user data (see GUIDATA)
2286
2287% Hints: get(hObject,'String') returns contents of ans_bpm_c04 as text
2288%        str2double(get(hObject,'String')) returns contents of ans_bpm_c04 as a double
2289ext_offset=str2double(get(handles.ext_offset,'String'));
2290delay=str2double(get(hObject,'String'))+ext_offset;
2291tango_write_attribute2('ANS-C04/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2292
2293
2294% --- Executes during object creation, after setting all properties.
2295function ans_bpm_c04_CreateFcn(hObject, eventdata, handles)
2296% hObject    handle to ans_bpm_c04 (see GCBO)
2297% eventdata  reserved - to be defined in a future version of MATLAB
2298% handles    empty - handles not created until after all CreateFcns called
2299
2300% Hint: edit controls usually have a white background on Windows.
2301%       See ISPC and COMPUTER.
2302if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2303    set(hObject,'BackgroundColor','white');
2304end
2305
2306
2307
2308function ans_bpm_c05_Callback(hObject, eventdata, handles)
2309% hObject    handle to ans_bpm_c05 (see GCBO)
2310% eventdata  reserved - to be defined in a future version of MATLAB
2311% handles    structure with handles and user data (see GUIDATA)
2312
2313% Hints: get(hObject,'String') returns contents of ans_bpm_c05 as text
2314%        str2double(get(hObject,'String')) returns contents of ans_bpm_c05 as a double
2315ext_offset=str2double(get(handles.ext_offset,'String'));
2316delay=str2double(get(hObject,'String'))+ext_offset;
2317tango_write_attribute2('ANS-C05/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2318
2319
2320% --- Executes during object creation, after setting all properties.
2321function ans_bpm_c05_CreateFcn(hObject, eventdata, handles)
2322% hObject    handle to ans_bpm_c05 (see GCBO)
2323% eventdata  reserved - to be defined in a future version of MATLAB
2324% handles    empty - handles not created until after all CreateFcns called
2325
2326% Hint: edit controls usually have a white background on Windows.
2327%       See ISPC and COMPUTER.
2328if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2329    set(hObject,'BackgroundColor','white');
2330end
2331
2332
2333
2334function ans_bpm_c06_Callback(hObject, eventdata, handles)
2335% hObject    handle to ans_bpm_c06 (see GCBO)
2336% eventdata  reserved - to be defined in a future version of MATLAB
2337% handles    structure with handles and user data (see GUIDATA)
2338
2339% Hints: get(hObject,'String') returns contents of ans_bpm_c06 as text
2340%        str2double(get(hObject,'String')) returns contents of ans_bpm_c06 as a double
2341ext_offset=str2double(get(handles.ext_offset,'String'));
2342delay=str2double(get(hObject,'String'))+ext_offset;
2343tango_write_attribute2('ANS-C06/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2344
2345
2346% --- Executes during object creation, after setting all properties.
2347function ans_bpm_c06_CreateFcn(hObject, eventdata, handles)
2348% hObject    handle to ans_bpm_c06 (see GCBO)
2349% eventdata  reserved - to be defined in a future version of MATLAB
2350% handles    empty - handles not created until after all CreateFcns called
2351
2352% Hint: edit controls usually have a white background on Windows.
2353%       See ISPC and COMPUTER.
2354if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2355    set(hObject,'BackgroundColor','white');
2356end
2357
2358
2359
2360function ans_bpm_c07_Callback(hObject, eventdata, handles)
2361% hObject    handle to ans_bpm_c07 (see GCBO)
2362% eventdata  reserved - to be defined in a future version of MATLAB
2363% handles    structure with handles and user data (see GUIDATA)
2364
2365% Hints: get(hObject,'String') returns contents of ans_bpm_c07 as text
2366%        str2double(get(hObject,'String')) returns contents of ans_bpm_c07 as a double
2367ext_offset=str2double(get(handles.ext_offset,'String'));
2368delay=str2double(get(hObject,'String'))+ext_offset;
2369tango_write_attribute2('ANS-C07/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2370
2371
2372% --- Executes during object creation, after setting all properties.
2373function ans_bpm_c07_CreateFcn(hObject, eventdata, handles)
2374% hObject    handle to ans_bpm_c07 (see GCBO)
2375% eventdata  reserved - to be defined in a future version of MATLAB
2376% handles    empty - handles not created until after all CreateFcns called
2377
2378% Hint: edit controls usually have a white background on Windows.
2379%       See ISPC and COMPUTER.
2380if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2381    set(hObject,'BackgroundColor','white');
2382end
2383
2384
2385
2386function ans_bpm_c08_Callback(hObject, eventdata, handles)
2387% hObject    handle to ans_bpm_c08 (see GCBO)
2388% eventdata  reserved - to be defined in a future version of MATLAB
2389% handles    structure with handles and user data (see GUIDATA)
2390
2391% Hints: get(hObject,'String') returns contents of ans_bpm_c08 as text
2392%        str2double(get(hObject,'String')) returns contents of ans_bpm_c08 as a double
2393ext_offset=str2double(get(handles.ext_offset,'String'));
2394delay=str2double(get(hObject,'String'))+ext_offset;
2395tango_write_attribute2('ANS-C08/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2396
2397
2398% --- Executes during object creation, after setting all properties.
2399function ans_bpm_c08_CreateFcn(hObject, eventdata, handles)
2400% hObject    handle to ans_bpm_c08 (see GCBO)
2401% eventdata  reserved - to be defined in a future version of MATLAB
2402% handles    empty - handles not created until after all CreateFcns called
2403
2404% Hint: edit controls usually have a white background on Windows.
2405%       See ISPC and COMPUTER.
2406if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2407    set(hObject,'BackgroundColor','white');
2408end
2409
2410
2411
2412function ans_bpm_c09_Callback(hObject, eventdata, handles)
2413% hObject    handle to ans_bpm_c09 (see GCBO)
2414% eventdata  reserved - to be defined in a future version of MATLAB
2415% handles    structure with handles and user data (see GUIDATA)
2416
2417% Hints: get(hObject,'String') returns contents of ans_bpm_c09 as text
2418%        str2double(get(hObject,'String')) returns contents of ans_bpm_c09 as a double
2419ext_offset=str2double(get(handles.ext_offset,'String'));
2420delay=str2double(get(hObject,'String'))+ext_offset;
2421tango_write_attribute2('ANS-C09/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2422
2423
2424% --- Executes during object creation, after setting all properties.
2425function ans_bpm_c09_CreateFcn(hObject, eventdata, handles)
2426% hObject    handle to ans_bpm_c09 (see GCBO)
2427% eventdata  reserved - to be defined in a future version of MATLAB
2428% handles    empty - handles not created until after all CreateFcns called
2429
2430% Hint: edit controls usually have a white background on Windows.
2431%       See ISPC and COMPUTER.
2432if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2433    set(hObject,'BackgroundColor','white');
2434end
2435
2436
2437
2438function ans_bpm_c10_Callback(hObject, eventdata, handles)
2439% hObject    handle to ans_bpm_c10 (see GCBO)
2440% eventdata  reserved - to be defined in a future version of MATLAB
2441% handles    structure with handles and user data (see GUIDATA)
2442
2443% Hints: get(hObject,'String') returns contents of ans_bpm_c10 as text
2444%        str2double(get(hObject,'String')) returns contents of ans_bpm_c10 as a double
2445ext_offset=str2double(get(handles.ext_offset,'String'));
2446delay=str2double(get(hObject,'String'))+ext_offset;
2447tango_write_attribute2('ANS-C10/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2448
2449
2450% --- Executes during object creation, after setting all properties.
2451function ans_bpm_c10_CreateFcn(hObject, eventdata, handles)
2452% hObject    handle to ans_bpm_c10 (see GCBO)
2453% eventdata  reserved - to be defined in a future version of MATLAB
2454% handles    empty - handles not created until after all CreateFcns called
2455
2456% Hint: edit controls usually have a white background on Windows.
2457%       See ISPC and COMPUTER.
2458if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2459    set(hObject,'BackgroundColor','white');
2460end
2461
2462
2463
2464function ans_bpm_c11_Callback(hObject, eventdata, handles)
2465% hObject    handle to ans_bpm_c11 (see GCBO)
2466% eventdata  reserved - to be defined in a future version of MATLAB
2467% handles    structure with handles and user data (see GUIDATA)
2468
2469% Hints: get(hObject,'String') returns contents of ans_bpm_c11 as text
2470%        str2double(get(hObject,'String')) returns contents of ans_bpm_c11 as a double
2471ext_offset=str2double(get(handles.ext_offset,'String'));
2472delay=str2double(get(hObject,'String'))+ext_offset;
2473tango_write_attribute2('ANS-C11/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2474
2475
2476% --- Executes during object creation, after setting all properties.
2477function ans_bpm_c11_CreateFcn(hObject, eventdata, handles)
2478% hObject    handle to ans_bpm_c11 (see GCBO)
2479% eventdata  reserved - to be defined in a future version of MATLAB
2480% handles    empty - handles not created until after all CreateFcns called
2481
2482% Hint: edit controls usually have a white background on Windows.
2483%       See ISPC and COMPUTER.
2484if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2485    set(hObject,'BackgroundColor','white');
2486end
2487
2488
2489
2490function ans_bpm_c12_Callback(hObject, eventdata, handles)
2491% hObject    handle to ans_bpm_c12 (see GCBO)
2492% eventdata  reserved - to be defined in a future version of MATLAB
2493% handles    structure with handles and user data (see GUIDATA)
2494
2495% Hints: get(hObject,'String') returns contents of ans_bpm_c12 as text
2496%        str2double(get(hObject,'String')) returns contents of ans_bpm_c12 as a double
2497ext_offset=str2double(get(handles.ext_offset,'String'));
2498delay=str2double(get(hObject,'String'))+ext_offset;
2499tango_write_attribute2('ANS-C12/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2500
2501
2502% --- Executes during object creation, after setting all properties.
2503function ans_bpm_c12_CreateFcn(hObject, eventdata, handles)
2504% hObject    handle to ans_bpm_c12 (see GCBO)
2505% eventdata  reserved - to be defined in a future version of MATLAB
2506% handles    empty - handles not created until after all CreateFcns called
2507
2508% Hint: edit controls usually have a white background on Windows.
2509%       See ISPC and COMPUTER.
2510if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2511    set(hObject,'BackgroundColor','white');
2512end
2513
2514
2515
2516function ans_bpm_c13_Callback(hObject, eventdata, handles)
2517% hObject    handle to ans_bpm_c13 (see GCBO)
2518% eventdata  reserved - to be defined in a future version of MATLAB
2519% handles    structure with handles and user data (see GUIDATA)
2520
2521% Hints: get(hObject,'String') returns contents of ans_bpm_c13 as text
2522%        str2double(get(hObject,'String')) returns contents of ans_bpm_c13 as a double
2523ext_offset=str2double(get(handles.ext_offset,'String'));
2524delay=str2double(get(hObject,'String'))+ext_offset;
2525tango_write_attribute2('ANS-C13/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2526
2527
2528% --- Executes during object creation, after setting all properties.
2529function ans_bpm_c13_CreateFcn(hObject, eventdata, handles)
2530% hObject    handle to ans_bpm_c13 (see GCBO)
2531% eventdata  reserved - to be defined in a future version of MATLAB
2532% handles    empty - handles not created until after all CreateFcns called
2533
2534% Hint: edit controls usually have a white background on Windows.
2535%       See ISPC and COMPUTER.
2536if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2537    set(hObject,'BackgroundColor','white');
2538end
2539
2540
2541
2542function ans_bpm_c14_Callback(hObject, eventdata, handles)
2543% hObject    handle to ans_bpm_c14 (see GCBO)
2544% eventdata  reserved - to be defined in a future version of MATLAB
2545% handles    structure with handles and user data (see GUIDATA)
2546
2547% Hints: get(hObject,'String') returns contents of ans_bpm_c14 as text
2548%        str2double(get(hObject,'String')) returns contents of ans_bpm_c14 as a double
2549ext_offset=str2double(get(handles.ext_offset,'String'));
2550delay=str2double(get(hObject,'String'))+ext_offset;
2551tango_write_attribute2('ANS-C14/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2552
2553
2554% --- Executes during object creation, after setting all properties.
2555function ans_bpm_c14_CreateFcn(hObject, eventdata, handles)
2556% hObject    handle to ans_bpm_c14 (see GCBO)
2557% eventdata  reserved - to be defined in a future version of MATLAB
2558% handles    empty - handles not created until after all CreateFcns called
2559
2560% Hint: edit controls usually have a white background on Windows.
2561%       See ISPC and COMPUTER.
2562if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2563    set(hObject,'BackgroundColor','white');
2564end
2565
2566
2567
2568function ans_bpm_c15_Callback(hObject, eventdata, handles)
2569% hObject    handle to ans_bpm_c15 (see GCBO)
2570% eventdata  reserved - to be defined in a future version of MATLAB
2571% handles    structure with handles and user data (see GUIDATA)
2572
2573% Hints: get(hObject,'String') returns contents of ans_bpm_c15 as text
2574%        str2double(get(hObject,'String')) returns contents of ans_bpm_c15 as a double
2575ext_offset=str2double(get(handles.ext_offset,'String'));
2576delay=str2double(get(hObject,'String'))+ext_offset;
2577tango_write_attribute2('ANS-C15/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2578
2579
2580% --- Executes during object creation, after setting all properties.
2581function ans_bpm_c15_CreateFcn(hObject, eventdata, handles)
2582% hObject    handle to ans_bpm_c15 (see GCBO)
2583% eventdata  reserved - to be defined in a future version of MATLAB
2584% handles    empty - handles not created until after all CreateFcns called
2585
2586% Hint: edit controls usually have a white background on Windows.
2587%       See ISPC and COMPUTER.
2588if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2589    set(hObject,'BackgroundColor','white');
2590end
2591
2592
2593
2594function ans_bpm_c16_Callback(hObject, eventdata, handles)
2595% hObject    handle to ans_bpm_c16 (see GCBO)
2596% eventdata  reserved - to be defined in a future version of MATLAB
2597% handles    structure with handles and user data (see GUIDATA)
2598
2599% Hints: get(hObject,'String') returns contents of ans_bpm_c16 as text
2600%        str2double(get(hObject,'String')) returns contents of ans_bpm_c16 as a double
2601ext_offset=str2double(get(handles.ext_offset,'String'));
2602delay=str2double(get(hObject,'String'))+ext_offset;
2603tango_write_attribute2('ANS-C16/SY/LOCAL.DG.1', 'bpm.trigTimeDelay',delay);
2604
2605
2606% --- Executes during object creation, after setting all properties.
2607function ans_bpm_c16_CreateFcn(hObject, eventdata, handles)
2608% hObject    handle to ans_bpm_c16 (see GCBO)
2609% eventdata  reserved - to be defined in a future version of MATLAB
2610% handles    empty - handles not created until after all CreateFcns called
2611
2612% Hint: edit controls usually have a white background on Windows.
2613%       See ISPC and COMPUTER.
2614if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2615    set(hObject,'BackgroundColor','white');
2616end
2617
2618
2619
2620function edit_filling_relecture_tables_Callback(hObject, eventdata, handles)
2621% hObject    handle to edit_filling_relecture_tables (see GCBO)
2622% eventdata  reserved - to be defined in a future version of MATLAB
2623% handles    structure with handles and user data (see GUIDATA)
2624
2625% Hints: get(hObject,'String') returns contents of edit_filling_relecture_tables as text
2626%        str2double(get(hObject,'String')) returns contents of edit_filling_relecture_tables as a double
2627
2628
2629% --- Executes during object creation, after setting all properties.
2630function edit_filling_relecture_tables_CreateFcn(hObject, eventdata, handles)
2631% hObject    handle to edit_filling_relecture_tables (see GCBO)
2632% eventdata  reserved - to be defined in a future version of MATLAB
2633% handles    empty - handles not created until after all CreateFcns called
2634
2635% Hint: edit controls usually have a white background on Windows.
2636%       See ISPC and COMPUTER.
2637if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2638    set(hObject,'BackgroundColor','white');
2639end
2640
2641
2642
2643function edit_filling_relecture_bunch_Callback(hObject, eventdata, handles)
2644% hObject    handle to edit_filling_relecture_bunch (see GCBO)
2645% eventdata  reserved - to be defined in a future version of MATLAB
2646% handles    structure with handles and user data (see GUIDATA)
2647
2648% Hints: get(hObject,'String') returns contents of edit_filling_relecture_bunch as text
2649%        str2double(get(hObject,'String')) returns contents of edit_filling_relecture_bunch as a double
2650
2651
2652% --- Executes during object creation, after setting all properties.
2653function edit_filling_relecture_bunch_CreateFcn(hObject, eventdata, handles)
2654% hObject    handle to edit_filling_relecture_bunch (see GCBO)
2655% eventdata  reserved - to be defined in a future version of MATLAB
2656% handles    empty - handles not created until after all CreateFcns called
2657
2658% Hint: edit controls usually have a white background on Windows.
2659%       See ISPC and COMPUTER.
2660if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2661    set(hObject,'BackgroundColor','white');
2662end
2663
2664
2665
2666function edit_filling_entrer_bunch_Callback(hObject, eventdata, handles)
2667% hObject    handle to edit_filling_entrer_bunch (see GCBO)
2668% eventdata  reserved - to be defined in a future version of MATLAB
2669% handles    structure with handles and user data (see GUIDATA)
2670
2671% Hints: get(hObject,'String') returns contents of edit_filling_entrer_bunch as text
2672%        str2double(get(hObject,'String')) returns contents of edit_filling_entrer_bunch as a double
2673
2674%set(handles.listbox_fillingmode,'value',12);
2675%listbox_fillingmode_Callback;
2676
2677% --- Executes during object creation, after setting all properties.
2678function edit_filling_entrer_bunch_CreateFcn(hObject, eventdata, handles)
2679% hObject    handle to edit_filling_entrer_bunch (see GCBO)
2680% eventdata  reserved - to be defined in a future version of MATLAB
2681% handles    empty - handles not created until after all CreateFcns called
2682
2683% Hint: edit controls usually have a white background on Windows.
2684%       See ISPC and COMPUTER.
2685if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2686    set(hObject,'BackgroundColor','white');
2687end
2688
2689
2690% --- Executes on button press in button_update.
2691function button_update_Callback(hObject, eventdata, handles)
2692% hObject    handle to button_update (see GCBO)
2693% eventdata  reserved - to be defined in a future version of MATLAB
2694% handles    structure with handles and user data (see GUIDATA)
2695
2696do_update
2697
2698% --- Executes on button press in button_acquisition_trigstatus.
2699function button_acquisition_trigstatus_Callback(hObject, eventdata, handles)
2700% hObject    handle to button_acquisition_trigstatus (see GCBO)
2701% eventdata  reserved - to be defined in a future version of MATLAB
2702% handles    structure with handles and user data (see GUIDATA)
2703
2704test_modes(handles);
2705
2706set(handles.inj_offset,'Enable','off');
2707set(handles.sdc1,'Enable','off');
2708set(handles.lin_canon_lpm,'Enable','off');set(handles.boo_alim_sd,'Enable','off');
2709set(handles.lin_canon_spm,'Enable','off');
2710set(handles.lin_canon_spm_fin,'Enable','off');
2711set(handles.lin_alim,'Enable','off');
2712set(handles.boo_bpm,'Enable','off');
2713set(handles.lt1_emittance,'Enable','off');
2714set(handles.lt1_MC1,'Enable','off');
2715set(handles.lt1_MC2,'Enable','off');
2716set(handles.lt1_osc,'Enable','off');
2717set(handles.boo_dcct,'Enable','off');
2718set(handles.boo_nod,'Enable','off');
2719set(handles.boo_inj_septum,'Enable','off');
2720set(handles.boo_inj_kicker,'Enable','off');
2721set(handles.boo_alim_dipole,'Enable','off');
2722set(handles.boo_alim_qf,'Enable','off');
2723set(handles.boo_alim_qd,'Enable','off');
2724set(handles.boo_alim_sf,'Enable','off');
2725set(handles.boo_alim_sd,'Enable','off');
2726set(handles.boo_alim_cp,'Enable','off');
2727set(handles.boo_rf,'Enable','off');
2728set(handles.boo_mrsv,'Enable','off');
2729set(handles.lin_modulateur,'Enable','off');
2730set(handles.ext_offset,'Enable','off');
2731set(handles.boo_ext_dof,'Enable','off');
2732set(handles.boo_ext_sept_p,'Enable','off');
2733set(handles.boo_ext_sept_a,'Enable','off');
2734set(handles.boo_ext_kicker,'Enable','off');
2735set(handles.sdc2,'Enable','off');
2736set(handles.lt2_emittance,'Enable','off');
2737set(handles.lt2_osc,'Enable','off');
2738set(handles.lt2_bpm,'Enable','off');
2739set(handles.ans_inj_k1,'Enable','off');
2740set(handles.ans_inj_k2,'Enable','off');
2741set(handles.ans_inj_k3,'Enable','off');
2742set(handles.ans_inj_k4,'Enable','off');
2743set(handles.ans_inj_sept_p,'Enable','off');
2744set(handles.ans_inj_sept_a,'Enable','off');
2745set(handles.ans_fbt,'Enable','off');
2746set(handles.ans_dcct,'Enable','off');
2747set(handles.ans_nod,'Enable','off');
2748set(handles.ans_bpm_c01,'Enable','off');
2749set(handles.ans_bpm_c02,'Enable','off');
2750set(handles.ans_bpm_c03,'Enable','off');
2751set(handles.ans_bpm_c04,'Enable','off');
2752set(handles.ans_bpm_c05,'Enable','off');
2753set(handles.ans_bpm_c06,'Enable','off');
2754set(handles.ans_bpm_c07,'Enable','off');
2755set(handles.ans_bpm_c08,'Enable','off');
2756set(handles.ans_bpm_c09,'Enable','off');
2757set(handles.ans_bpm_c10,'Enable','off');
2758set(handles.ans_bpm_c11,'Enable','off');
2759set(handles.ans_bpm_c12,'Enable','off');
2760set(handles.ans_bpm_c13,'Enable','off');
2761set(handles.ans_bpm_c14,'Enable','off');
2762set(handles.ans_bpm_c15,'Enable','off');
2763set(handles.ans_bpm_c16,'Enable','off');
2764
2765get_synchro_trigstatus(handles)
2766
2767
2768
2769% --- Executes on button press in togglebutton2.
2770function togglebutton2_Callback(hObject, eventdata, handles)
2771% hObject    handle to togglebutton2 (see GCBO)
2772% eventdata  reserved - to be defined in a future version of MATLAB
2773% handles    structure with handles and user data (see GUIDATA)
2774
2775% Hint: get(hObject,'Value') returns toggle state of togglebutton2
2776
2777
2778% --- Executes on selection change in listbox_fillingmode.
2779function listbox_fillingmode_Callback(hObject, eventdata, handles)
2780% hObject    handle to listbox_fillingmode (see GCBO)
2781% eventdata  reserved - to be defined in a future version of MATLAB
2782% handles    structure with handles and user data (see GUIDATA)
2783
2784% Hints: contents = get(hObject,'String') returns listbox_fillingmode contents as cell array
2785%        contents{get(hObject,'Value')} returns selected item from listbox_fillingmode
2786pattern=get(hObject,'String');
2787mode=get(hObject,'Value');
2788fprintf('***************************************************\n')
2789fprintf('Mode de remplissage sélectionné : %s\n',pattern{mode})
2790fprintf('***************************************************\n')
2791
2792
2793% Prépare les tables pour le 3 Hz
2794quart=[1 105 209 313];
2795temp=tango_read_attribute('ANS/SY/CENTRAL', 'ExtractionOffsetClkStepValue');
2796offset_ext=temp.value(1)*52;
2797offset_linac=str2double(get(handles.lin_canon_spm_fin,'String')) ;% délai fin de réglage en ns
2798offset_linac=offset_linac/handles.lin_fin_step;                   % délai fin de réglage en pas de handles.lin_fin_step ps
2799bjump=handles.one_bunch;
2800
2801
2802if (mode<=4)    %LPM
2803    bunch=quart(mode);
2804    fillingmode='1/4';
2805elseif (mode>4)&&(mode<=7) %LPM
2806    bunch=quart(1:(mode-3));
2807    if mode==5 ; fillingmode='1/2'; end
2808    if mode==6 ; fillingmode='3/4'; end
2809    if mode==7 ; fillingmode='4/4'; end
2810elseif (mode==8)    %LPM
2811    bunch=[365];      % SPM hybride
2812    %bunch=[0 104+32 2*(104+40)]+1; % spécial 3/4
2813    fillingmode='3/4';
2814elseif (mode==9)   % SPM    1 paquet
2815    bunch=[1];
2816    fillingmode='1 bunch';
2817elseif (mode==10)  % SPM    8 paquets
2818    bunch=[0:7]*52+1;
2819    fillingmode='8 bunches';
2820elseif (mode==11)  % SPM    16 paquets
2821    %bunch=[0:15]*26+1;
2822    fillingmode='16 bunches';
2823    % Ludo, tu remplis bunch ici
2824     bunch=[1:25];
2825%     
2826    bunch=[bunch  ([1:25]+1*32)];
2827    bunch=[bunch  ([1:25]+2*32)];
2828    bunch=[bunch  ([1:25]+3*32)];
2829    bunch=[bunch  ([1:25]+4*32)];
2830    bunch=[bunch  ([1:25]+5*32)];
2831    bunch=[bunch  ([1:25]+6*32)];
2832    bunch=[bunch  ([1:25]+7*32)];
2833    bunch=[bunch  ([1:25]+8*32)];
2834    bunch=[bunch  ([1:25]+9*32)];
2835    bunch=[bunch  ([1:25]+10*32)];
2836    bunch=[bunch  ([1:25]+11*32)];
2837    bunch=[bunch  ([1:25]+12*32)];
2838   
2839elseif (mode==12)  % SPM    n paquets
2840    bunch=str2num(get(handles.edit_filling_entrer_bunch,'String'));
2841    if isempty(bunch)
2842        set(handles.edit_filling_entrer_bunch,'String','Bug format');
2843    end
2844    fillingmode='Few bunches';
2845
2846%     bunch=[0:12]*32+1;
2847%     fillingmode='3/4';
2848   
2849%     bunch=[0 136 272]+1;
2850%     fillingmode='LPM spaced 3/4';
2851
2852%     bunch=[0 2 4 6]*52+1;
2853%     fillingmode='LPM 8 pulses';
2854
2855%     bunch=[1 105 209 313  1 105 209];
2856%     fillingmode='3.5/4';
2857
2858elseif (mode==13)  % SPM    n paquets
2859    paq=str2num(get(handles.edit_filling_entrer_bunch1,'String'));
2860    if (length(paq) == 2)
2861       bunch=paq(1):paq(2);
2862    else
2863       set(handles.edit_filling_entrer_bunch1,'String','Bug format')
2864    end
2865    fillingmode='Few bunches';
2866
2867%     bunch=[1 3 5 7]*52+1 + 8;
2868%     fillingmode='LPM 8 pulses';
2869end
2870
2871% Renseigne le filling Mode
2872tango_write_attribute2('ANS/DG/PUB-FillingMode', 'fillingMode',fillingmode)
2873
2874% Charge la longueur de la rafale par défaut sur un cycle
2875Ncoup=length(bunch);
2876boucle=int16(str2double(get(handles.edit_Ncycle,'String')));
2877if Ncoup>=1
2878    set(handles.edit_Ncoup,'String',num2str(Ncoup));
2879    tango_write_attribute2('ANS/SY/CENTRAL', 'burstSize',int32(Ncoup*boucle));
2880end
2881   
2882   
2883[dtour,dpaquet]=bucketnumber(bunch);
2884dpaquet=dpaquet*bjump+offset_linac;
2885table=int32([length(bunch) dtour dpaquet]);
2886handles.table=table;
2887handles.bunch=bunch;
2888
2889%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'table');
2890FileName = [handles.DirName 'table.mat'];
2891save(FileName, 'table'); % pour palier aux handles via timer non mis à jour !!!!!!
2892
2893modeinj='togglebutton_3Hz';
2894if strcmp(modeinj,'togglebutton_soft')  % on rempli la table sur paquet 1 par défaut, pas utilisée
2895    table=handles.table0;
2896    tango_command_inout('ANS/SY/CENTRAL','SetTables',table);
2897   
2898elseif strcmp(modeinj,'togglebutton_3Hz') % on rempli la table associée au remplissage
2899    tango_command_inout('ANS/SY/CENTRAL','SetTables',table);
2900    pause(1); % mise a jour table ATK
2901    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TablesCurrentDepth');
2902    n=temp.value;
2903    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'ExtractionDelayTable');
2904    table_ext=temp.value(1:n); %-offset_ext;
2905    temp=tango_read_attribute2('ANS/SY/CENTRAL', 'LinacDelayTable');
2906    table_linac=(temp.value(1:n)-offset_linac)/bjump;
2907    table=[];
2908    for i=1:n
2909        table=[table ' ' '(' num2str([table_ext(i)])  ' '  num2str([table_linac(i)]) ')'];
2910    end
2911end
2912
2913set(handles.edit_filling_relecture_tables,'String',[num2str(table)]);
2914set(handles.edit_filling_relecture_bunch, 'String',[num2str(bunch)]);
2915
2916
2917guidata(hObject, handles);
2918
2919
2920% --- Executes during object creation, after setting all properties.
2921function listbox_fillingmode_CreateFcn(hObject, eventdata, handles)
2922% hObject    handle to listbox_fillingmode (see GCBO)
2923% eventdata  reserved - to be defined in a future version of MATLAB
2924% handles    empty - handles not created until after all CreateFcns called
2925
2926% Hint: listbox controls usually have a white background on Windows.
2927%       See ISPC and COMPUTER.
2928if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2929    set(hObject,'BackgroundColor','white');
2930end
2931
2932
2933% --- Executes on button press in button_fix.
2934function button_fix_Callback(hObject, eventdata, handles)
2935% hObject    handle to button_fix (see GCBO)
2936% eventdata  reserved - to be defined in a future version of MATLAB
2937% handles    structure with handles and user data (see GUIDATA)
2938
2939[clk_spare,clk_soft]=fix_quart;
2940handles.clk_spare  =clk_spare;
2941handles.clk_soft=clk_soft;
2942
2943% n=1;
2944% temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSprStepDelay');
2945% clk1=temp.value(n);
2946% temp=tango_read_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay');
2947% clk2=temp.value(n);
2948%
2949% jump=int32([0 39 26 13]);
2950% handles.clk_spare  =jump +  int32(clk1);
2951% handles.clk_soft=jump  + int32(clk2);
2952
2953guidata(hObject, handles);
2954
2955
2956
2957function edit_Ncycle_Callback(hObject, eventdata, handles)
2958% hObject    handle to edit_Ncycle (see GCBO)
2959% eventdata  reserved - to be defined in a future version of MATLAB
2960% handles    structure with handles and user data (see GUIDATA)
2961
2962% Hints: get(hObject,'String') returns contents of edit_Ncycle as text
2963%        str2double(get(hObject,'String')) returns contents of edit_Ncycle as a double
2964boucle=str2double(get(hObject,'String'));
2965Ncoup=str2double(get(handles.edit_Ncoup,'String'));
2966tango_write_attribute2('ANS/SY/CENTRAL', 'burstSize',int32(Ncoup*boucle));
2967
2968% --- Executes during object creation, after setting all properties.
2969function edit_Ncycle_CreateFcn(hObject, eventdata, handles)
2970% hObject    handle to edit_Ncycle (see GCBO)
2971% eventdata  reserved - to be defined in a future version of MATLAB
2972% handles    empty - handles not created until after all CreateFcns called
2973
2974% Hint: edit controls usually have a white background on Windows.
2975%       See ISPC and COMPUTER.
2976if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2977    set(hObject,'BackgroundColor','white');
2978end
2979
2980
2981
2982function edit_Ncoup_Callback(hObject, eventdata, handles)
2983% hObject    handle to edit_Ncoup (see GCBO)
2984% eventdata  reserved - to be defined in a future version of MATLAB
2985% handles    structure with handles and user data (see GUIDATA)
2986
2987% Hints: get(hObject,'String') returns contents of edit_Ncoup as text
2988%        str2double(get(hObject,'String')) returns contents of edit_Ncoup as a double
2989Ncoup=str2double(get(hObject,'String'));
2990boucle=str2double(get(handles.edit_Ncycle,'String'));
2991tango_write_attribute2('ANS/SY/CENTRAL', 'burstSize',int32(Ncoup*boucle));
2992
2993% --- Executes during object creation, after setting all properties.
2994function edit_Ncoup_CreateFcn(hObject, eventdata, handles)
2995% hObject    handle to edit_Ncoup (see GCBO)
2996% eventdata  reserved - to be defined in a future version of MATLAB
2997% handles    empty - handles not created until after all CreateFcns called
2998
2999% Hint: edit controls usually have a white background on Windows.
3000%       See ISPC and COMPUTER.
3001if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3002    set(hObject,'BackgroundColor','white');
3003end
3004
3005
3006
3007function edit_qlt1_Callback(hObject, eventdata, handles)
3008% hObject    handle to edit_qlt1 (see GCBO)
3009% eventdata  reserved - to be defined in a future version of MATLAB
3010% handles    structure with handles and user data (see GUIDATA)
3011
3012% Hints: get(hObject,'String') returns contents of edit_qlt1 as text
3013%        str2double(get(hObject,'String')) returns contents of edit_qlt1 as a double
3014
3015
3016% --- Executes during object creation, after setting all properties.
3017function edit_qlt1_CreateFcn(hObject, eventdata, handles)
3018% hObject    handle to edit_qlt1 (see GCBO)
3019% eventdata  reserved - to be defined in a future version of MATLAB
3020% handles    empty - handles not created until after all CreateFcns called
3021
3022% Hint: edit controls usually have a white background on Windows.
3023%       See ISPC and COMPUTER.
3024if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3025    set(hObject,'BackgroundColor','white');
3026end
3027
3028
3029
3030function edit_iboo_Callback(hObject, eventdata, handles)
3031% hObject    handle to edit_iboo (see GCBO)
3032% eventdata  reserved - to be defined in a future version of MATLAB
3033% handles    structure with handles and user data (see GUIDATA)
3034
3035% Hints: get(hObject,'String') returns contents of edit_iboo as text
3036%        str2double(get(hObject,'String')) returns contents of edit_iboo as a double
3037
3038
3039% --- Executes during object creation, after setting all properties.
3040function edit_iboo_CreateFcn(hObject, eventdata, handles)
3041% hObject    handle to edit_iboo (see GCBO)
3042% eventdata  reserved - to be defined in a future version of MATLAB
3043% handles    empty - handles not created until after all CreateFcns called
3044
3045% Hint: edit controls usually have a white background on Windows.
3046%       See ISPC and COMPUTER.
3047if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3048    set(hObject,'BackgroundColor','white');
3049end
3050
3051
3052
3053function edit_dians_Callback(hObject, eventdata, handles)
3054% hObject    handle to edit_dians (see GCBO)
3055% eventdata  reserved - to be defined in a future version of MATLAB
3056% handles    structure with handles and user data (see GUIDATA)
3057
3058% Hints: get(hObject,'String') returns contents of edit_dians as text
3059%        str2double(get(hObject,'String')) returns contents of edit_dians as a double
3060
3061
3062% --- Executes during object creation, after setting all properties.
3063function edit_dians_CreateFcn(hObject, eventdata, handles)
3064% hObject    handle to edit_dians (see GCBO)
3065% eventdata  reserved - to be defined in a future version of MATLAB
3066% handles    empty - handles not created until after all CreateFcns called
3067
3068% Hint: edit controls usually have a white background on Windows.
3069%       See ISPC and COMPUTER.
3070if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3071    set(hObject,'BackgroundColor','white');
3072end
3073
3074
3075
3076function edit_rlt1_Callback(hObject, eventdata, handles)
3077% hObject    handle to edit_rlt1 (see GCBO)
3078% eventdata  reserved - to be defined in a future version of MATLAB
3079% handles    structure with handles and user data (see GUIDATA)
3080
3081% Hints: get(hObject,'String') returns contents of edit_rlt1 as text
3082%        str2double(get(hObject,'String')) returns contents of edit_rlt1 as a double
3083
3084
3085% --- Executes during object creation, after setting all properties.
3086function edit_rlt1_CreateFcn(hObject, eventdata, handles)
3087% hObject    handle to edit_rlt1 (see GCBO)
3088% eventdata  reserved - to be defined in a future version of MATLAB
3089% handles    empty - handles not created until after all CreateFcns called
3090
3091% Hint: edit controls usually have a white background on Windows.
3092%       See ISPC and COMPUTER.
3093if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3094    set(hObject,'BackgroundColor','white');
3095end
3096
3097
3098
3099function edit_rboo_Callback(hObject, eventdata, handles)
3100% hObject    handle to edit_rboo (see GCBO)
3101% eventdata  reserved - to be defined in a future version of MATLAB
3102% handles    structure with handles and user data (see GUIDATA)
3103
3104% Hints: get(hObject,'String') returns contents of edit_rboo as text
3105%        str2double(get(hObject,'String')) returns contents of edit_rboo as a double
3106
3107
3108% --- Executes during object creation, after setting all properties.
3109function edit_rboo_CreateFcn(hObject, eventdata, handles)
3110% hObject    handle to edit_rboo (see GCBO)
3111% eventdata  reserved - to be defined in a future version of MATLAB
3112% handles    empty - handles not created until after all CreateFcns called
3113
3114% Hint: edit controls usually have a white background on Windows.
3115%       See ISPC and COMPUTER.
3116if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3117    set(hObject,'BackgroundColor','white');
3118end
3119
3120
3121
3122function edit_rans_Callback(hObject, eventdata, handles)
3123% hObject    handle to edit_rans (see GCBO)
3124% eventdata  reserved - to be defined in a future version of MATLAB
3125% handles    structure with handles and user data (see GUIDATA)
3126
3127% Hints: get(hObject,'String') returns contents of edit_rans as text
3128%        str2double(get(hObject,'String')) returns contents of edit_rans as a double
3129
3130
3131% --- Executes during object creation, after setting all properties.
3132function edit_rans_CreateFcn(hObject, eventdata, handles)
3133% hObject    handle to edit_rans (see GCBO)
3134% eventdata  reserved - to be defined in a future version of MATLAB
3135% handles    empty - handles not created until after all CreateFcns called
3136
3137% Hint: edit controls usually have a white background on Windows.
3138%       See ISPC and COMPUTER.
3139if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3140    set(hObject,'BackgroundColor','white');
3141end
3142
3143
3144
3145function edit_dians1_Callback(hObject, eventdata, handles)
3146% hObject    handle to edit_dians1 (see GCBO)
3147% eventdata  reserved - to be defined in a future version of MATLAB
3148% handles    structure with handles and user data (see GUIDATA)
3149
3150% Hints: get(hObject,'String') returns contents of edit_dians1 as text
3151%        str2double(get(hObject,'String')) returns contents of edit_dians1 as a double
3152
3153
3154% --- Executes during object creation, after setting all properties.
3155function edit_dians1_CreateFcn(hObject, eventdata, handles)
3156% hObject    handle to edit_dians1 (see GCBO)
3157% eventdata  reserved - to be defined in a future version of MATLAB
3158% handles    empty - handles not created until after all CreateFcns called
3159
3160% Hint: edit controls usually have a white background on Windows.
3161%       See ISPC and COMPUTER.
3162if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3163    set(hObject,'BackgroundColor','white');
3164end
3165
3166
3167
3168function edit_cycle_Callback(hObject, eventdata, handles)
3169% hObject    handle to edit_cycle (see GCBO)
3170% eventdata  reserved - to be defined in a future version of MATLAB
3171% handles    structure with handles and user data (see GUIDATA)
3172
3173% Hints: get(hObject,'String') returns contents of edit_cycle as text
3174%        str2double(get(hObject,'String')) returns contents of edit_cycle as a double
3175
3176
3177% --- Executes during object creation, after setting all properties.
3178function edit_cycle_CreateFcn(hObject, eventdata, handles)
3179% hObject    handle to edit_cycle (see GCBO)
3180% eventdata  reserved - to be defined in a future version of MATLAB
3181% handles    empty - handles not created until after all CreateFcns called
3182
3183% Hint: edit controls usually have a white background on Windows.
3184%       See ISPC and COMPUTER.
3185if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3186    set(hObject,'BackgroundColor','white');
3187end
3188
3189
3190
3191function edit_courant_total_Callback(hObject, eventdata, handles)
3192% hObject    handle to edit_courant_total (see GCBO)
3193% eventdata  reserved - to be defined in a future version of MATLAB
3194% handles    structure with handles and user data (see GUIDATA)
3195
3196% Hints: get(hObject,'String') returns contents of edit_courant_total as text
3197%        str2double(get(hObject,'String')) returns contents of edit_courant_total as a double
3198
3199
3200% --- Executes during object creation, after setting all properties.
3201function edit_courant_total_CreateFcn(hObject, eventdata, handles)
3202% hObject    handle to edit_courant_total (see GCBO)
3203% eventdata  reserved - to be defined in a future version of MATLAB
3204% handles    empty - handles not created until after all CreateFcns called
3205
3206% Hint: edit controls usually have a white background on Windows.
3207%       See ISPC and COMPUTER.
3208if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3209    set(hObject,'BackgroundColor','white');
3210end
3211
3212
3213
3214function lin_canon_spm_Callback(hObject, eventdata, handles)
3215% hObject    handle to lin_alim_canon_spm (see GCBO)
3216% eventdata  reserved - to be defined in a future version of MATLAB
3217% handles    structure with handles and user data (see GUIDATA)
3218
3219% Hints: get(hObject,'String') returns contents of lin_alim_canon_spm as text
3220%        str2double(get(hObject,'String')) returns contents of lin_alim_canon_spm as a double
3221
3222inj_offset=str2double(get(handles.inj_offset,'String'));
3223delay=str2double(get(hObject,'String'))+inj_offset;
3224tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacTimeDelay',delay);
3225
3226
3227% --- Executes during object creation, after setting all properties.
3228function lin_canon_spm_CreateFcn(hObject, eventdata, handles)
3229% hObject    handle to lin_alim_canon_spm (see GCBO)
3230% eventdata  reserved - to be defined in a future version of MATLAB
3231% handles    empty - handles not created until after all CreateFcns called
3232
3233% Hint: edit controls usually have a white background on Windows.
3234%       See ISPC and COMPUTER.
3235if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3236    set(hObject,'BackgroundColor','white');
3237end
3238
3239
3240function  uipanel_mode_CreateFcn(hObject, eventdata, handles)
3241% hObject    handle to lin_alim_canon_spm (see GCBO)
3242% eventdata  reserved - to be defined in a future version of MATLAB
3243% handles    empty - handles not created until after all CreateFcns called
3244
3245
3246% % % --------------------------------------------------------------------
3247% function uipanel_mode_SelectionChangeFcn(hObject, eventdata, handles)
3248% % % hObject    handle to uipanel_mode (see GCBO)
3249% % % eventdata  reserved - to be defined in a future version of MATLAB
3250% % % handles    structure with handles and user data (see GUIDATA)
3251%
3252% set(handles.button_injection_soft,'Enable','Off')
3253% set(handles.edit_modes,'String','Please WAIT !!!!')
3254% mode=get(get(handles.uipanel_mode,'SelectedObject'),'Tag');
3255%
3256% switch mode  % Get Tag of selected object
3257%     case 'togglebutton_soft'
3258%         % switch to soft (load golden)
3259%         
3260%         Directory=handles.Directory;
3261%         DirName=handles.DirName;
3262%         file='golden_rafale_soft.mat';
3263%         load_synchro_rafale(Directory,file,DirName)
3264%         
3265%         
3266%         % special septum actif boo et ans
3267%         r=(1-0.0004);
3268%         try
3269%             temp=tango_read_attribute2('BOO-C12/EP/AL_SEP_A.Ext','voltage');boo=temp.value(2)*r
3270%             tango_write_attribute2('BOO-C12/EP/AL_SEP_A.Ext','voltage',boo);
3271%             temp=tango_read_attribute2('ANS-C01/EP/AL_SEP_A','voltage');ans=temp.value(2)*r
3272%             tango_write_attribute2('ANS-C01/EP/AL_SEP_A','voltage',ans);
3273%         catch
3274%             display('Erreur ajustement tension septa passif')
3275%         end
3276%         set(handles.edit_Ncoup,'Enable','off');
3277%         tango_command_inout('ANS/SY/CENTRAL','SetTables',handles.table0);
3278%
3279%     case 'togglebutton_3Hz'
3280%         % switch to 3Hz(load golden)
3281%         
3282%         Directory=handles.Directory;
3283%         DirName=handles.DirName;
3284%         file='golden_rafale_3Hz.mat';
3285%         load_synchro_rafale(Directory,file,DirName)
3286%         
3287%         % special septum actif boo et ans
3288%         r=(1+0.0004);
3289%         try
3290%             temp=tango_read_attribute2('BOO-C12/EP/AL_SEP_A.Ext','voltage');boo=temp.value(2)*r
3291%             tango_write_attribute2('BOO-C12/EP/AL_SEP_A.Ext','voltage',boo);
3292%             temp=tango_read_attribute2('ANS-C01/EP/AL_SEP_A','voltage');    ans=temp.value(2)*r
3293%             tango_write_attribute2('ANS-C01/EP/AL_SEP_A','voltage',ans);
3294%         catch
3295%             display('Erreur ajustement tension septa passif')
3296%         end
3297%         set(handles.edit_Ncoup,'Enable','on');
3298%         tango_command_inout('ANS/SY/CENTRAL','SetTables',handles.table);
3299% end
3300%
3301% set(handles.button_injection_soft,'Enable','On')
3302% test_modes(handles);
3303% display('ok change address')
3304
3305
3306
3307function edit_filling_entrer_bunch1_Callback(hObject, eventdata, handles)
3308% hObject    handle to edit_filling_entrer_bunch1 (see GCBO)
3309% eventdata  reserved - to be defined in a future version of MATLAB
3310% handles    structure with handles and user data (see GUIDATA)
3311
3312% Hints: get(hObject,'String') returns contents of edit_filling_entrer_bunch1 as text
3313%        str2double(get(hObject,'String')) returns contents of edit_filling_entrer_bunch1 as a double
3314
3315
3316
3317
3318% --- Executes during object creation, after setting all properties.
3319function edit_filling_entrer_bunch1_CreateFcn(hObject, eventdata, handles)
3320% hObject    handle to edit_filling_entrer_bunch1 (see GCBO)
3321% eventdata  reserved - to be defined in a future version of MATLAB
3322% handles    empty - handles not created until after all CreateFcns called
3323
3324% Hint: edit controls usually have a white background on Windows.
3325%       See ISPC and COMPUTER.
3326if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3327    set(hObject,'BackgroundColor','white');
3328end
3329
3330
3331
3332function edit_Imin_Callback(hObject, eventdata, handles)
3333% hObject    handle to edit_Imin (see GCBO)
3334% eventdata  reserved - to be defined in a future version of MATLAB
3335% handles    structure with handles and user data (see GUIDATA)
3336
3337% Hints: get(hObject,'String') returns contents of edit_Imin as text
3338%        str2double(get(hObject,'String')) returns contents of edit_Imin as a double
3339
3340
3341% --- Executes during object creation, after setting all properties.
3342function edit_Imin_CreateFcn(hObject, eventdata, handles)
3343% hObject    handle to edit_Imin (see GCBO)
3344% eventdata  reserved - to be defined in a future version of MATLAB
3345% handles    empty - handles not created until after all CreateFcns called
3346
3347% Hint: edit controls usually have a white background on Windows.
3348%       See ISPC and COMPUTER.
3349if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3350    set(hObject,'BackgroundColor','white');
3351end
3352
3353
3354% --------------------------------------------------------------------
3355function uipanel_spm_mode_SelectionChangeFcn(hObject, eventdata, handles)
3356% hObject    handle to uipanel_spm_mode (see GCBO)
3357% eventdata  reserved - to be defined in a future version of MATLAB
3358% handles    structure with handles and user data (see GUIDATA)
3359
3360%h=get(handles.uipanel_spm_mode);
3361%get(h.Children)
3362
3363mode=get(get(handles.uipanel_spm_mode,'SelectedObject'),'Tag');
3364
3365switch mode  % Get Tag of selected object
3366    case 'spm_mode_1'
3367        display('spm_mode_1')     
3368        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'mode',int16(1));
3369    case 'spm_mode_2'
3370        display('spm_mode_2') 
3371        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'mode',int16(2));
3372    case 'spm_mode_2p'
3373        display('spm_mode_2p')   
3374        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'mode',int16(3));
3375    case 'spm_mode_3'
3376        display('spm_mode_3')   
3377        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'mode',int16(4));   
3378end
3379
3380test_modes(handles);
3381
3382% --------------------------------------------------------------------
3383function uipanel_lpm_spm_mode_SelectionChangeFcn(hObject, eventdata, handles)
3384% hObject    handle to uipanel_lpm_spm_mode (see GCBO)
3385% eventdata  reserved - to be defined in a future version of MATLAB
3386% handles    structure with handles and user data (see GUIDATA)
3387
3388
3389mode=get(get(handles.uipanel_lpm_spm_mode,'SelectedObject'),'Tag');
3390%modeinj=get(get(handles.uipanel_mode,'SelectedObject'),'Tag');
3391modeinj='togglebutton_3Hz';
3392event0=int32(0);
3393if     strcmp(modeinj,'togglebutton_soft')
3394    event=int32(5);
3395elseif strcmp(modeinj,'togglebutton_3Hz')
3396    event=int32(2);
3397else
3398    %%%
3399end
3400
3401switch mode  % Get Tag of selected object
3402    case 'no_mode'
3403        tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent',event0);
3404        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacEvent',event0);
3405       
3406    case 'lpm_mode'
3407        tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent',event);
3408        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacEvent',event0);     
3409       
3410%         tango_write_attribute('LT1/AE/CV.2', 'current',  0.058 );
3411%         tango_write_attribute('LT1/AE/CV.3', 'current', -0.119 );
3412
3413    case 'spm_mode'
3414        tango_write_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent',event0);
3415        tango_write_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacEvent',event);   
3416       
3417%         tango_write_attribute('LT1/AE/CV.2', 'current',  0.058 );
3418%         tango_write_attribute('LT1/AE/CV.3', 'current', -0.119 );
3419       
3420end
3421test_modes(handles);
3422
3423
3424
3425
3426       
3427
3428% --------------------------------------------------------------------
3429function uipanel_central_mode_SelectionChangeFcn(hObject, eventdata, handles)
3430% hObject    handle to uipanel_central_mode (see GCBO)
3431% eventdata  reserved - to be defined in a future version of MATLAB
3432% handles    structure with handles and user data (see GUIDATA)
3433
3434mode=get(get(handles.uipanel_central_mode,'SelectedObject'),'Tag');
3435%modeinj=get(get(handles.uipanel_mode,'SelectedObject'),'Tag');
3436modeinj='togglebutton_3Hz';
3437
3438h='Yes';
3439if strcmp(mode,'continuous_mode')
3440    if strcmp(modeinj,'togglebutton_3Hz')
3441        h = questdlg('Attention, déclenchement continu des équipements sur adresses 1 2 3');
3442    end
3443end
3444
3445if strcmp(h,'Yes')
3446    switch mode  % Get Tag of selected object
3447        case 'burst_mode'
3448            tango_command_inout2('ANS/SY/CENTRAL', 'SetBurstMode');
3449        case 'continuous_mode'
3450            tango_command_inout2('ANS/SY/CENTRAL', 'SetContinuousMode');
3451    end
3452end
3453pause(1)
3454test_modes(handles);
3455
3456% [etat_central]=test_central_mode(handles);
3457% h='Yes';
3458% if strcmp(etat_central,'Continu')
3459%     h = questdlg('Attention, Trigger en mode continu');
3460% end
3461% if strcmp(h,'Yes')
3462%     set(handles.button_injection_soft,'Enable','Off')
3463%     set(handles.edit_modes,'String','Please WAIT !!!!')
3464%     file='golden_rafale_3Hz.mat';
3465%     load_synchro_rafale(file)
3466%     set(handles.button_injection_soft,'Enable','On')
3467%     test_modes(handles);
3468% end
3469
3470
3471function  [etat]=test_central_mode(handles)
3472% Verifie le mode central selectionné  : rafale ou continue
3473temp=tango_read_attribute2('ANS/SY/CENTRAL', 'currentMode');
3474mode=temp.value;
3475h=get(handles.uipanel_central_mode);
3476switch mode  % Get Tag of selected object
3477    case 'BURST'
3478       set(handles.uipanel_central_mode,'SelectedObject',h.Children(2))
3479       etat='Rafale';
3480    case 'CONTINUOUS'
3481       set(handles.uipanel_central_mode,'SelectedObject',h.Children(1))
3482       etat='Continu';
3483end
3484
3485function  [etat]=test_injection_mode(handles)
3486% Verifie le mode d'injection selectionné : soft ou 3Hz
3487%temp=tango_read_attribute2('lin_alim/SY/LOCAL.LPM.1', 'spareEvent');
3488etat='3Hz';
3489
3490
3491function  [etat]=test_lpm_spm_mode(handles)
3492% Verifie le mode selectionné en SPM ou LPM
3493temp=tango_read_attribute2('LIN/SY/LOCAL.LPM.1', 'lpmEvent');
3494modelpm=temp.value(1);
3495temp=tango_read_attribute2('LIN/SY/LOCAL.SPM.1', 'spmLinacEvent');
3496modespm=temp.value(1);
3497h=get(handles.uipanel_lpm_spm_mode);
3498if     (modelpm==5)&(modespm==0) | (modelpm==2)&(modespm==0)
3499    set(handles.uipanel_lpm_spm_mode,'SelectedObject',h.Children(2))
3500    etat='LPM';
3501elseif (modelpm==0)&(modespm==5) | (modelpm==0)&(modespm==2)
3502    set(handles.uipanel_lpm_spm_mode,'SelectedObject',h.Children(1))
3503    etat='SPM';
3504else
3505    set(handles.uipanel_lpm_spm_mode,'SelectedObject',h.Children(3))
3506    etat='NONE';
3507end
3508
3509function  [etat]=test_spm_mode(handles)
3510% Verifie le mode selectionné en SPM : 1 2 ou 3 paquets
3511temp=tango_read_attribute2('LIN/SY/LOCAL.SPM.1', 'mode');
3512mode=temp.value(1);
3513h=get(handles.uipanel_spm_mode);
3514select=h.Children(5-mode);
3515set(handles.uipanel_spm_mode,'SelectedObject',select)
3516etat=num2str(5-mode);
3517
3518function  [etat]=test_cond_inj(handles)
3519% Verifie si tir autorise  (Grp fonctionnement)
3520try temp=tango_read_attribute2('ANS/FC/INJ_COND', 'COND_INJ'); % 0 no injection,  1 injection
3521    val=temp.value; catch val=1 ; end; if val~=0 ; val=1; end;
3522if (val==1)
3523    etat='TIR AUTORISE';
3524else
3525    etat='TIR NON AUTORISE';
3526end
3527
3528
3529function  test_modes(handles)
3530% Verifie le mode central selectionné  : rafale ou continue
3531[etat_central]=test_central_mode(handles);
3532% Verifie le mode d'injection selectionné : soft ou 3Hz
3533[etat_injection]=test_injection_mode(handles);
3534% Verifie le mode selectionné en SPM ou LPM
3535[etat_linac]=test_lpm_spm_mode(handles);
3536% Verifie le mode selectionné en SPM : 1 2 ou 3 paquets
3537[etat_linac_spm]=test_spm_mode(handles);
3538% Vérifie si injectio autorisee
3539%[etat_inj]=test_cond_inj(handles);
3540
3541
3542% txt=[etat_inj,'    ####     ', ...
3543%      'CENTRAL : ',etat_central,'   #   INJECTION : ',etat_injection,'   #   LINAC : ',etat_linac];
3544txt=['CENTRAL : ',etat_central,'   #   INJECTION : ',etat_injection,'   #   LINAC : ',etat_linac];
3545set(handles.edit_modes,'String',txt)
3546
3547
3548
3549function edit_modes_Callback(hObject, eventdata, handles)
3550% hObject    handle to edit_modes (see GCBO)
3551% eventdata  reserved - to be defined in a future version of MATLAB
3552% handles    structure with handles and user data (see GUIDATA)
3553
3554% Hints: get(hObject,'String') returns contents of edit_modes as text
3555%        str2double(get(hObject,'String')) returns contents of edit_modes as a double
3556
3557
3558% --- Executes during object creation, after setting all properties.
3559function edit_modes_CreateFcn(hObject, eventdata, handles)
3560% hObject    handle to edit_modes (see GCBO)
3561% eventdata  reserved - to be defined in a future version of MATLAB
3562% handles    empty - handles not created until after all CreateFcns called
3563
3564% Hint: edit controls usually have a white background on Windows.
3565%       See ISPC and COMPUTER.
3566if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3567    set(hObject,'BackgroundColor','white');
3568end
3569
3570function ans_k_pc_Callback(hObject, eventdata, handles)
3571% hObject    handle to ans_k_pc (see GCBO)
3572% eventdata  reserved - to be defined in a future version of MATLAB
3573% handles    structure with handles and user data (see GUIDATA)
3574
3575% Hints: get(hObject,'String') returns contents of ans_k_pc as text
3576%        str2double(get(hObject,'String')) returns contents of ans_k_pc as a double
3577
3578
3579% --- Executes during object creation, after setting all properties.
3580function ans_k_pc_CreateFcn(hObject, eventdata, handles)
3581% hObject    handle to ans_k_pc (see GCBO)
3582% eventdata  reserved - to be defined in a future version of MATLAB
3583% handles    empty - handles not created until after all CreateFcns called
3584
3585% Hint: edit controls usually have a white background on Windows.
3586%       See ISPC and COMPUTER.
3587if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3588    set(hObject,'BackgroundColor','white');
3589end
3590
3591
3592
3593function ans_k_h_Callback(hObject, eventdata, handles)
3594% hObject    handle to ans_k_h (see GCBO)
3595% eventdata  reserved - to be defined in a future version of MATLAB
3596% handles    structure with handles and user data (see GUIDATA)
3597
3598% Hints: get(hObject,'String') returns contents of ans_k_h as text
3599%        str2double(get(hObject,'String')) returns contents of ans_k_h as a double
3600
3601
3602% --- Executes during object creation, after setting all properties.
3603function ans_k_h_CreateFcn(hObject, eventdata, handles)
3604% hObject    handle to ans_k_h (see GCBO)
3605% eventdata  reserved - to be defined in a future version of MATLAB
3606% handles    empty - handles not created until after all CreateFcns called
3607
3608% Hint: edit controls usually have a white background on Windows.
3609%       See ISPC and COMPUTER.
3610if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3611    set(hObject,'BackgroundColor','white');
3612end
3613
3614
3615
3616function ans_k_v_Callback(hObject, eventdata, handles)
3617% hObject    handle to ans_k_v (see GCBO)
3618% eventdata  reserved - to be defined in a future version of MATLAB
3619% handles    structure with handles and user data (see GUIDATA)
3620
3621% Hints: get(hObject,'String') returns contents of ans_k_v as text
3622%        str2double(get(hObject,'String')) returns contents of ans_k_v as a double
3623
3624
3625% --- Executes during object creation, after setting all properties.
3626function ans_k_v_CreateFcn(hObject, eventdata, handles)
3627% hObject    handle to ans_k_v (see GCBO)
3628% eventdata  reserved - to be defined in a future version of MATLAB
3629% handles    empty - handles not created until after all CreateFcns called
3630
3631% Hint: edit controls usually have a white background on Windows.
3632%       See ISPC and COMPUTER.
3633if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3634    set(hObject,'BackgroundColor','white');
3635end
3636
3637
3638% --- Executes on button press in button_kicker.
3639function button_kicker_Callback(hObject, eventdata, handles)
3640% hObject    handle to button_kicker (see GCBO)
3641% eventdata  reserved - to be defined in a future version of MATLAB
3642% handles    structure with handles and user data (see GUIDATA)
3643
3644% Hint: get(hObject,'Value') returns toggle state of button_kicker
3645
3646bpm=get(hObject,'Value');
3647
3648if (bpm==0)
3649   set(handles.uipanel_kicker_machine,'Visible','off');
3650elseif (bpm==1)
3651    set(handles.uipanel_kicker_machine,'Visible','on');
3652end
3653
3654
3655% --- Executes on button press in button_save_golden_soft.
3656function button_save_golden_soft_Callback(hObject, eventdata, handles)
3657% hObject    handle to button_save_golden_soft (see GCBO)
3658% eventdata  reserved - to be defined in a future version of MATLAB
3659% handles    structure with handles and user data (see GUIDATA)
3660h = questdlg('Attention, sauvegarde nouvelle golden !!!');
3661
3662if strcmp(h,'Yes')
3663
3664    DirName=handles.DirName;
3665    [timing]=get_synchro_rafale(DirName);
3666    % sauvegarde
3667    file='golden_rafale_soft.mat';
3668    %Directory =  [getfamilydata('Directory','DataRoot') 'Datatemp'];
3669    Directory=handles.Directory;
3670    pwdold = pwd;
3671    cd(Directory);
3672    save(file, 'timing');
3673    cd(pwdold);
3674
3675end
3676
3677
3678% --- Executes on button press in button_load_golden_soft.
3679function button_load_golden_soft_Callback(hObject, eventdata, handles)
3680% hObject    handle to button_load_golden_soft (see GCBO)
3681% eventdata  reserved - to be defined in a future version of MATLAB
3682% handles    structure with handles and user data (see GUIDATA)
3683
3684set(handles.button_injection_soft,'Enable','Off')
3685set(handles.edit_modes,'String','Please WAIT !!!!')
3686Directory=handles.Directory;
3687DirName=handles.DirName;
3688file='golden_rafale_soft.mat';
3689load_synchro_rafale(Directory,file,DirName)
3690set(handles.button_injection_soft,'Enable','On')
3691test_modes(handles);
3692
3693
3694% --- Executes on button press in button_load_golden_3Hz.
3695function button_load_golden_3Hz_Callback(hObject, eventdata, handles)
3696% hObject    handle to button_load_golden_3Hz (see GCBO)
3697% eventdata  reserved - to be defined in a future version of MATLAB
3698% handles    structure with handles and user data (see GUIDATA)
3699
3700[etat_central]=test_central_mode(handles);
3701h='Yes';
3702if strcmp(etat_central,'Continu')
3703    h = questdlg('Attention, Trigger en mode continu');
3704end
3705if strcmp(h,'Yes')
3706    set(handles.button_injection_soft,'Enable','Off')
3707    set(handles.edit_modes,'String','Please WAIT !!!!')
3708    Directory=handles.Directory;
3709    DirName=handles.DirName;
3710    file='golden_rafale_3Hz.mat';
3711    load_synchro_rafale(Directory,file,DirName)
3712    set(handles.button_injection_soft,'Enable','On')
3713    test_modes(handles);
3714end
3715
3716% --- Executes on button press in button_save_golden_3Hz.
3717function button_save_golden_3Hz_Callback(hObject, eventdata, handles)
3718% hObject    handle to button_save_golden_3Hz (see GCBO)
3719% eventdata  reserved - to be defined in a future version of MATLAB
3720% handles    structure with handles and user data (see GUIDATA)
3721h = questdlg('Attention, sauvegarde nouvelle golden !!!');
3722
3723if strcmp(h,'Yes')
3724   
3725    DirName=handles.DirName;
3726    [timing]=get_synchro_rafale(DirName);
3727    % sauvegarde
3728    file='golden_rafale_3Hz.mat';
3729    %Directory =  [getfamilydata('Directory','DataRoot') 'Datatemp'];
3730    Directory=handles.Directory;
3731    pwdold = pwd;
3732    cd(Directory);
3733    save(file, 'timing');
3734    cd(pwdold);
3735
3736end
3737
3738% --- Executes on button press in button_load_golden_3Hz_66MeV.
3739function button_load_golden_3Hz_66MeV_Callback(hObject, eventdata, handles)
3740% hObject    handle to button_load_golden_3Hz_66MeV (see GCBO)
3741% eventdata  reserved - to be defined in a future version of MATLAB
3742% handles    structure with handles and user data (see GUIDATA)
3743[etat_central]=test_central_mode(handles);
3744h='Yes';
3745if strcmp(etat_central,'Continu')
3746    h = questdlg('Attention, Trigger en mode continu');
3747end
3748if strcmp(h,'Yes')
3749    set(handles.button_injection_soft,'Enable','Off')
3750    set(handles.edit_modes,'String','Please WAIT !!!!')
3751    Directory=handles.Directory;
3752    DirName=handles.DirName;
3753    file='golden_rafale_3Hz_66MeV.mat';
3754    load_synchro_rafale(Directory,file,DirName)
3755    set(handles.button_injection_soft,'Enable','On')
3756    test_modes(handles);
3757end
3758
3759
3760% --- Executes on button press in button_save_golden_66MeV.
3761function button_save_golden_66MeV_Callback(hObject, eventdata, handles)
3762% hObject    handle to button_save_golden_66MeV (see GCBO)
3763% eventdata  reserved - to be defined in a future version of MATLAB
3764% handles    structure with handles and user data (see GUIDATA)
3765h = questdlg('Attention, sauvegarde nouvelle golden 66 MeV!!!');
3766
3767if strcmp(h,'Yes')
3768
3769    DirName=handles.DirName;
3770    [timing]=get_synchro_rafale(DirName);
3771    % sauvegarde
3772    file='golden_rafale_3Hz_66MeV.mat';
3773    %Directory =  [getfamilydata('Directory','DataRoot') 'Datatemp'];
3774    Directory=handles.Directory;
3775    pwdold = pwd;
3776    cd(Directory);
3777    save(file, 'timing');
3778    cd(pwdold);
3779
3780end
3781
3782
3783
3784function boo_mrsv_Callback(hObject, eventdata, handles)
3785% hObject    handle to boo_mrsv (see GCBO)
3786% eventdata  reserved - to be defined in a future version of MATLAB
3787% handles    structure with handles and user data (see GUIDATA)
3788
3789% Hints: get(hObject,'String') returns contents of boo_mrsv as text
3790%        str2double(get(hObject,'String')) returns contents of boo_mrsv as a double
3791
3792ext_offset=str2double(get(handles.ext_offset,'String'));
3793delay=str2double(get(hObject,'String'))+ext_offset;
3794tango_write_attribute2('BOO/SY/LOCAL.DG.3', 'emittanceTimeDelay',delay);
3795
3796% --- Executes during object creation, after setting all properties.
3797function boo_mrsv_CreateFcn(hObject, eventdata, handles)
3798% hObject    handle to boo_mrsv (see GCBO)
3799% eventdata  reserved - to be defined in a future version of MATLAB
3800% handles    empty - handles not created until after all CreateFcns called
3801
3802% Hint: edit controls usually have a white background on Windows.
3803%       See ISPC and COMPUTER.
3804if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3805    set(hObject,'BackgroundColor','white');
3806end
3807
3808
3809
3810function central_pc_Callback(hObject, eventdata, handles)
3811% hObject    handle to central_pc (see GCBO)
3812% eventdata  reserved - to be defined in a future version of MATLAB
3813% handles    structure with handles and user data (see GUIDATA)
3814
3815% Hints: get(hObject,'String') returns contents of central_pc as text
3816%        str2double(get(hObject,'String')) returns contents of central_pc as a double
3817
3818
3819delay=str2double(get(hObject,'String'));
3820tango_write_attribute2('ANS/SY/CENTRAL', 'TPcTimeDelay',delay);
3821
3822
3823% --- Executes during object creation, after setting all properties.
3824function central_pc_CreateFcn(hObject, eventdata, handles)
3825% hObject    handle to central_pc (see GCBO)
3826% eventdata  reserved - to be defined in a future version of MATLAB
3827% handles    empty - handles not created until after all CreateFcns called
3828
3829% Hint: edit controls usually have a white background on Windows.
3830%       See ISPC and COMPUTER.
3831if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3832    set(hObject,'BackgroundColor','white');
3833end
3834
3835
3836
3837function lin_alim_Callback(hObject, eventdata, handles)
3838% hObject    handle to lin_alim (see GCBO)
3839% eventdata  reserved - to be defined in a future version of MATLAB
3840% handles    structure with handles and user data (see GUIDATA)
3841
3842% Hints: get(hObject,'String') returns contents of lin_alim as text
3843%        str2double(get(hObject,'String')) returns contents of lin_alim as a double
3844
3845
3846delay=str2double(get(hObject,'String'));
3847tango_write_attribute2('LT1/SY/LOCAL.DG.1', 'libre.1TimeDelay',delay);
3848
3849
3850% --- Executes during object creation, after setting all properties.
3851function lin_alim_CreateFcn(hObject, eventdata, handles)
3852% hObject    handle to lin_alim (see GCBO)
3853% eventdata  reserved - to be defined in a future version of MATLAB
3854% handles    empty - handles not created until after all CreateFcns called
3855
3856% Hint: edit controls usually have a white background on Windows.
3857%       See ISPC and COMPUTER.
3858if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3859    set(hObject,'BackgroundColor','white');
3860end
3861
3862
3863
3864function ans_nod_Callback(hObject, eventdata, handles)
3865% hObject    handle to ans_nod (see GCBO)
3866% eventdata  reserved - to be defined in a future version of MATLAB
3867% handles    structure with handles and user data (see GUIDATA)
3868
3869% Hints: get(hObject,'String') returns contents of ans_nod as text
3870%        str2double(get(hObject,'String')) returns contents of ans_nod as a double
3871
3872ext_offset=str2double(get(handles.ext_offset,'String'));
3873delay=str2double(get(hObject,'String'))+ext_offset;
3874tango_write_attribute2('ANS-C14/SY/LOCAL.DG.1', 'perteTimeDelay',delay);
3875
3876
3877% --- Executes during object creation, after setting all properties.
3878function ans_nod_CreateFcn(hObject, eventdata, handles)
3879% hObject    handle to ans_nod (see GCBO)
3880% eventdata  reserved - to be defined in a future version of MATLAB
3881% handles    empty - handles not created until after all CreateFcns called
3882
3883% Hint: edit controls usually have a white background on Windows.
3884%       See ISPC and COMPUTER.
3885if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3886    set(hObject,'BackgroundColor','white');
3887end
3888
3889
3890
3891function boo_alim_cp_Callback(hObject, eventdata, handles)
3892% hObject    handle to boo_alim_cp (see GCBO)
3893% eventdata  reserved - to be defined in a future version of MATLAB
3894% handles    structure with handles and user data (see GUIDATA)
3895
3896% Hints: get(hObject,'String') returns contents of boo_alim_cp as text
3897%        str2double(get(hObject,'String')) returns contents of boo_alim_cp as a double
3898
3899
3900% --- Executes during object creation, after setting all properties.
3901function boo_alim_cp_CreateFcn(hObject, eventdata, handles)
3902% hObject    handle to boo_alim_cp (see GCBO)
3903% eventdata  reserved - to be defined in a future version of MATLAB
3904% handles    empty - handles not created until after all CreateFcns called
3905
3906% Hint: edit controls usually have a white background on Windows.
3907%       See ISPC and COMPUTER.
3908if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3909    set(hObject,'BackgroundColor','white');
3910end
Note: See TracBrowser for help on using the repository browser.