Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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