diff --git a/code/classes/SCDclass_expcode.m b/code/classes/SCDclass_expcode.m index f3b0a2ccad1a60f1a314c58294d1c05e51165d9e..06e7754e68e28841580d914c1e174f207aa7bd26 100644 --- a/code/classes/SCDclass_expcode.m +++ b/code/classes/SCDclass_expcode.m @@ -315,7 +315,7 @@ classdef SCDclass_expcode 'set node number and node property do not match while setting node %s',nodenr) obj.nodes{node.nodenr} = node; - % process data dicationaries, mds objects, init functions etc + % Make lists of data dictionaries, mds objects, init functions etc % that come with this node. % wrapper algorithms @@ -344,6 +344,7 @@ classdef SCDclass_expcode obj.nodes{nodenr}.wrapper{cpunr}.wrapperObj.printinfo; return elseif nargin==2 + if isempty(obj.nodes{nodenr}); fprintf('no node %d defined\n',nodenr); end obj.nodes{nodenr}.printinfo; return end diff --git a/code/classes/SCDclass_node.m b/code/classes/SCDclass_node.m index 646cdcd5d201a5d8aa70dd2cb4868ef375693ee5..23b10a81d15cb0dd0659c1314b1b8a12b97e75f1 100644 --- a/code/classes/SCDclass_node.m +++ b/code/classes/SCDclass_node.m @@ -26,17 +26,24 @@ classdef SCDclass_node < SCDclass_component methods function obj = SCDclass_node(nodenr) + % constructor name = sprintf('SCD_rtc_%02d',nodenr); obj.nodenr = nodenr; obj.name = name; obj.algos = []; obj.ddname = [name,'.sldd']; obj.mdlname = [name,'.slx']; - + + % get node-specific configurations obj = defaultnodeconfig(obj,nodenr); end function obj = addwrapper(obj,wrapperObj,cpunr,varalgo,isactive) + % add wrapper to a node at a given cpunumber + % varalgo is the variant subsystem number used to select this wrapper + % isactive (true by default) sets whether the addition of the wrapper + % also sets the cpu to be active; + % by default, activate CPU when adding a wrapper if nargin==4, isactive=true; end @@ -56,7 +63,7 @@ classdef SCDclass_node < SCDclass_component end function node = defaultnodeconfig(node,nodenr) - % [general part] + % Default configuration for nodes switch nodenr case 1 node.ncpu = 1; @@ -189,45 +196,11 @@ classdef SCDclass_node < SCDclass_component end function obj = setactive(obj,value) + % set the node to be active assert(islogical(value),'value must be boolean') obj.active = value; end - function linknodedd(obj,node) - % link node data dictionary to main expcode object data dicationary - assert(isa(node,'SCDclass_node'),'node must be an SCDclass_node object') - ddObj = Simulink.data.dictionary.open(obj.ddname); - - prefix = 'SCD_rtc'; - - % already linked sources - prevsources = ddObj.DataSources; - prevsources_nodes = prevsources(startsWith(prevsources,prefix)); - - % make algo data dictionary list list - reqsources = node.ddname; - - % removing unnecessary ones - for ii=1:numel(prevsources_nodes) - mysource = prevsources_nodes{ii}; - if ~contains(reqsources,mysource) - obj.printlog('Removing algorithm data source %s from %s',mysource,obj.ddname); - ddObj.removeDataSource(prevsources_nodes{ii}) - end - end - - % add new ones not yet present - mysource = reqsources; - assert(startsWith(mysource,prefix),... - 'attempting to add algo dd: %s that does not start with ''%s''-aborting',prefix,mysource); - if contains(prevsources,mysource) - obj.printlog('Not adding node data source %s - already exists',mysource); - else - obj.printlog('Adding node data source %s to %s',mysource,obj.ddname); - ddObj.addDataSource(mysource); - end - end - function updatetemplatetp(obj) % update wrapper algos for ii=1:numel(obj.wrappers)