classdef SCDclass_taskmdscheckbusnames < SCDclass_task % This is a special class which checks the names % of a Simulink bus against the list names given by the tdi expression % some rules apply: % 1) : in MDS+ fields are subsituted by _ % 2) check is performed up to the minimum number of elemes ether if the % MDS+ node or in the simulink one. % if MDS+ begins with a number, a leading 's' is added to its name % if MDS+ name is empty the check is skipped (Q: is it safe ?, at least not on -1 shot!) properties modelbus end methods function obj=SCDclass_taskmdscheckbusnames(id, modelbus, varargin) obj@SCDclass_task(id, varargin); obj.modelbus=modelbus; obj.classname=mfilename; end function init(obj, shot) mdsconnect(obj.mdsserver); mdsopen(obj.mdstree, shot); [obj,value]=obj.getdata(shot); if obj.verbose==1 fprintf('Cheking bus: ''%s'' <-> ''%s'' (%s, shot %d)\n', obj.modelbus, obj.tdiexprused, obj.classname, shot); end d=Simulink.data.dictionary.open(sprintf('%s',obj.datadictionary)); dd=getSection(d, 'Design Data'); busElems=dd.getEntry(obj.modelbus).getValue.Elements; %assert(numel(busElems)==numel(value), 'SCDclass_mdscheckbus: Number of elements must match.'); lastcheck=min(numel(busElems), numel(value)); for ii=1:lastcheck if numel(char(value{ii}))==0 || numel(strfind(char(value{ii}),' '))==numel(char(value{ii})) continue end strsrc=upper(deblank(strrep(char(value{ii}),':','_'))); if(isstrprop(strsrc(1),'digit')) strsrc=['S' strsrc]; end strdst=upper(deblank(busElems(ii).Name)); assert(strcmp(strsrc,strdst), 'SCDclass_mdscheckbus: names mismatching, MDS+ name: ''%s'', Bus name: ''%s''', strsrc, strdst); end end %function term(obj, shot) % %end function [obj, value] = getdata(obj,shot) obj=obj.actualizegetcmd('mdsvalue(''%s'')', shot); value=eval(obj.getcommand); end function printinfo(obj) obj.printinfocommon; fprintf(' Checked model bus: %s\n',obj.modelbus); end end end