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
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