1 | function varargout = archiving_panel_mode(varargin) |
---|
2 | % ARCHIVING_PANEL_MODE M-file for archiving_panel_mode.fig |
---|
3 | % ARCHIVING_PANEL_MODE, by itself, creates a new ARCHIVING_PANEL_MODE or raises the existing |
---|
4 | % singleton*. |
---|
5 | % |
---|
6 | % H = ARCHIVING_PANEL_MODE returns the handle to a new ARCHIVING_PANEL_MODE or the handle to |
---|
7 | % the existing singleton*. |
---|
8 | % |
---|
9 | % ARCHIVING_PANEL_MODE('CALLBACK',hObject,eventData,handles,...) calls the local |
---|
10 | % function named CALLBACK in ARCHIVING_PANEL_MODE.M with the given input arguments. |
---|
11 | % |
---|
12 | % ARCHIVING_PANEL_MODE('Property','Value',...) creates a new ARCHIVING_PANEL_MODE or raises the |
---|
13 | % existing singleton*. Starting from the left, property value pairs are |
---|
14 | % applied to the GUI before archiving_panel_mode_OpeningFunction gets called. An |
---|
15 | % unrecognized property name or invalid value makes property application |
---|
16 | % stop. All inputs are passed to archiving_panel_mode_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 archiving_panel_mode |
---|
26 | |
---|
27 | % Last Modified by GUIDE v2.5 18-Nov-2004 17:18:51 |
---|
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', @archiving_panel_mode_OpeningFcn, ... |
---|
34 | 'gui_OutputFcn', @archiving_panel_mode_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 | % Written by Laurent S. Nadolski |
---|
50 | |
---|
51 | |
---|
52 | % --- Executes just before archiving_panel_mode is made visible. |
---|
53 | function archiving_panel_mode_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
54 | % This function has no output args, see OutputFcn. |
---|
55 | % hObject handle to figure |
---|
56 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
57 | % handles structure with handles and user data (see GUIDATA) |
---|
58 | % varargin command line arguments to archiving_panel_mode (see VARARGIN) |
---|
59 | |
---|
60 | % Choose default command line output for archiving_panel_mode |
---|
61 | handles.output = hObject; |
---|
62 | |
---|
63 | % keep track of whether OK was clicked, this will be used in the OutputFcn |
---|
64 | % to determine whether to use the selected value |
---|
65 | |
---|
66 | handles.mode.selection = {'0','0','0','0'}; |
---|
67 | |
---|
68 | handles.mode.periodic.period = '30'; %seconds |
---|
69 | |
---|
70 | handles.mode.absolute.period = '60'; %seconds |
---|
71 | handles.mode.absolute.upperlimit = '50'; |
---|
72 | handles.mode.absolute.lowerlimit = '50'; |
---|
73 | |
---|
74 | handles.mode.relative.period = '60'; %seconds |
---|
75 | handles.mode.relative.upperlimit = '50'; |
---|
76 | handles.mode.relative.lowerlimit = '50'; |
---|
77 | |
---|
78 | handles.mode.difference.period = '3600'; %seconds |
---|
79 | |
---|
80 | handles.mode.keepingwindow = '3600000'; %ms, here for 1h |
---|
81 | handles.mode.exportwindow = '600000'; %ms, here for 10 min |
---|
82 | handles.mode.grouped = '0'; % 1: grouped, 0 ungrouped |
---|
83 | |
---|
84 | %% Case of no DB specified => force to HDB |
---|
85 | if isempty(varargin) |
---|
86 | disp('No database specified: HDB by default') |
---|
87 | handles.database = 'HDB'; |
---|
88 | else |
---|
89 | handles.database = varargin{1}; |
---|
90 | end |
---|
91 | |
---|
92 | if strcmpi(handles.database,'TDB') % convert to milliseconds |
---|
93 | handles.mode.periodic.period = '100'; %ms |
---|
94 | handles.mode.absolute.period = '1000'; %ms; |
---|
95 | handles.mode.relative.period = '1000'; %ms; |
---|
96 | end |
---|
97 | |
---|
98 | %% Load actual parameter if they exist |
---|
99 | if size(varargin,2) == 2 && isnumeric(varargin{2}) |
---|
100 | temp = varargin{2}; |
---|
101 | if temp(1,1) % if periodic |
---|
102 | handles.mode.selection{1} = '1'; |
---|
103 | handles.mode.periodic.period = num2str(temp(1,1)); %seconds |
---|
104 | end |
---|
105 | if temp(1,2) % if absolute |
---|
106 | handles.mode.selection{2} = '1'; |
---|
107 | handles.mode.absolute.period = num2str(temp(1,2)); %seconds |
---|
108 | handles.mode.absolute.upperlimit = num2str(temp(1,3)); |
---|
109 | handles.mode.absolute.lowerlimit = num2str(temp(1,4)); |
---|
110 | end |
---|
111 | if temp(1,5) % if relative |
---|
112 | handles.mode.selection{5} = '1'; |
---|
113 | handles.mode.relative.period = num2str(temp(1,5)); %seconds |
---|
114 | handles.mode.relative.upperlimit = num2str(temp(1,6)); |
---|
115 | handles.mode.relative.lowerlimit = num2str(temp(1,7)); |
---|
116 | end |
---|
117 | end |
---|
118 | |
---|
119 | %% Create export window menu |
---|
120 | list_export = {'5 secondes','10 minutes'}; |
---|
121 | set(handles.popupmenu_exportwindow,'String',list_export,'Value',2); |
---|
122 | |
---|
123 | %% Create keeping window menu |
---|
124 | list_keeping = {'1 hour','10 hours', '1 day'}; |
---|
125 | set(handles.popupmenu_keepingwindow,'String',list_keeping,'Value',1); |
---|
126 | |
---|
127 | %Checked already running modes |
---|
128 | if str2double(handles.mode.selection{1}) |
---|
129 | set(handles.checkbox_periodic,'Value',1) |
---|
130 | end |
---|
131 | if str2double(handles.mode.selection{2}) |
---|
132 | set(handles.checkbox_absolute,'Value',1) |
---|
133 | end |
---|
134 | if str2double(handles.mode.selection{3}) |
---|
135 | set(handles.checkbox_relative,'Value',1) |
---|
136 | end |
---|
137 | |
---|
138 | %% Default value for parameter group |
---|
139 | set(handles.checkbox_grouped,'Value',str2double(handles.mode.grouped)); |
---|
140 | |
---|
141 | % Update handles structure |
---|
142 | guidata(hObject, handles); |
---|
143 | % Update handles structure |
---|
144 | guidata(handles.figure1, handles); |
---|
145 | |
---|
146 | % UIWAIT makes tango_archiving_config wait for user response (see UIRESUME) |
---|
147 | uiwait(handles.figure1); |
---|
148 | |
---|
149 | % --- Outputs from this function are returned to the command line. |
---|
150 | function varargout = archiving_panel_mode_OutputFcn(hObject, eventdata, handles) |
---|
151 | % varargout cell array for returning output args (see VARARGOUT); |
---|
152 | % hObject handle to figure |
---|
153 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
154 | % handles structure with handles and user data (see GUIDATA) |
---|
155 | |
---|
156 | % Get default command line output from handles structure |
---|
157 | |
---|
158 | %% Returns archiving parameters |
---|
159 | varargout{1} = handles.mode; |
---|
160 | |
---|
161 | % The figure can be deleted now |
---|
162 | delete(handles.figure1); |
---|
163 | |
---|
164 | % --- Executes on button press in checkbox_periodic. |
---|
165 | function checkbox_periodic_Callback(hObject, eventdata, handles) |
---|
166 | % hObject handle to checkbox_periodic (see GCBO) |
---|
167 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
168 | % handles structure with handles and user data (see GUIDATA) |
---|
169 | |
---|
170 | % Hint: get(hObject,'Value') returns toggle state of checkbox_periodic |
---|
171 | val = get(hObject,'Value'); |
---|
172 | |
---|
173 | % Build dialogbox inputs |
---|
174 | if strcmpi(handles.database,'TDB') |
---|
175 | timeformat = 'ms'; |
---|
176 | else |
---|
177 | timeformat = 's'; |
---|
178 | end |
---|
179 | |
---|
180 | prompt = {['Enter period (',timeformat,')']}; |
---|
181 | name = 'Input for periodic archiving'; |
---|
182 | numlines = 1; |
---|
183 | defaultanswer = {handles.mode.periodic.period}; |
---|
184 | answer = inputdlg(prompt, name, numlines, defaultanswer); |
---|
185 | |
---|
186 | if ~isempty(answer) |
---|
187 | handles.mode.selection{1} = '1'; |
---|
188 | handles.mode.periodic.period = answer{1}; |
---|
189 | |
---|
190 | %% Force checkbox if mode is running |
---|
191 | set(handles.checkbox_periodic,'Value',1) |
---|
192 | else |
---|
193 | disp('No selection'); |
---|
194 | handles.mode.selection{1} = '0'; |
---|
195 | end |
---|
196 | |
---|
197 | % Update handles structure |
---|
198 | guidata(handles.figure1, handles); |
---|
199 | |
---|
200 | % --- Executes on button press in checkbox_absolute. |
---|
201 | function checkbox_absolute_Callback(hObject, eventdata, handles) |
---|
202 | % hObject handle to checkbox_absolute (see GCBO) |
---|
203 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
204 | % handles structure with handles and user data (see GUIDATA) |
---|
205 | |
---|
206 | % Hint: get(hObject,'Value') returns toggle state of checkbox_absolute |
---|
207 | |
---|
208 | val = get(hObject,'Value'); |
---|
209 | |
---|
210 | if strcmpi(handles.database,'TDB') |
---|
211 | timeformat = 'ms'; |
---|
212 | else |
---|
213 | timeformat = 's'; |
---|
214 | end |
---|
215 | |
---|
216 | % Build dialogbox inputs |
---|
217 | prompt = {... |
---|
218 | ['Default period (',timeformat,')'], ... |
---|
219 | ['Relative period (',timeformat,')'], ... |
---|
220 | 'Upper limit', ... |
---|
221 | 'Lower limit'}; |
---|
222 | name = 'Input for absolute archiving'; |
---|
223 | numlines = 1; |
---|
224 | defaultanswer = {... |
---|
225 | handles.mode.periodic.period, ... |
---|
226 | handles.mode.absolute.period, ... |
---|
227 | handles.mode.absolute.lowerlimit, ... |
---|
228 | handles.mode.absolute.upperlimit}; |
---|
229 | |
---|
230 | answer = inputdlg(prompt, name, numlines, defaultanswer); |
---|
231 | |
---|
232 | if ~isempty(answer) |
---|
233 | % Periodic part |
---|
234 | handles.mode.selection{1} = '1'; |
---|
235 | handles.mode.periodic.period = answer{1}; |
---|
236 | % Absolute part |
---|
237 | handles.mode.selection{2} = '1'; |
---|
238 | handles.mode.absolute.period = answer{2}; |
---|
239 | handles.mode.absolute.lowerlimit = answer{3}; |
---|
240 | handles.mode.absolute.upperlimit = answer{4}; |
---|
241 | |
---|
242 | %% Force checkbox if mode is running |
---|
243 | set(handles.checkbox_absolute,'Value',1) |
---|
244 | set(handles.checkbox_periodic,'Value',1) |
---|
245 | else |
---|
246 | disp('No selection'); |
---|
247 | handles.mode.selection{2} = '0'; |
---|
248 | end |
---|
249 | |
---|
250 | |
---|
251 | % Update handles structure |
---|
252 | guidata(handles.figure1, handles); |
---|
253 | |
---|
254 | |
---|
255 | % --- Executes on button press in checkbox_relative. |
---|
256 | function checkbox_relative_Callback(hObject, eventdata, handles) |
---|
257 | % hObject handle to checkbox_relative (see GCBO) |
---|
258 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
259 | % handles structure with handles and user data (see GUIDATA) |
---|
260 | |
---|
261 | % Hint: get(hObject,'Value') returns toggle state of checkbox_relative |
---|
262 | |
---|
263 | val = get(hObject,'Value'); |
---|
264 | |
---|
265 | if strcmpi(handles.database,'TDB') |
---|
266 | timeformat = 'ms'; |
---|
267 | else |
---|
268 | timeformat = 's'; |
---|
269 | end |
---|
270 | |
---|
271 | % Build dialogbox inputs |
---|
272 | prompt = {... |
---|
273 | ['Default period (',timeformat,')'], ... |
---|
274 | ['Relative period (',timeformat,')'], ... |
---|
275 | 'Upper limit (%)', ... |
---|
276 | 'Lower limit (%)'}; |
---|
277 | name = 'Input for relative archiving'; |
---|
278 | numlines = 1; |
---|
279 | defaultanswer = {... |
---|
280 | handles.mode.periodic.period, ... |
---|
281 | handles.mode.relative.period, ... |
---|
282 | handles.mode.relative.lowerlimit, ... |
---|
283 | handles.mode.relative.upperlimit}; |
---|
284 | |
---|
285 | answer = inputdlg(prompt, name, numlines, defaultanswer); |
---|
286 | |
---|
287 | if ~isempty(answer) |
---|
288 | % Periodic part |
---|
289 | handles.mode.selection{1} = '1'; |
---|
290 | handles.mode.periodic.period = answer{1}; |
---|
291 | % Relative mode part |
---|
292 | handles.mode.selection{3} = '1'; |
---|
293 | handles.mode.relative.period = answer{2}; |
---|
294 | handles.mode.relative.upperlimit = answer{3}; |
---|
295 | handles.mode.relative.lowerlimit = answer{4}; |
---|
296 | |
---|
297 | %% Force checkbox if mode is running |
---|
298 | set(handles.checkbox_relative,'Value',1) |
---|
299 | set(handles.checkbox_periodic,'Value',1) |
---|
300 | else |
---|
301 | disp('No selection'); |
---|
302 | handles.mode.selection{3} = '0'; |
---|
303 | end |
---|
304 | |
---|
305 | % Update handles structure |
---|
306 | guidata(handles.figure1, handles); |
---|
307 | |
---|
308 | |
---|
309 | % --- Executes on button press in checkbox_difference. |
---|
310 | function checkbox_difference_Callback(hObject, eventdata, handles) |
---|
311 | % hObject handle to checkbox_difference (see GCBO) |
---|
312 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
313 | % handles structure with handles and user data (see GUIDATA) |
---|
314 | |
---|
315 | % Hint: get(hObject,'Value') returns toggle state of checkbox_difference |
---|
316 | |
---|
317 | val = get(hObject,'Value'); |
---|
318 | |
---|
319 | switch val |
---|
320 | case 1 |
---|
321 | prompt = {'Default period (s)'}; |
---|
322 | name = 'Input for on difference archiving'; |
---|
323 | numlines = 1; |
---|
324 | defaultanswer = {'3600'}; |
---|
325 | answer = inputdlg(prompt, name, numlines, defaultanswer); |
---|
326 | handles.mode.selection{4} = '1'; |
---|
327 | handles.mode.difference.defaultperiod = answer(1); |
---|
328 | otherwise |
---|
329 | disp('No selection'); |
---|
330 | end |
---|
331 | |
---|
332 | % Update handles structure |
---|
333 | guidata(handles.figure1, handles); |
---|
334 | |
---|
335 | |
---|
336 | % --- Executes on button press in pushbutton_OK. |
---|
337 | function pushbutton_OK_Callback(hObject, eventdata, handles) |
---|
338 | % hObject handle to pushbutton_OK (see GCBO) |
---|
339 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
340 | % handles structure with handles and user data (see GUIDATA) |
---|
341 | |
---|
342 | uiresume(handles.figure1); |
---|
343 | |
---|
344 | % --- Executes on button press in pushbutton_cancel. |
---|
345 | function pushbutton_cancel_Callback(hObject, eventdata, handles) |
---|
346 | % hObject handle to pushbutton_cancel (see GCBO) |
---|
347 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
348 | % handles structure with handles and user data (see GUIDATA) |
---|
349 | |
---|
350 | uiresume(handles.figure1); |
---|
351 | handles.mode = -1; |
---|
352 | |
---|
353 | % Update handles structure |
---|
354 | guidata(handles.figure1, handles); |
---|
355 | |
---|
356 | % --- Executes on button press in checkbox_grouped. |
---|
357 | function checkbox_grouped_Callback(hObject, eventdata, handles) |
---|
358 | % hObject handle to checkbox_grouped (see GCBO) |
---|
359 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
360 | % handles structure with handles and user data (see GUIDATA) |
---|
361 | |
---|
362 | % Hint: get(hObject,'Value') returns toggle state of checkbox_grouped |
---|
363 | |
---|
364 | handles.mode.grouped = num2str(get(hObject,'Value')); |
---|
365 | |
---|
366 | % Update handles structure |
---|
367 | guidata(handles.figure1, handles); |
---|
368 | |
---|
369 | % --- Executes on selection change in popupmenu_exportwindow. |
---|
370 | function popupmenu_exportwindow_Callback(hObject, eventdata, handles) |
---|
371 | % hObject handle to popupmenu_exportwindow (see GCBO) |
---|
372 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
373 | % handles structure with handles and user data (see GUIDATA) |
---|
374 | |
---|
375 | % Hints: contents = get(hObject,'String') returns popupmenu_exportwindow contents as cell array |
---|
376 | % contents{get(hObject,'Value')} returns selected item from popupmenu_exportwindow |
---|
377 | |
---|
378 | contents = get(hObject,'String'); |
---|
379 | |
---|
380 | %% converts entree to milliseconds |
---|
381 | switch contents{get(hObject,'Value')} |
---|
382 | case '5 seconds' |
---|
383 | handles.mode.exportwindow = '5000'; %ms |
---|
384 | case '10 minutes' |
---|
385 | handles.mode.exportwindow = '600000'; %ms |
---|
386 | end |
---|
387 | |
---|
388 | % Update handles structure |
---|
389 | guidata(handles.figure1, handles); |
---|
390 | |
---|
391 | % --- Executes during object creation, after setting all properties. |
---|
392 | function popupmenu_exportwindow_CreateFcn(hObject, eventdata, handles) |
---|
393 | % hObject handle to popupmenu_exportwindow (see GCBO) |
---|
394 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
395 | % handles empty - handles not created until after all CreateFcns called |
---|
396 | |
---|
397 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
398 | % See ISPC and COMPUTER. |
---|
399 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
400 | set(hObject,'BackgroundColor','white'); |
---|
401 | end |
---|
402 | |
---|
403 | |
---|
404 | % --- Executes on selection change in popupmenu_keepingwindow. |
---|
405 | function popupmenu_keepingwindow_Callback(hObject, eventdata, handles) |
---|
406 | % hObject handle to popupmenu_keepingwindow (see GCBO) |
---|
407 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
408 | % handles structure with handles and user data (see GUIDATA) |
---|
409 | |
---|
410 | % Hints: contents = get(hObject,'String') returns popupmenu_keepingwindow contents as cell array |
---|
411 | % contents{get(hObject,'Value')} returns selected item from popupmenu_keepingwindow |
---|
412 | |
---|
413 | contents = get(hObject,'String'); |
---|
414 | |
---|
415 | %% converts entree to milliseconds |
---|
416 | switch contents{get(hObject,'Value')} |
---|
417 | case '1 hour' |
---|
418 | handles.mode.keepingwindow = '3600000'; %ms |
---|
419 | case '10 hours' |
---|
420 | handles.mode.keepingwindow = '36000000'; %ms |
---|
421 | case '1 day' |
---|
422 | handles.mode.keepingwindow = '86400000'; %ms |
---|
423 | end |
---|
424 | |
---|
425 | % Update handles structure |
---|
426 | guidata(handles.figure1, handles); |
---|
427 | |
---|
428 | % --- Executes during object creation, after setting all properties. |
---|
429 | function popupmenu_keepingwindow_CreateFcn(hObject, eventdata, handles) |
---|
430 | % hObject handle to popupmenu_keepingwindow (see GCBO) |
---|
431 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
432 | % handles empty - handles not created until after all CreateFcns called |
---|
433 | |
---|
434 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
435 | % See ISPC and COMPUTER. |
---|
436 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
437 | set(hObject,'BackgroundColor','white'); |
---|
438 | end |
---|
439 | |
---|
440 | |
---|