User`s guide

Model Advisor Code Examples
25-59
% Basic checks do not have subresults, supress line
setSubBar(ft,false);
% Check for unconnected lines, inputs, and outputs
sysHandle = get_param(system, 'Handle');
uLines = find_system(sysHandle, ...
'Findall', 'on', ...
'LookUnderMasks', 'on', ...
'Type', 'line', ...
'Connected', 'off');
uPorts = find_system(sysHandle, ...
'Findall', 'on', ...
'LookUnderMasks', 'on', ...
'Type', 'port', ...
'Line', -1);
% Use parents of port objects for the correct highlight behavior
if ~isempty(uPorts)
for i=1:length(uPorts)
uPorts(i) = get_param(get_param(uPorts(i), 'Parent'), 'Handle');
end
end
% Create cell array of unconnected object handles
modelObj = {};
searchResult = union(uLines, uPorts);
for i = 1:length(searchResult)
modelObj{i} = searchResult(i);
end
% No unconnected objects in model
% Set result status to 'Pass' and display text describing the status
if isempty(modelObj)
setSubResultStatus(ft,'Pass');
if isSubsystem
setSubResultStatusText(ft,['There are no unconnected lines, ' ...
'input ports, and output ports in this subsystem.']);
else
setSubResultStatusText(ft,['There are no unconnected lines, ' ...
'input ports, and output ports in this model.']);
end
ResultStatus = true;
% Unconnected objects in model
% Set result status to 'Warning' and display text describing the status
else
setSubResultStatus(ft,'Warn');
if ~isSubsystem
setSubResultStatusText(ft,['The following lines, input ports, ' ...
'or output ports are not properly connected in the system: ' system]);
else
setSubResultStatusText(ft,['The following lines, input ports, or ' ...
'output ports are not properly connected in the subsystem: ' system]);
end
% Specify recommended action to fix the warning