-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitializeVariables.m
191 lines (134 loc) · 5.58 KB
/
InitializeVariables.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
function InitializeVariables(handles)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
%% initializing settings parameter variables -- do not initialize defaults here because this function is called each time at each start button press and also the formatting is done in DaqMultiChannelGuiInit() before calling this function
% Daq Date and Time code
daqDateTime = datetime('now');
setappdata(handles.figure1,'settings_daqDateTime',daqDateTime);
% Session Date
sessionDate = datestr(daqDateTime,'dd-mmmm-yyyy');
setappdata(handles.figure1,'settings_sessionDate',sessionDate);
% Session Time
sessionTime = datestr(daqDateTime,'HH:MM:SS AM');
setappdata(handles.figure1,'settings_sessionTime',sessionTime);
% Custom ID
customId = get(handles.edit_customId,'String');
setappdata(handles.figure1,'settings_customId',customId);
% Session ID
yearValue = daqDateTime.Year;
yearValue = num2str(yearValue);
monthValue = daqDateTime.Month;
if(monthValue<10)
monthValue = sprintf('0%d',monthValue);
else
monthValue = num2str(monthValue);
end
dateValue = daqDateTime.Day;
if(dateValue<10)
dateValue = sprintf('0%d',dateValue);
else
dateValue = num2str(dateValue);
end
hourValue = daqDateTime.Hour;
if(hourValue<10)
hourValue = sprintf('0%d',hourValue);
else
hourValue = num2str(hourValue);
end
minuteValue = daqDateTime.Minute;
if(minuteValue<10)
minuteValue = sprintf('0%d',minuteValue);
else
minuteValue = num2str(minuteValue);
end
secondValue = fix(daqDateTime.Second);
if(secondValue<10)
secondValue = sprintf('0%d',secondValue);
else
secondValue = num2str(secondValue);
end
sessionId = sprintf('%s%s%s%s%s%s%s', yearValue, monthValue, dateValue, hourValue, minuteValue, secondValue,customId);
setappdata(handles.figure1,'settings_sessionId',sessionId);
% Session Duration
sessionDuration = str2double(get(handles.edit_sessionDuration,'String'));
setappdata(handles.figure1,'settings_sessionDuration',sessionDuration);
% Sampling Frequency
samplingFrequency = str2double(get(handles.edit_samplingFrequency,'String'));
setappdata(handles.figure1,'settings_samplingFrequency',samplingFrequency);
% Sampling Time Interval
setappdata(handles.figure1,'settings_samplingTimeInterval',1/samplingFrequency);
% Scroll Plot Width
scrollPlotWidth = str2double(get(handles.edit_scrollPlotWidth,'String'));
setappdata(handles.figure1,'setting_scrollPlotWidth',scrollPlotWidth);
% Right Offset
setappdata(handles.figure1,'settings_rightOffset',ceil(scrollPlotWidth/10));
% Scaling Function
isDataScaling = getappdata(handles.figure1,'flags_isDataScaling');
if(isDataScaling)
scalingFunction = get(handles.edit_scalingFunction,'String');
setappdata(handles.figure1,'settings_scalingFunction',scalingFunction);
end
% Number of samples to be recorded
numberOfSamples = samplingFrequency * sessionDuration;
setappdata(handles.figure1,'settings_numberOfSamples',numberOfSamples);
% Number of channels to be recorded
setappdata(handles.figure1,'settings_numberOfActiveChannels',[]);
isChannel1Running = getappdata(handles.figure1,'flags_isChannel1Running');
isChannel2Running = getappdata(handles.figure1,'flags_isChannel2Running');
isChannel3Running = getappdata(handles.figure1,'flags_isChannel3Running');
isChannel4Running = getappdata(handles.figure1,'flags_isChannel4Running');
isChannel5Running = getappdata(handles.figure1,'flags_isChannel5Running');
if(~isChannel1Running)
% Channel 1 type and pin
setappdata(handles.figure1,'settings_channel1Type',[]);
setappdata(handles.figure1,'settings_channel1Pin',[]);
end
if(~isChannel2Running)
% Channel 2 type and pin
setappdata(handles.figure1,'settings_channel2Type',[]);
setappdata(handles.figure1,'settings_channel2Pin',[]);
end
if(~isChannel3Running)
% Channel 2 type and pin
setappdata(handles.figure1,'settings_channel3Type',[]);
setappdata(handles.figure1,'settings_channel3Pin',[]);
end
if(~isChannel4Running)
% Channel 2 type and pin
setappdata(handles.figure1,'settings_channel4Type',[]);
setappdata(handles.figure1,'settings_channel4Pin',[]);
end
if(~isChannel5Running)
% Channel 2 type and pin
setappdata(handles.figure1,'settings_channel5Type',[]);
setappdata(handles.figure1,'settings_channel5Pin',[]);
end
% yMin and yMax value
setappdata(handles.figure1,'settings_yMinValue',str2double(get(handles.edit_yMinValue,'String')));
setappdata(handles.figure1,'settings_yMaxValue',str2double(get(handles.edit_yMaxValue,'String')));
% Status message for the user
setappdata(handles.figure1,'settings_statusMsg',[]);
%% initializing data parameter variables and populating with the blank
% The time stamps of the data
setappdata(handles.figure1,'data_timeStampsRaw',[]);
setappdata(handles.figure1,'data_timeStampsMsec',[]);
% The raw data acquired - Channel 1 to 5
setappdata(handles.figure1,'data_rawDataChannel1',[]);
setappdata(handles.figure1,'data_rawDataChannel2',[]);
setappdata(handles.figure1,'data_rawDataChannel3',[]);
setappdata(handles.figure1,'data_rawDataChannel4',[]);
setappdata(handles.figure1,'data_rawDataChannel5',[]);
% The scaled data based on selected scaling function
setappdata(handles.figure1,'data_scaledDataChannel1',[]);
% the actual recorded session duration
setappdata(handles.figure1,'data_recordedSessionDuration',[]);
% The actual recorded sampling frequency (This will be computed after acquisition)
setappdata(handles.figure1,'data_recordedSamplingFrequency',[]);
% The actual recorded number of samples
setappdata(handles.figure1,'data_recordedNumberOfSamples',[]);
% Data Quality
setappdata(handles.figure1,'data_dataQuality',[]);
% The sample number
setappdata(handles.figure1,'data_sampleNumber',[]);
drawnow
end