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

Various cleanups

parent 73aa7ed1
No related branches found
No related tags found
No related merge requests found
......@@ -496,10 +496,12 @@ classdef SCDclass_algo
end
function obj = addwavegen(obj, wavegen)
for ii=1:numel(wavegen)
wavegen(ii) = wavegen(ii).bind(obj.modelname,obj.datadictionary,obj.timing);
end
obj.mdscontainer=obj.mdscontainer.addwavegen(wavegen);
% bind wavegen to modelname, dd and algo timing
for ii=1:numel(wavegen)
wavegen(ii) = wavegen(ii).bind(obj.modelname,obj.datadictionary,obj.timing);
end
% add to algo's mds object container
obj.mdscontainer=obj.mdscontainer.addwavegen(wavegen);
end
function obj = printwavegens(obj)
......
......@@ -37,13 +37,13 @@ classdef SCDclass_mdsobjcontainer
end
function obj = actualizeparameters(obj, shot)
% actualize the parameters on the gove data dictionary,
% actualize the parameters in the data dictionary,
% naive version with a mds acces for every parameter
for ii=1:obj.getnumparams
if(strcmp(obj.modeltoactualize,'all'))
if strcmp(obj.modeltoactualize,'all')
obj.mdsparams(ii).actualizedata(shot);
else
if(strcmp(obj.modeltoactualize,obj.mdsparams(ii).getmodelname))
if strcmp(obj.modeltoactualize,obj.mdsparams(ii).getmodelname)
obj.mdsparams(ii).actualizedata(shot);
end
end
......@@ -56,36 +56,29 @@ classdef SCDclass_mdsobjcontainer
end
function obj = setwavegenbasestruct(obj, basestruct)
if obj.getnumwavegens>0
for ii=1:obj.getnumwavegens
obj.mdswavegens(ii)=obj.mdswavegens(ii).setbasestruct(basestruct);
end
end
for ii=1:obj.getnumwavegens
obj.mdswavegens(ii)=obj.mdswavegens(ii).setbasestruct(basestruct);
end
end
function obj = printwavegens(obj)
% prints the wavegen list
if obj.getnumwavegens>0
for ii=1:obj.getnumwavegens
obj.mdswavegens(ii).printinfo();
end
end
for ii=1:obj.getnumwavegens
obj.mdswavegens(ii).printinfo();
end
end
function obj = actualizewavegens(obj, shot)
% actualize the wavegen waves timeseries
% naive version, a mds connection is called for every object
if obj.getnumwavegens>0
for ii=1:obj.getnumwavegens
if(strcmp(obj.modeltoactualize,'all'))
obj.mdswavegens(ii).actualizedata(shot);
else
if(strcmp(obj.modeltoactualize,obj.mdswavegens(ii).getmodelname))
obj.mdswavegens(ii).actualizedata(shot);
end
end
end
% actualize the wavegen waves timeseries
% naive version, a mds connection is called for every object
for ii=1:obj.getnumwavegens
if(strcmp(obj.modeltoactualize,'all'))
obj.mdswavegens(ii).actualizedata(shot);
else
if(strcmp(obj.modeltoactualize,obj.mdswavegens(ii).getmodelname))
obj.mdswavegens(ii).actualizedata(shot);
end
end
end
end
function obj = cleanwavegens(obj)
......@@ -99,26 +92,28 @@ classdef SCDclass_mdsobjcontainer
end
function obj = importmdsparams(obj, source)
% parameters import
% import mds parameters into this container from another source
numparamstoimport = source.getnumparams;
paramstoimport = source.mdsparams;
exclusionlist = false(size(paramstoimport));
if ~isempty(obj.mdsparams)
destparamlist = obj.mdsparams.gettargetparam; % existing destination parameter names
for ii=1:numparamstoimport
targetparam = paramstoimport(ii).gettargetparam;
if ismember(destparamlist,targetparam)
% exclusion list of parameters already imported that shuold not
% be imported again.
exclusionlist = false(size(paramstoimport)); % init
if ~isempty(obj.mdsparams) % if there are already model params in the destination
destparamlist = obj.mdsparams.getmodelparam; % existing parameter names in destination
for ii=1:numparamstoimport % loop over params to import
my_modelparam = paramstoimport(ii).getmodelparam;
if ismember(destparamlist,my_modelparam)
warning('SCDclass_mdsobjcontainer:importmdsobjects',...
'An mds object driving ''%s'' is already present in the destination expcode, skipping!',...
targetparam);
my_modelparam);
exclusionlist(ii) = true;
end
end
end
% add non-excluded parameters
% import non-excluded source parameters into parameter list
obj=obj.addparameter(paramstoimport(~exclusionlist));
end
......
......@@ -13,7 +13,6 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
tdiexprused % TDI expression actually used
%tdiexprmarte % TDI expression actually used converted to MARTe cfg convections
modelparam % Full expansion of the model target parameter (modeltpstruct+modeltargetpar)
modelparammarte % Full expansion of the model target oarameter (modeltpstruct+modeltargetpar) with marte separators
modeltpstruct % target tunable parameter structure, if left empty it will be filled once binding to an algorithm
modeltargetpar % Model parameter w/o tunable parameters structure
value % value of the parameter
......@@ -193,7 +192,6 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
obj.tdiexprused=obj.tdiexprshot;
end
obj.modelparam=[obj.modeltpstruct '.' obj.modeltargetpar];
obj.modelparammarte = strrep(obj.modelparam, obj.matlabseparator, obj.marteseparator);
end
function obj=actualizetdiexpr(obj, shot)
......@@ -242,7 +240,6 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
obj.modeltpstruct = structname;
end
obj.modelparam=[obj.modeltpstruct '.' obj.modeltargetpar];
obj.modelparammarte = strrep(obj.modelparam, obj.matlabseparator, obj.marteseparator);
end
function obj = setmodelname(obj, modelname)
......@@ -257,7 +254,7 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
end
methods(Sealed) % works for heterogeneous class arrays
function out = gettargetparam(obj)
function out = getmodelparam(obj)
if numel(obj) == 1
out = obj.modelparam;
else
......@@ -266,11 +263,8 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
end
function out = gettargetparammarte(obj)
if numel(obj) == 1
out = obj.modelparammarte;
else
out = {obj.modelparammarte}';
end
% convert model param list into version with marte separators
out = strrep(obj.modelparam, obj.matlabseparator, obj.marteseparator);
end
function obj = bind(obj,modelname,datadictionary,exportedtp)
......@@ -286,7 +280,6 @@ classdef SCDclass_mdspar < matlab.mixin.Heterogeneous
function entrystring = genMARTe2entrycommon(obj, shot)
obj=obj.actualizetdiexpr(shot);
%entrystring = sprintf('+%-50s = { Class=%-30s Path=%-40s',obj.gettargetparammarte,obj.marteclassname,obj.tdiexprused);
entrystring = sprintf('+%-50s = { Class=%-30s Path=%-40s',obj.gettargetparammarte,obj.marteclassname,obj.genMARTe2MDStdiexpression);
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