Skip to content
Snippets Groups Projects
Commit c11ac4c3 authored by Cristian Galperti's avatar Cristian Galperti
Browse files

wavegen mds automatic population from sigsingle class

parent 543089de
No related branches found
No related tags found
No related merge requests found
......@@ -341,17 +341,19 @@ classdef SCDclass_expcode
function updatemds(obj, algo, shot)
if shot~=-1
error('SCDclass_expcode:updatemds','update not permitted on a standard shot');
error('SCDclass_expcode:updatemds','update permitted only on the model shot');
end
% first update algorithm tunparams default locally
for ii=1:numel(obj.algonamelist)
if strcmp(algo, obj.algonamelist{ii})
obj.algos{ii}.updatetemplatetp();
end
end
% then update mds
% % then update mds
obj.mdscontainer.modeltogenerate=algo;
obj.mdscontainer.autopopulateMDSparams(shot);
obj.mdscontainer.autopopulateMDSwavegens(shot);
end
function compile(~,varargin)
......@@ -936,6 +938,9 @@ classdef SCDclass_expcode
inode = obj.activenodes(ii);
buildworkspacesimstructnode(obj,inode,dd);
end
evalin('base', 'SCDrefdata = SCDsimdata');
end
function obj = setupmain(obj)
......
......@@ -258,6 +258,13 @@ classdef SCDclass_mdsobjcontainer
end
end
function autopopulateMDSwavegens(obj, shot)
for ii=1:obj.numwavegens
if(strcmp(obj.modeltogenerate,obj.mdswavegens(ii).getmodelname))
obj.mdswavegens(ii).autopopulatemds(shot);
end
end
end
function iorder = getParamsServerTreeOrder(obj)
% find server-tree order of parameters
......
......@@ -22,6 +22,9 @@ classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
timebasestart % timebase start time variable
timebasedt % timebase dt variable
timebasestop % timebase stop time variable
mdshelpstr % MDS help string used in tree autopopulation
mdsvalidationstr % MDS validation string used in autopopulation
end
properties
......@@ -38,7 +41,9 @@ classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
addParameter(obj.cparser,'srcsrv','tcvdata',@(x) ischar(x));
addParameter(obj.cparser,'srctree','tcv_shot',@(x) ischar(x));
addParameter(obj.cparser,'modelname','',@(x) ischar(x));
addParameter(obj.cparser,'mdshelp','',@(x) ischar(x));
addParameter(obj.cparser,'mdsvalid','1',@(x) ischar(x));
obj.verbose=1;
obj.wavegenbasestruct='';
end
......@@ -51,7 +56,8 @@ classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
obj.tdiexpr=obj.cparser.Results.srctdi;
obj.wavegentarget=obj.cparser.Results.destwavegen;
obj.modelname=obj.cparser.Results.modelname;
obj.mdshelpstr=obj.cparser.Results.mdshelp;
obj.mdsvalidationstr=obj.cparser.Results.mdsvalid;
end
end
......@@ -136,6 +142,10 @@ classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
martetdi=['"' martetdi '"'];
str=martetdi;
end
function obj = autopopulatemdscommon(obj, shot)
end
end
......@@ -161,6 +171,10 @@ classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
% Prints the parameter info summary
printinfo(obj)
% Populates the corresponding MDS node with workspace values
autopopulatemds(obj, shot)
end
end
......@@ -153,8 +153,7 @@ classdef SCDclass_mdswgsigarray1 < SCDclass_mdswg
entrystring=obj.genMARTe2entrycommon(shot);
entrystring=[entrystring ' StartIdx=' num2str(obj.srcstartidx) ' StopIdx=' num2str(obj.srcstopidx) ' }'];
end
% * S_uint8 = {
% * NodeName = "S_uint8" // node of the tree node
......@@ -175,7 +174,9 @@ classdef SCDclass_mdswgsigarray1 < SCDclass_mdswg
end
end
function autopopulatemds(obj, shot)
fprintf('This should populate %s from %s\n', obj.tdiexpr, obj.gettargetwavegen);
end
end
end
......
......@@ -2,7 +2,7 @@ classdef SCDclass_mdswgsigsingle < SCDclass_mdswg
% This class loads a signal from MDS+ and puts it into
% the target wavegen timeseries, the signal postition
% in the target timeseries structure is remapped according to
% the optional destidx constructor parameter. If it is not
% the optional destindex constructor parameter. If it is not
% specified, no remapping takes places (1-1 load)
properties
......@@ -124,107 +124,82 @@ classdef SCDclass_mdswgsigsingle < SCDclass_mdswg
entrystring=[obj.genMARTe2entrycommon(shot) ' }'];
end
end
end
function autopopulatemds(obj, shot)
% _node = 'waves.ip_01';
% _nodeval = _node//'.data';
% _nodedim = _node//'.dim';
% _nodecom = _node//'.comment';
% _nodevalid = '1';
% _signal = 'build_signal(build_with_units('//_nodeval//',"A"),*,build_with_units('//_nodedim//',"s"))';
% _expr = 'build_param('//_signal//','//_nodecom//','//_nodevalid//')';
% TreePut(_node,_expr);
% TreePut(_nodeval,'$',[0,1]);
% TreePut(_nodedim,'$',[0,1]);
% TreePut(_nodecom,'$','Ip upper ref');
fprintf('Changing node : ''%s''\n',obj.tdiexpr);
baseparam=strrep(obj.wavegenbasestruct,'SCDsimdata','SCDrefdata'); % name of base workspace structure
structparam=obj.wavegentarget; % name of target field
wgentryval = evalin('base',baseparam); % structure of wavegen in base workspace
value = wgentryval.(structparam).Data(:,obj.destidx);
dim = wgentryval.(structparam).Time;
units = wgentryval.(structparam).DataInfo.Units;
node = obj.tdiexpr;
nodeval = [node '.data'];
nodedim = [node '.dim'];
nodecom = [node '.comment'];
nodevalid = obj.mdsvalidationstr;
signal = ['build_signal(build_with_units(' nodeval ',"' units '"),*,build_with_units(' nodedim ',"s"))'];
expr = ['build_param(' signal ',' nodecom ',' nodevalid ')'];
obj.mdsconnect(shot);
retval=mdsput(node, expr, 'x');
if isnumeric(retval)
if ~rem(retval,2)
warning('SCDclass_mdswgsingle:MDSerror','Error writing node build_param.');
end
else
warning('SCDclass_mdswgsingle:MDSerror','Error writing node build_param.');
end
retval=mdsput(nodeval, value);
if isnumeric(retval)
if ~rem(retval,2)
warning('SCDclass_mdswgsingle:MDSerror','Error writing node data.');
end
else
warning('SCDclass_mdswgsingle:MDSerror','Error writing node data.');
end
retval=mdsput(nodedim, dim);
if isnumeric(retval)
if ~rem(retval,2)
warning('SCDclass_mdswgsingle:MDSerror','Error writing node dim.');
end
else
warning('SCDclass_mdswgsingle:MDSerror','Error writing node dim.');
end
retval=mdsput(nodecom, obj.mdshelpstr);
if isnumeric(retval)
if ~rem(retval,2)
warning('SCDclass_mdswgsingle:MDSerror','Error writing node comment.');
end
else
warning('SCDclass_mdswgsingle:MDSerror','Error writing node comment.');
end
end
end
end
% methods(Access=protected)
%
% function actualizedatadd(obj, shot)
% % Actualizes data in the data dictionary
% % BEWARE at saving and committing big dimension useless
% % data dictionaries
%
% errstr=sprintf('%s:actualizedatadd', obj.classname);
% error(errstr,'actualizing wavegens on data dictionaries not supported');
%
% mdsconnect(obj.mdsserver);
% mdsopen(obj.mdstree, shot);
%
% if obj.verbose==1
% fprintf('Actualizing (DATADICT!) wavegen: ''%s'' [%d] <- ''%s'' (%s, shot %d)\n', ...
% obj.wavegentarget, obj.destidx, ...
% obj.tdiexpr, ...
% obj.classname, shot);
% end
%
% value=obj.getdata();
%
% % We need to access the data dictionary directly here,
% % no way to used automatic dd assign and eval functions,
% % they do not work with timeseries
%
% d=Simulink.data.dictionary.open(sprintf('%s.sldd',obj.modelname));
% dd=getSection(d, 'Design Data');
%
% pointspos=strfind(obj.wavegentarget,'.');
% baseparam=obj.wavegentarget(1:pointspos(1)-1);
% structparam=obj.wavegentarget(pointspos(1)+1:end);
% wgentry=dd.getEntry(baseparam);
% wgentryval=wgentry.getValue;
%
% getcurrenttssize =sprintf('ddtssamples=numel(wgentryval.%s.Time);',structparam);
% eval(getcurrenttssize);
% if(ddtssamples~=numel(value.Time))
% % the dd timeseries has different dims w.r.t. the signals
% % to be loaded, we have to load the timeseries as it is
%
% assigncmd =sprintf('wgentryval.%s=value;',structparam);
% eval(assigncmd);
% else
% % the dd timeseries has the same size than the signals
% % to be loaded, we can do a partial loading
%
% assigncmdtime =sprintf('wgentryval.%s.Time=value.Time;',structparam);
% assigncmddata =sprintf('wgentryval.%s.Data(:,%d)=value.Data;',structparam,obj.destidx);
%
% eval(assigncmdtime);
% eval(assigncmddata);
% end
%
% wgentry.setValue(wgentryval);
%
% end
%
%
%
% function cleandata(obj)
%
% error('SCDclass_mdswgsigsingle:cleandata','cleandata has been deprecated');
%
%
% if obj.verbose==1
% fprintf('Cleaning wavegen: %s [%d] (%s)\n', ...
% obj.wavegentarget, obj.destidx, ...
% obj.classname);
% end
%
% d=Simulink.data.dictionary.open(sprintf('%s.sldd',obj.modelname));
% dd=getSection(d, 'Design Data');
%
% pointspos=strfind(obj.wavegentarget,'.');
% baseparam=obj.wavegentarget(1:pointspos(1)-1);
% structparam=obj.wavegentarget(pointspos(1)+1:end);
% wgentry=dd.getEntry(baseparam);
% wgentryval=wgentry.getValue;
%
% datasizecmd=sprintf('datasize=size(wgentryval.%s.Data);',structparam);
% eval(datasizecmd);
% datasize=datasize(2);
%
% emptyts=timeseries;
% emptyts.Time=[0;1];
% emptyts.Data=single(zeros(2,datasize));
%
% assigncmd=sprintf('wgentryval.%s=emptyts;',structparam);
% eval(assigncmd);
% wgentry.setValue(wgentryval);
%
%
% end
%
%
% 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