-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkOut.m
181 lines (145 loc) · 7.05 KB
/
checkOut.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
function [project]=checkOut(project,TaskIndex,MethodIndex,varargin)
% checkOut a method from the pipeline environment.
%
% If no workspace and/or project exist on disc a new project and log file
% are created, else they are updated.
% NOTE: names and directory for Workdir and project are alwas automatic created.
% When errors are detected: Clean up actual task and update project and return
% Task: 'Others': Has no influence on the status of the pipeline given in
% 'project.pipeline.statusTask(TaskIndex)'
%
% Input:
% project : Structure containing all information of actual pipeline
% TaskIndex : Index to active task in the project structure
% MethodIndex : Index to used method in a TaskIndex in the project structure
% varargin : Abitrary number of input arguments. (NOT USED)
%
% Output:
% project : Return updated project
%
% Uses special functions:
% Updateproject:
% logProject:
% rmProjectfiles:
% setupPipeline:
% drawGUI:
%____________________________________________
%SW version: 240803TD. By T. Dyrby, 120303, NRU
% TO DO, and DONE:
% - OK 220503TD: check clean up
% - OK 210503TD: save filestatus in .tasks{TaskIndex}
% - OK 210503TD: Update lastTaskIndex
% - OK 140603TD: Add error flag to .statusTask
% - OK 070803TD: Add configurator checkOut
% - OK 120803TD: Possible to Save as template if a configuration is done before files is loaded or project created
% - OK 180803TD: Add project.sysinfo.workspace to Matlabpath and cnhange directory
% - OK 180803TD: Possible to select a main workspace where project and other files can be saved in a subdir
% - OK 240803TD: Promt user to change name of project. This option is only available if mainGUI exist
% - OK 270803TD: Add prefix to workdir given in setupfile
s_clock=clock;
msglog=sprintf('_______Time stamp: %s.%s.%s.%s.%s (mm.hh.dd.mm.yyyy)',num2str(s_clock(5)),num2str(s_clock(4)),num2str(s_clock(3)),num2str(s_clock(2)),num2str(s_clock(1)));
project=logProject(msglog,project,TaskIndex,MethodIndex);
%remove processID if any
if isfield(project.taskDone{TaskIndex},'processID')
project.taskDone{TaskIndex}=rmfield(project.taskDone{TaskIndex},'processID');
end
%_________ CheckOut a configurator
if(isfield(project.taskDone{TaskIndex},'command') && ...
~isempty(project.taskDone{TaskIndex}.command) && ...
strcmp(project.taskDone{TaskIndex}.command{1},'configurator'))
chkOutConfigurator=1;
else
chkOutConfigurator=0;
end
%__________ Check done-entry
switch project.pipeline.statusTask(TaskIndex)
case {0,3} %READY, Added ERROR=3,140603TD
[project,msg]=logProject('CheckOut: Has NOT been checkedIn, is READY.',project,TaskIndex,MethodIndex);
if ischar(project.taskDone{TaskIndex}.error)
project.taskDone{TaskIndex}.error{1}=msg;
else
project.taskDone{TaskIndex}.error{end}=msg;% Add error msg
end
return
case 1 %Active OK
%project=logProject('CheckOut: OK, Active.',project,TaskIndex,MethodIndex);
case 2 %DONE
[project,msg]=logProject('CheckOut: Has already been checkedOut, is DONE',project,TaskIndex,MethodIndex);
project.taskDone{TaskIndex}.error{end+1}=msg;% Add error msg
return
otherwise
[project,msg]=logProject('CheckOut: Unknown done-entry',project,TaskIndex,MethodIndex);
project.taskDone{TaskIndex}.error{end+1}=msg;% Add error msg
return
end%switch
%end
taskName= project.pipeline.taskSetup{TaskIndex,MethodIndex}.task;
if(strcmpi(taskName,'others'))
%Task 'Others' is alwas ready!!
project.pipeline.statusTask(TaskIndex)=0;% Set actual method as 'READY'=0
%Log info
%project=logProject('CheckOut: Others',project,TaskIndex,MethodIndex);
project.taskDone{TaskIndex}.error='';
%__________ Update project and log file
project=Updateproject(project,TaskIndex,MethodIndex);
%______ Update MainGUI if mainfig exist
if(ishandle(project.handles.h_mainfig) && ~chkOutConfigurator)
drawGUI(project.handles.h_mainfig,TaskIndex);
end
return
end
%__________ Check for errors, if detected clean, update project and return
if(~isempty(project.taskDone{TaskIndex}.error))
%______ Configurator?
if(chkOutConfigurator)
%________ Update logfile before erase actual task
[project,msg]=logProject('Error detected in configurator, settings are cleared.',project,TaskIndex,MethodIndex);
%project.pipeline.taskSetup{TaskIndex,MethodIndex}=[];
project.pipeline.statusTask(TaskIndex)=3;% Done=2, Active=1, Ready=0,Error=3,Added ERROR,140603TD
%__________ Update project and log file
project=Updateproject(project,TaskIndex,MethodIndex);
return
end
project.pipeline.statusTask(TaskIndex)=3;% Done=2, Active=1, Ready=0,Error=3,Added ERROR,140603TD
%________ Update logfile before erase actual task
[project,msg]=logProject('Error detected, task is cleaned-up at checkOut.',project,TaskIndex,MethodIndex);
%________ Clean-up after erase (except input files)
project=rmProjectfiles(project,TaskIndex,MethodIndex);
%________ Clear actual task...
project.taskDone{TaskIndex}='';
%__________ Update project and log file
project=Updateproject(project,TaskIndex,MethodIndex);
%______ Update MainGUI if mainfig exist
if(ishandle(project.handles.h_mainfig) & ~chkOutConfigurator)
drawGUI(project.handles.h_mainfig,TaskIndex);
end
return
end
%__________ Update time-entry (finish)
project.taskDone{TaskIndex}.time.finish=num2str(clock);
%____ Update task w. Configuration parameters
if(chkOutConfigurator)
config_TaskIndex=project.taskDone{TaskIndex}.command{2};
config_MethodIndex=project.taskDone{TaskIndex}.command{3};
%Copy settings from temp task in project
project.pipeline.taskSetup{config_TaskIndex,config_MethodIndex}.configurator=...
project.pipeline.taskSetup{TaskIndex,MethodIndex}.configurator;
project.pipeline.statusTask(TaskIndex)=0;% Done=2, Active=1, Ready=0
%Clear temp. task in project
TaskIndex=config_TaskIndex;
MethodIndex=config_MethodIndex;
else
%___________Transfer configuration settings to taskDone
project.taskDone{TaskIndex}.configuration=project.pipeline.taskSetup{TaskIndex,MethodIndex}.configurator.user;
%__________ Update Last TaskIndex if success (NOT configurators):
project.pipeline.statusTask(TaskIndex)=2;% Done=2, Active=1, Ready=0
if(project.pipeline.lastTaskIndex(end)~=TaskIndex)
project.pipeline.lastTaskIndex(end+1)=TaskIndex;
end
end
%__________ Update project and log file
project=Updateproject(project,TaskIndex,MethodIndex);
%______ Update MainGUI if mainfig exist
if(ishandle(project.handles.h_mainfig) & ~chkOutConfigurator)
drawGUI(project.handles.h_mainfig,TaskIndex);
end