Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
20d389ed
Commit
20d389ed
authored
5 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
Fixing tests
parent
1f724de8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/classes/SCDclass_expcode.m
+46
-36
46 additions, 36 deletions
code/classes/SCDclass_expcode.m
tests/test_expcodes.m
+8
-3
8 additions, 3 deletions
tests/test_expcodes.m
with
54 additions
and
39 deletions
code/classes/SCDclass_expcode.m
+
46
−
36
View file @
20d389ed
...
...
@@ -189,32 +189,23 @@ classdef SCDclass_expcode
end
end
function
setcachefolder
(
obj
)
%% Set Cache Folder for experimental code (avoid conflicts with other tmp files)
CacheFolder
=
fullfile
(
fileparts
(
mfilename
(
'fullpath'
)),
'..'
,
'..'
,
...
'gencodes'
,
sprintf
(
'CacheFolder-%d'
,
obj
.
maincode
));
fprintf
(
'Setting Simulink Cache folder to %s\n'
,
CacheFolder
)
Simulink
.
fileGenControl
(
'set'
,
...
'CacheFolder'
,
CacheFolder
,
...
'createdir'
,
true
);
end
function
setcodegenfolder
(
obj
)
CodeGenFolder
=
fullfile
(
fileparts
(
mfilename
(
'fullpath'
)),
'..'
,
'..'
,
...
'gencodes'
,
sprintf
(
'CodeGenFolder-%d'
,
obj
.
maincode
));
function
close_all
(
saveflag
)
if
nargin
==
0
saveflag
=
1
;
end
assert
(
saveflag
==
1
||
saveflag
==
0
,
'saveflag must be 1 or 0'
)
if
saveflag
==
1
closemsg
=
'Saving and Closing %s\n'
;
else
closemsg
=
'Dicarding changes and closing %s\n'
;
end
fprintf
(
'Setting code generation folder to %s\n'
,
CodeGenFolder
)
Simulink
.
fileGenControl
(
'set'
,
...
'CodeGenFolder'
,
CodeGenFolder
,
...
'createdir'
,
true
);
end
function
close_all
()
while
~
isempty
(
bdroot
)
fprintf
(
'C
los
ing %s\n'
,
bdroot
)
close_system
(
bdroot
)
fprintf
(
c
los
emsg
,
bdroot
)
;
close_system
(
bdroot
,
saveflag
)
end
end
end
methods
...
...
@@ -281,6 +272,26 @@ classdef SCDclass_expcode
fprintf
(
'* Configured init scripts: %d (use printinits method for details)\n'
,
numel
(
obj
.
stdinits
));
end
function
CacheFolder
=
setcachefolder
(
obj
)
%% Set Cache Folder for experimental code (avoid conflicts with other tmp files)
CacheFolder
=
fullfile
(
fileparts
(
mfilename
(
'fullpath'
)),
'..'
,
'..'
,
...
'gencodes'
,
sprintf
(
'CacheFolder-%d'
,
obj
.
maincode
));
fprintf
(
'Setting Simulink Cache folder to %s\n'
,
CacheFolder
)
Simulink
.
fileGenControl
(
'set'
,
...
'CacheFolder'
,
CacheFolder
,
...
'createdir'
,
true
);
end
function
CodeGenFolder
=
setcodegenfolder
(
obj
)
CodeGenFolder
=
fullfile
(
fileparts
(
mfilename
(
'fullpath'
)),
'..'
,
'..'
,
...
'gencodes'
,
sprintf
(
'CodeGenFolder-%d'
,
obj
.
maincode
));
fprintf
(
'Setting code generation folder to %s\n'
,
CodeGenFolder
)
Simulink
.
fileGenControl
(
'set'
,
...
'CodeGenFolder'
,
CodeGenFolder
,
...
'createdir'
,
true
);
end
function
obj
=
addwrapper
(
obj
,
node
,
cpu
,
varalgo
,
wrappername
,
varargin
)
p
=
inputParser
;
...
...
@@ -445,8 +456,7 @@ classdef SCDclass_expcode
% parameters import
obj
.
mdscontainer
=
obj
.
mdscontainer
.
importmdsobjects
(
expcode
.
mdscontainer
);
end
function
setup
(
obj
)
% This function sets up the TCV Simulink model
% to simulate this experimental code.
...
...
@@ -465,8 +475,8 @@ classdef SCDclass_expcode
obj
.
buildworkspacetpstruct
;
% Set cache and codegen folders
SCDclass_expcode
.
setcachefolder
(
obj
)
;
SCDclass_expcode
.
setcodegenfolder
(
obj
)
;
obj
.
setcachefolder
;
obj
.
setcodegenfolder
;
end
...
...
@@ -504,8 +514,7 @@ classdef SCDclass_expcode
fprintf
(
'Actualizing expcode %d,
''
%s
''
, configuring wavegens ...\n'
,
obj
.
maincode
,
obj
.
name
);
obj
.
actualizewavegens
(
shot
);
end
function
printparameters
(
obj
)
obj
.
mdscontainer
.
printparameters
;
end
...
...
@@ -526,8 +535,7 @@ classdef SCDclass_expcode
function
actualizewavegens
(
obj
,
shot
)
obj
.
mdscontainer
.
modeltoactualize
=
obj
.
modeltoactualize
;
obj
.
mdscontainer
.
actualizewavegens
(
shot
);
end
end
function
printinits
(
obj
)
if
(
~
isempty
(
obj
.
stdinits
))
...
...
@@ -536,11 +544,10 @@ classdef SCDclass_expcode
end
end
end
function
callinits
(
obj
,
shot
)
if
(
~
isempty
(
obj
.
algoobjlist
))
for
(
ii
=
1
:
numel
(
obj
.
algoobjlist
)
)
for
ii
=
1
:
numel
(
obj
.
algoobjlist
)
if
nargin
==
1
obj
.
algoobjlist
{
ii
}
.
callinits
();
elseif
nargin
==
2
...
...
@@ -583,8 +590,7 @@ classdef SCDclass_expcode
end
obj
.
mdscontainer
.
printMARTe2parconfig
(
shot
);
end
function
printMARTe2wgbusconfig
(
obj
,
shot
,
ddname
,
busname
,
frequency
)
fprintf
(
"+MDSWavegen_%s = {\n"
,
busname
);
fprintf
(
" Class = MDSWavegen\n"
);
...
...
@@ -631,8 +637,12 @@ classdef SCDclass_expcode
nodeinfo
=
obj
.
(
sprintf
(
'node%02d'
,
inode
));
for
icpu
=
1
:
nodeinfo
.
ncpu
if
nodeinfo
.
cpuactive
(
icpu
)
if
inode
~=
1
compileslx_list
=
[
compileslx_list
,
...
SCDclass_expcode
.
getslxname
(
inode
,
icpu
)];
%#ok<AGROW>
else
warning
(
'Do not compile node %d thread %d since this is just a dummy'
,
inode
,
icpu
);
end
end
end
end
...
...
@@ -648,7 +658,7 @@ classdef SCDclass_expcode
end
% set CodeGen folder for this expcode (allows fast rebuilding)
SCDclass_expcode
.
setcodegenfolder
(
obj
)
CodeGenFolder
=
obj
.
setcodegenfolder
;
% check env variable
assert
(
~
isempty
(
getenv
(
'RTCCODE_LIBPATH'
)),
'RTCCODE_LIBPATH environment variable needs to be defined to compile'
);
...
...
This diff is collapsed.
Click to expand it.
tests/test_expcodes.m
+
8
−
3
View file @
20d389ed
...
...
@@ -3,6 +3,7 @@ classdef test_expcodes < matlab.unittest.TestCase
properties
expcode_obj
;
SCDexps
;
shot
=
65668
;
% a shot with data, for actualize/sim purposes
end
properties
(
MethodSetupParameter
)
...
...
@@ -53,11 +54,14 @@ classdef test_expcodes < matlab.unittest.TestCase
function
test_expcode_setup
(
testCase
)
fprintf
(
'\n=== Testing callinits for expcode %d: %s === \n'
,
...
testCase
.
expcode_obj
.
maincode
,
testCase
.
expcode_obj
.
name
);
testCase
.
expcode_obj
.
callinits
;
testCase
.
expcode_obj
.
maincode
,
...
testCase
.
expcode_obj
.
name
);
testCase
.
expcode_obj
.
callinits
(
testCase
.
shot
);
fprintf
(
'\n=== Testing setup for expcode %d: %s === \n'
,
...
testCase
.
expcode_obj
.
maincode
,
testCase
.
expcode_obj
.
name
);
testCase
.
expcode_obj
.
maincode
,
...
testCase
.
expcode_obj
.
name
);
testCase
.
expcode_obj
.
setup
;
% run setup this exp code
end
...
...
@@ -69,6 +73,7 @@ classdef test_expcodes < matlab.unittest.TestCase
fprintf
(
'\n === Testing Simulink compilation for expcode %d: %s === \n'
,
...
testCase
.
expcode_obj
.
maincode
,
testCase
.
expcode_obj
.
name
);
% attempt compiling tcv.slx for this expcode
testCase
.
expcode_obj
.
compile
;
% compile tcv.slx with this expcode
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment