From 26b91de525e06c1d541325b7af6b77856fb5bf47 Mon Sep 17 00:00:00 2001 From: Federico Felici <federico.felici@epfl.ch> Date: Fri, 19 Nov 2021 17:39:10 +0100 Subject: [PATCH] More class method comments and remove useless ones --- code/classes/SCDclass_expcode.m | 3 ++- code/classes/SCDclass_node.m | 47 +++++++-------------------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/code/classes/SCDclass_expcode.m b/code/classes/SCDclass_expcode.m index f3b0a2c..06e7754 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 646cdcd..23b10a8 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) -- GitLab