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

wavegen loader classes tolerates errors during actualization

issuing a warning
parent 866e1df1
No related branches found
No related tags found
No related merge requests found
......@@ -46,53 +46,56 @@ classdef SCDclass_mdswgsigarray1 < SCDclass_mdswg
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
try
mdsconnect(obj.mdsserver);
mdsopen(obj.mdstree, shot);
assignin('base','temp',wgentryval);
assigncmd=sprintf('%s=temp;',baseparam);
evalin('base',assigncmd);
evalin('base','clear temp');
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');
catch
warning('SCDclass_mdswgsigsingle:actualizationerror','Actualization error for wavegen %s. Actualization skipped.',obj.wavegentarget);
end
end
function value=getdata(obj)
......
......@@ -33,45 +33,48 @@ classdef SCDclass_mdswgsigsingle < SCDclass_mdswg
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] <- ''%s'' (%s, shot %d)\n', ...
targetfullexpansion, obj.destidx, ...
obj.tdiexpr, ...
obj.classname, shot);
end
value=obj.getdata();
try
mdsconnect(obj.mdsserver);
mdsopen(obj.mdstree, shot);
baseparam=obj.wavegenbasestruct; % name of base workspace structure
structparam=obj.wavegentarget; % name of target field
wgentryval = evalin('base',baseparam); % structure of wavegen in base workspace
assert(isfield(wgentryval,structparam),...
'Wavegen field %s does not exist in target structure %s. ',structparam,baseparam)
% assign field from wavegen entry value
ddtssamples=numel(wgentryval.(structparam).Time);
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
wgentryval.(structparam)=value;
else
% the dd timeseries has the same size than the signals
% to be loaded, we can do a partial loading
wgentryval.(structparam).Time=value.Time;
wgentryval.(structparam).Data(:,obj.destidx)=value.Data;
end
assignin('base','temp',wgentryval);
assigncmd=sprintf('%s=temp;',baseparam);
evalin('base',assigncmd);
evalin('base','clear temp');
targetfullexpansion=[obj.wavegenbasestruct,'.',obj.wavegentarget];
if obj.verbose==1
fprintf('Actualizing wavegen: ''%s'' [%d] <- ''%s'' (%s, shot %d)\n', ...
targetfullexpansion, obj.destidx, ...
obj.tdiexpr, ...
obj.classname, shot);
end
value=obj.getdata();
baseparam=obj.wavegenbasestruct; % name of base workspace structure
structparam=obj.wavegentarget; % name of target field
wgentryval = evalin('base',baseparam); % structure of wavegen in base workspace
assert(isfield(wgentryval,structparam),...
'Wavegen field %s does not exist in target structure %s. ',structparam,baseparam)
% assign field from wavegen entry value
ddtssamples=numel(wgentryval.(structparam).Time);
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
wgentryval.(structparam)=value;
else
% the dd timeseries has the same size than the signals
% to be loaded, we can do a partial loading
wgentryval.(structparam).Time=value.Time;
wgentryval.(structparam).Data(:,obj.destidx)=value.Data;
end
assignin('base','temp',wgentryval);
assigncmd=sprintf('%s=temp;',baseparam);
evalin('base',assigncmd);
evalin('base','clear temp');
catch
warning('SCDclass_mdswgsigsingle:actualizationerror','Actualization error for wavegen %s. Actualization skipped.',obj.wavegentarget);
end
end
function value=getdata(obj)
......
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