45 lines
1.7 KiB
Matlab
45 lines
1.7 KiB
Matlab
function output = save(obj)
|
|
%SAVE Save a PricklyPear run
|
|
% save(PP(0)) stores the unsaved run from experiment(PP) to the next
|
|
% available irec. Storing already saved runs is not allowed.
|
|
|
|
% The object must be the unsaved simulation (irec = 0)
|
|
assert(~isempty(experiment(obj)), 'Please specify an experiment');
|
|
assert(~isempty(obj.irec) && obj.irec == 0, 'Only the unsaved simulation (irec = 0) can be saved');
|
|
|
|
% The unsaved experiment must exist
|
|
assert(exist(obj) == true, 'No unsaved simulation found');
|
|
|
|
% What is the next available irec?
|
|
parobj = parent(obj);
|
|
nextIrec = [];
|
|
ii = 1;
|
|
while isempty(nextIrec)
|
|
if ~exist(child(parobj, ii), 'full', true)
|
|
nextIrec = ii;
|
|
else
|
|
ii = ii + 1;
|
|
end
|
|
end
|
|
|
|
% Move data
|
|
[unused unused] = mkdir(obj.datadir());
|
|
for ii = 1:numel(obj.sim_channels)
|
|
movefile(fullfile(obj.datadir(), sprintf('run_unsaved__vm_%s.txt', obj.sim_channels{ii})),...
|
|
fullfile(obj.datadir(), sprintf('run_%05i__vm_%s.txt', nextIrec, obj.sim_channels{ii})));
|
|
end
|
|
movefile(fullfile(obj.datadir(), sprintf('run_unsaved__evt_contra.txt')),...
|
|
fullfile(obj.datadir(), sprintf('run_%05i__evt_contra.txt', nextIrec)));
|
|
movefile(fullfile(obj.datadir(), sprintf('run_unsaved__evt_ipsi.txt')),...
|
|
fullfile(obj.datadir(), sprintf('run_%05i__evt_ipsi.txt', nextIrec)));
|
|
movefile(fullfile(obj.datadir(), sprintf('run_unsaved__properties.ppbin')),...
|
|
fullfile(obj.datadir(), sprintf('run_%05i__properties.ppbin', nextIrec)));
|
|
|
|
% Notify the user or output the irec
|
|
output = nextIrec;
|
|
if nargout == 0
|
|
fprintf('Run saved as run %i\n', nextIrec);
|
|
end
|
|
|
|
end
|