source: MML/trunk/machine/SOLEIL/StorageRing/RFPostmortem/RFPM_LectureLabVIEW.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: 46.5 KB
Line 
1function varargout = RFPM_LectureLabVIEW(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 GUIDE v2.5 31-Mar-2008 18:21:40
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', @RFPM_LectureLabVIEW_OpeningFcn, ...
32                   'gui_OutputFcn',  @RFPM_LectureLabVIEW_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 RFPM_LectureLabVIEW_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 = RFPM_LectureLabVIEW_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%               Lecture des fichiers LabVIEW
622%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623% --- Executes on button press in pushbutton16.
624function pushbutton16_Callback(hObject, eventdata, handles)
625% hObject    handle to pushbutton16 (see GCBO)
626% eventdata  reserved - to be defined in a future version of MATLAB
627% handles    structure with handles and user data (see GUIDATA)
628
629%DirectoryName = getfamilydata('Directory', 'RFPostmortem');
630%DirectoryName = getfamilydata('Directory', 'RFPostmortem');
631cd('/home/matlabML/measdata/SOLEIL/StorageRingdata/Postmortem/RFPostmortem/Labview')
632DirStart = pwd;
633%DirectoryName = gotodirectory(DirectoryName);
634[FileName, DirectoryName] = uigetfile('*.*','Select File (or Cancel)');
635%disp (FileName);
636
637%global DirectoryNameGlobal;
638%DirectoryNameGlobal=DirectoryName;
639%global FileNameGlobal;
640FileNameGlobal=FileName;
641
642if FileName == 0
643    msgbox('No file chosen','Info','warn');
644    %disp('   No file chosen');
645    return;
646else
647    load(FileName);
648end
649cd(DirStart);
650
651%setappdata(handles.figure1, 'RFdata_CAV1', Data);
652
653[fid,message]=fopen(FileName,'r');
654if fid==-1
655    disp(message);
656else
657    load(FileName);
658    whos
659end
660
661table=textscan(fid,'%f %f %f %f', 400000);
662%table{4}(1:10)
663
664NbrPoint=size(table{1});
665
666%[NbrColumn,NbrPoint] = size (Data.PM1.DataHR1);
667
668    %%Data.PM1.DataHR1 = -(Data.PM1.DataHR1/5)*10^6; 
669    %disp (Data.PM1.DataHR1(2));
670    %%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;
671    %%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;
672    %%Data.PM1.DataHR4 = (Data.PM1.DataHR4)*10^4;
673
674    %global NbrPoint
675    %[NbrColumn,NbrPoint2] = size (Data.PM1.DataHR1);
676    %NbrPoint2=10000;
677
678%table{1}= -(table{1}/5)*10^2; 
679%table{2} = ((0.0361 + 0.2542*(table{2}) - 0.0112*(table{2}).^2 + 0.0011*(table{2}).^3).^2/50)*2.74*10^4;
680%table{3} = ((0.0361 + 0.2542*(table{3}) - 0.0112*(table{3}).^2 + 0.0011*(table{3}).^3).^2/50)*8.2*10^2;
681%table{4} = (table{4})*10^2;
682
683hold off;
684pnt=[1:NbrPoint];
685
686axes(handles.graph1);
687
688%hold off;
689%pnt=[valmin:valmax];
690%axis([valmin valmax mini maxi]);
691%set(gca,'XTick',[valmin valmax]);
692plot(table{1},'b'); hold on; grid on;
693%axis([valmin valmax mini maxi])
694plot(table{2},'r');
695plot(table{3},'g');
696plot(table{4},'k');
697legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
698xlabel('nombre de points (temps: 1 us par point)');
699ylabel('Signal');
700%text(1000,0.5,Data.PM1.triggerTimestamp);
701
702
703%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
705%                                                       CAVITE 2                                                       %
706%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
707%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
708
709% --- Executes on button press in pushbutton_cav2_Acquisition.
710function pushbutton_cav2_Acquisition_Callback(hObject, eventdata, handles)
711% hObject    handle to pushbutton_cav2_Acquisition (see GCBO)
712% eventdata  reserved - to be defined in a future version of MATLAB
713% handles    structure with handles and user data (see GUIDATA)
714
715%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
716
717statusAcquisition_cav2=tango_read_attribute2('ANS-C03/RF/PM.2','Status');
718text=statusAcquisition_cav2.value;
719if findstr(text, 'running')
720    msgbox('Fonctionnement Normal: pas d''acquisition à faire','Info','warn');
721    return;
722   
723else
724
725set(handles.text_cav2_PR1,'String','Pr1');
726set(handles.text_cav2_PR2,'String','Pr2');
727set(handles.text_cav2_PR3,'String','Pr3');
728set(handles.text_cav2_PR4,'String','Pr4');
729
730rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'reflectedPowerSecurityT1','reflectedPowerSecurityT2',...
731        'reflectedPowerSecurityT3','reflectedPowerSecurityT4'});
732
733%%rep = tango_read_attribute2('ANS-C03/RF/AMP.2-DATA','reflectedPowerSecurityT1')
734
735%%Data.AMP2.reflectedPowerSecurityT1 = rep.value;   
736Data.AMP2.reflectedPowerSecurityT1 = rep(1).value;
737Data.AMP2.reflectedPowerSecurityT2 = rep(2).value;
738Data.AMP2.reflectedPowerSecurityT3 = rep(3).value;
739Data.AMP2.reflectedPowerSecurityT4 = rep(4).value;
740   
741if Data.AMP2.reflectedPowerSecurityT1
742    set(handles.text_cav2_PR1,'BackgroundColor', [0 1 0]); %green
743else
744    set(handles.text_cav2_PR1,'BackgroundColor', [1 0 0]); %red
745end
746   
747if Data.AMP2.reflectedPowerSecurityT2
748    set(handles.text_cav2_PR2,'BackgroundColor', [0 1 0]); %green
749else
750    set(handles.text_cav2_PR2,'BackgroundColor', [1 0 0]); %red
751end
752
753if Data.AMP2.reflectedPowerSecurityT3
754    set(handles.text_cav2_PR3,'BackgroundColor', [0 1 0]); %green
755else
756    set(handles.text_cav2_PR3,'BackgroundColor', [1 0 0]); %red
757end
758   
759if Data.AMP2.reflectedPowerSecurityT4
760    set(handles.text_cav2_PR4,'BackgroundColor', [0 1 0]); %green
761else
762    set(handles.text_cav2_PR4,'BackgroundColor', [1 0 0]); %red
763end
764
765%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766
767rep = tango_read_attributes2('ANS-C03/RF/PM.2', {'acqHighResolutionCh1', 'acqHighResolutionCh2', 'acqHighResolutionCh3', ...
768    'acqHighResolutionCh4'});
769Data.PM2.DataHR1 = rep(1).value;
770Data.PM2.DataHR2 = rep(2).value;
771Data.PM2.DataHR3 = rep(3).value;
772Data.PM2.DataHR4 = rep(4).value;
773
774Data.PM2.TimestampHR = tango_shift_time(rep(1).time);
775
776reptrig2 = tango_read_attribute2('ANS-C03/RF/PM.2','triggerTimestamp');
777Data.PM2.triggerTimestamp = reptrig2.value;
778
779[NbrColumn,NbrPoint3] = size (Data.PM2.DataHR1);
780
781axes(handles.graph2);
782   
783    name2='_AcRAPIDE'
784   
785    %pnt=1:10000;
786    pnt=1:NbrPoint3;
787
788    hold off;
789    plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
790    plot(pnt, Data.PM2.DataHR2,'r');
791    plot(pnt, Data.PM2.DataHR3,'g');
792    plot(pnt, Data.PM2.DataHR4,'k');
793    legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
794    xlabel('nombre de points (temps: 1 us par point)');
795    ylabel('Signal');
796
797%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798
799set(handles.text_cav2_PI,'String','Pi');
800set(handles.text_cav2_PSS,'String','PSS Sec');
801set(handles.text_cav2_uC,'String','uC');
802   
803repPSS = tango_read_attribute2('ANS-C03/RF/LLE.2','pssSecurity');
804    %rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'incidentPowerSecurity','pssSecurity','microcontrollerSecurity'});
805    rep = tango_read_attributes2('ANS-C03/RF/AMP.2-DATA', {'incidentPowerSecurity','microcontrollerSecurity'});
806   
807    Data.AMP2.incidentPowerSecurity = rep(1).value;
808    Data.AMP2.pssSecurity = repPSS.value;
809    Data.AMP2.microcontrollerSecurity=rep(2).value;
810   
811    if Data.AMP2.incidentPowerSecurity
812      set(handles.text_cav2_PI,'BackgroundColor', [0 1 0]); %green
813    else
814      set(handles.text_cav2_PI,'BackgroundColor', [1 0 0]); %red
815    end
816   
817    if Data.AMP2.pssSecurity
818      set(handles.text_cav2_PSS,'BackgroundColor', [0 1 0]); %green
819    else
820      set(handles.text_cav2_PSS,'BackgroundColor', [1 0 0]); %red
821    end
822   
823    if Data.AMP2.microcontrollerSecurity
824      set(handles.text_cav2_uC,'BackgroundColor', [0 1 0]); %green
825    else
826      set(handles.text_cav2_uC,'BackgroundColor', [1 0 0]); %red
827    end
828   
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830
831 set(handles.text_cav2_InterLCKmach,'String','Interlck MACH');
832 set(handles.text_cav2_VAC,'String','VAC');
833 set(handles.text_cav2_CRYO,'String','CRYO');
834   
835 repINTER = tango_read_attribute2('ANS-C03/RF/LLE.2','machineSecurity');
836    %rep = tango_read_attributes2('ANS-C03/RF/CAV.2', {'interlock','vacuumSecurity','cryomoduleSecurity'});
837    rep = tango_read_attributes2('ANS-C03/RF/CAV.2', {'vacuumSecurity','cryomoduleSecurity'});
838   
839    Data.CAV2.interlock = repINTER.value;
840    %Data.CAV2.interlock = rep(1).value;
841    Data.CAV2.vacuum    = rep(1).value;
842    Data.CAV2.cryo = rep(2).value;
843
844    if Data.CAV2.interlock
845      set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0 1 0]); %green
846    else
847        %disp (Data.CAV2.interlock);
848      set(handles.text_cav2_InterLCKmach,'BackgroundColor', [1 0 0]); %red
849    end
850   
851    if Data.CAV2.vacuum
852        %disp (Data.CAV2.vacuum);
853      set(handles.text_cav2_VAC,'BackgroundColor', [0 1 0]); %green
854    else
855        %disp (Data.CAV2.vacuum)
856      set(handles.text_cav2_VAC,'BackgroundColor', [1 0 0]); %red
857    end
858   
859    if Data.CAV2.cryo
860        %disp (Data.CAV2.cryo);
861      set(handles.text_cav2_CRYO,'BackgroundColor', [0 1 0]); %green
862    else
863        %disp (Data.CAV2.vacuum)
864      set(handles.text_cav2_CRYO,'BackgroundColor', [1 0 0]); %red
865    end
866   
867%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%   
868
869DirectoryName = getfamilydata('Directory', 'RFPostmortem');
870%FileName = appendtimestamp('RFdata_CAV2', Data.PM2.TimestampHR);
871%comment% FileName = appendtimestamp('RFdata_CAV2', Data.PM2.triggerTimestamp);
872%disp (Data.PM2.triggerTimestamp);
873%disp (datevec(Data.PM2.triggerTimestamp));
874%FileName = appendtimestamp('RFdata_CAV2', Data.PM2.triggerTimestamp);
875FileName =['RFdata_CAV2_', Data.PM2.triggerTimestamp];
876
877[token,remain]=strtok(FileName);
878res=datevec(remain);
879resp1=num2str(res(1));
880resp2=num2str(res(2));
881resp3=num2str(res(3));
882resp4=num2str(res(4));
883resp5=num2str(res(5));
884resp6=num2str(res(6));
885FileNameLAST2=strcat('RFdata_CAV2','_',resp1,'-',resp2,'-',resp3,'_',resp4,'h',resp5,'mn',resp6,'s');
886disp (FileNameLAST2);
887
888%FileName = strcat(FileName,name2);
889%button group
890[FileNameLAST2, DirectoryName] = uiputfile('*.mat', 'Select File (Cancel to not save to a file)', [DirectoryName FileNameLAST2, '.mat']);
891if FileNameLAST2 == 0
892    disp('   No data saved');
893    return;
894    %RFdata_2007-10-10_13-48-23.mat
895end
896
897DirStart = pwd;
898[DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
899save(FileNameLAST2, 'Data');
900cd(DirStart);
901fprintf('   Data saved to %s\n', [DirectoryName FileNameLAST2]);
902
903setappdata(handles.figure1, 'RFdata_CAV2', Data);   
904
905
906end
907 
908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
909 
910% --- Executes on button press in pushbutton_cav2_OPEN.
911function pushbutton_cav2_OPEN_Callback(hObject, eventdata, handles)
912% hObject    handle to pushbutton_cav2_OPEN (see GCBO)
913% eventdata  reserved - to be defined in a future version of MATLAB
914% handles    structure with handles and user data (see GUIDATA)
915   
916DirectoryName = getfamilydata('Directory', 'RFPostmortem');
917
918DirStart = pwd;
919DirectoryName = gotodirectory(DirectoryName);
920[FileName, DirectoryName] = uigetfile('*.mat', 'Select File (Cancel to not save to a file)','RFdata_CAV2*');
921
922global DirectoryNameGlobal;
923DirectoryNameGlobal=DirectoryName;
924global FileNameGlobal;
925FileNameGlobal=FileName;
926
927if FileName == 0
928    msgbox('No file chosen','Info','warn');
929    %disp('   No file chosen');
930    return;
931else
932    load(FileName, 'Data');
933end
934cd(DirStart);
935
936setappdata(handles.figure1, 'RFdata_CAV2', Data);
937
938%disp (Data.PM2.DataLR);
939
940
941
942if Data.AMP2.reflectedPowerSecurityT1
943    set(handles.text_cav2_PR1,'BackgroundColor', [0 1 0]); %green
944else
945    set(handles.text_cav2_PR1,'BackgroundColor', [1 0 0]); %red
946end
947
948if Data.AMP2.reflectedPowerSecurityT2
949    set(handles.text_cav2_PR2,'BackgroundColor', [0 1 0]); %green
950else
951    set(handles.text_cav2_PR2,'BackgroundColor', [1 0 0]); %red
952end   
953
954if Data.AMP2.reflectedPowerSecurityT3
955    set(handles.text_cav2_PR3,'BackgroundColor', [0 1 0]); %green
956else
957    set(handles.text_cav2_PR3,'BackgroundColor', [1 0 0]); %red
958end
959
960if Data.AMP2.reflectedPowerSecurityT4
961    set(handles.text_cav2_PR4,'BackgroundColor', [0 1 0]); %green
962else
963    set(handles.text_cav2_PR4,'BackgroundColor', [1 0 0]); %red
964end
965
966
967
968if Data.AMP2.incidentPowerSecurity
969    set(handles.text_cav2_PI,'BackgroundColor', [0 1 0]); %green
970else
971    set(handles.text_cav2_PI,'BackgroundColor', [1 0 0]); %red
972end
973   
974if Data.AMP2.pssSecurity
975    set(handles.text_cav2_PSS,'BackgroundColor', [0 1 0]); %green
976else
977    set(handles.text_cav2_PSS,'BackgroundColor', [1 0 0]); %red
978end
979   
980if Data.AMP2.microcontrollerSecurity
981    set(handles.text_cav2_uC,'BackgroundColor', [0 1 0]); %green
982else
983    set(handles.text_cav2_uC,'BackgroundColor', [1 0 0]); %red
984end
985
986if Data.CAV2.interlock
987    set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0 1 0]); %green
988else
989    set(handles.text_cav2_InterLCKmach,'BackgroundColor', [1 0 0]); %red
990end
991   
992if Data.CAV2.vacuum
993    set(handles.text_cav2_VAC,'BackgroundColor', [0 1 0]); %green
994else
995    set(handles.text_cav2_VAC,'BackgroundColor', [1 0 0]); %red
996end
997   
998if Data.CAV2.cryo
999    set(handles.text_cav2_CRYO,'BackgroundColor', [0 1 0]); %green
1000else
1001    set(handles.text_cav2_CRYO,'BackgroundColor', [1 0 0]); %red
1002end
1003
1004axes(handles.graph2);
1005
1006
1007[NbrColumn,NbrPoint4] = size (Data.PM2.DataHR1);
1008
1009%//Data.PM2.DataHR1 = -(Data.PM2.DataHR1/5)*10^6;   
1010%//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;
1011%//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;
1012%//Data.PM2.DataHR4 = (Data.PM2.DataHR4)*10^4;     
1013
1014hold off;
1015%hold on; grid on;
1016
1017pnt=[1:NbrPoint4];
1018
1019%//pnt1=1:10000;
1020%//pnt2=1:10000;
1021        %[haxes,hline1,hline2,hline3]=plotyy(pnt,Data.PM2.DataHR1,pnt,Data.PM2.DataHR2,pnt,Data.PM2.DataHR3);
1022%[haxes,hline1,hline2]=plotyy(pnt,Data.PM2.DataHR1,pnt,Data.PM2.DataHR2);
1023%//[haxes,hline1,hline2]=plotyy(pnt1,Data.PM2.DataHR1,pnt2,Data.PM2.DataHR2,'plot');
1024%//set(hline1,'Color','b');
1025%//set(hline2,'Color','r');
1026        %[haxes,hline3,hline4]=plotyy(pnt,Data.PM2.DataHR3,pnt,Data.PM2.DataHR4);
1027plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
1028plot(pnt, Data.PM2.DataHR2,'r');
1029plot(pnt, Data.PM2.DataHR3,'g');
1030plot(pnt, Data.PM2.DataHR4,'k');
1031legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1032    %%legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi');
1033xlabel('nombre de points (temps: 1 us par point)');
1034    %//axes(haxes(1));
1035    %//axis auto;
1036    %zoom on;
1037    %ylabel('Vcav [V]','Color','b');
1038    %//ylabel('Vcav [V]');
1039ylabel('Signal');
1040    %//LegVcav=legend('Ac. Rapide CH1: Vcav');
1041    %//set(LegVcav,'Location','NorthWest');
1042    %set(LegVcav,'background','g');
1043    %//axes(haxes(2));
1044    %//axis auto;
1045    %axes(h,'Color','b');
1046    %//ylabel('Power [Watts]');
1047    %//hold on; grid on;
1048    %//plot(pnt2,Data.PM2.DataHR3,'y');
1049
1050    %hold on; grid on;
1051    %//plot(pnt2, Data.PM2.DataHR4,'k');
1052    %//LegPuissance=legend('Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1053    %legend('Ac. Rapide CH4: Ib');
1054    %ylabel('Signal');
1055text(1000,0.5,Data.PM2.triggerTimestamp);
1056   
1057   
1058    %SAVED
1059    %hold off;
1060    %pnt=1:10000;
1061    %plot(pnt, Data.PM2.DataHR1,'b'); hold on; grid on;
1062    %plot(pnt, Data.PM2.DataHR2,'r');
1063    %plot(pnt, Data.PM2.DataHR3,'g');
1064    %plot(pnt, Data.PM2.DataHR4,'k');
1065    %legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1066    %text(1000,0.5,Data.PM2.triggerTimestamp);
1067    %xlabel('nombre de points (temps: 1 us par point)');
1068    %ylabel('Signal');
1069
1070
1071
1072
1073
1074
1075%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1076
1077% --- Executes on button press in pushbutton_cav2_clear.
1078function pushbutton_cav2_clear_Callback(hObject, eventdata, handles)
1079% hObject    handle to pushbutton_cav2_clear (see GCBO)
1080% eventdata  reserved - to be defined in a future version of MATLAB
1081% handles    structure with handles and user data (see GUIDATA)
1082
1083axes(handles.graph2);
1084hold off;
1085plot(NaN);
1086
1087set(handles.text_cav2_PR1,'BackgroundColor', [0.702 0.702 0.702]); %gray
1088set(handles.text_cav2_PR2,'BackgroundColor', [0.702 0.702 0.702]); %gray
1089set(handles.text_cav2_PR3,'BackgroundColor', [0.702 0.702 0.702]); %gray
1090set(handles.text_cav2_PR4,'BackgroundColor', [0.702 0.702 0.702]); %gray
1091   
1092set(handles.text_cav2_PI,'BackgroundColor', [0.702 0.702 0.702]); %gray
1093set(handles.text_cav2_PSS,'BackgroundColor', [0.702 0.702 0.702]); %gray
1094set(handles.text_cav2_uC,'BackgroundColor', [0.702 0.702 0.702]); %gray
1095 
1096set(handles.text_cav2_InterLCKmach,'BackgroundColor', [0.702 0.702 0.702]); %gray
1097set(handles.text_cav2_VAC,'BackgroundColor', [0.702 0.702 0.702]); %gray
1098set(handles.text_cav2_CRYO,'BackgroundColor', [0.702 0.702 0.702]); %gray
1099
1100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1101%           Lecture des fichiers LabVIEW
1102%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103
1104% --- Executes on button press in pushbutton17.
1105function pushbutton17_Callback(hObject, eventdata, handles)
1106% hObject    handle to pushbutton17 (see GCBO)
1107% eventdata  reserved - to be defined in a future version of MATLAB
1108% handles    structure with handles and user data (see GUIDATA)
1109
1110cd('/home/matlabML/measdata/SOLEIL/StorageRingdata/Postmortem/RFPostmortem/Labview')
1111DirStart = pwd;
1112
1113[FileName, DirectoryName] = uigetfile('*.*','Select File (or Cancel)');
1114
1115FileNameGlobal=FileName;
1116
1117if FileName == 0
1118    msgbox('No file chosen','Info','warn');
1119    return;
1120else
1121    load(FileName);
1122end
1123cd(DirStart);
1124
1125[fid,message]=fopen(FileName,'r');
1126if fid==-1
1127    disp(message);
1128else
1129    load(FileName);
1130    whos
1131end
1132
1133table=textscan(fid,'%f %f %f %f', 400000);
1134
1135NbrPoint=size(table{1});
1136
1137hold off;
1138pnt=[1:NbrPoint];
1139
1140axes(handles.graph2);
1141
1142plot(table{1},'b'); hold on; grid on;
1143plot(table{2},'r');
1144plot(table{3},'g');
1145plot(table{4},'k');
1146legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1147xlabel('nombre de points (temps: 1 us par point)');
1148ylabel('Signal');
1149
1150
1151%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1152%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1153
1154% --- Executes on button press in pushbutton_RESET_cav2.
1155function pushbutton_RESET_cav2_Callback(hObject, eventdata, handles)
1156% hObject    handle to pushbutton_RESET_cav2 (see GCBO)
1157% eventdata  reserved - to be defined in a future version of MATLAB
1158% handles    structure with handles and user data (see GUIDATA)
1159
1160statusAcquisition_cav2=tango_read_attribute2('ANS-C03/RF/PM.2','Status');
1161text=statusAcquisition_cav2.value;
1162if findstr(text, 'running')
1163    %%set(handles.pushbutton_RESET_cav2,'String','NO need reset, Device is Running');
1164    msgbox('Un reset a déjà été fait, le device fonctionne Normalement','Info','warn');
1165    return;
1166else
1167    set(handles.pushbutton_RESET_cav2,'Tag','pushbutton_RESET_cav2');
1168    %tango_command_inout2('ANS-C03/RF/PM.2','Init');
1169    tango_command_inout2('ANS-C03/RF/PM.2','Start');
1170   
1171    fid=0;
1172    filenameRES='/home/operateur/GrpRF/Nicolas/SUIVIreset';
1173    %filenameRES='TESTres';
1174    fid=fopen(filenameRES,'a+');
1175    %disp (fid);
1176    %disp ('2');
1177    %valeurTEST='test11111';
1178    valeurTEST=datestr(clock,0);
1179   
1180    fprintf(fid,'Reset CAV2 at: %s \n',valeurTEST);
1181    fclose(fid);
1182end
1183
1184%tango_command_inout2('ANS-C03/RF/PM.2','Stop'); %NE PAS OUBLIER D'ENLEVER CETTE LIGNE APRES TEST
1185
1186
1187% --- Executes on button press in pushbutton12.
1188function pushbutton12_Callback(hObject, eventdata, handles)
1189% hObject    handle to pushbutton12 (see GCBO)
1190% eventdata  reserved - to be defined in a future version of MATLAB
1191% handles    structure with handles and user data (see GUIDATA)
1192
1193
1194function edit2_Callback(hObject, eventdata, handles)
1195% hObject    handle to edit2 (see GCBO)
1196% eventdata  reserved - to be defined in a future version of MATLAB
1197% handles    structure with handles and user data (see GUIDATA)
1198
1199% Hints: get(hObject,'String') returns contents of edit2 as text
1200%        str2double(get(hObject,'String')) returns contents of edit2 as a double
1201
1202
1203% --- Executes during object creation, after setting all properties.
1204function edit2_CreateFcn(hObject, eventdata, handles)
1205% hObject    handle to edit2 (see GCBO)
1206% eventdata  reserved - to be defined in a future version of MATLAB
1207% handles    empty - handles not created until after all CreateFcns called
1208
1209% Hint: edit controls usually have a white background on Windows.
1210%       See ISPC and COMPUTER.
1211if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1212    set(hObject,'BackgroundColor','white');
1213end
1214
1215
1216
1217function edit3_Callback(hObject, eventdata, handles)
1218% hObject    handle to edit3 (see GCBO)
1219% eventdata  reserved - to be defined in a future version of MATLAB
1220% handles    structure with handles and user data (see GUIDATA)
1221
1222% Hints: get(hObject,'String') returns contents of edit3 as text
1223%        str2double(get(hObject,'String')) returns contents of edit3 as a double
1224
1225
1226% --- Executes during object creation, after setting all properties.
1227function edit3_CreateFcn(hObject, eventdata, handles)
1228% hObject    handle to edit3 (see GCBO)
1229% eventdata  reserved - to be defined in a future version of MATLAB
1230% handles    empty - handles not created until after all CreateFcns called
1231
1232% Hint: edit controls usually have a white background on Windows.
1233%       See ISPC and COMPUTER.
1234if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1235    set(hObject,'BackgroundColor','white');
1236end
1237
1238
1239
1240function edit5_Callback(hObject, eventdata, handles)
1241% hObject    handle to edit5 (see GCBO)
1242% eventdata  reserved - to be defined in a future version of MATLAB
1243% handles    structure with handles and user data (see GUIDATA)
1244
1245% Hints: get(hObject,'String') returns contents of edit5 as text
1246%        str2double(get(hObject,'String')) returns contents of edit5 as a double
1247
1248
1249% --- Executes during object creation, after setting all properties.
1250function edit5_CreateFcn(hObject, eventdata, handles)
1251% hObject    handle to edit5 (see GCBO)
1252% eventdata  reserved - to be defined in a future version of MATLAB
1253% handles    empty - handles not created until after all CreateFcns called
1254
1255% Hint: edit controls usually have a white background on Windows.
1256%       See ISPC and COMPUTER.
1257if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1258    set(hObject,'BackgroundColor','white');
1259end
1260
1261
1262
1263function edit6_Callback(hObject, eventdata, handles)
1264% hObject    handle to edit6 (see GCBO)
1265% eventdata  reserved - to be defined in a future version of MATLAB
1266% handles    structure with handles and user data (see GUIDATA)
1267
1268% Hints: get(hObject,'String') returns contents of edit6 as text
1269%        str2double(get(hObject,'String')) returns contents of edit6 as a double
1270
1271
1272% --- Executes during object creation, after setting all properties.
1273function edit6_CreateFcn(hObject, eventdata, handles)
1274% hObject    handle to edit6 (see GCBO)
1275% eventdata  reserved - to be defined in a future version of MATLAB
1276% handles    empty - handles not created until after all CreateFcns called
1277
1278% Hint: edit controls usually have a white background on Windows.
1279%       See ISPC and COMPUTER.
1280if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1281    set(hObject,'BackgroundColor','white');
1282end
1283
1284
1285% --- Executes on button press in pushbutton15.
1286function pushbutton15_Callback(hObject, eventdata, handles)
1287% hObject    handle to pushbutton15 (see GCBO)
1288% eventdata  reserved - to be defined in a future version of MATLAB
1289% handles    structure with handles and user data (see GUIDATA)
1290
1291valmax=1;
1292valmin=0;
1293
1294valminINIT=get(handles.edit5,'String');
1295valmin=str2num(valminINIT{1});
1296valmaxINIT=get(handles.edit6,'String');
1297valmax=str2num(valmaxINIT{1});
1298
1299n=valmax-valmin+1;
1300i=1;
1301
1302global DirectoryNameGlobal;
1303disp ('DirectoryNameGlobal');
1304gotodirectory(DirectoryNameGlobal);
1305
1306global FileNameGlobal;
1307load(FileNameGlobal, 'Data');   
1308
1309%//Data.PM2.DataHR1 = -(Data.PM2.DataHR1/5)*10^6;   
1310%//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;
1311%//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;
1312%//Data.PM2.DataHR4 = (Data.PM2.DataHR4)*10^4; 
1313
1314for i=1:n
1315    Data.PM2.DataHR1(valmin+i-1)=-((Data.PM2.DataHR1(valmin+i-1))/5)*10^2;
1316    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;
1317    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;
1318    Data.PM2.DataHR4(valmin+i-1)=(Data.PM2.DataHR4(valmin+i-1))*10^2;
1319end
1320
1321maxHR1=max(Data.PM2.DataHR1);
1322maxHR2=max(Data.PM2.DataHR2);
1323maxHR3=max(Data.PM2.DataHR3);
1324maxHR4=max(Data.PM2.DataHR4);
1325minHR1=min(Data.PM2.DataHR1);
1326minHR2=min(Data.PM2.DataHR2);
1327minHR3=min(Data.PM2.DataHR3);
1328minHR4=min(Data.PM2.DataHR4);
1329
1330if (maxHR2(1)>maxHR3(1))
1331    max1=maxHR2(1)
1332else max1=maxHR3(1);
1333end
1334if (max1<maxHR4(1))
1335    max1=maxHR4(1);
1336end
1337
1338if (minHR2(1)<minHR3(1))
1339   min1=minHR2(1)
1340else min1=minHR3(1);
1341end
1342if (min1>minHR4(1))
1343    min1=minHR4(1);
1344end
1345
1346minHR1app=minHR1(1);
1347maxHR1app=maxHR1(1);
1348
1349if (minHR1app<min1)
1350    mini=minHR1
1351else
1352    mini=min1
1353end
1354
1355if (maxHR1app>max1)
1356    maxi=maxHR1
1357else
1358    maxi=max1
1359end
1360
1361axes(handles.graph2);
1362
1363hold off;
1364pnt=[valmin:valmax];
1365axis([valmin valmax mini maxi])
1366plot(Data.PM2.DataHR1,'b'); hold on; grid on;
1367axis([valmin valmax mini maxi])
1368plot(Data.PM2.DataHR2,'r');
1369plot(Data.PM2.DataHR3,'g');
1370plot(Data.PM2.DataHR4,'k');
1371legend('Ac. Rapide CH1: Vcav', 'Ac. Rapide CH2: Pi','Ac. Rapide CH3: Pr','Ac. Rapide CH4: Ib');
1372xlabel('nombre de points (temps: 1 us par point)');
1373ylabel('Signal');
1374text(1000,0.5,Data.PM2.triggerTimestamp);
1375
1376
1377
1378
1379
Note: See TracBrowser for help on using the repository browser.