This repository was archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGui_main.m
232 lines (182 loc) · 7.98 KB
/
Gui_main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
%E.E.E.-analyzer - Gui_main by Fabio Pinciroli
%Copyright 2017 Fabio Pinciroli DISTRIBUTED UNDER GPL V3 LICENSE
% Start initialization code - DO NOT EDIT - AUTOGENERATED
function varargout = Gui_main(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Gui_main_OpeningFcn, ...
'gui_OutputFcn', @Gui_main_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
end
function varargout = Gui_main_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
end
function txt_Filepath_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
function txt_WgetPath_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
function txt_V20Path_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
function ppmen_GraphFormat_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% End initialization code - DO NOT EDIT - AUTOGENERATED
%CALLBACKS-----------------------------------------------------------------
% Initialization callback(executes when window is shown)
function Gui_main_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject; %autogenerated
CheckOk = true;
%Check if other matlab files exist
if exist('EEEanalyzer_bin.m', 'file') ~= 2
CheckOk = false;
end
if exist('GraphStats.m', 'file') ~= 2
CheckOk = false;
end
if exist('Gui_main.fig', 'file') ~= 2
CheckOk = false;
end
if CheckOk == false
errordlg('Integrity control failed.');
quit();
end
handles.GraphFormat = 'png'; %create default values
handles.StatsEnable = 1;
handles.DqmEnable = 1;
handles.wGetName = '';
%handle preferences
try %try to load preferences
handles.v20Name = getpref('EEEanalyzer','v20Name');
handles.v20Dir = getpref('EEEanalyzer','v20Dir');
set(handles.txt_V20Path, 'String', strcat(handles.v20Dir, handles.v20Name));
catch A %if failed
%do nothing
end
guidata(hObject, handles); %update preferences
end
% Go button
function btn_Go_Callback(hObject, eventdata, handles)
isDataValid = true %data valid flag
try %check if variable is good by trying to read it
tmp = handles.fName;
catch A %if it isn't
errordlg('Data file path is incorrect.'); %alert
isDataValid = false; %set flag to false
end
try %check if variable is good by trying to read it
tmp = handles.fDir;
catch A %if it isn't
errordlg('Data file path is incorrect.'); %alert
isDataValid = false; %set flag to false
end
try %check if variable is good by trying to read it
tmp = handles.v20Name;
catch A %if it isn't
errordlg('EEE_V20.exe executable path is incorrect.'); %alert
isDataValid = false; %set flag to false
end
try %check if variable is good by trying to read it
tmp = handles.v20Dir;
catch A %if it isn't
errordlg('EEE_V20.exe executable path is incorrect.'); %alert
isDataValid = false; %set flag to false
end
%save preferences
getpref('EEEanalyzer','v20Name', handles.v20Name);
getpref('EEEanalyzer','v20Dir', handles.v20Dir);
guidata(hObject, handles); %update global handle
if(isDataValid == true) %if all data is valid
EEEanalyzer_bin(handles.GraphFormat, handles.fName, handles.fDir, handles.v20Name, handles.v20Dir, handles.DqmEnable, handles.StatsEnable); %run analysis
waitfor(msgbox('Conversion finished'));
end
end
%Choose File button
function btn_ChooseFile_Callback(hObject, eventdata, handles)
[fName, fDir] = uigetfile('*.bin', 'Select data file'); %spawn choose file dialog and get data into local variables
handles.fName = fName; %move variables to matlab handle
handles.fDir = fDir;
guidata(hObject,handles); %update global handle
set(handles.txt_Filepath, 'String', strcat(fDir, fName)); %Update the the filepath text
end
%Filepath text modified
function txt_Filepath_Callback(hObject, eventdata, handles)
str = get(handles.txt_Filepath, 'String'); %get string into local variable
cnt = length(str); %set counter to string length
while(str((cnt - 1) : cnt) ~= '\') %go backwards from the end of the string until you find \
cnt = cnt - 1;
end
fName = str(cnt : length(str)); %from the next character to the last \ to the end of the string is the file name
fDir = str(1 : (cnt - 1)); %from the beginning of the string to the last \ is the directory
handles.fName = fName; %move variables to matlab handle
handles.fDir = fDir;
guidata(hObject,handles); %update global handle
end
%V20 button pressed
function btn_ChooseV20_Callback(hObject, eventdata, handles)
[v20Name, v20Dir] = uigetfile('*.exe', 'Select EEE_V20.exe'); %spawn choose file dialog and get data into local variables
handles.v20Name = v20Name; %move variables to matlab handle
handles.v20Dir = v20Dir;
guidata(hObject,handles); %update global handle
set(handles.txt_V20Path, 'String', strcat(v20Dir, v20Name)); %Update the the filepath text
end
%V20 text changed
function txt_V20Path_Callback(hObject, eventdata, handles)
str = get(handles.txt_V20Path, 'String'); %get string into local variable
cnt = length(str); %set counter to string length
while(str((cnt - 1) : cnt) ~= '\') %go backwards from the end of the string until you find \
cnt = cnt - 1;
end
v20Name = str(cnt : length(str)); %from the next character to the last \ to the end of the string is the file name
v20Dir = str(1 : (cnt - 1)); %from the beginning of the string to the last \ is the directory
handles.v20Name = v20Name; %move variables to matlab handle
handles.v20Dir = v20Dir;
guidata(hObject,handles); %update global handle
end
%Dqm enable checkbox changed
function cbx_DqmEnable_Callback(hObject, eventdata, handles)
var = get(handles.cbx_DqmEnable, 'Value'); %get checkbox value into local variable
if(var == 0) %if variable 0
var = false; %result is false
else %else
var = true; %result is true
end
handles.DqmEnable = var; %move variable to matlab handle
guidata(hObject,handles); %update global handle
end
%Statistics enable checkbox changed
function cbx_StatsEnable_Callback(hObject, eventdata, handles)
var = get(handles.cbx_StatsEnable, 'Value'); %get checkbox value into local variable
if(var == 0) %if variable 0
var = false; %result is false
else %else
var = true; %result is true
end
handles.StatsEnable = var; %move variable to matlab handle
guidata(hObject,handles); %update global handle
end
%Graphs save mode changed
function ppmen_GraphFormat_Callback(hObject, eventdata, handles)
handles.GraphFormat = get(handles.ppmen_GraphFormat, 'String');; %get data and move it to matlab handle
guidata(hObject,handles); %update global handle
end