source: MML/trunk/machine/THOMX/common/archiving/archiving_panel_mode.m @ 5

Last change on this file since 5 was 5, checked in by zhangj, 10 years ago

ThomX MML version on the LAL server @ 17/12/2013

  • Property svn:executable set to *
File size: 14.8 KB
Line 
1function 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
30gui_Singleton = 1;
31gui_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',   []);
37if nargin && ischar(varargin{1})
38    gui_State.gui_Callback = str2func(varargin{1});
39end
40
41if nargout
42    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
43else
44    gui_mainfcn(gui_State, varargin{:});
45end
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.
53function 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
61handles.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
66handles.mode.selection = {'0','0','0','0'};
67
68handles.mode.periodic.period     = '30'; %seconds
69
70handles.mode.absolute.period     = '60'; %seconds
71handles.mode.absolute.upperlimit = '50';
72handles.mode.absolute.lowerlimit = '50';
73
74handles.mode.relative.period     = '60'; %seconds
75handles.mode.relative.upperlimit = '50';
76handles.mode.relative.lowerlimit = '50';
77
78handles.mode.difference.period   = '3600'; %seconds
79
80handles.mode.keepingwindow = '3600000'; %ms, here for 1h
81handles.mode.exportwindow  = '600000';  %ms, here for 10 min
82handles.mode.grouped  = '0'; % 1: grouped, 0 ungrouped
83
84%% Case of no DB specified => force to HDB
85if isempty(varargin)
86    disp('No database specified: HDB by default')
87    handles.database = 'HDB';
88else
89    handles.database = varargin{1};
90end
91
92if 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;
96end
97
98%% Load actual parameter if they exist
99if 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
117end
118
119%% Create export window menu
120list_export = {'5 secondes','10 minutes'};
121set(handles.popupmenu_exportwindow,'String',list_export,'Value',2);
122
123%% Create keeping window menu
124list_keeping = {'1 hour','10 hours', '1 day'};
125set(handles.popupmenu_keepingwindow,'String',list_keeping,'Value',1);
126
127%Checked already running modes
128if str2double(handles.mode.selection{1})
129    set(handles.checkbox_periodic,'Value',1)
130end
131if str2double(handles.mode.selection{2})
132    set(handles.checkbox_absolute,'Value',1)
133end
134if str2double(handles.mode.selection{3})
135    set(handles.checkbox_relative,'Value',1)
136end
137
138%% Default value for parameter group
139set(handles.checkbox_grouped,'Value',str2double(handles.mode.grouped));
140
141% Update handles structure
142guidata(hObject, handles);
143% Update handles structure
144guidata(handles.figure1, handles);
145
146% UIWAIT makes tango_archiving_config wait for user response (see UIRESUME)
147uiwait(handles.figure1);
148
149% --- Outputs from this function are returned to the command line.
150function 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
159varargout{1} = handles.mode;
160
161% The figure can be deleted now
162delete(handles.figure1);
163
164% --- Executes on button press in checkbox_periodic.
165function 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
171val = get(hObject,'Value');
172
173% Build dialogbox inputs
174if strcmpi(handles.database,'TDB')
175    timeformat = 'ms';
176else
177    timeformat = 's';
178end
179
180prompt = {['Enter period (',timeformat,')']};
181name = 'Input for periodic archiving';
182numlines = 1;
183defaultanswer = {handles.mode.periodic.period};
184answer = inputdlg(prompt, name, numlines, defaultanswer);
185
186if ~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)
192else
193    disp('No selection');
194    handles.mode.selection{1} = '0';
195end
196
197% Update handles structure
198guidata(handles.figure1, handles);
199
200% --- Executes on button press in checkbox_absolute.
201function 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
208val = get(hObject,'Value');
209
210if strcmpi(handles.database,'TDB')
211    timeformat = 'ms';
212else
213    timeformat = 's';
214end
215
216% Build dialogbox inputs
217prompt = {...
218    ['Default period (',timeformat,')'], ...
219    ['Relative period (',timeformat,')'], ...
220    'Upper limit', ...
221    'Lower limit'};
222name = 'Input for absolute archiving';
223numlines = 1;
224defaultanswer = {...
225    handles.mode.periodic.period, ...
226    handles.mode.absolute.period, ...
227    handles.mode.absolute.lowerlimit, ...
228    handles.mode.absolute.upperlimit};
229
230answer = inputdlg(prompt, name, numlines, defaultanswer);
231
232if ~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)
245else
246    disp('No selection');
247    handles.mode.selection{2} = '0';
248end
249           
250
251% Update handles structure
252guidata(handles.figure1, handles);
253
254
255% --- Executes on button press in checkbox_relative.
256function 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
263val = get(hObject,'Value');
264
265if strcmpi(handles.database,'TDB')
266    timeformat = 'ms';
267else
268    timeformat = 's';
269end
270
271% Build dialogbox inputs
272prompt = {...
273    ['Default period (',timeformat,')'], ...
274    ['Relative period (',timeformat,')'], ...
275    'Upper limit (%)', ...
276    'Lower limit (%)'};
277name = 'Input for relative archiving';
278numlines = 1;
279defaultanswer = {...
280    handles.mode.periodic.period, ...
281    handles.mode.relative.period, ...
282    handles.mode.relative.lowerlimit, ...
283    handles.mode.relative.upperlimit};
284
285answer = inputdlg(prompt, name, numlines, defaultanswer);
286
287if ~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)
300else
301    disp('No selection');
302    handles.mode.selection{3} = '0';
303end
304
305% Update handles structure
306guidata(handles.figure1, handles);
307
308
309% --- Executes on button press in checkbox_difference.
310function 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
317val = get(hObject,'Value');
318
319switch 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');
330end
331
332% Update handles structure
333guidata(handles.figure1, handles);
334
335
336% --- Executes on button press in pushbutton_OK.
337function 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
342uiresume(handles.figure1);
343
344% --- Executes on button press in pushbutton_cancel.
345function 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
350uiresume(handles.figure1);
351handles.mode = -1;
352
353% Update handles structure
354guidata(handles.figure1, handles);
355
356% --- Executes on button press in checkbox_grouped.
357function 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
364handles.mode.grouped = num2str(get(hObject,'Value'));
365
366% Update handles structure
367guidata(handles.figure1, handles);
368
369% --- Executes on selection change in popupmenu_exportwindow.
370function 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
378contents = get(hObject,'String');
379
380%% converts entree to milliseconds
381switch contents{get(hObject,'Value')}
382    case '5 seconds'
383        handles.mode.exportwindow = '5000'; %ms
384    case '10 minutes'
385        handles.mode.exportwindow = '600000'; %ms
386end
387
388% Update handles structure
389guidata(handles.figure1, handles);
390
391% --- Executes during object creation, after setting all properties.
392function 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.
399if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
400    set(hObject,'BackgroundColor','white');
401end
402
403
404% --- Executes on selection change in popupmenu_keepingwindow.
405function 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
413contents = get(hObject,'String');
414
415%% converts entree to milliseconds
416switch 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
423end
424
425% Update handles structure
426guidata(handles.figure1, handles);
427
428% --- Executes during object creation, after setting all properties.
429function 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.
436if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
437    set(hObject,'BackgroundColor','white');
438end
439
440
Note: See TracBrowser for help on using the repository browser.