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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
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
% specified, no remapping takes places (1-1 load)
properties
destidx
end
methods
function obj=SCDclass_mdswgsigsingle(srctdi, destwavegen, varargin)
obj@SCDclass_mdswg(srctdi, destwavegen, varargin);
destidxvalchecker=@(x) isscalar(x);
p=inputParser;
addParameter(p,'destindex',1,destidxvalchecker);
parse(p,varargin{:});
obj.destidx=p.Results.destindex;
obj.classname='SCDclass_mdswgsigsingle';
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] <- ''%s'' (%s, shot %d)\n', ...
targetfullexpansion, obj.destidx, ...
obj.tdiexpr, ...
obj.classname, shot);
end
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)=value.Data;',structparam,obj.destidx);
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;
value.Time = timebase;
value.Data = single(zeros(numel(timebase),1));
data=tdi(obj.tdiexpr);
value.Data = single(interp1(data.dim{1},data.data,timebase,'linear',0))';
end
function out=gettargetwavegen(obj)
if(isempty(obj.wavegenbasestruct))
out=sprintf('%s[%d]',obj.wavegentarget, obj.destidx);
else
out=sprintf('%s.%s[%d]',obj.wavegenbasestruct,obj.wavegentarget, obj.destidx);
end
end
function printinfo(obj)
obj.printinfocommon;
if(obj.destidx~=1)
fprintf(' Remapping: destination signal index is %d\n', obj.destidx);
end
end
function entrystring = genMARTe2entry(obj, shot)
entrystring=obj.genMARTe2entrycommon(shot);
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
%