Newer
Older
classdef SCDclass_mdswg < matlab.mixin.Heterogeneous
% Superclass for MDS+ wavegens
% the superclass matlab.mixin.Heterogeneous allows
% building of lists of mixed kind parameters in the
% expcode configuration (and later in C++ code)
properties (Access = protected)
%properties
mdsserver % The MDS+ server hosting the parameter
mdstree % The MDS+ Tree hosting the parameter
tdiexpr % TDI expression to retrieve data
wavegenbasestruct % Wavegen base structure hosting the wavegen toimeseries struct
wavegentarget % Wavegen target to be filled
value % commandile output of the wavegen
datadictionary % data dictionary hosting the parameter, if empty base workspace
modelname % name of the Simulink model using the parameter
getcommand % full command for getting the value (callablSCDalgo_f4ealgoe by matlab eval)
marteclassname % class name for generating MARTe2 cfg file
cparser % constructor parameters parser
timebasestart % timebase start time variable
timebasedt % timebase dt variable
timebasestop % timebase stop time variable
end
properties
verbose % Verbosity of the class
end
methods
%function obj=SCDclass_mdswavegen(srcsrv, srctree, srctdi, modelname, destwavegen, timebasestart, timebasedt, timebasestop)
function obj=SCDclass_mdswg()
obj.cparser=inputParser;
addRequired(obj.cparser,'srctdi',@(x) ischar(x));
addRequired(obj.cparser,'destwavegen',@(x) ischar(x));
addParameter(obj.cparser,'srcsrv','tcvdata',@(x) ischar(x));
addParameter(obj.cparser,'srctree','tcv_shot',@(x) ischar(x));
addParameter(obj.cparser,'modelname','',@(x) ischar(x));
obj.verbose=1;
obj.wavegenbasestruct='';
end
function obj=parseconstructorcommon(obj, srctdi, destwavegen, varargin)
parse(obj.cparser,srctdi,destwavegen,varargin{:}{:});
obj.mdsserver=obj.cparser.Results.srcsrv;
obj.mdstree=obj.cparser.Results.srctree;
obj.tdiexpr=obj.cparser.Results.srctdi;
obj.wavegentarget=obj.cparser.Results.destwavegen;
obj.modelname=obj.cparser.Results.modelname;
end
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
end
% Not abstract methods common to all child classes
methods
function mdsconnect(obj, shot)
mdsconnect(obj.mdsserver);
s=mdsopen(obj.mdstree, shot);
str=sprintf('SCDclass_mdswavegen (%s), failed opening MDS+ tree', obj.wavegentarget);
assert(s==shot, str);
end
function printinfocommon(obj)
fprintf('%s (class %s):\n', obj.gettargetwavegen, obj.classname);
fprintf(' Simulink model: ''%s''\n', obj.modelname);
fprintf(' MDS+ source server: ''%s'', Tree: ''%s''\n', obj.mdsserver, obj.mdstree);
fprintf(' MDS+ TDI expression: ''%s''\n',obj.tdiexpr);
end
function obj = settiminginfo(obj, timeinfo)
obj.timebasestart=timeinfo.t_start;
obj.timebasedt=timeinfo.dt;
obj.timebasestop=timeinfo.t_stop;
end
function obj = setmodelname(obj, modelname)
if(isempty(obj.modelname))
obj.modelname = modelname;
end
end
function obj = setdatadictionary(obj, ddname)
if(isempty(obj.datadictionary))
obj.datadictionary = ddname;
end
end
function obj = setbasestruct(obj, basestruct)
obj.wavegenbasestruct = basestruct;
end
%function out = gettargetparam(obj)
% out = obj.modelparam;
%end
function entrystring = genMARTe2entrycommon(obj, shot)
%entrystring = ['+' obj.wavegentarget ' = { Class=' obj.classname ' Path=' obj.tdiexpr ];
entrystring = sprintf('+%-50s = { Class=%-30s Path=%-40s',obj.wavegentarget,obj.marteclassname,obj.genMARTe2MDStdiexpression);
function name=getmodelname(obj)
name=obj.modelname;
end
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
function [mdsserver] = getMDSserver(obj)
mdsserver = obj.mdsserver;
end
function [mdstree] = getMDStree(obj)
mdstree = obj.mdstree;
end
function str=gettarget(obj)
str = obj.wavegentarget;
end
function str = genMARTe2MDStdiexpression(obj)
% Duplicate first backslash
% if(obj.tdiexprused(1)=='\' && not(obj.tdiexprused(2)=='\'))
% martetdi=['\' obj.tdiexprused];
% else
% martetdi=obj.tdiexprused;
% end
% Duplicate backslashes
%martetdi=strrep(obj.tdiexpr, '\', '\\');
martetdi=obj.tdiexpr;
%substitute every " with '
martetdi=strrep(martetdi, '"', '''');
%put double string quota
martetdi=['"' martetdi '"'];
str=martetdi;
end
end
% Abstract method actually implemented by child classes
methods (Abstract)
% Gets data from MDS+ and actualizes it on the model,
% MDS+ connection is reopened for every call ...
actualizedata(obj, shot)
% Gets data from mds, mds connection is assumed already estabilished
% and tree opened
value = getdata(obj)
% Gets a string containing the target wavegen of the model
out = gettargetwavegen(obj)
% Generate C++ code
%gencode(obj)
% Generate MARTe2 configuration entry
entrystring = genMARTe2entry(obj, shot)
% Prints the parameter info summary
printinfo(obj)
end
end