-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprocessLoad.m
88 lines (70 loc) · 2.57 KB
/
processLoad.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
function [processObj msg]=processLoad(filename)
msg=[];
if nargin==0
[file,path] = uigetfile('*.mat','Select a processor (i.e. a XXXXX_processor.mat file)',pwd);
if isequal(file,0)
disp('User selected Cancel')
processObj=[];
return;
else
disp(['User selected ', fullfile(path, file)]);
filename=fullfile(path, file);
end
end
% if isnumeric(filename) % loads classi from repository
% list=listRepositoryClassi;
% if numel(list)==0
% processObj=[];
% return;
% end
%
% disp(list)
%
% prompt='Please enter the number associated with the processor you wish to set from the repository ? (Default:1): ';
% classitype= input(prompt);
% if numel(classitype)==0
% classitype=1;
% end
%
% filename=listRepositoryClassi(classitype);
% end
[path file ext]=fileparts(filename);
%filename
abspath=what(path);
abspath=abspath.path;
filename=fullfile(abspath,[file ext]);
load(filename);
path=abspath;
if ~isa(processObj,'process')
msg='This file does not correspond to a processot object';
disp('This file does not correspond to a processor object');
processObj=[];
return;
end
% check if classi is already open in the workspace
varlist=evalin('base','who');
for i=1:numel(varlist)
if strcmp(varlist{i},'ans')
continue;
end
tmp=evalin('base',varlist{i});
if isa(tmp,'process')
% check path & filenemae
% path,file
% a=tmp.path, b=tmp.strid
if strcmp(path,tmp.path(1:end-1)) & strcmp(file, [tmp.strid '_processor']) % var exists already
msg=['Processor is already in the workspace under the var name:' varlist{i} '; Quitting...'];
disp(msg);
processObj=[];
return
end
end
end
if isunix || ismac
processObj.setPath([path '/'],file); % adjust path
else
processObj.setPath([path '\'],file); % adjust path
end
msg=['Process was loaded with this path:' path];
processObj.log(['Process was loaded with this path:' path],'Creation');
disp(['Successfully loaded processor ' fullfile(path,[file '.mat']) '!']);