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

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

Initial import--MML version from SOLEIL@2013

File size: 42.5 KB
Line 
1function varargout = RFPostMortem(varargin)
2%RFPOSTMORTEM121007 M-file for RFPostMortem121007.fig
3%      RFPOSTMORTEM121007, by itself, creates a new RFPOSTMORTEM121007 or raises the existing
4%      singleton*.
5%
6%      H = RFPOSTMORTEM121007 returns the handle to a new RFPOSTMORTEM121007 or the handle to
7%      the existing singleton*.
8%
9%      RFPOSTMORTEM121007('Property','Value',...) creates a new RFPOSTMORTEM121007 using the
10%      given property value pairs. Unrecognized properties are passed via
11%      varargin to RFPostMortem121007_OpeningFcn.  This calling syntax produces a
12%      warning when there is an existing singleton*.
13%
14%      RFPOSTMORTEM121007('CALLBACK') and RFPOSTMORTEM121007('CALLBACK',hObject,...) call the
15%      local function named CALLBACK in RFPOSTMORTEM121007.M with the given input
16%      arguments.
17%
18%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19%      instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22
23% Edit the above text to modify the response to help RFPostMortem121007
24
25% Last Modified by G+1UIDE v2.5 29-Feb-2008 13:41:07
26
27% Begin initialization code - DO NOT EDIT
28gui_Singleton = 1;
29gui_State = struct('gui_Name',       mfilename, ...
30                   'gui_Singleton',  gui_Singleton, ...
31                   'gui_OpeningFcn', @RFPostMortem_OpeningFcn, ...
32                   'gui_OutputFcn',  @RFPostMortem_OutputFcn, ...
33                   'gui_LayoutFcn',  [], ...
34                   'gui_Callback',   []);
35if nargin && ischar(varargin{1})
36   gui_State.gui_Callback = str2func(varargin{1});
37end
38
39if nargout
40    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41else
42    gui_mainfcn(gui_State, varargin{:});
43end
44% End initialization code - DO NOT EDIT
45
46% --- Executes just before RFPostMortem121007 is made visible.
47function RFPostMortem_OpeningFcn(hObject, eventdata, handles, varargin)
48% This function has no output args, see OutputFcn.
49% hObject    handle to figure
50% eventdata  reserved - to be defined in a future version of MATLAB
51% handles    structure with handles and user data (see GUIDATA)
52% varargin   unrecognized PropertyName/PropertyValue pairs from the
53%            command line (see VARARGIN)
54
55% Choose default command line output for RFPostMortem121007
56handles.output = hObject;
57
58% Update handles structure
59guidata(hObject, handles);
60
61% UIWAIT makes RFPostMortem121007 wait for user response (see UIRESUME)
62% uiwait(handles.figure1);
63
64
65% --- Outputs from this function are returned to the command line.
66function varargout = RFPostMortem_OutputFcn(hObject, eventdata, handles)
67% varargout  cell array for returning output args (see VARARGOUT);
68% hObject    handle to figure
69% eventdata  reserved - to be defined in a future version of MATLAB
70% handles    structure with handles and user data (see GUIDATA)
71
72% Get default command line output from handles structure
73varargout{1} = handles.output;
74
75
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78%                                                       CAVITE 1                                                       %
79%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81
82
83% --- Executes on button press in pushbutton1_ACQUISITION.
84function pushbutton1_ACQUISITION_Callback(hObject, eventdata, handles)
85% hObject    handle to pushbutton1_ACQUISITION (see GCBO)
86% eventdata  reserved - to be defined in a future version of MATLAB
87% handles    structure with handles and user data (see GUIDATA)
88
89%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90
91statusAcquisition_cav1=tango_read_attribute2('ANS-C03/RF/PM.1','Status');
92text=statusAcquisition_cav1.value;
93if findstr(text, 'running')
94    msgbox('Fonctionnement Normal: pas d''acquisition à faire','Info','warn');
95    return;
96   
97else
98
99    set(handles.text4_PR1,'String','Pr1');
100    set(handles.text_PR2,'String','Pr2');
101    set(handles.text_PR3,'String','Pr3');
102    set(handles.text_PR4,'String','Pr4');
103
104    rep = tango_read_attributes2('ANS-C03/RF/AMP.1-DATA', {'reflectedPowerSecurityT1','reflectedPowerSecurityT2',...
105        'reflectedPowerSecurityT3','reflectedPowerSecurityT4'});
106
107    Data.AMP1.reflectedPowerSecurityT1 = rep(1).value;
108    Data.AMP1.reflectedPowerSecurityT2 = rep(2).value;
109    Data.AMP1.reflectedPowerSecurityT3 = rep(3).value;
110    Data.AMP1.reflectedPowerSecurityT4 = rep(4).value;
111   
112   
113    if Data.AMP1.reflectedPowerSecurityT1
114     set(handles.text4_PR1,'BackgroundColor', [0 1 0]); %green
115    else
116     set(handles.text4_PR1,'BackgroundColor', [1 0 0]); %red
117    end
118   
119    if Data.AMP1.reflectedPowerSecurityT2
120     set(handles.text_PR2,'BackgroundColor', [0 1 0]); %green
121    else
122     set(handles.text_PR2,'BackgroundColor', [1 0 0]); %red
123    end
124
125    if Data.AMP1.reflectedPowerSecurityT3
126     set(handles.text_PR3,'BackgroundColor', [0 1 0]); %green
127    else
128     set(handles.text_PR3,'BackgroundColor', [1 0 0]); %red
129    end
130   
131    if Data.AMP1.reflectedPowerSecurityT4
132     set(handles.text_PR4,'BackgroundColor', [0 1 0]); %green
133    else
134     set(handles.text_PR4,'BackgroundColor', [1 0 0]); %red
135    end
136   
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
138    set(handles.text_Pi,'String','Pi');
139    set(handles.text_PSS,'String','PSS Sec');
140    set(handles.text_uC,'String','uC');
141   
142    repPSS = tango_read_attribute2('ANS-C03/RF/LLE.1','pssSecurity');
143    %rep = tango_read_attributes2('ANS-C03/RF/AMP.1-DATA', {'incidentPowerSecurity','pssSecurity','microcontrollerSecurity'});
144    rep = tango_read_attributes2('ANS-C03/RF/AMP.1-DATA', {'incidentPowerSecurity','microcontrollerSecurity'});
145   
146    Data.AMP1.incidentPowerSecurity = rep(1).value;
147    Data.AMP1.pssSecurity = repPSS.value;
148    Data.AMP1.microcontrollerSecurity=rep(2).value;
149   
150    if Data.AMP1.incidentPowerSecurity
151      set(handles.text_Pi,'BackgroundColor', [0 1 0]); %green
152    else
153      set(handles.text_Pi,'BackgroundColor', [1 0 0]); %red
154    end
155   
156    if Data.AMP1.pssSecurity
157      set(handles.text_PSS,'BackgroundColor', [0 1 0]); %green
158    else
159      set(handles.text_PSS,'BackgroundColor', [1 0 0]); %red
160    end
161   
162    if Data.AMP1.microcontrollerSecurity
163      set(handles.text_uC,'BackgroundColor', [0 1 0]); %green
164    else
165      set(handles.text_uC,'BackgroundColor', [1 0 0]); %red
166    end
167 
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
169   
170    set(handles.text_InterLCKmach,'String','Interlck MACH');
171    set(handles.text_VAC,'String','VAC');
172    set(handles.text_CRYO,'String','CRYO');
173   
174   
175    repINTER = tango_read_attribute2('ANS-C03/RF/LLE.1','machineSecurity');
176    %rep = tango_read_attributes2('ANS-C03/RF/CAV.1', {'interlock','vacuumSecurity','cryomoduleSecurity'});
177    rep = tango_read_attributes2('ANS-C03/RF/CAV.1', {'vacuumSecurity','cryomoduleSecurity'});
178   
179    Data.CAV1.interlock = repINTER.value;
180    %Data.CAV1.interlock = rep(1).value;
181    Data.CAV1.vacuum    = rep(1).value;
182    Data.CAV1.cryo = rep(2).value;
183
184    if Data.CAV1.interlock
185      set(handles.text_InterLCKmach,'BackgroundColor', [0 1 0]); %green
186    else
187        %disp (Data.CAV1.interlock);
188      set(handles.text_InterLCKmach,'BackgroundColor', [1 0 0]); %red
189    end
190   
191    if Data.CAV1.vacuum
192        %disp (Data.CAV1.vacuum);
193      set(handles.text_VAC,'BackgroundColor', [0 1 0]); %green
194    else
195        %disp (Data.CAV1.vacuum)
196      set(handles.text_VAC,'BackgroundColor', [1 0 0]); %red
197    end
198   
199    if Data.CAV1.cryo
200        %disp (Data.CAV1.cryo);
201      set(handles.text_CRYO,'BackgroundColor', [0 1 0]); %green
202    else
203        %disp (Data.CAV1.vacuum)
204      set(handles.text_CRYO,'BackgroundColor', [1 0 0]); %red
205    end
206   
207%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
208
209rep = tango_read_attributes2('ANS-C03/RF/PM.1', {'acqHighResolutionCh1', 'acqHighResolutionCh2', 'acqHighResolutionCh3', ...
210    'acqHighResolutionCh4'});
211Data.PM1.DataHR1 = rep(1).value;
212Data.PM1.DataHR2 = rep(2).value;
213Data.PM1.DataHR3 = rep(3).value;
214Data.PM1.DataHR4 = rep(4).value;
215
216Data.PM1.TimestampHR = tango_shift_time(rep(1).time);
217
218reptrig1 = tango_read_attribute2('ANS-C03/RF/PM.1','triggerTimestamp');
219Data.PM1.triggerTimestamp = reptrig1.value;
220
221[NbrColumn,NbrPoint1] = size (Data.PM1.DataHR1);
222
223axes(handles.graph1);
224   
225    name1='_AcRAPIDE'
226   
227    %pnt=1:10000;
228    pnt=1:NbrPoint1;
229
230
231    hold off;
232    plot(pnt, Data.PM1.DataHR1,'b'); hold on; grid on;
233    plot(pnt, Data.PM1.DataHR2,'r');
234    plot(pnt, Data.PM1.DataHR3,'g');
235    plot(pnt, Data.PM1.DataHR4,'k');
236    legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
237    %text(Data.PM1.triggerTimestamp);
238    xlabel('nombre de points (temps: 1 us par point)');
239    ylabel('Signal');
240
241
242
243%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
244
245DirectoryName = getfamilydata('Directory', 'RFPostmortem');
246%FileName = appendtimestamp('RFdata_CAV1', Data.PM1.TimestampHR);
247%COMMENT% FileName = appendtimestamp('RFdata_CAV1', Data.PM1.triggerTimestamp);
248%FileName = appendtimestamp('RFdata_CAV1', Data.PM1.triggerTimestamp);
249FileName =['RFdata_CAV1_', Data.PM1.triggerTimestamp];
250%FileName = strcat(FileName,name1);
251%button group
252
253[token,remain]=strtok(FileName);
254res=datevec(remain);
255resp1=num2str(res(1));
256resp2=num2str(res(2));
257resp3=num2str(res(3));
258resp4=num2str(res(4));
259resp5=num2str(res(5));
260resp6=num2str(res(6));
261FileNameLAST=strcat('RFdata_CAV1','_',resp1,'-',resp2,'-',resp3,'_',resp4,'h',resp5,'mn',resp6,'s');
262disp (FileNameLAST);
263
264[FileNameLAST, DirectoryName] = uiputfile('*.mat', 'Select File (Cancel to not save to a file)', [DirectoryName FileNameLAST, '.mat']);
265if FileNameLAST == 0
266    disp('   No data saved');
267    return;
268    %RFdata_2007-10-10_13-48-23.mat
269end
270
271DirStart = pwd;
272[DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
273save(FileNameLAST, 'Data');
274cd(DirStart);
275fprintf('   Data saved to %s\n', [DirectoryName FileNameLAST]);
276
277setappdata(handles.figure1, 'RFdata_CAV1', Data);
278
279end
280%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
281
282
283
284% --- Executes on button press in pushbutton2_CLEA*.matR.
285function pushbutton2_CLEAR_Callback(hObject, eventdata, handles)
286% hObject    handle to pushbutton2_CLEAR (see GCBO)
287% eventdata  reserved - to be defined in a future version of MATLAB
288% handles    structure*.mat with handles and user data (see GUIDATA)
289
290axes(handles.graph1);
291hold off;
292plot(NaN);
293
294
295set(handles.text4_PR1,'BackgroundColor', [0.702 0.702 0.702]); %gray
296set(handles.text_PR2,'BackgroundColor', [0.702 0.702 0.702]); %gray
297set(handles.text_PR3,'BackgroundColor', [0.702 0.702 0.702]); %gray
298set(handles.text_PR4,'BackgroundColor', [0.702 0.702 0.702]); %gray
299   
300set(handles.text_Pi,'BackgroundColor', [0.702 0.702 0.702]); %gray
301set(handles.text_PSS,'BackgroundColor', [0.702 0.702 0.702]); %gray
302set(handles.text_uC,'BackgroundColor', [0.702 0.702 0.702]); %gray
303 
304set(handles.text_InterLCKmach,'BackgroundColor', [0.702 0.702 0.702]); %gray
305set(handles.text_VAC,'BackgroundColor', [0.702 0.702 0.702]); %gray
306set(handles.text_CRYO,'BackgroundColor', [0.702 0.702 0.702]); %gray
307   
308
309%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
310
311%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312
313% --- Executes on button press in pushbutton_Open.
314function pushbutton_Open_Callback(hObject, eventdata, handles)
315% hObject    handle to pushbutton_Open (see GCBO)
316% eventdata  reserved - to be defined in a future version of MATLAB
317% handles    structure with handles and user data (see GUIDATA)
318
319DirectoryName = getfamilydata('Directory', 'RFPostmortem');
320DirStart = pwd;
321DirectoryName = gotodirectory(DirectoryName);
322[FileName, DirectoryName] = uigetfile('*.mat', 'Select File (Cancel to not save to a file)','RFdata_CAV1*');
323disp (FileName);
324
325global DirectoryNameGlobal;
326DirectoryNameGlobal=DirectoryName;
327global FileNameGlobal;
328FileNameGlobal=FileName;
329
330if FileName == 0
331    msgbox('No file chosen','Info','warn');
332    %disp('   No file chosen');
333    return;
334else
335    load(FileName, 'Data');
336end
337cd(DirStart);
338
339setappdata(handles.figure1, 'RFdata_CAV1', Data);
340
341
342
343if Data.AMP1.reflectedPowerSecurityT1
344    set(handles.text4_PR1,'BackgroundColor', [0 1 0]); %green
345else
346    set(handles.text4_PR1,'BackgroundColor', [1 0 0]); %red
347end
348
349if Data.AMP1.reflectedPowerSecurityT2
350    set(handles.text_PR2,'BackgroundColor', [0 1 0]); %green
351else
352    set(handles.text_PR2,'BackgroundColor', [1 0 0]); %red
353end   
354
355if Data.AMP1.reflectedPowerSecurityT3
356    set(handles.text_PR3,'BackgroundColor', [0 1 0]); %green
357else
358    set(handles.text_PR3,'BackgroundColor', [1 0 0]); %red
359end
360
361if Data.AMP1.reflectedPowerSecurityT4
362    set(handles.text_PR4,'BackgroundColor', [0 1 0]); %green
363else
364    set(handles.text_PR4,'BackgroundColor', [1 0 0]); %red
365end
366
367
368if Data.AMP1.incidentPowerSecurity
369    set(handles.text_Pi,'BackgroundColor', [0 1 0]); %green
370else
371    set(handles.text_Pi,'BackgroundColor', [1 0 0]); %red
372end
373   
374if Data.AMP1.pssSecurity
375    set(handles.text_PSS,'BackgroundColor', [0 1 0]); %green
376else
377    set(handles.text_PSS,'BackgroundColor', [1 0 0]); %red
378end
379   
380if Data.AMP1.microcontrollerSecurity
381    set(handles.text_uC,'BackgroundColor', [0 1 0]); %green
382else
383    set(handles.text_uC,'BackgroundColor', [1 0 0]); %red
384end
385
386if Data.CAV1.interlock
387    set(handles.text_InterLCKmach,'BackgroundColor', [0 1 0]); %green
388else
389    set(handles.text_InterLCKmach,'BackgroundColor', [1 0 0]); %red
390end
391   
392if Data.CAV1.vacuum
393    set(handles.text_VAC,'BackgroundColor', [0 1 0]); %green
394else
395    set(handles.text_VAC,'BackgroundColor', [1 0 0]); %red
396end
397   
398if Data.CAV1.cryo
399    set(handles.text_CRYO,'BackgroundColor', [0 1 0]); %green
400else
401    set(handles.text_CRYO,'BackgroundColor', [1 0 0]); %red
402end
403
404axes(handles.graph1);
405
406[NbrColumn,NbrPoint2] = size (Data.PM1.DataHR1);
407
408    %%Data.PM1.DataHR1 = -(Data.PM1.DataHR1/5)*10^6; 
409    %disp (Data.PM1.DataHR1(2));
410    %%Data.PM1.DataHR2 = ((0.0361 + 0.2542*Data.PM1.DataHR2 - 0.0112*Data.PM1.DataHR2.^2 + 0.0011*Data.PM1.DataHR2.^3).^2/50)*2.74*10^7;
411    %%Data.PM1.DataHR3 = ((0.0361 + 0.2542*Data.PM1.DataHR3 - 0.0112*Data.PM1.DataHR3.^2 + 0.0011*Data.PM1.DataHR3.^3).^2/50)*8.2*10^5;
412    %%Data.PM1.DataHR4 = (Data.PM1.DataHR4)*10^4;
413
414    %global NbrPoint
415    %[NbrColumn,NbrPoint2] = size (Data.PM1.DataHR1);
416    %NbrPoint2=10000;
417
418hold off;
419pnt=[1:NbrPoint2];
420
421    %pnt=1:NbrPoint2;
422
423    %hold on; grid on;
424    %//pnt1=1:200000;
425    %//pnt2=1:200000;
426        %[haxes,hline1,hline2,hline3]=plotyy(pnt,Data.PM1.DataHR1,pnt,Data.PM1.DataHR2,pnt,Data.PM1.DataHR3);
427    %[haxes,hline1,hline2]=plotyy(pnt,Data.PM1.DataHR1,pnt,Data.PM1.DataHR2);
428    %//[haxes,hline1,hline2]=plotyy(pnt1,Data.PM1.DataHR1,pnt2,Data.PM1.DataHR2,'plot');
429    %//set(hline1,'Color','b');
430    %//set(hline2,'Color','r');
431    %//axes(haxes(1));%110108%
432    %110108%axis([valmin valmax minHR1app maxHR1app]);%110108%
433    %110108%set(gca,'YTick',minHR1app:((maxHR1app-minHR1app)/10):maxHR1app);%110108%
434        %[haxes,hline3,hline4]=plotyy(pnt,Data.PM1.DataHR3,pnt,Data.PM1.DataHR4);
435plot(pnt, Data.PM1.DataHR1,'b'); hold on; grid on;
436plot(pnt, Data.PM1.DataHR2,'r');
437plot(pnt, Data.PM1.DataHR3,'g');
438plot(pnt, Data.PM1.DataHR4,'k');
439legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
440%%legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi');
441xlabel('nombre de points (temps: 1 us par point)');
442 
443    %zoom on;
444    %//ylabel('Vcav [V]','Color','b');
445ylabel('Signal');
446    %//ylabel('Vcav [V]');
447    %LegVcav=legend('Ac. Rapide CH1: Vcav');
448    %121108 set(LegVcav,'Location','NorthWest');
449    %set(LegVcav,'background','g');
450    %//axes(haxes(2));
451    %110108%axis([valmin valmax minapp1 maxapp1]);%110108%
452    %110108%set(gca,'YTick',minapp1:((maxapp1-minapp1)/10):maxapp1);%110108%
453    %//axis auto;
454    %axes(h,'Color','b');
455    %//ylabel('Power [Watts]');
456    %//hold on; grid on;
457    %//plot(pnt2,Data.PM1.DataHR3,'y');
458
459    %hold on; grid on;
460    %//plot(pnt2, Data.PM1.DataHR4,'k');
461    %//LegPuissance=legend('Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
462    %legend('Ac. Rapide CH4: Ib');
463    %ylabel('Signal');
464text(1000,0.5,Data.PM1.triggerTimestamp);
465
466   
467
468
469
470
471
472
473
474% --- Executes on button press in pushbutton13.
475function pushbutton13_Callback(hObject, eventdata, handles)
476% hObject    handle to pushbutton13 (see GCBO)
477% eventdata  reserved - to be defined in a future version of MATLAB
478% handles    structure with handles and user data (see GUIDATA)
479
480valmax=1;
481valmin=0;
482
483valminINIT=get(handles.edit2,'String');
484valmin=str2num(valminINIT{1});
485valmaxINIT=get(handles.edit3,'String');
486valmax=str2num(valmaxINIT{1});
487
488n=valmax-valmin+1;
489i=1;
490
491global DirectoryNameGlobal;
492disp ('DirectoryNameGlobal');
493gotodirectory(DirectoryNameGlobal);
494
495global FileNameGlobal;
496load(FileNameGlobal, 'Data');   
497
498for i=1:n
499    %matAbscisse(i)=valmin+i-1;
500    %matHR1(i)=Data.PM1.DataHR1(i);
501    %matHR1(i)=-(Data.PM1.DataHR1(valmin+i-1)/5)*10^6;
502    Data.PM1.DataHR1(valmin+i-1)=-((Data.PM1.DataHR1(valmin+i-1))/5)*10^2;
503    %Data.PM1.DataHR1=-Data.PM1.DataHR1(1,valmin:valmax)*10;
504    %matHR2(i)=Data.PM1.DataHR2(i);
505    %matHR2(i)=((0.0361 + 0.2542*Data.PM1.DataHR2(valmin+i-1) - 0.0112*Data.PM1.DataHR2(valmin+i-1).^2 + 0.0011*Data.PM1.DataHR2(valmin+i-1).^3).^2/50)*2.74*10^7;
506    Data.PM1.DataHR2(valmin+i-1)=((0.0361 + 0.2542*Data.PM1.DataHR2(valmin+i-1) - 0.0112*Data.PM1.DataHR2(valmin+i-1).^2 + 0.0011*Data.PM1.DataHR2(valmin+i-1).^3).^2/50)*2.74*10^4;
507    %%Data.PM1.DataHR2=Data.PM1.DataHR2*12;
508    %matHR3(i)=Data.PM1.DataHR3(i);
509    %matHR3(i)=((0.0361 + 0.2542*Data.PM1.DataHR3(valmin+i-1) - 0.0112*Data.PM1.DataHR3(valmin+i-1).^2 + 0.0011*Data.PM1.DataHR3(valmin+i-1).^3).^2/50)*8.2*10^5;
510    Data.PM1.DataHR3(valmin+i-1)=((0.0361 + 0.2542*Data.PM1.DataHR3(valmin+i-1) - 0.0112*Data.PM1.DataHR3(valmin+i-1).^2 + 0.0011*Data.PM1.DataHR3(valmin+i-1).^3).^2/50)*8.2*10^2;
511    %%Data.PM1.DataHR3=Data.PM1.DataHR3*14;
512    %matHR4(i)=Data.PM1.DataHR4(i);
513    %matHR4(i)=(Data.PM1.DataHR4(valmin+i-1))*10^3;
514    Data.PM1.DataHR4(valmin+i-1)=(Data.PM1.DataHR4(valmin+i-1))*10^2;
515    %%Data.PM1.DataHR4=Data.PM1.DataHR4*16;
516end
517
518maxHR1=max(Data.PM1.DataHR1);
519maxHR2=max(Data.PM1.DataHR2);
520maxHR3=max(Data.PM1.DataHR3);
521maxHR4=max(Data.PM1.DataHR4);
522minHR1=min(Data.PM1.DataHR1);
523minHR2=min(Data.PM1.DataHR2);
524minHR3=min(Data.PM1.DataHR3);
525minHR4=min(Data.PM1.DataHR4);
526
527if (maxHR2(1)>maxHR3(1))
528    max1=maxHR2(1)
529else max1=maxHR3(1);
530end
531if (max1<maxHR4(1))
532    max1=maxHR4(1);
533end
534
535if (minHR2(1)<minHR3(1))
536   min1=minHR2(1)
537else min1=minHR3(1);
538end
539if (min1>minHR4(1))
540    min1=minHR4(1);
541end
542
543%minapp1=min1;
544%maxapp1=max1;
545minHR1app=minHR1(1);
546maxHR1app=maxHR1(1);
547
548if (minHR1app<min1)
549    mini=minHR1
550else
551    mini=min1
552end
553
554if (maxHR1app>max1)
555    maxi=maxHR1
556else
557    maxi=max1
558end
559
560axes(handles.graph1);
561
562
563hold off;
564pnt=[valmin:valmax];
565axis([valmin valmax mini maxi]);
566set(gca,'XTick',[valmin valmax]);
567plot(Data.PM1.DataHR1,'b'); hold on; grid on;
568axis([valmin valmax mini maxi])
569plot(Data.PM1.DataHR2,'r');
570plot(Data.PM1.DataHR3,'g');
571plot(Data.PM1.DataHR4,'k');
572legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
573xlabel('nombre de points (temps: 1 us par point)');
574ylabel('Signal');
575text(1000,0.5,Data.PM1.triggerTimestamp);
576
577
578
579%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581
582% --- Executes on button press in pushbutton_RESET_cav1.
583function pushbutton_RESET_cav1_Callback(hObject, eventdata, handles)
584% hObject    handle to pushbutton_RESET_cav1 (see GCBO)
585% eventdata  reserved - to be defined in a future version of MATLAB
586% handles    structure with handles and user data (see GUIDATA)
587
588%DirectoryNameESP='/home/operateur/GrpRF/Nicolas';
589%DirectoryNameESP = gotodirectory(DirectoryNameESP);
590%FilenameESP='ESP';
591%load(Filename);
592
593statusAcquisition_cav1=tango_read_attribute2('ANS-C03/RF/PM.1','Status');
594text=statusAcquisition_cav1.value;
595if findstr(text, 'running')
596    msgbox('Un reset a déjà été fait, le device fonctionne Normalement','Info','warn');
597    return;
598else
599    set(handles.pushbutton_RESET_cav1,'Tag','pushbutton_RESET_cav1');
600    %set(handles.pushbutton_RESET_cav1,'String','RESET');
601    %tango_command_inout2('ANS-C03/RF/PM.1','Init');
602    tango_command_inout2('ANS-C03/RF/PM.1','Start');
603   
604    fid=0;
605    filenameRES='/home/operateur/GrpRF/Nicolas/SUIVIreset';
606    %filenameRES='TESTres';
607    fid=fopen(filenameRES,'a+');
608    %disp (fid);
609    %disp ('2');
610    %valeurTEST='test11111';
611    valeurTEST=datestr(clock,0);
612   
613    fprintf(fid,'Reset CAV1 at: %s \n',valeurTEST);
614    fclose(fid);
615    %DateReset = clock;
616end
617
618%tango_command_inout2('ANS-C03/RF/PM.1','Stop'); %NE PAS OUBLIER D'ENLEVER CETTE LIGNE APRES TEST
619
620
621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623%                                                       CAVITE 2                                                       %
624%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626
627% --- Executes on button press in pushbutton_cav2_Acquisition.
628function pushbutton_cav2_Acquisition_Callback(hObject, eventdata, handles)
629% hObject    handle to pushbutton_cav2_Acquisition (see GCBO)
630% eventdata  reserved - to be defined in a future version of MATLAB
631% handles    structure with handles and user data (see GUIDATA)
632
633%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
634
635statusAcquisition_cav2=tango_read_attribute2('ANS-C03/RF/PM.2','Status');
636text=statusAcquisition_cav2.value;
637if findstr(text, 'running')
638    msgbox('Fonctionnement Normal: pas d''acquisition à faire','Info','warn');
639    return;
640   
641else
642
643set(handles.text_cav2_PR1,'String','Pr1');
644set(handles.text_cav2_PR2,'String','Pr2');
645set(handles.text_cav2_PR3,'String','Pr3');
646set(handles.text_cav2_PR4,'String','Pr4');
647
648rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'reflectedPowerSecurityT1','reflectedPowerSecurityT2',...
649        'reflectedPowerSecurityT3','reflectedPowerSecurityT4'});
650
651%%rep = tango_read_attribute2('ANS-C03/RF/AMP.2-DATA','reflectedPowerSecurityT1')
652
653%%Data.AMP2.reflectedPowerSecurityT1 = rep.value;   
654Data.AMP2.reflectedPowerSecurityT1 = rep(1).value;
655Data.AMP2.reflectedPowerSecurityT2 = rep(2).value;
656Data.AMP2.reflectedPowerSecurityT3 = rep(3).value;
657Data.AMP2.reflectedPowerSecurityT4 = rep(4).value;
658   
659if Data.AMP2.reflectedPowerSecurityT1
660    set(handles.text_cav2_PR1,'BackgroundColor', [0 1 0]); %green
661else
662    set(handles.text_cav2_PR1,'BackgroundColor', [1 0 0]); %red
663end
664   
665if Data.AMP2.reflectedPowerSecurityT2
666    set(handles.text_cav2_PR2,'BackgroundColor', [0 1 0]); %green
667else
668    set(handles.text_cav2_PR2,'BackgroundColor', [1 0 0]); %red
669end
670
671if Data.AMP2.reflectedPowerSecurityT3
672    set(handles.text_cav2_PR3,'BackgroundColor', [0 1 0]); %green
673else
674    set(handles.text_cav2_PR3,'BackgroundColor', [1 0 0]); %red
675end
676   
677if Data.AMP2.reflectedPowerSecurityT4
678    set(handles.text_cav2_PR4,'BackgroundColor', [0 1 0]); %green
679else
680    set(handles.text_cav2_PR4,'BackgroundColor', [1 0 0]); %red
681end
682
683%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
684
685rep = tango_read_attributes2('ANS-C03/RF/PM.2', {'acqHighResolutionCh1', 'acqHighResolutionCh2', 'acqHighResolutionCh3', ...
686    'acqHighResolutionCh4'});
687Data.PM2.DataHR1 = rep(1).value;
688Data.PM2.DataHR2 = rep(2).value;
689Data.PM2.DataHR3 = rep(3).value;
690Data.PM2.DataHR4 = rep(4).value;
691
692Data.PM2.TimestampHR = tango_shift_time(rep(1).time);
693
694reptrig2 = tango_read_attribute2('ANS-C03/RF/PM.2','triggerTimestamp');
695Data.PM2.triggerTimestamp = reptrig2.value;
696
697[NbrColumn,NbrPoint3] = size (Data.PM2.DataHR1);
698
699axes(handles.graph2);
700   
701    name2='_AcRAPIDE'
702   
703    %pnt=1:10000;
704    pnt=1:NbrPoint3;
705
706    hold off;
707    plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
708    plot(pnt, Data.PM2.DataHR2,'r');
709    plot(pnt, Data.PM2.DataHR3,'g');
710    plot(pnt, Data.PM2.DataHR4,'k');
711    legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
712    xlabel('nombre de points (temps: 1 us par point)');
713    ylabel('Signal');
714
715%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
716
717set(handles.text_cav2_PI,'String','Pi');
718set(handles.text_cav2_PSS,'String','PSS Sec');
719set(handles.text_cav2_uC,'String','uC');
720   
721repPSS = tango_read_attribute2('ANS-C03/RF/LLE.2','pssSecurity');
722    %rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'incidentPowerSecurity','pssSecurity','microcontrollerSecurity'});
723    rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'incidentPowerSecurity','microcontrollerSecurity'});
724   
725    Data.AMP2.incidentPowerSecurity = rep(1).value;
726    Data.AMP2.pssSecurity = repPSS.value;
727    Data.AMP2.microcontrollerSecurity=rep(2).value;
728   
729    if Data.AMP2.incidentPowerSecurity
730      set(handles.text_cav2_PI,'BackgroundColor', [0 1 0]); %green
731    else
732      set(handles.text_cav2_PI,'BackgroundColor', [1 0 0]); %red
733    end
734   
735    if Data.AMP2.pssSecurity
736      set(handles.text_cav2_PSS,'BackgroundColor', [0 1 0]); %green
737    else
738      set(handles.text_cav2_PSS,'BackgroundColor', [1 0 0]); %red
739    end
740   
741    if Data.AMP2.microcontrollerSecurity
742      set(handles.text_cav2_uC,'BackgroundColor', [0 1 0]); %green
743    else
744      set(handles.text_cav2_uC,'BackgroundColor', [1 0 0]); %red
745    end
746   
747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
748
749 set(handles.text_cav2_InterLCKmach,'String','Interlck MACH');
750 set(handles.text_cav2_VAC,'String','VAC');
751 set(handles.text_cav2_CRYO,'String','CRYO');
752   
753 repINTER = tango_read_attribute2('ANS-C03/RF/LLE.2','machineSecurity');
754    %rep = tango_read_attributes2('ANS-C03/RF/CAV.2', {'interlock','vacuumSecurity','cryomoduleSecurity'});
755    rep = tango_read_attributes2('ANS-C03/RF/CAV.2', {'vacuumSecurity','cryomoduleSecurity'});
756   
757    Data.CAV2.interlock = repINTER.value;
758    %Data.CAV2.interlock = rep(1).value;
759    Data.CAV2.vacuum    = rep(1).value;
760    Data.CAV2.cryo = rep(2).value;
761
762    if Data.CAV2.interlock
763      set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0 1 0]); %green
764    else
765        %disp (Data.CAV2.interlock);
766      set(handles.text_cav2_InterLCKmach,'BackgroundColor', [1 0 0]); %red
767    end
768   
769    if Data.CAV2.vacuum
770        %disp (Data.CAV2.vacuum);
771      set(handles.text_cav2_VAC,'BackgroundColor', [0 1 0]); %green
772    else
773        %disp (Data.CAV2.vacuum)
774      set(handles.text_cav2_VAC,'BackgroundColor', [1 0 0]); %red
775    end
776   
777    if Data.CAV2.cryo
778        %disp (Data.CAV2.cryo);
779      set(handles.text_cav2_CRYO,'BackgroundColor', [0 1 0]); %green
780    else
781        %disp (Data.CAV2.vacuum)
782      set(handles.text_cav2_CRYO,'BackgroundColor', [1 0 0]); %red
783    end
784   
785%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%   
786
787DirectoryName = getfamilydata('Directory', 'RFPostmortem');
788%FileName = appendtimestamp('RFdata_CAV2', Data.PM2.TimestampHR);
789%comment% FileName = appendtimestamp('RFdata_CAV2', Data.PM2.triggerTimestamp);
790%disp (Data.PM2.triggerTimestamp);
791%disp (datevec(Data.PM2.triggerTimestamp));
792%FileName = appendtimestamp('RFdata_CAV2', Data.PM2.triggerTimestamp);
793FileName =['RFdata_CAV2_', Data.PM2.triggerTimestamp];
794
795[token,remain]=strtok(FileName);
796res=datevec(remain);
797resp1=num2str(res(1));
798resp2=num2str(res(2));
799resp3=num2str(res(3));
800resp4=num2str(res(4));
801resp5=num2str(res(5));
802resp6=num2str(res(6));
803FileNameLAST2=strcat('RFdata_CAV2','_',resp1,'-',resp2,'-',resp3,'_',resp4,'h',resp5,'mn',resp6,'s');
804disp (FileNameLAST2);
805
806%FileName = strcat(FileName,name2);
807%button group
808[FileNameLAST2, DirectoryName] = uiputfile('*.mat', 'Select File (Cancel to not save to a file)', [DirectoryName FileNameLAST2, '.mat']);
809if FileNameLAST2 == 0
810    disp('   No data saved');
811    return;
812    %RFdata_2007-10-10_13-48-23.mat
813end
814
815DirStart = pwd;
816[DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
817save(FileNameLAST2, 'Data');
818cd(DirStart);
819fprintf('   Data saved to %s\n', [DirectoryName FileNameLAST2]);
820
821setappdata(handles.figure1, 'RFdata_CAV2', Data);   
822
823
824end
825 
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
827 
828% --- Executes on button press in pushbutton_cav2_OPEN.
829function pushbutton_cav2_OPEN_Callback(hObject, eventdata, handles)
830% hObject    handle to pushbutton_cav2_OPEN (see GCBO)
831% eventdata  reserved - to be defined in a future version of MATLAB
832% handles    structure with handles and user data (see GUIDATA)
833   
834DirectoryName = getfamilydata('Directory', 'RFPostmortem');
835
836DirStart = pwd;
837DirectoryName = gotodirectory(DirectoryName);
838[FileName, DirectoryName] = uigetfile('*.mat', 'Select File (Cancel to not save to a file)','RFdata_CAV2*');
839
840global DirectoryNameGlobal;
841DirectoryNameGlobal=DirectoryName;
842global FileNameGlobal;
843FileNameGlobal=FileName;
844
845if FileName == 0
846    msgbox('No file chosen','Info','warn');
847    %disp('   No file chosen');
848    return;
849else
850    load(FileName, 'Data');
851end
852cd(DirStart);
853
854setappdata(handles.figure1, 'RFdata_CAV2', Data);
855
856%disp (Data.PM2.DataLR);
857
858
859
860if Data.AMP2.reflectedPowerSecurityT1
861    set(handles.text_cav2_PR1,'BackgroundColor', [0 1 0]); %green
862else
863    set(handles.text_cav2_PR1,'BackgroundColor', [1 0 0]); %red
864end
865
866if Data.AMP2.reflectedPowerSecurityT2
867    set(handles.text_cav2_PR2,'BackgroundColor', [0 1 0]); %green
868else
869    set(handles.text_cav2_PR2,'BackgroundColor', [1 0 0]); %red
870end   
871
872if Data.AMP2.reflectedPowerSecurityT3
873    set(handles.text_cav2_PR3,'BackgroundColor', [0 1 0]); %green
874else
875    set(handles.text_cav2_PR3,'BackgroundColor', [1 0 0]); %red
876end
877
878if Data.AMP2.reflectedPowerSecurityT4
879    set(handles.text_cav2_PR4,'BackgroundColor', [0 1 0]); %green
880else
881    set(handles.text_cav2_PR4,'BackgroundColor', [1 0 0]); %red
882end
883
884
885
886if Data.AMP2.incidentPowerSecurity
887    set(handles.text_cav2_PI,'BackgroundColor', [0 1 0]); %green
888else
889    set(handles.text_cav2_PI,'BackgroundColor', [1 0 0]); %red
890end
891   
892if Data.AMP2.pssSecurity
893    set(handles.text_cav2_PSS,'BackgroundColor', [0 1 0]); %green
894else
895    set(handles.text_cav2_PSS,'BackgroundColor', [1 0 0]); %red
896end
897   
898if Data.AMP2.microcontrollerSecurity
899    set(handles.text_cav2_uC,'BackgroundColor', [0 1 0]); %green
900else
901    set(handles.text_cav2_uC,'BackgroundColor', [1 0 0]); %red
902end
903
904if Data.CAV2.interlock
905    set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0 1 0]); %green
906else
907    set(handles.text_cav2_InterLCKmach,'BackgroundColor', [1 0 0]); %red
908end
909   
910if Data.CAV2.vacuum
911    set(handles.text_cav2_VAC,'BackgroundColor', [0 1 0]); %green
912else
913    set(handles.text_cav2_VAC,'BackgroundColor', [1 0 0]); %red
914end
915   
916if Data.CAV2.cryo
917    set(handles.text_cav2_CRYO,'BackgroundColor', [0 1 0]); %green
918else
919    set(handles.text_cav2_CRYO,'BackgroundColor', [1 0 0]); %red
920end
921
922axes(handles.graph2);
923
924
925[NbrColumn,NbrPoint4] = size (Data.PM2.DataHR1);
926
927%//Data.PM2.DataHR1 = -(Data.PM2.DataHR1/5)*10^6;   
928%//Data.PM2.DataHR2 = ((0.0361 + 0.2542*Data.PM2.DataHR2 - 0.0112*Data.PM2.DataHR2.^2 + 0.0011*Data.PM2.DataHR2.^3).^2/50)*3.0*10^7;
929%//Data.PM2.DataHR3 = ((0.0361 + 0.2542*Data.PM2.DataHR3 - 0.0112*Data.PM2.DataHR3.^2 + 0.0011*Data.PM2.DataHR3.^3).^2/50)*10.5*10^5;
930%//Data.PM2.DataHR4 = (Data.PM2.DataHR4)*10^4;     
931
932hold off;
933%hold on; grid on;
934
935pnt=[1:NbrPoint4];
936
937%//pnt1=1:10000;
938%//pnt2=1:10000;
939        %[haxes,hline1,hline2,hline3]=plotyy(pnt,Data.PM2.DataHR1,pnt,Data.PM2.DataHR2,pnt,Data.PM2.DataHR3);
940%[haxes,hline1,hline2]=plotyy(pnt,Data.PM2.DataHR1,pnt,Data.PM2.DataHR2);
941%//[haxes,hline1,hline2]=plotyy(pnt1,Data.PM2.DataHR1,pnt2,Data.PM2.DataHR2,'plot');
942%//set(hline1,'Color','b');
943%//set(hline2,'Color','r');
944        %[haxes,hline3,hline4]=plotyy(pnt,Data.PM2.DataHR3,pnt,Data.PM2.DataHR4);
945plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
946plot(pnt, Data.PM2.DataHR2,'r');
947plot(pnt, Data.PM2.DataHR3,'g');
948plot(pnt, Data.PM2.DataHR4,'k');
949legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
950    %%legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi');
951xlabel('nombre de points (temps: 1 us par point)');
952    %//axes(haxes(1));
953    %//axis auto;
954    %zoom on;
955    %ylabel('Vcav [V]','Color','b');
956    %//ylabel('Vcav [V]');
957ylabel('Signal');
958    %//LegVcav=legend('Ac. Rapide CH1: Vcav');
959    %//set(LegVcav,'Location','NorthWest');
960    %set(LegVcav,'background','g');
961    %//axes(haxes(2));
962    %//axis auto;
963    %axes(h,'Color','b');
964    %//ylabel('Power [Watts]');
965    %//hold on; grid on;
966    %//plot(pnt2,Data.PM2.DataHR3,'y');
967
968    %hold on; grid on;
969    %//plot(pnt2, Data.PM2.DataHR4,'k');
970    %//LegPuissance=legend('Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
971    %legend('Ac. Rapide CH4: Ib');
972    %ylabel('Signal');
973text(1000,0.5,Data.PM2.triggerTimestamp);
974   
975   
976    %SAVED
977    %hold off;
978    %pnt=1:10000;
979    %plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
980    %plot(pnt, Data.PM2.DataHR2,'r');
981    %plot(pnt, Data.PM2.DataHR3,'g');
982    %plot(pnt, Data.PM2.DataHR4,'k');
983    %legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
984    %text(1000,0.5,Data.PM2.triggerTimestamp);
985    %xlabel('nombre de points (temps: 1 us par point)');
986    %ylabel('Signal');
987
988
989
990
991
992
993%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994
995% --- Executes on button press in pushbutton_cav2_clear.
996function pushbutton_cav2_clear_Callback(hObject, eventdata, handles)
997% hObject    handle to pushbutton_cav2_clear (see GCBO)
998% eventdata  reserved - to be defined in a future version of MATLAB
999% handles    structure with handles and user data (see GUIDATA)
1000
1001axes(handles.graph2);
1002hold off;
1003plot(NaN);
1004
1005set(handles.text_cav2_PR1,'BackgroundColor', [0.702 0.702 0.702]); %gray
1006set(handles.text_cav2_PR2,'BackgroundColor', [0.702 0.702 0.702]); %gray
1007set(handles.text_cav2_PR3,'BackgroundColor', [0.702 0.702 0.702]); %gray
1008set(handles.text_cav2_PR4,'BackgroundColor', [0.702 0.702 0.702]); %gray
1009   
1010set(handles.text_cav2_PI,'BackgroundColor', [0.702 0.702 0.702]); %gray
1011set(handles.text_cav2_PSS,'BackgroundColor', [0.702 0.702 0.702]); %gray
1012set(handles.text_cav2_uC,'BackgroundColor', [0.702 0.702 0.702]); %gray
1013 
1014set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0.702 0.702 0.702]); %gray
1015set(handles.text_cav2_VAC,'BackgroundColor', [0.702 0.702 0.702]); %gray
1016set(handles.text_cav2_CRYO,'BackgroundColor', [0.702 0.702 0.702]); %gray
1017
1018%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1019%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020
1021% --- Executes on button press in pushbutton_RESET_cav2.
1022function pushbutton_RESET_cav2_Callback(hObject, eventdata, handles)
1023% hObject    handle to pushbutton_RESET_cav2 (see GCBO)
1024% eventdata  reserved - to be defined in a future version of MATLAB
1025% handles    structure with handles and user data (see GUIDATA)
1026
1027statusAcquisition_cav2=tango_read_attribute2('ANS-C03/RF/PM.2','Status');
1028text=statusAcquisition_cav2.value;
1029if findstr(text, 'running')
1030    %%set(handles.pushbutton_RESET_cav2,'String','NO need reset, Device is Running');
1031    msgbox('Un reset a déjà été fait, le device fonctionne Normalement','Info','warn');
1032    return;
1033else
1034    set(handles.pushbutton_RESET_cav2,'Tag','pushbutton_RESET_cav2');
1035    %tango_command_inout2('ANS-C03/RF/PM.2','Init');
1036    tango_command_inout2('ANS-C03/RF/PM.2','Start');
1037   
1038    fid=0;
1039    filenameRES='/home/operateur/GrpRF/Nicolas/SUIVIreset';
1040    %filenameRES='TESTres';
1041    fid=fopen(filenameRES,'a+');
1042    %disp (fid);
1043    %disp ('2');
1044    %valeurTEST='test11111';
1045    valeurTEST=datestr(clock,0);
1046   
1047    fprintf(fid,'Reset CAV2 at: %s \n',valeurTEST);
1048    fclose(fid);
1049end
1050
1051%tango_command_inout2('ANS-C03/RF/PM.2','Stop'); %NE PAS OUBLIER D'ENLEVER CETTE LIGNE APRES TEST
1052
1053
1054% --- Executes on button press in pushbutton12.
1055function pushbutton12_Callback(hObject, eventdata, handles)
1056% hObject    handle to pushbutton12 (see GCBO)
1057% eventdata  reserved - to be defined in a future version of MATLAB
1058% handles    structure with handles and user data (see GUIDATA)
1059
1060
1061function edit2_Callback(hObject, eventdata, handles)
1062% hObject    handle to edit2 (see GCBO)
1063% eventdata  reserved - to be defined in a future version of MATLAB
1064% handles    structure with handles and user data (see GUIDATA)
1065
1066% Hints: get(hObject,'String') returns contents of edit2 as text
1067%        str2double(get(hObject,'String')) returns contents of edit2 as a double
1068
1069
1070% --- Executes during object creation, after setting all properties.
1071function edit2_CreateFcn(hObject, eventdata, handles)
1072% hObject    handle to edit2 (see GCBO)
1073% eventdata  reserved - to be defined in a future version of MATLAB
1074% handles    empty - handles not created until after all CreateFcns called
1075
1076% Hint: edit controls usually have a white background on Windows.
1077%       See ISPC and COMPUTER.
1078if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1079    set(hObject,'BackgroundColor','white');
1080end
1081
1082
1083
1084function edit3_Callback(hObject, eventdata, handles)
1085% hObject    handle to edit3 (see GCBO)
1086% eventdata  reserved - to be defined in a future version of MATLAB
1087% handles    structure with handles and user data (see GUIDATA)
1088
1089% Hints: get(hObject,'String') returns contents of edit3 as text
1090%        str2double(get(hObject,'String')) returns contents of edit3 as a double
1091
1092
1093% --- Executes during object creation, after setting all properties.
1094function edit3_CreateFcn(hObject, eventdata, handles)
1095% hObject    handle to edit3 (see GCBO)
1096% eventdata  reserved - to be defined in a future version of MATLAB
1097% handles    empty - handles not created until after all CreateFcns called
1098
1099% Hint: edit controls usually have a white background on Windows.
1100%       See ISPC and COMPUTER.
1101if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1102    set(hObject,'BackgroundColor','white');
1103end
1104
1105
1106
1107function edit5_Callback(hObject, eventdata, handles)
1108% hObject    handle to edit5 (see GCBO)
1109% eventdata  reserved - to be defined in a future version of MATLAB
1110% handles    structure with handles and user data (see GUIDATA)
1111
1112% Hints: get(hObject,'String') returns contents of edit5 as text
1113%        str2double(get(hObject,'String')) returns contents of edit5 as a double
1114
1115
1116% --- Executes during object creation, after setting all properties.
1117function edit5_CreateFcn(hObject, eventdata, handles)
1118% hObject    handle to edit5 (see GCBO)
1119% eventdata  reserved - to be defined in a future version of MATLAB
1120% handles    empty - handles not created until after all CreateFcns called
1121
1122% Hint: edit controls usually have a white background on Windows.
1123%       See ISPC and COMPUTER.
1124if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1125    set(hObject,'BackgroundColor','white');
1126end
1127
1128
1129
1130function edit6_Callback(hObject, eventdata, handles)
1131% hObject    handle to edit6 (see GCBO)
1132% eventdata  reserved - to be defined in a future version of MATLAB
1133% handles    structure with handles and user data (see GUIDATA)
1134
1135% Hints: get(hObject,'String') returns contents of edit6 as text
1136%        str2double(get(hObject,'String')) returns contents of edit6 as a double
1137
1138
1139% --- Executes during object creation, after setting all properties.
1140function edit6_CreateFcn(hObject, eventdata, handles)
1141% hObject    handle to edit6 (see GCBO)
1142% eventdata  reserved - to be defined in a future version of MATLAB
1143% handles    empty - handles not created until after all CreateFcns called
1144
1145% Hint: edit controls usually have a white background on Windows.
1146%       See ISPC and COMPUTER.
1147if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1148    set(hObject,'BackgroundColor','white');
1149end
1150
1151
1152% --- Executes on button press in pushbutton15.
1153function pushbutton15_Callback(hObject, eventdata, handles)
1154% hObject    handle to pushbutton15 (see GCBO)
1155% eventdata  reserved - to be defined in a future version of MATLAB
1156% handles    structure with handles and user data (see GUIDATA)
1157
1158valmax=1;
1159valmin=0;
1160
1161valminINIT=get(handles.edit5,'String');
1162valmin=str2num(valminINIT{1});
1163valmaxINIT=get(handles.edit6,'String');
1164valmax=str2num(valmaxINIT{1});
1165
1166n=valmax-valmin+1;
1167i=1;
1168
1169global DirectoryNameGlobal;
1170disp ('DirectoryNameGlobal');
1171gotodirectory(DirectoryNameGlobal);
1172
1173global FileNameGlobal;
1174load(FileNameGlobal, 'Data');   
1175
1176%//Data.PM2.DataHR1 = -(Data.PM2.DataHR1/5)*10^6;   
1177%//Data.PM2.DataHR2 = ((0.0361 + 0.2542*Data.PM2.DataHR2 - 0.0112*Data.PM2.DataHR2.^2 + 0.0011*Data.PM2.DataHR2.^3).^2/50)*3.0*10^7;
1178%//Data.PM2.DataHR3 = ((0.0361 + 0.2542*Data.PM2.DataHR3 - 0.0112*Data.PM2.DataHR3.^2 + 0.0011*Data.PM2.DataHR3.^3).^2/50)*10.5*10^5;
1179%//Data.PM2.DataHR4 = (Data.PM2.DataHR4)*10^4; 
1180
1181for i=1:n
1182    Data.PM2.DataHR1(valmin+i-1)=-((Data.PM2.DataHR1(valmin+i-1))/5)*10^2;
1183    Data.PM2.DataHR2(valmin+i-1)=((0.0361 + 0.2542*Data.PM2.DataHR2(valmin+i-1) - 0.0112*Data.PM2.DataHR2(valmin+i-1).^2 + 0.0011*Data.PM2.DataHR2(valmin+i-1).^3).^2/50)*3.0*10^4;
1184    Data.PM2.DataHR3(valmin+i-1)=((0.0361 + 0.2542*Data.PM2.DataHR3(valmin+i-1) - 0.0112*Data.PM2.DataHR3(valmin+i-1).^2 + 0.0011*Data.PM2.DataHR3(valmin+i-1).^3).^2/50)*10.5*10^2;
1185    Data.PM2.DataHR4(valmin+i-1)=(Data.PM2.DataHR4(valmin+i-1))*10^2;
1186end
1187
1188maxHR1=max(Data.PM2.DataHR1);
1189maxHR2=max(Data.PM2.DataHR2);
1190maxHR3=max(Data.PM2.DataHR3);
1191maxHR4=max(Data.PM2.DataHR4);
1192minHR1=min(Data.PM2.DataHR1);
1193minHR2=min(Data.PM2.DataHR2);
1194minHR3=min(Data.PM2.DataHR3);
1195minHR4=min(Data.PM2.DataHR4);
1196
1197if (maxHR2(1)>maxHR3(1))
1198    max1=maxHR2(1)
1199else max1=maxHR3(1);
1200end
1201if (max1<maxHR4(1))
1202    max1=maxHR4(1);
1203end
1204
1205if (minHR2(1)<minHR3(1))
1206   min1=minHR2(1)
1207else min1=minHR3(1);
1208end
1209if (min1>minHR4(1))
1210    min1=minHR4(1);
1211end
1212
1213minHR1app=minHR1(1);
1214maxHR1app=maxHR1(1);
1215
1216if (minHR1app<min1)
1217    mini=minHR1
1218else
1219    mini=min1
1220end
1221
1222if (maxHR1app>max1)
1223    maxi=maxHR1
1224else
1225    maxi=max1
1226end
1227
1228axes(handles.graph2);
1229
1230hold off;
1231pnt=[valmin:valmax];
1232axis([valmin valmax mini maxi])
1233plot(Data.PM2.DataHR1,'b'); hold on; grid on;
1234axis([valmin valmax mini maxi])
1235plot(Data.PM2.DataHR2,'r');
1236plot(Data.PM2.DataHR3,'g');
1237plot(Data.PM2.DataHR4,'k');
1238legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1239xlabel('nombre de points (temps: 1 us par point)');
1240ylabel('Signal');
1241text(1000,0.5,Data.PM2.triggerTimestamp);
Note: See TracBrowser for help on using the repository browser.