1 | function varargout = bpmconfigurator(varargin) |
---|
2 | % BPMCONFIGURATOR M-file for bpmconfigurator.fig |
---|
3 | % BPMCONFIGURATOR, by itself, creates a new BPMCONFIGURATOR or raises the existing |
---|
4 | % singleton*. |
---|
5 | % |
---|
6 | % H = BPMCONFIGURATOR returns the handle to a new BPMCONFIGURATOR or the handle to |
---|
7 | % the existing singleton*. |
---|
8 | % |
---|
9 | % BPMCONFIGURATOR('CALLBACK',hObject,eventData,handles,...) calls the local |
---|
10 | % function named CALLBACK in BPMCONFIGURATOR.M with the given input arguments. |
---|
11 | % |
---|
12 | % BPMCONFIGURATOR('Property','Value',...) creates a new BPMCONFIGURATOR or raises the |
---|
13 | % existing singleton*. Starting from the left, property value pairs are |
---|
14 | % applied to the GUI before bpmconfigurator_OpeningFunction gets called. An |
---|
15 | % unrecognized property name or invalid value makes property application |
---|
16 | % stop. All inputs are passed to bpmconfigurator_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 | % Copyright 2002-2003 The MathWorks, Inc. |
---|
24 | |
---|
25 | % Edit the above text to modify the response to help bpmconfigurator |
---|
26 | |
---|
27 | % Last Modified by GUIDE v2.5 20-Mar-2007 12:21:43 |
---|
28 | |
---|
29 | % Begin initialization code - DO NOT EDIT |
---|
30 | gui_Singleton = 1; |
---|
31 | gui_State = struct('gui_Name', mfilename, ... |
---|
32 | 'gui_Singleton', gui_Singleton, ... |
---|
33 | 'gui_OpeningFcn', @bpmconfigurator_OpeningFcn, ... |
---|
34 | 'gui_OutputFcn', @bpmconfigurator_OutputFcn, ... |
---|
35 | 'gui_LayoutFcn', [] , ... |
---|
36 | 'gui_Callback', []); |
---|
37 | if nargin && ischar(varargin{1}) |
---|
38 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
39 | end |
---|
40 | |
---|
41 | if nargout |
---|
42 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
43 | else |
---|
44 | gui_mainfcn(gui_State, varargin{:}); |
---|
45 | end |
---|
46 | % End initialization code - DO NOT EDIT |
---|
47 | |
---|
48 | |
---|
49 | % --- Executes just before bpmconfigurator is made visible. |
---|
50 | function bpmconfigurator_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
51 | % This function has no output args, see OutputFcn. |
---|
52 | % hObject handle to figure |
---|
53 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
54 | % handles structure with handles and user data (see GUIDATA) |
---|
55 | % varargin command line arguments to bpmconfigurator (see VARARGIN) |
---|
56 | |
---|
57 | % Choose default command line output for bpmconfigurator |
---|
58 | handles.output = hObject; |
---|
59 | |
---|
60 | % Update handles structure |
---|
61 | guidata(hObject, handles); |
---|
62 | |
---|
63 | % UIWAIT makes bpmconfigurator wait for user response (see UIRESUME) |
---|
64 | % uiwait(handles.figure1); |
---|
65 | AO = {}; |
---|
66 | setappdata(handles.figure1,'AO', AO); |
---|
67 | |
---|
68 | % init oppmenu for commands and attributes |
---|
69 | % Mode is not read by readattribute |
---|
70 | |
---|
71 | switch getsubmachinename |
---|
72 | case 'Booster_old' |
---|
73 | set(handles.popupmenu_Attribute,'String',{'NumSamples','Mode', ... |
---|
74 | 'BufferFreezingEnabled','BufferFrozen'}); |
---|
75 | set(handles.popupmenu_Command,'String',{'Init','State', ... |
---|
76 | 'DisableBufferFreezing', 'EnableBufferFreezing', 'UnFreezeBuffer'}); |
---|
77 | case {'Booster', 'StorageRing', 'LT2'} |
---|
78 | set(handles.popupmenu_Attribute,'String',{'AGCEnabled', 'DDBufferSize','Gain','DDTriggerCounter', ... |
---|
79 | 'DDBufferFreezingEnabled','DDBufferFrozen', 'DDEnabled','SAEnabled','Switches'}); |
---|
80 | set(handles.popupmenu_Command,'String',{'Init','State', 'Status', ... |
---|
81 | 'DisableDD', 'DisableSA','EnableDDBufferFreezing', 'UnFreezeDDBuffer', ... |
---|
82 | 'DisableDDBufferFreezing', 'EnableDD', 'EnableSA', 'SetTimeOnNextTrigger'}); |
---|
83 | tablist = (0:-1:-60)'; |
---|
84 | set(handles.popupmenu_Gain,'String', num2str(tablist)); |
---|
85 | handles.groupID = tango_group_create('BPM'); |
---|
86 | tango_group_add(handles.groupID,family2tangodev('BPMx')'); |
---|
87 | otherwise |
---|
88 | error('Wrong SubMachine %s', getsubmachinename); |
---|
89 | end |
---|
90 | |
---|
91 | % Update handles structure |
---|
92 | guidata(hObject, handles); |
---|
93 | |
---|
94 | % --- Outputs from this function are returned to the command line. |
---|
95 | function varargout = bpmconfigurator_OutputFcn(hObject, eventdata, handles) |
---|
96 | % varargout cell array for returning output args (see VARARGOUT); |
---|
97 | % hObject handle to figure |
---|
98 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
99 | % handles structure with handles and user data (see GUIDATA) |
---|
100 | |
---|
101 | % Get default command line output from handles structure |
---|
102 | varargout{1} = handles.output; |
---|
103 | |
---|
104 | |
---|
105 | % --- Executes on selection change in popupmenu_Command. |
---|
106 | function popupmenu_Command_Callback(hObject, eventdata, handles) |
---|
107 | % hObject handle to popupmenu_Command (see GCBO) |
---|
108 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
109 | % handles structure with handles and user data (see GUIDATA) |
---|
110 | |
---|
111 | % Hints: contents = get(hObject,'String') returns popupmenu_Command contents as cell array |
---|
112 | % contents{get(hObject,'Value')} returns selected item from popupmenu_Command |
---|
113 | |
---|
114 | |
---|
115 | % --- Executes during object creation, after setting all properties. |
---|
116 | function popupmenu_Command_CreateFcn(hObject, eventdata, handles) |
---|
117 | % hObject handle to popupmenu_Command (see GCBO) |
---|
118 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
119 | % handles empty - handles not created until after all CreateFcns called |
---|
120 | |
---|
121 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
122 | % See ISPC and COMPUTER. |
---|
123 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
124 | set(hObject,'BackgroundColor','white'); |
---|
125 | end |
---|
126 | |
---|
127 | |
---|
128 | % --- Executes on button press in pushbutton_Apply. |
---|
129 | function pushbutton_Apply_Callback(hObject, eventdata, handles) |
---|
130 | % hObject handle to pushbutton_Apply (see GCBO) |
---|
131 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
132 | % handles structure with handles and user data (see GUIDATA) |
---|
133 | |
---|
134 | answer = questdlg('Do you want to apply change ?','Confirmation dialog box'); |
---|
135 | |
---|
136 | % get selected bpm |
---|
137 | iSelected = get(handles.listbox_Bpm,'Value'); |
---|
138 | |
---|
139 | AO = getappdata(handles.figure1,'AO'); |
---|
140 | % Status one devices |
---|
141 | valid = find(AO.Status); |
---|
142 | valid = intersect(iSelected,valid); |
---|
143 | |
---|
144 | if isempty(valid) |
---|
145 | disp('Non BPM selected or status 0'); |
---|
146 | return; |
---|
147 | end |
---|
148 | |
---|
149 | |
---|
150 | valS = repmat('NaN',size(AO.DeviceName)); |
---|
151 | val = cellstr(valS); |
---|
152 | |
---|
153 | switch answer |
---|
154 | case 'Yes' |
---|
155 | %get selected command |
---|
156 | icmd = get(handles.popupmenu_Command,'Value'); |
---|
157 | cmdlist = get(handles.popupmenu_Command,'String'); |
---|
158 | command = cmdlist{icmd}; |
---|
159 | switch command |
---|
160 | case 'State' |
---|
161 | set(handles.listbox_Attribute,'String',val); |
---|
162 | for k=1:length(valid), |
---|
163 | val0 = tango_command_inout2(AO.DeviceName{valid(k)},command); |
---|
164 | val{valid(k)} = val0; |
---|
165 | end |
---|
166 | set(handles.listbox_Attribute,'String',val); |
---|
167 | otherwise % not output command |
---|
168 | for k=1:length(valid), |
---|
169 | tango_command_inout2(AO.DeviceName{valid(k)},command); |
---|
170 | end |
---|
171 | end |
---|
172 | case {'No','Cancel'} |
---|
173 | return; |
---|
174 | otherwise |
---|
175 | warning('Wrong answer') |
---|
176 | end |
---|
177 | |
---|
178 | |
---|
179 | function edit_Attribute_Callback(hObject, eventdata, handles) |
---|
180 | % hObject handle to edit_Attribute (see GCBO) |
---|
181 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
182 | % handles structure with handles and user data (see GUIDATA) |
---|
183 | |
---|
184 | % Hints: get(hObject,'String') returns contents of edit_Attribute as text |
---|
185 | % str2double(get(hObject,'String')) returns contents of edit_Attribute as a double |
---|
186 | |
---|
187 | answer = questdlg('Do you want to apply change ?','Confirmation dialog box'); |
---|
188 | iSelected = get(handles.listbox_Bpm,'Value'); |
---|
189 | |
---|
190 | AO = getappdata(handles.figure1,'AO'); |
---|
191 | % Status one devices |
---|
192 | valid = find(AO.Status); |
---|
193 | |
---|
194 | valid = intersect(iSelected,valid); |
---|
195 | |
---|
196 | if isempty(valid) |
---|
197 | disp('Non BPM selected or status 0'); |
---|
198 | return; |
---|
199 | end |
---|
200 | |
---|
201 | switch answer |
---|
202 | case 'Yes' |
---|
203 | |
---|
204 | % Get the new value |
---|
205 | value = get(hObject,'String'); |
---|
206 | if iscell(value) |
---|
207 | value = cellstr(value); |
---|
208 | end |
---|
209 | |
---|
210 | iAttribute = get(handles.popupmenu_Attribute,'Value'); |
---|
211 | attribute = get(handles.popupmenu_Attribute,'String'); |
---|
212 | |
---|
213 | if iAttribute == 1 || iAttribute == 2 || iAttribute == 3 || iAttribute == 6 || iAttribute == 7 |
---|
214 | value = str2double(value); |
---|
215 | end |
---|
216 | value = repmat(value,size(valid')); |
---|
217 | |
---|
218 | % Test on variable type |
---|
219 | switch attribute{iAttribute} |
---|
220 | case {'NumSamples','DDBufferSize'} |
---|
221 | type = 'int32'; |
---|
222 | case 'Switches' |
---|
223 | type = 'int16'; |
---|
224 | case 'Mode' |
---|
225 | type = 'String'; |
---|
226 | case {'DDEnabled','SAEnabled','AGCEnabled'} |
---|
227 | type = 'uint8'; |
---|
228 | otherwise |
---|
229 | type = 'double'; |
---|
230 | end |
---|
231 | |
---|
232 | disp([mfilename ': Processing ...']); |
---|
233 | % if (get(handles.checkbox_All,'Value') == 0) |
---|
234 | %% Get selected elements |
---|
235 | |
---|
236 | writeattribute(strcat(AO.DeviceName(valid), ... |
---|
237 | '/',attribute(iAttribute)), value,type); |
---|
238 | % else % All the same |
---|
239 | % writeattribute(strcat(AO.DeviceName(valid), ... |
---|
240 | % '/',attribute(iAttribute)), value,type) |
---|
241 | % end |
---|
242 | disp([mfilename ': Done ']); |
---|
243 | % refresh display |
---|
244 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
245 | |
---|
246 | case {'No','Cancel'} |
---|
247 | return; |
---|
248 | otherwise |
---|
249 | warning('Wrong answer') |
---|
250 | end |
---|
251 | |
---|
252 | |
---|
253 | % --- Executes during object creation, after setting all properties. |
---|
254 | function edit_Attribute_CreateFcn(hObject, eventdata, handles) |
---|
255 | % hObject handle to edit_Attribute (see GCBO) |
---|
256 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
257 | % handles empty - handles not created until after all CreateFcns called |
---|
258 | |
---|
259 | % Hint: edit controls usually have a white background on Windows. |
---|
260 | % See ISPC and COMPUTER. |
---|
261 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
262 | set(hObject,'BackgroundColor','white'); |
---|
263 | end |
---|
264 | |
---|
265 | |
---|
266 | % --- Executes on button press in pushbutton_Refresh. |
---|
267 | function pushbutton_Refresh_Callback(hObject, eventdata, handles) |
---|
268 | % hObject handle to pushbutton_Refresh (see GCBO) |
---|
269 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
270 | % handles structure with handles and user data (see GUIDATA) |
---|
271 | |
---|
272 | % refresh ALL |
---|
273 | iBpm = get(handles.listbox_Bpm,'Value'); |
---|
274 | iAttribute = get(handles.popupmenu_Attribute,'Value'); |
---|
275 | attribute = get(handles.popupmenu_Attribute,'String'); |
---|
276 | |
---|
277 | AO = getappdata(handles.figure1,'AO'); |
---|
278 | |
---|
279 | valid = find(AO.Status); |
---|
280 | val = ones(size(AO.DeviceName))*NaN'; |
---|
281 | valS = repmat('NaN',size(AO.DeviceName)); |
---|
282 | val0 = readattribute(strcat(AO.DeviceName(valid),'/',char(attribute(iAttribute)))); |
---|
283 | |
---|
284 | if iscellstr(val0) |
---|
285 | val = cellstr(valS); |
---|
286 | for k=1:length(valid) |
---|
287 | val{valid(k)} = val0{k}; |
---|
288 | end |
---|
289 | else |
---|
290 | val(valid) = val0; |
---|
291 | end |
---|
292 | |
---|
293 | % unpdate listbox |
---|
294 | set(handles.listbox_Attribute,'String',val); |
---|
295 | % update editbox |
---|
296 | set(handles.edit_Attribute,'String',val(1)); |
---|
297 | set(handles.listbox_Attribute,'Value',1); |
---|
298 | set(handles.listbox_Bpm,'Value',1); |
---|
299 | % uncheckk buttons |
---|
300 | set(handles.checkbox_All,'Value', 0); |
---|
301 | set(handles.checkbox_None,'Value', 0); |
---|
302 | |
---|
303 | % --- Executes on selection change in popupmenu_Attribute. |
---|
304 | function popupmenu_Attribute_Callback(hObject, eventdata, handles) |
---|
305 | % hObject handle to popupmenu_Attribute (see GCBO) |
---|
306 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
307 | % handles structure with handles and user data (see GUIDATA) |
---|
308 | |
---|
309 | % Hints: contents = get(hObject,'String') returns popupmenu_Attribute contents as cell array |
---|
310 | % contents{get(hObject,'Value')} returns selected item from popupmenu_Attribute |
---|
311 | |
---|
312 | % Force a refresh |
---|
313 | bpmconfigurator('pushbutton_Refresh_Callback',hObject, eventdata, handles); |
---|
314 | |
---|
315 | % --- Executes during object creation, after setting all properties. |
---|
316 | function popupmenu_Attribute_CreateFcn(hObject, eventdata, handles) |
---|
317 | % hObject handle to popupmenu_Attribute (see GCBO) |
---|
318 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
319 | % handles empty - handles not created until after all CreateFcns called |
---|
320 | |
---|
321 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
322 | % See ISPC and COMPUTER. |
---|
323 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
324 | set(hObject,'BackgroundColor','white'); |
---|
325 | end |
---|
326 | |
---|
327 | |
---|
328 | % --- Executes on button press in checkbox_All. |
---|
329 | function checkbox_All_Callback(hObject, eventdata, handles) |
---|
330 | % hObject handle to checkbox_All (see GCBO) |
---|
331 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
332 | % handles structure with handles and user data (see GUIDATA) |
---|
333 | |
---|
334 | % Hint: get(hObject,'Value') returns toggle state of checkbox_All |
---|
335 | |
---|
336 | val = get(handles.listbox_Bpm,'String'); |
---|
337 | |
---|
338 | if get(hObject,'Value') == 1 |
---|
339 | set(handles.checkbox_None,'Value',0); |
---|
340 | set(handles.listbox_Bpm,'Value',1:length(val)); |
---|
341 | set(handles.listbox_Attribute,'Value',1:length(val)); |
---|
342 | set(handles.listbox_Bpm,'listboxtop',1); |
---|
343 | set(handles.listbox_Attribute,'listboxtop',1); |
---|
344 | end |
---|
345 | |
---|
346 | % --- Executes on button press in checkbox_None. |
---|
347 | function checkbox_None_Callback(hObject, eventdata, handles) |
---|
348 | % hObject handle to checkbox_None (see GCBO) |
---|
349 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
350 | % handles structure with handles and user data (see GUIDATA) |
---|
351 | |
---|
352 | % Hint: get(hObject,'Value') returns toggle state of checkbox_None |
---|
353 | |
---|
354 | if get(hObject,'Value') == 1 |
---|
355 | set(handles.checkbox_All,'Value',0); |
---|
356 | set(handles.listbox_Bpm,'Value',1); |
---|
357 | set(handles.listbox_Attribute,'Value',1); |
---|
358 | end |
---|
359 | |
---|
360 | |
---|
361 | % --- Executes on selection change in listbox_Bpm. |
---|
362 | function listbox_Bpm_Callback(hObject, eventdata, handles) |
---|
363 | % hObject handle to listbox_Bpm (see GCBO) |
---|
364 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
365 | % handles structure with handles and user data (see GUIDATA) |
---|
366 | |
---|
367 | % Hints: contents = get(hObject,'String') returns listbox_Bpm contents as cell array |
---|
368 | % contents{get(hObject,'Value')} returns selected item from listbox_Bpm |
---|
369 | |
---|
370 | idx = get(hObject,'Value'); |
---|
371 | set(handles.listbox_Attribute,'Value',idx,'ListBoxTop',get(hObject,'ListboxTop')); |
---|
372 | |
---|
373 | set(handles.checkbox_All,'Value',0); |
---|
374 | set(handles.checkbox_None,'Value',0); |
---|
375 | |
---|
376 | |
---|
377 | % --- Executes during object creation, after setting all properties. |
---|
378 | function listbox_Bpm_CreateFcn(hObject, eventdata, handles) |
---|
379 | % hObject handle to listbox_Bpm (see GCBO) |
---|
380 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
381 | % handles empty - handles not created until after all CreateFcns called |
---|
382 | |
---|
383 | % Hint: listbox controls usually have a white background on Windows. |
---|
384 | % See ISPC and COMPUTER. |
---|
385 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
386 | set(hObject,'BackgroundColor','white'); |
---|
387 | end |
---|
388 | |
---|
389 | |
---|
390 | % --- Executes on selection change in listbox_Attribute. |
---|
391 | function listbox_Attribute_Callback(hObject, eventdata, handles) |
---|
392 | % hObject handle to listbox_Attribute (see GCBO) |
---|
393 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
394 | % handles structure with handles and user data (see GUIDATA) |
---|
395 | |
---|
396 | % Hints: contents = get(hObject,'String') returns listbox_Attribute contents as cell array |
---|
397 | % contents{get(hObject,'Value')} returns selected item from listbox_Attribute |
---|
398 | contents = get(hObject,'String'); |
---|
399 | idx = get(hObject,'Value'); |
---|
400 | set(handles.listbox_Bpm,'Value',idx,'ListBoxTop',get(hObject,'ListboxTop')); |
---|
401 | set(handles.checkbox_All,'Value',0); |
---|
402 | set(handles.checkbox_None,'Value',0); |
---|
403 | |
---|
404 | % Selected only first element |
---|
405 | % If all elements are numeric, return a char array and not a cell! |
---|
406 | if ischar(contents) |
---|
407 | contents = cellstr(contents); |
---|
408 | end |
---|
409 | set(handles.edit_Attribute,'String',contents{idx(1)}); |
---|
410 | |
---|
411 | % --- Executes during object creation, after setting all properties. |
---|
412 | function listbox_Attribute_CreateFcn(hObject, eventdata, handles) |
---|
413 | % hObject handle to listbox_Attribute (see GCBO) |
---|
414 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
415 | % handles empty - handles not created until after all CreateFcns called |
---|
416 | |
---|
417 | % Hint: listbox controls usually have a white background on Windows. |
---|
418 | % See ISPC and COMPUTER. |
---|
419 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
420 | set(hObject,'BackgroundColor','white'); |
---|
421 | end |
---|
422 | |
---|
423 | |
---|
424 | % -------------------------------------------------------------------- |
---|
425 | function uimenuBooster_Callback(hObject, eventdata, handles) |
---|
426 | % hObject handle to uimenuBooster (see GCBO) |
---|
427 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
428 | % handles structure with handles and user data (see GUIDATA) |
---|
429 | |
---|
430 | AD = getad; |
---|
431 | |
---|
432 | if isempty(AD) || ~strcmpi(AD.SubMachine,'Booster') |
---|
433 | setpathsoleil('Booster'); |
---|
434 | end |
---|
435 | |
---|
436 | init_uimenu(hObject, eventdata, handles); |
---|
437 | |
---|
438 | % -------------------------------------------------------------------- |
---|
439 | function uimenuAnneau_Callback(hObject, eventdata, handles) |
---|
440 | % hObject handle to uimenuAnneau (see GCBO) |
---|
441 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
442 | % handles structure with handles and user data (see GUIDATA) |
---|
443 | |
---|
444 | AD = getad; |
---|
445 | |
---|
446 | if isempty(AD) || ~strcmpi(AD.SubMachine,'StorageRing') |
---|
447 | setpathsoleil('StorageRing'); |
---|
448 | end |
---|
449 | |
---|
450 | init_uimenu(hObject, eventdata, handles); |
---|
451 | |
---|
452 | % -------------------------------------------------------------------- |
---|
453 | function Untitled_1_Callback(hObject, eventdata, handles) |
---|
454 | % hObject handle to Untitled_1 (see GCBO) |
---|
455 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
456 | % handles structure with handles and user data (see GUIDATA) |
---|
457 | |
---|
458 | function handles = init_uimenu(hObject, eventdata, handles) |
---|
459 | |
---|
460 | AO = getfamilydata('BPMx'); |
---|
461 | setappdata(handles.figure1,'AO', AO); |
---|
462 | |
---|
463 | %% Checked box |
---|
464 | all = findobj(get(hObject,'Parent'),'Type','UImenu'); |
---|
465 | set(all, 'Checked', 'Off'); |
---|
466 | set(hObject, 'Checked', 'On'); |
---|
467 | |
---|
468 | %% Initialize popupmenu w/ BPM |
---|
469 | listbpm = AO.DeviceName; |
---|
470 | set(handles.listbox_Bpm,'String',listbpm); |
---|
471 | |
---|
472 | devlist = get(handles.listbox_Bpm,'String'); |
---|
473 | val = readattribute([devlist{1},'/', 'SAEnabled']); |
---|
474 | ii = get(handles.uipanel_mode,'Children'); |
---|
475 | if val == 1 |
---|
476 | set(handles.uipanel_mode,'SelectedObject', ii(2)); |
---|
477 | else |
---|
478 | set(handles.uipanel_mode,'SelectedObject', ii(1)); |
---|
479 | end |
---|
480 | val = readattribute([devlist{1},'/', 'AGCEnabled']); |
---|
481 | set(handles.radiobutton_AGC,'Value', val); |
---|
482 | %cmdlist = get(handles.popupmenu_Command,'String'); |
---|
483 | |
---|
484 | |
---|
485 | % -------------------------------------------------------------------- |
---|
486 | function uimenuLT2_Callback(hObject, eventdata, handles) |
---|
487 | % hObject handle to uimenuLT2 (see GCBO) |
---|
488 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
489 | % handles structure with handles and user data (see GUIDATA) |
---|
490 | |
---|
491 | AD = getad; |
---|
492 | |
---|
493 | if isempty(AD) || ~strcmpi(AD.SubMachine,'LT2') |
---|
494 | setpathsoleil('LT2'); |
---|
495 | end |
---|
496 | |
---|
497 | init_uimenu(hObject, eventdata, handles); |
---|
498 | |
---|
499 | |
---|
500 | % --- Executes on selection change in popupmenu_Gain. |
---|
501 | function popupmenu_Gain_Callback(hObject, eventdata, handles) |
---|
502 | % hObject handle to popupmenu_Gain (see GCBO) |
---|
503 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
504 | % handles structure with handles and user data (see GUIDATA) |
---|
505 | |
---|
506 | % Hints: contents = get(hObject,'String') returns popupmenu_Gain contents as cell array |
---|
507 | % contents{get(hObject,'Value')} returns selected item from popupmenu_Gain |
---|
508 | |
---|
509 | contents = get(hObject,'String'); |
---|
510 | att = str2double(contents(get(hObject,'Value'),:)); |
---|
511 | tango_group_write_attribute(handles.groupID,'Gain',0,att); |
---|
512 | pause(1); |
---|
513 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
514 | |
---|
515 | % --- Executes during object creation, after setting all properties. |
---|
516 | function popupmenu_Gain_CreateFcn(hObject, eventdata, handles) |
---|
517 | % hObject handle to popupmenu_Gain (see GCBO) |
---|
518 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
519 | % handles empty - handles not created until after all CreateFcns called |
---|
520 | |
---|
521 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
522 | % See ISPC and COMPUTER. |
---|
523 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
524 | set(hObject,'BackgroundColor','white'); |
---|
525 | end |
---|
526 | |
---|
527 | |
---|
528 | % --- Executes on button press in checkbox_TbyTmode. |
---|
529 | function checkbox_TbyTmode_Callback(hObject, eventdata, handles) |
---|
530 | % hObject handle to checkbox_TbyTmode (see GCBO) |
---|
531 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
532 | % handles structure with handles and user data (see GUIDATA) |
---|
533 | |
---|
534 | % Hint: get(hObject,'Value') returns toggle state of checkbox_TbyTmode |
---|
535 | |
---|
536 | value = get(hObject,'Value'); |
---|
537 | if value == 0 % deactivation of SA mode |
---|
538 | tango_group_write_attribute(handles.groupID,'DDEnabled',0, uint8(0)); |
---|
539 | else % activation of SA mode |
---|
540 | tango_group_write_attribute(handles.groupID,'DDEnabled',0, uint8(1)); |
---|
541 | end |
---|
542 | pause(1); |
---|
543 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
544 | |
---|
545 | % --- Executes on button press in checkbox_SAmode. |
---|
546 | function checkbox_SAmode_Callback(hObject, eventdata, handles) |
---|
547 | % hObject handle to checkbox_SAmode (see GCBO) |
---|
548 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
549 | % handles structure with handles and user data (see GUIDATA) |
---|
550 | |
---|
551 | % Hint: get(hObject,'Value') returns toggle state of checkbox_SAmode |
---|
552 | |
---|
553 | value = get(hObject,'Value'); |
---|
554 | if value == 0 % deactivation of SA mode |
---|
555 | tango_group_write_attribute(handles.groupID,'SAEnabled',0, uint8(0)); |
---|
556 | %% deactivate switching Switches attribute 255 to 3 |
---|
557 | tango_group_write_attribute(handles.groupID,'Switches',0, 3); |
---|
558 | else % activation of SA mode |
---|
559 | tango_group_write_attribute(handles.groupID,'SAEnabled',0, uint8(1)); |
---|
560 | %% activate switching Digital Signal Conditioning |
---|
561 | tango_group_write_attribute(handles.groupID,'DSCEnabled',0, uint8(1)); |
---|
562 | end |
---|
563 | pause(1); |
---|
564 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
565 | |
---|
566 | |
---|
567 | % -------------------------------------------------------------------- |
---|
568 | function uipanel_mode_SelectionChangeFcn(hObject, eventdata, handles) |
---|
569 | % hObject handle to uipanel_mode (see GCBO) |
---|
570 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
571 | % handles structure with handles and user data (see GUIDATA) |
---|
572 | |
---|
573 | switch get(hObject,'Tag') % Get Tag of selected object |
---|
574 | case 'radiobutton1' % SA mode |
---|
575 | % Active switching mecanisme (work around for now because of Device |
---|
576 | % bugs) |
---|
577 | tango_group_write_attribute(handles.groupID,'Switches',0,int16(255)); |
---|
578 | tango_group_write_attribute(handles.groupID,'DSCEnabled',0,uint8(1)); |
---|
579 | pause(1); |
---|
580 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
581 | case 'radiobutton2' |
---|
582 | % Deactive switching mecanisme (work around for now because of Device |
---|
583 | % bugs) |
---|
584 | tango_group_write_attribute(handles.groupID,'Switches',0,int16(3)); |
---|
585 | pause(1); |
---|
586 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
587 | % Continue with more cases as necessary. |
---|
588 | end |
---|
589 | |
---|
590 | |
---|
591 | % --- Executes on button press in radiobutton_AGC. |
---|
592 | function radiobutton_AGC_Callback(hObject, eventdata, handles) |
---|
593 | % hObject handle to radiobutton_AGC (see GCBO) |
---|
594 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
595 | % handles structure with handles and user data (see GUIDATA) |
---|
596 | |
---|
597 | % Hint: get(hObject,'Value') returns toggle state of radiobutton_AGC |
---|
598 | |
---|
599 | value = get(hObject,'Value'); |
---|
600 | if value == 1 |
---|
601 | tango_group_write_attribute(handles.groupID,'AGCEnabled',0,uint8(1)); |
---|
602 | pause(1); |
---|
603 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
604 | else |
---|
605 | tango_group_write_attribute(handles.groupID,'AGCEnabled',0,uint8(0)); |
---|
606 | pause(1); |
---|
607 | pushbutton_Refresh_Callback(handles.pushbutton_Refresh,eventdata, handles); |
---|
608 | end |
---|
609 | |
---|
610 | |
---|
611 | % --- Executes on button press in pushbutton_initALL. |
---|
612 | function pushbutton_initALL_Callback(hObject, eventdata, handles) |
---|
613 | % hObject handle to pushbutton_initALL (see GCBO) |
---|
614 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
615 | % handles structure with handles and user data (see GUIDATA) |
---|
616 | |
---|
617 | commandName = 'Init'; |
---|
618 | tango_group_command_inout2(handles.groupID,commandName,0,0); |
---|
619 | pause(1); |
---|
620 | |
---|