-
Notifications
You must be signed in to change notification settings - Fork 4
/
awgclear.m
executable file
·97 lines (87 loc) · 2.67 KB
/
awgclear.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
function awgclear(groups,options)
% awgclear(groups)
% OR
% awgclear('all')
% awgclear('pack') removes all groups, adds back groups loaded in sequences
% awgclear('all','paranoid') removes all waveforms, including those not known to be loaded.
% awgclear('pack','paranoid') similar
% (c) 2010 Hendrik Bluhm. Please see LICENSE and COPYRIGHT information in plssetup.m.
if ~exist('options','var')
options='';
end
global awgdata;
global plsdata;
if strcmp(groups, 'pack')
grps={awgdata(1).pulsegroups.name};
awgclear('all',options);
awgadd(grps);
return;
end
if strcmp(groups, 'all')
% Mark only groups known to be loaded as loaded.
if isempty(strfind(options,'paranoid'))
g=awgwaveforms;
else % Mark all pulse groups as not loaded
g=plsinfo('ls');
end
for a=1:length(awgdata)
fprintf(awgdata(a).awg,'WLIS:WAV:DEL ALL\n')
awgdata(a).zeropls=[];
end
logentry('Cleared all pulses.');
for i=1:length(g)
load([plsdata.grpdir, 'pg_', g{i}, '.mat'], 'plslog');
if(plslog(end).time(end) <= 0)
%fprintf('Skipping group ''%s''; already unloaded\n',g{i});
else
plslog(end).time(end+1) = -now;
save([plsdata.grpdir, 'pg_', g{i}, '.mat'], 'plslog','-append');
%fprintf('Marking group ''%s'' as unloaded\n',g{i});
end
end
awgrm('all');
return;
end
if strcmp(groups,'unused')
g=awgwaveforms;
g2={awgdata(1).pulsegroups.name};
groups=setdiff(g,g2);
for i=1:length(groups)
fprintf('Unloading %s\n',groups{i});
end
end
if ischar(groups)
groups = {groups};
end
tic;
for a=1:length(awgdata)
if isreal(groups)
groups = sort(groups, 'descend');
for i = groups
wf = query(awgdata(a).awg, sprintf('WLIS:NAME? %d', i));
if ~query(awgdata(a).awg, sprintf('WLIS:WAV:PRED? %s', wf), '%s\n', '%i')
fprintf(awgdata(a).awg, 'WLIS:WAV:DEL %s', wf);
end
if toc > 20
fprintf('%i/%i\n', i, length(groups));
tic;
end
end
awgcntrl('wait');
return;
end
end
for k = 1:length(groups)
load([plsdata.grpdir, 'pg_', groups{k}], 'plslog');
for a=1:length(awgdata)
wfms=awgwaveforms(groups{k},a,'delete');
for i=1:length(wfms)
fprintf(awgdata(a).awg, sprintf('WLIS:WAV:DEL "%s"', wfms{i}));
end
end
plslog(end).time(end+1) = -now;
save([plsdata.grpdir, 'pg_', groups{k}], '-append', 'plslog');
logentry('Cleared group %s.', groups{k});
fprintf('Cleared group %s.\n', groups{k});
awgrm(groups{k});
end