classdef SCDclass_mdswgsigarray1 < SCDclass_mdswg % This class loads an array of signals from MDS+, linearly indicized % linear signal rempping between source and destination can be % specified as a optional parameter, if not present no remapping % takes place properties srcinterval dstinterval srcstartidx srcstopidx deststartidx deststopidx end methods %function obj=SCDclass_mdswgsigarray1(srcsrv, srctree, srctdi, modelname, destwavegen, tbstart, tbdt, tbstop, srcstartidx, srcstopidx, deststartidx, deststopidx) function obj=SCDclass_mdswgsigarray1(srctdi, destwavegen, srcinterval, varargin) obj@SCDclass_mdswg(srctdi, destwavegen, varargin); intervalchecker=@(x) isnumeric(x) && min(diff(x))==1 && max(diff(x))==1; assert(intervalchecker(srcinterval)); p=inputParser; p.addParameter('destinterval',srcinterval,intervalchecker); parse(p,varargin{:}); dstinterval=p.Results.destinterval; obj.srcstartidx=srcinterval(1); obj.srcstopidx=srcinterval(end); obj.deststartidx=dstinterval(1); obj.deststopidx=dstinterval(end); obj.classname='SCDclass_mdswgsigarray1'; end end methods function actualizedata(obj, shot) mdsconnect(obj.mdsserver); mdsopen(obj.mdstree, shot); targetfullexpansion=[obj.wavegenbasestruct,'.',obj.wavegentarget]; if obj.verbose==1 fprintf('Actualizing wavegen: ''%s'' [%d,%d] <- ''%s'' [%d,%d] (%s, shot %d)\n', ... targetfullexpansion, obj.deststartidx, obj.deststopidx, ... obj.tdiexpr, obj.srcstartidx, obj.srcstopidx, ... obj.classname, shot); end sourceidxs=obj.srcstartidx:obj.srcstopidx; destidxs=obj.deststartidx:obj.deststopidx; assert(numel(sourceidxs)==numel(destidxs), 'SCDclass_mdswgsigarray1: destination channel count is different w.r.t. source'); value=obj.getdata(); baseparam=obj.wavegenbasestruct; structparam=obj.wavegentarget; wgentryval=evalin('base',baseparam); 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:%d)=value.Data;',structparam,obj.deststartidx,obj.deststopidx); eval(assigncmdtime); eval(assigncmddata); end assignin('base','temp',wgentryval); assigncmd=sprintf('%s=temp;',baseparam); evalin('base',assigncmd); evalin('base','clear temp'); end function value=getdata(obj) value=timeseries; % Getting the timebase of the model tstart=obj.timebasestart; dt=obj.timebasedt; tstop=obj.timebasestop; timebase=tstart:dt:tstop; sourceidxs=obj.srcstartidx:obj.srcstopidx; value.Time = timebase; value.Data = single(zeros(numel(timebase), numel(sourceidxs))); for ii=1:numel(sourceidxs) mdschannel=sprintf(obj.tdiexpr, sourceidxs(ii)); data=tdi(mdschannel); value.Data(:,ii)= single(interp1(data.dim{1},data.data,timebase,'linear',0)); end end function out=gettargetwavegen(obj) if(isempty(obj.wavegenbasestruct)) out=sprintf('%s[%d,%d]',obj.wavegentarget, obj.deststartidx, obj.deststopidx); else out=sprintf('%s.%s[%d,%d]',obj.wavegenbasestruct,obj.wavegentarget, obj.deststartidx, obj.deststopidx); end end function printinfo(obj) obj.printinfocommon; if(obj.srcstartidx~=obj.deststartidx || obj.srcstopidx~=obj.deststopidx) fprintf(' Remapping: source interval [%d,%d] remapped into dest. interval [%d,%d]\n', obj.srcstartidx, obj.srcstopidx, obj.deststartidx, obj.deststopidx); end end function entrystring = genMARTe2entry(obj, shot) entrystring=obj.genMARTe2entrycommon(shot); entrystring=[entrystring ' StartIdx=' num2str(obj.srcstartidx) ' StopIdx=' num2str(obj.srcstopidx) ' }']; end end end