source: MML/trunk/machine/SOLEIL/common/synchro/fire_injection.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: 5.8 KB
Line 
1function [r1,r2]=fire_injection(handles)
2
3set(handles.button_injection_soft,'Enable','inactive');
4
5offset_linac=10*str2double(get(handles.lin_canon_spm_fin,'String'));     % délai fin de réglage en pas de 100 ps
6%modeinj=get(get(handles.uipanel_mode,'SelectedObject'),'Tag');           % mode soft ou 3Hz
7modeinj='togglebutton_3Hz';
8modecent=get(get(handles.uipanel_central_mode,'SelectedObject'),'Tag');  % mode rafale ou continu (cas 3Hz)
9modefill=get(handles.listbox_fillingmode,'Value');
10pattern= get(handles.listbox_fillingmode,'String');                      % mode de remplissage
11[clk1,clk2]=get_start_clk_rafale;                                        % get clk spare et soft initiaux
12table=handles.table;                                                     % table de délais
13
14
15%FileName = fullfile(getfamilydata('Directory', 'Synchro'), 'table.mat');
16FileName = [handles.DirName 'table.mat'];
17load(FileName, 'table');     % pour palier aux handles via timer non mis à jour !!!!!!
18nb=table(1) ;                % Nombre de paq
19dtour=table(2:1+nb);         % delais associés extraction, tour booster
20paq  =table(2+nb:1+2*nb);    % delais associés linac, saut de paquets
21
22
23dt=1.5; % délais pour acquisitions rendements
24
25%Initialise data pour les rendements
26try
27    q1=0;q2=0;n=0;
28    temp=tango_read_attribute2('ANS/DG/DCCT-CTRL','current');anscur0=temp.value;
29    %temp=tango_read_attribute2('ANS-C14/DG/DCCT','current');anscur0=temp.value;
30catch
31    disp('Erreur lecture DCCT, skipped')
32    anscur0=0;
33end
34
35boucle=int16(str2double(get(handles.edit_Ncycle,'String')));
36Ncoup=str2double(get(handles.edit_Ncoup,'String'));
37
38if strcmp(modeinj,'togglebutton_soft')
39    modeinj='Injection soft';
40    for k=1:boucle
41        for i=1:nb
42            clk_spare  =int32(clk1+dtour(i));
43            clk_soft=int32(clk2+dtour(i));
44            table0=int32([1 0 paq(i)]);
45            tango_command_inout2('ANS/SY/CENTRAL','SetTables',table0); pause(0.2)  ;
46            tango_write_attribute2('ANS/SY/CENTRAL', 'TSprStepDelay',clk_spare);
47            tango_write_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay',clk_soft);
48            tango_command_inout2('ANS/SY/CENTRAL','FireSoftEvent');
49            pause(dt)
50            [q1,q2,n]=getcharge(q1,q2,n);
51        end
52    end
53
54    % retour délais initiaux
55    tango_write_attribute2('ANS/SY/CENTRAL', 'TSprStepDelay',clk1);
56    tango_write_attribute2('ANS/SY/CENTRAL', 'TSoftStepDelay',clk2);
57
58elseif strcmp(modeinj,'togglebutton_3Hz')
59
60    if strcmp(modecent,'continuous_mode')
61
62        %             modelinac=get(get(handles.uipanel_lpm_spm_mode,'SelectedObject'),'Tag');
63        %             switch modelinac  % Get Tag of selected object
64        %                 case 'no_mode'
65        %                     event=[0 0];
66        %                 case 'lpm_mode'
67        %                     event=[2 0];
68        %                 case 'spm_mode'
69        %                     event=[0 2];
70        %             end
71        %
72        %             modeinj='Injection 3 Hz';
73        %             start_3Hz(event)
74        %             pause(Ncoup*0.340 + 0.340)
75        %             stop_3Hz
76
77    elseif strcmp(modecent,'burst_mode')
78
79        modeinj='Injection rafale';
80        tango_command_inout2('ANS/SY/CENTRAL','FireBurstEvent');
81        dtt=Ncoup*boucle*0.340 + 5;
82        pause(dtt) % durée rafale + pause lecture DCCT
83        [q1,q2,n]=getcharge(q1,q2,n);
84    end
85end
86
87% Calcul des rendements
88%pause(dt);
89try
90    temp=tango_read_attribute2('ANS/DG/DCCT-CTRL','current');anscur=temp.value;
91    %temp=tango_read_attribute2('ANS-C14/DG/DCCT','current');anscur=temp.value;
92catch
93    disp('Erreur lecture DCCT, skipped')
94    anscur=0;
95end
96%modeinj=get(get(handles.uipanel_mode,'SelectedObject'),'Tag');
97modinj='togglebutton_3Hz';
98dcur=anscur-anscur0;
99if strcmp(modeinj,'togglebutton_soft')
100    % moyenne sur chaque tirs
101    r1=0;if (q1~=0);r1=q2/q1*100;end
102    r2=0;if (q2~=0);r2=dcur/q2*0.524*416/184*100;end
103    if(r1<0);r1=0;elseif(r1>100);r1=100;end
104    if(r2<0);r2=0;elseif(r2>100);r2=100;end
105    q1=q1/n;q2=q2/n;dcur=dcur/n;
106else
107    % estime sur dernier tir
108    r1=0;if (q1~=0);r1=q2/q1*100;end
109    r2=0;if (q2~=0);r2=dcur/Ncoup/double(boucle)/q2*0.524*416/184*100;end
110    if(r1<0);r1=0;elseif(r1>100);r1=100;end
111    if(r2<0);r2=0;elseif(r2>100);r2=100;end
112    q1=q1/n;q2=q2/n;dcur=dcur/n;
113end
114
115set(handles.edit_qlt1,'String',num2str(q1,'%5.2f'));
116set(handles.edit_iboo,'String',num2str(q2/0.524,'%5.2f'));
117set(handles.edit_dians,'String',num2str(dcur,'%5.2f'));
118set(handles.edit_rboo,'String',num2str(int16(r1)));
119set(handles.edit_rans,'String',num2str(int16(r2)));
120set(handles.edit_cycle,'String',num2str(n,'%g'));
121set(handles.edit_dians1,'String',num2str(dcur,'%5.2f'));
122set(handles.edit_courant_total,'String', num2str(anscur,'%5.2f'));
123
124try
125    temp=tango_read_attribute2('ANS/DG/BPM-tunex','Nu'); nux=temp.value;
126    temp=tango_read_attribute2('ANS/DG/BPM-tunez','Nu'); nuz=temp.value;
127    temp=tango_read_attribute2('ANS-C03/RF/lle.1','voltageRF');v1=temp.value(1);
128    temp=tango_read_attribute2('ANS-C03/RF/lle.2','voltageRF');v2=temp.value(1);
129    temp=tango_read_attribute2('ANS-C02/RF/lle.3','voltageRF');v3=temp.value(1);
130    temp=tango_read_attribute2('ANS-C02/RF/lle.4','voltageRF');v4=temp.value(1);
131    vrf=(v1+v2+v3+v4)/1000;
132catch
133    disp('Erreur lecture tunes voltage : skipped')
134    nux = NaN;
135    nuz = NaN;
136    vrf = NaN;
137end
138
139% renseigne les rendements
140try
141    tango_write_attribute2('ANS/DG/PUB-FillingMode', 'rendement_BOO',r1)
142    tango_write_attribute2('ANS/DG/PUB-FillingMode', 'rendement_ANS',r2)
143catch
144
145end
146
147txt=modeinj;
148txt(1:13)='';
149fprintf('%s  /  %s  %d Coups  %s  /  R=%5.2f %5.2f   I=%5.3f A  /  Tunes=%5.3f %5.3f  Vrf=%5.2f MV\n',...
150    datestr(clock),txt,Ncoup*boucle,pattern{modefill},r1,r2,anscur, nux,nuz,vrf);
151
152
153set(handles.button_injection_soft,'Enable','On');
154
Note: See TracBrowser for help on using the repository browser.