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 (callable by matlab eval) classname % class name for logging 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(srctdi, destwavegen, varargin) % MDS source and model destination constructor p=inputParser; addRequired(p,'srctdi',@(x) ischar(x)); addRequired(p,'destwavegen',@(x) ischar(x)); addParameter(p,'srcsrv','tcvdata',@(x) ischar(x)); addParameter(p,'srctree','tcv_shot',@(x) ischar(x)); addParameter(p,'modelname','',@(x) ischar(x)); % From subclasses constructors, unused here addParameter(p,'destinterval',0); addParameter(p,'destindex',0); parse(p,srctdi,destwavegen,varargin{:}{:}); obj.mdsserver=p.Results.srcsrv; obj.mdstree=p.Results.srctree; obj.tdiexpr=p.Results.srctdi; obj.wavegentarget=p.Results.destwavegen; obj.modelname=p.Results.modelname; obj.verbose=1; obj.wavegenbasestruct=''; end 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) %obj.mdsconnect(shot); %[obj,~]=obj.getdata; %entrystring = ['+' obj.wavegentarget ' = { Class=' obj.classname ' Path=' obj.tdiexpr ' }']; entrystring = ['+' obj.wavegentarget ' = { Class=' obj.classname ' Path=' obj.tdiexpr ]; 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) % Prints the parameter info summary printinfo(obj) end end