Skip to content
Snippets Groups Projects
Commit 20d389ed authored by Federico Felici's avatar Federico Felici
Browse files

Fixing tests

parent 1f724de8
No related branches found
No related tags found
No related merge requests found
......@@ -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('Closing %s\n',bdroot)
close_system(bdroot)
fprintf(closemsg,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');
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment