source: MML/trunk/machine/SOLEIL/StorageRing/plot_synchrotron_tune.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: 9.2 KB
Line 
1function varargout = plot_synchrotron_tune(varargin)
2% PLOT_SYNCHROTRON_TUNE M-file for plot_synchrotron_tune.fig
3%      PLOT_SYNCHROTRON_TUNE, by itself, creates a new PLOT_SYNCHROTRON_TUNE or raises the existing
4%      singleton*.
5%
6%      H = PLOT_SYNCHROTRON_TUNE returns the handle to a new PLOT_SYNCHROTRON_TUNE or the handle to
7%      the existing singleton*.
8%
9%      PLOT_SYNCHROTRON_TUNE('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in PLOT_SYNCHROTRON_TUNE.M with the given input arguments.
11%
12%      PLOT_SYNCHROTRON_TUNE('Property','Value',...) creates a new PLOT_SYNCHROTRON_TUNE or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before plot_synchrotron_tune_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to plot_synchrotron_tune_OpeningFcn via varargin.
17%
18%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
19%      instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22
23% Edit the above text to modify the response to help plot_synchrotron_tune
24
25% Last Modified by GUIDE v2.5 07-May-2008 15:57:55
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', @plot_synchrotron_tune_OpeningFcn, ...
32                   'gui_OutputFcn',  @plot_synchrotron_tune_OutputFcn, ...
33                   'gui_LayoutFcn',  [] , ...
34                   'gui_Callback',   []);
35if nargin && ischar(varargin{1})
36    gui_State.gui_Callback = str2func(varargin{1});
37end
38
39if nargout
40    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41else
42    gui_mainfcn(gui_State, varargin{:});
43end
44% End initialization code - DO NOT EDIT
45
46
47% --- Executes just before plot_synchrotron_tune is made visible.
48function plot_synchrotron_tune_OpeningFcn(hObject, eventdata, handles, varargin)
49% This function has no output args, see OutputFcn.
50% hObject    handle to figure
51% eventdata  reserved - to be defined in a future version of MATLAB
52% handles    structure with handles and user data (see GUIDATA)
53% varargin   command line arguments to plot_synchrotron_tune (see VARARGIN)
54
55% Choose default command line output for plot_synchrotron_tune
56handles.output = hObject;
57
58BPM='ANS-C09/DG/BPM.NOD';
59
60
61% get BPM value
62rep = tango_read_attribute2(BPM,'DDBufferSize');pro=rep.value(1);
63set(handles.edit_profondeur,'String',num2str(pro))
64rep = tango_read_attribute2(BPM,'DDDecimationFactor');dec=rep.value(1);
65set(handles.edit_decimation,'String',num2str(dec))
66rep = tango_read_attribute2('ANS-C13/SY/LOCAL.DG.1', 'dcctEvent');adr=rep.value(1);
67set(handles.edit_adress,'String',num2str(adr))
68
69handles.bpm=BPM;
70% Update handles structure
71guidata(hObject, handles);
72
73% UIWAIT makes plot_synchrotron_tune wait for user response (see UIRESUME)
74% uiwait(handles.figure1);
75
76
77% --- Outputs from this function are returned to the command line.
78function varargout = plot_synchrotron_tune_OutputFcn(hObject, eventdata, handles)
79% varargout  cell array for returning output args (see VARARGOUT);
80% hObject    handle to figure
81% eventdata  reserved - to be defined in a future version of MATLAB
82% handles    structure with handles and user data (see GUIDATA)
83
84% Get default command line output from handles structure
85varargout{1} = handles.output;
86
87
88% --- Executes on button press in pushbutton_run.
89function pushbutton_run_Callback(hObject, eventdata, handles)
90% hObject    handle to pushbutton_run (see GCBO)
91% eventdata  reserved - to be defined in a future version of MATLAB
92% handles    structure with handles and user data (see GUIDATA)
93
94% Hint: get(hObject,'Value') returns toggle state of pushbutton_run
95BPM=handles.bpm;
96rep = tango_read_attribute2(BPM,'DDDecimationFactor');dec=rep.value(1);
97rep = tango_read_attribute2(BPM,'XPosDD');
98N = length(rep.value);
99
100minfreq=str2double(get(handles.edit_minfreq,'String'));
101maxfreq=str2double(get(handles.edit_maxfreq,'String'));
102
103
104Xvalue = zeros(1,N);
105for ik =1:3, % averaging
106    rep = tango_read_attribute2(BPM,'XPosDD');
107    Xvalue = Xvalue + rep.value;
108    pause(0.3)
109end
110
111Xvalue = Xvalue/3;
112Amp=abs(fft(Xvalue));
113
114frev = getrf/416;
115freq =(1:N)/N*frev*1e6/double(dec);
116len=length(freq);
117
118plot(freq(1:len/2)/1000,Amp(1:len/2))
119xaxis([minfreq maxfreq]);
120grid on
121xlabel('Frequency kHz')
122
123%[a ind] = max(abs(fft(rep.value)))
124
125   
126   
127function edit_profondeur_Callback(hObject, eventdata, handles)
128% hObject    handle to edit_profondeur (see GCBO)
129% eventdata  reserved - to be defined in a future version of MATLAB
130% handles    structure with handles and user data (see GUIDATA)
131
132% Hints: get(hObject,'String') returns contents of edit_profondeur as text
133%        str2double(get(hObject,'String')) returns contents of edit_profondeur as a double
134
135
136% --- Executes during object creation, after setting all properties.
137function edit_profondeur_CreateFcn(hObject, eventdata, handles)
138% hObject    handle to edit_profondeur (see GCBO)
139% eventdata  reserved - to be defined in a future version of MATLAB
140% handles    empty - handles not created until after all CreateFcns called
141
142% Hint: edit controls usually have a white background on Windows.
143%       See ISPC and COMPUTER.
144if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
145    set(hObject,'BackgroundColor','white');
146end
147
148
149
150function edit_decimation_Callback(hObject, eventdata, handles)
151% hObject    handle to edit_decimation (see GCBO)
152% eventdata  reserved - to be defined in a future version of MATLAB
153% handles    structure with handles and user data (see GUIDATA)
154
155% Hints: get(hObject,'String') returns contents of edit_decimation as text
156%        str2double(get(hObject,'String')) returns contents of edit_decimation as a double
157
158
159% --- Executes during object creation, after setting all properties.
160function edit_decimation_CreateFcn(hObject, eventdata, handles)
161% hObject    handle to edit_decimation (see GCBO)
162% eventdata  reserved - to be defined in a future version of MATLAB
163% handles    empty - handles not created until after all CreateFcns called
164
165% Hint: edit controls usually have a white background on Windows.
166%       See ISPC and COMPUTER.
167if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
168    set(hObject,'BackgroundColor','white');
169end
170
171
172
173function edit_adress_Callback(hObject, eventdata, handles)
174% hObject    handle to edit_adress (see GCBO)
175% eventdata  reserved - to be defined in a future version of MATLAB
176% handles    structure with handles and user data (see GUIDATA)
177
178% Hints: get(hObject,'String') returns contents of edit_adress as text
179%        str2double(get(hObject,'String')) returns contents of edit_adress as a double
180
181
182% --- Executes during object creation, after setting all properties.
183function edit_adress_CreateFcn(hObject, eventdata, handles)
184% hObject    handle to edit_adress (see GCBO)
185% eventdata  reserved - to be defined in a future version of MATLAB
186% handles    empty - handles not created until after all CreateFcns called
187
188% Hint: edit controls usually have a white background on Windows.
189%       See ISPC and COMPUTER.
190if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
191    set(hObject,'BackgroundColor','white');
192end
193
194
195
196function edit_minfreq_Callback(hObject, eventdata, handles)
197% hObject    handle to edit_minfreq (see GCBO)
198% eventdata  reserved - to be defined in a future version of MATLAB
199% handles    structure with handles and user data (see GUIDATA)
200
201% Hints: get(hObject,'String') returns contents of edit_minfreq as text
202%        str2double(get(hObject,'String')) returns contents of edit_minfreq as a double
203
204
205% --- Executes during object creation, after setting all properties.
206function edit_minfreq_CreateFcn(hObject, eventdata, handles)
207% hObject    handle to edit_minfreq (see GCBO)
208% eventdata  reserved - to be defined in a future version of MATLAB
209% handles    empty - handles not created until after all CreateFcns called
210
211% Hint: edit controls usually have a white background on Windows.
212%       See ISPC and COMPUTER.
213if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
214    set(hObject,'BackgroundColor','white');
215end
216
217
218
219function edit_maxfreq_Callback(hObject, eventdata, handles)
220% hObject    handle to edit_maxfreq (see GCBO)
221% eventdata  reserved - to be defined in a future version of MATLAB
222% handles    structure with handles and user data (see GUIDATA)
223
224% Hints: get(hObject,'String') returns contents of edit_maxfreq as text
225%        str2double(get(hObject,'String')) returns contents of edit_maxfreq as a double
226
227
228% --- Executes during object creation, after setting all properties.
229function edit_maxfreq_CreateFcn(hObject, eventdata, handles)
230% hObject    handle to edit_maxfreq (see GCBO)
231% eventdata  reserved - to be defined in a future version of MATLAB
232% handles    empty - handles not created until after all CreateFcns called
233
234% Hint: edit controls usually have a white background on Windows.
235%       See ISPC and COMPUTER.
236if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
237    set(hObject,'BackgroundColor','white');
238end
239
240
Note: See TracBrowser for help on using the repository browser.