-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor_log.m
More file actions
63 lines (54 loc) · 2.02 KB
/
monitor_log.m
File metadata and controls
63 lines (54 loc) · 2.02 KB
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
%% monitor_log.m
% Simple function to provide user feedback for long transients.
function monitor_log()
global UUT %Make base workspace variable visible in function
ID = tcpip(UUT,2235); % 2235 = Transient Log
ID.terminator = 10; % ASCII line feed
ID.InputBufferSize = 200;
ID.Timeout = 5;
fopen(ID);
sample_count ='0';
lastwarn('');
while(1)
readback = fscanf(ID);
while(1) % Catch timeouts
if strfind(lastwarn,'Unsuccessful read')
lastwarn('');
readback = fscanf(ID);
else
break;
end
end
if strcmp(readback(1),'3') == 1 % When we move out of arm we know trigger has been received.
fprintf('\n...Trigger received...\n\n');
fprintf('...Running Transient Capture ...\n');
break;
end
end
while(1)
readback = fscanf(ID);
while(1) % Catch timeouts
if strfind(lastwarn,'Unsuccessful read')
lastwarn('');
readback = fscanf(ID);
else
break;
end
end
if (strcmp(readback(1),'1') == 1 || strcmp(readback(1),'2') == 1 || strcmp(readback(1),'3') == 1) % If transient is ongoing printout number of samples captured so far.
readback = textscan(readback,'%f');
readback = readback{1};
if strcmp(sample_count,readback(3)) == 0 % Only printout when sample number has updated.
readout = sprintf(' Samples captured = %i\n',readback(3));
fprintf(readout);
sample_count = readback(3);
end
elseif (strcmp(readback(1),'0') == 1 || strcmp(readback(1),'4') == 1) % Transient complete. Set done flag and escape.
fclose(ID);
delete(ID);
done = 1;
fprintf('\n...Post-processing...\n');
return;
end
end
end