Skip to content
Snippets Groups Projects
Commit 9414a773 authored by Ravensbergen Timo's avatar Ravensbergen Timo
Browse files

feature test to mask referenced models and expose its tp/fp struct. See gitlab issue 85

parent f904ca42
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,10 @@ obj=expcodeconf_node06_demo12_test; ...@@ -11,6 +11,10 @@ obj=expcodeconf_node06_demo12_test;
obj.init; obj.init;
obj.setup; obj.setup;
%% Feature test: expose model mask parameters of wrapper 1
load_system(obj.nodes{6}.wrappers{1}.wrapperobj.name);
obj.nodes{6}.wrappers{1}.wrapperobj.update_model_mask_params(algo_demo1_tp.Value);
%% expcode actualize %% expcode actualize
fprintf('\n### EXPCODE ACTUALIZE ###\n'); fprintf('\n### EXPCODE ACTUALIZE ###\n');
obj.actualize(-1); obj.actualize(-1);
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
classdef SCDDSdemo_wrapper < SCDDSclass_wrapper classdef SCDDSdemo_wrapper < SCDDSclass_wrapper
% superclass for SCDDSdemo wrapper % superclass for SCDDSdemo wrapper
% %
% %
% [ SCDDS - Simulink Control Development & Deployment Suite ] Copyright SPC-EPFL Lausanne 2022. % [ SCDDS - Simulink Control Development & Deployment Suite ] Copyright SPC-EPFL Lausanne 2022.
% Distributed under the terms of the GNU Lesser General Public License, LGPL-3.0-only. % Distributed under the terms of the GNU Lesser General Public License, LGPL-3.0-only.
methods
function update_model_mask_params(obj,tp)
% function to parametrize referenced models via a model mask
% this function takes the tp Simulink.Parameter and grabs the fp
% from the obj. It then creates Simulink.Parameters and sticks
% them in the model workspace of the wrapper. If the parameters
% are already there, the function checks whether they need
% updating and does so accordingly.
% open points:
% - requires model to be loaded
% - only works for one TP/FP with one model in the wrapper
% - Should be combined with the obj.setup to make sure the
% instance parameters are updated?
% - Buses seem to be not necessary. I am not sure what changed
% grab FP structures from obj (assume there's one for now)
fpinits = obj.algos.fpinits;
% for now assume only one FP exists
fphandle = str2func(fpinits{1}{1});
fp_val = fphandle(obj.algos);
% (!!) create buses TBD (!!)
% Create bus objects.
% businfoFP = Simulink.Bus.createObject(fp_val);
% businfoTP = Simulink.Bus.createObject(tp_val);
% write bus to sldd of wrapper here
% create Simulink.Parameter objects
fp = Simulink.Parameter(fp_val);
% tp.DataType = ['Bus:' 'blabla'];
% fp.DataType = ['Bus:' 'blabla'];
% grab model WS
hws = get_param(obj.name, 'modelworkspace');
% only update Tp/FP params in model workspace when (1) the params are not
% there or (2) outdated/dirty. The isequaln command is insensitive to
% ordering within the structures
if ~hws.hasVariable('tp') || ~hws.hasVariable('fp') % params absent
hws.assignin('tp', tp);
hws.assignin('fp', fp);
% set params as model argument
set_param(obj.name,'ParameterArgumentNames','tp,fp')
elseif ~isequaln(hws.getVariable('tp').Value, tp.Value) % TP outdated
hws.assignin('tp', tp);
elseif ~isequaln(hws.getVariable('fp').Value, fp_val) % FP outdated
hws.assignin('fp', fp);
end
end
end
end end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment