1 | function 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 |
---|
28 | gui_Singleton = 1; |
---|
29 | gui_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', []); |
---|
35 | if nargin && ischar(varargin{1}) |
---|
36 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
37 | end |
---|
38 | |
---|
39 | if nargout |
---|
40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
41 | else |
---|
42 | gui_mainfcn(gui_State, varargin{:}); |
---|
43 | end |
---|
44 | % End initialization code - DO NOT EDIT |
---|
45 | |
---|
46 | |
---|
47 | % --- Executes just before plot_synchrotron_tune is made visible. |
---|
48 | function 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 |
---|
56 | handles.output = hObject; |
---|
57 | |
---|
58 | BPM='ANS-C09/DG/BPM.NOD'; |
---|
59 | |
---|
60 | |
---|
61 | % get BPM value |
---|
62 | rep = tango_read_attribute2(BPM,'DDBufferSize');pro=rep.value(1); |
---|
63 | set(handles.edit_profondeur,'String',num2str(pro)) |
---|
64 | rep = tango_read_attribute2(BPM,'DDDecimationFactor');dec=rep.value(1); |
---|
65 | set(handles.edit_decimation,'String',num2str(dec)) |
---|
66 | rep = tango_read_attribute2('ANS-C13/SY/LOCAL.DG.1', 'dcctEvent');adr=rep.value(1); |
---|
67 | set(handles.edit_adress,'String',num2str(adr)) |
---|
68 | |
---|
69 | handles.bpm=BPM; |
---|
70 | % Update handles structure |
---|
71 | guidata(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. |
---|
78 | function 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 |
---|
85 | varargout{1} = handles.output; |
---|
86 | |
---|
87 | |
---|
88 | % --- Executes on button press in pushbutton_run. |
---|
89 | function 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 |
---|
95 | BPM=handles.bpm; |
---|
96 | rep = tango_read_attribute2(BPM,'DDDecimationFactor');dec=rep.value(1); |
---|
97 | rep = tango_read_attribute2(BPM,'XPosDD'); |
---|
98 | N = length(rep.value); |
---|
99 | |
---|
100 | minfreq=str2double(get(handles.edit_minfreq,'String')); |
---|
101 | maxfreq=str2double(get(handles.edit_maxfreq,'String')); |
---|
102 | |
---|
103 | |
---|
104 | Xvalue = zeros(1,N); |
---|
105 | for ik =1:3, % averaging |
---|
106 | rep = tango_read_attribute2(BPM,'XPosDD'); |
---|
107 | Xvalue = Xvalue + rep.value; |
---|
108 | pause(0.3) |
---|
109 | end |
---|
110 | |
---|
111 | Xvalue = Xvalue/3; |
---|
112 | Amp=abs(fft(Xvalue)); |
---|
113 | |
---|
114 | frev = getrf/416; |
---|
115 | freq =(1:N)/N*frev*1e6/double(dec); |
---|
116 | len=length(freq); |
---|
117 | |
---|
118 | plot(freq(1:len/2)/1000,Amp(1:len/2)) |
---|
119 | xaxis([minfreq maxfreq]); |
---|
120 | grid on |
---|
121 | xlabel('Frequency kHz') |
---|
122 | |
---|
123 | %[a ind] = max(abs(fft(rep.value))) |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | function 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. |
---|
137 | function 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. |
---|
144 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
145 | set(hObject,'BackgroundColor','white'); |
---|
146 | end |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | function 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. |
---|
160 | function 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. |
---|
167 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
168 | set(hObject,'BackgroundColor','white'); |
---|
169 | end |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | function 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. |
---|
183 | function 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. |
---|
190 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
191 | set(hObject,'BackgroundColor','white'); |
---|
192 | end |
---|
193 | |
---|
194 | |
---|
195 | |
---|
196 | function 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. |
---|
206 | function 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. |
---|
213 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
214 | set(hObject,'BackgroundColor','white'); |
---|
215 | end |
---|
216 | |
---|
217 | |
---|
218 | |
---|
219 | function 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. |
---|
229 | function 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. |
---|
236 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
237 | set(hObject,'BackgroundColor','white'); |
---|
238 | end |
---|
239 | |
---|
240 | |
---|