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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
classdef SCDclass_mdsobjcontainer
% This class is a container class
% for all MDS objects required for handling
% a no-nocompile Simulink SCD model
%
% Presently it implements methods for handling
% objects of the following classes:
% SCDclass_mdsparam (and childrens)
% SCDclass_mdswavegen (and childrens)
properties
numparams % number of configured params objects
mdsparams % params objects array
numwavegens % number od configured wavegens objects
mdswavegens % wavegens objects array
simstructlist % list of names of simstructs to be transferred to
% base workspace upon expcode setup
end
methods
function obj = SCDclass_mdsobjcontainer()
% contructor, empty container
obj.numparams=0;
obj.numwavegens=0;
obj.simstructlist= [ ...
{'SCDnode01simdata'},...
{'SCDnode02simdata'},...
{'SCDnode03simdata'},...
{'SCDnode06simdata'},...
{'SCDnode07simdata'},...
{'SCDnode08simdata'},...
{'SCDnode0201_simdata'},...
{'SCDnode0202_simdata'},...
{'SCDnode0203_simdata'},...
{'SCDnode0204_simdata'},...
{'SCDnode0301_simdata'},...
{'SCDnode0302_simdata'},...
{'SCDnode0303_simdata'},...
{'SCDnode0304_simdata'},...
{'SCDnode0601_simdata'},...
{'SCDnode0602_simdata'},...
{'SCDnode0603_simdata'},...
{'SCDnode0604_simdata'},...
{'SCDnode0701_simdata'},...
{'SCDnode0702_simdata'},...
{'SCDnode0703_simdata'},...
{'SCDnode0704_simdata'},...
{'SCDnode0801_simdata'}...
];
end
function obj = addparameter(obj, param)
% Adds a parameter object
if obj.numparams==0
obj.mdsparams=param;
else
obj.mdsparams=[obj.mdsparams; param];
end
obj.numparams=obj.numparams+1;
end
function obj = printparameters(obj)
% prints the parameters object list
if obj.numparams>0
for ii=1:obj.numparams
obj.mdsparams(ii).printinfo();
end
end
end
function obj = actualizeparameters(obj, shot)
% actualize the parameters on the gove data dictionary,
% naive version with a mds acces for every parameter
if obj.numparams>0
for ii=1:obj.numparams
obj.mdsparams(ii).actualizedata(shot);
end
end
end
function obj = bindparameters(obj, modelname, datadictionary, exportedtps)
if obj.numparams>0
for ii=1:obj.numparams
obj.mdsparams(ii)=obj.mdsparams(ii).setmodelname(modelname);
obj.mdsparams(ii)=obj.mdsparams(ii).setdatadictionary(datadictionary);
end
if numel(exportedtps)>0
for ii=1:obj.numparams
obj.mdsparams(ii)=obj.mdsparams(ii).setparamstructure(exportedtps{end});
end
end
end
end
function obj = bindlastparameter(obj, modelname, datadictionary, exportedtps)
if obj.numparams>0
obj.mdsparams(end)=obj.mdsparams(end).setmodelname(modelname);
obj.mdsparams(end)=obj.mdsparams(end).setdatadictionary(datadictionary);
if numel(exportedtps)>0
obj.mdsparams(end)=obj.mdsparams(end).setparamstructure(exportedtps{end});
end
end
end
function obj = addwavegen(obj, wavegen)
% adds a wavegen object
if obj.numwavegens==0
obj.mdswavegens=wavegen;
else
obj.mdswavegens=[obj.mdswavegens; wavegen];
end
obj.numwavegens=obj.numwavegens+1;
end
function obj = bindlastwavegen(obj, modelname, datadictionary, timingsrc)
if obj.numwavegens>0
obj.mdswavegens(end)=obj.mdswavegens(end).setmodelname(modelname);
obj.mdswavegens(end)=obj.mdswavegens(end).setdatadictionary(datadictionary);
obj.mdswavegens(end)=obj.mdswavegens(end).settiminginfo(timingsrc);
end
end
function obj = setwavegenbasestruct(obj, basestruct)
if obj.numwavegens>0
for ii=1:obj.numwavegens
obj.mdswavegens(ii)=obj.mdswavegens(ii).setbasestruct(basestruct);
end
end
end
function obj = printwavegens(obj)
% prints the wavegen list
if obj.numwavegens>0
for ii=1:obj.numwavegens
obj.mdswavegens(ii).printinfo();
end
end
end
function obj = actualizewavegens(obj, shot)
% actualize the wavegen waves timeseries
% naive version, a mds connection is called for every object
if obj.numwavegens>0
for ii=1:obj.numwavegens
obj.mdswavegens(ii).actualizedata(shot);
end
end
end
function obj = cleanwavegens(obj)
% clean wavegens leaving a consistent (with model buses)
% empty timeseries data structure
if obj.numwavegens>0
for ii=1:obj.numwavegens
obj.mdswavegens(ii).cleandata;
end
end
end
function obj = buildworkspacesimstruct(obj)
% this funtion builds a workspace structure containing
% a replica of all simulation structures in the data
% dictionaries, this structure is the one actually used
% for loading simulation wavegen data
% It is better not to use directly data dictionaries structures
% to avoid flooding dds with big sim data sets (and
% conseguently the SCD SVN itself
dd=SCDconf_getdatadict('tcv.sldd');
evalin('base','SCDsimdata=struct();');
for ii=1:numel(obj.simstructlist)
simstructname=char(obj.simstructlist(ii));
simstruct=dd.getEntry(simstructname).getValue;
assignstr=sprintf('SCDsimdata.%s=temp;',simstructname);
assignin('base','temp',simstruct);
evalin('base',assignstr);
end
evalin('base','clear temp;');
end
function obj = importmdsobjects(obj, source)
% parameters import
destparamtargets={};
if obj.numparams>0
for ii=1:obj.numparams
destparamtargets{end+1}=obj.mdsparams(ii).gettargetparam;
end
end
numparamstoimport = source.numparams;
paramstoimport = source.mdsparams;
if numparamstoimport>0
for ii=1:numparamstoimport
if ~ismember(paramstoimport(ii).gettargetparam, destparamtargets)
obj=obj.addparameter(paramstoimport(ii));
else
warning('SCDclass_mdsobjcontainer:importmdsobjects','A mds object driving ''%s'' is already present in the dest. expcode, skipping!',paramstoimport(ii).gettargetparam);
end
end
end
% wavegens import
destwavegentargets={};
if obj.numwavegens>0
for ii=1:obj.numwavegens
destwavegentargets{end+1}=obj.mdswavegens(ii).gettargetwavegen;
end
end
numwavegenstoimport = source.numwavegens;
wavegenstoimport = source.mdswavegens;
if numwavegenstoimport>0
for ii=1:numwavegenstoimport
if ~ismember(wavegenstoimport(ii).gettargetwavegen, destwavegentargets)
obj=obj.addwavegen(wavegenstoimport(ii));
else
warning('SCDclass_mdsobjcontainer:importmdsobjects','A mds object driving ''%s'' is already present in the dest. expcode, skipping!',wavegenstoimport(ii).gettargetwavegen);
end
end
end
end
function printMARTe2parconfig(obj, shot)
for ii=1:obj.numparams
str=obj.mdsparams(ii).genMARTe2entry(shot);
fprintf(" %s\n",str);
end
end
function printMARTe2wgconfig(obj, shot)
for ii=1:obj.numwavegens
str=obj.mdswavegens(ii).genMARTe2entry(shot);
fprintf(" %s\n",str);
end
end
end
end