I have many libraries containing the functionality of my whole system. I have a top model that includes all libraries to use those functionalities.
Each library has its own model notes. I made a report of the whole model containing the library blocks. I generate a diagram of every level of the model, which is displayed in the report.
Now I want to include all the notes from the libraries to get them displayed right underneath the diagram, in the report.
Since there are many note files and none of them is linked to the model, how can I include them? Better, how can he report those notes?

 採用された回答

MathWorks Support Team
MathWorks Support Team 2022 年 12 月 29 日

0 投票

Including notes inside the report, you need to get the library block path and then pass that to the "slreportgen.report.Notes" reporter.
In the following, you find an example, which shows how to do this:
function ex(model)
load_system(model);
d = slreportgen.report.Report('ex', 'pdf');
d.CompileModelBeforeReporting = false;
section = createSystemSection(d, model);
d.append(section);
d.close();
end
function section = createSystemSection(d, system)
%% system is string of model level to report
df = slreportgen.finder.DiagramFinder(system);
df.IncludeMaskedSubsystems = false;
df.IncludeSimulinkLibraryLinks = false;
df.SearchDepth = 1;
sysResult = next(df);
section = mlreportgen.report.Section();
diag = slreportgen.report.Diagram(sysResult);
height = mlreportgen.utils.units.toInches(diag.Height);
if height > 5
diag.Scaling = 'custom';
diag.Height = '5in';
end
section.append(diag)
if strcmp(sysResult.Type, 'Simulink.SubSystem')
libblk = get_param(sysResult.Object, 'ReferenceBlock');
if ~isempty(libblk)
notes = slreportgen.report.Notes(libblk);
%change imagesize
impl = notes.getImpl(d);
imgNodes = findByType(impl, 'mlreportgen.dom.Image');
for i = 1:numel(imgNodes)
imgNode = imgNodes{i};
imgNode.Height = '92px';
imgNode.Width = '92px';
end
add(section, impl);
end
append(section, mlreportgen.dom.PageBreak());
end
while hasNext(df)
childSysResult = next(df);
subSection = createSystemSection(d, childSysResult.Object);
append(section, subSection);
end
end
function nodes = findByType(node, type)
nodes = {};
children = node.Children;
for i = 1:length(children)
node = children(i);
if isa(node, type)
nodes = [nodes {node}]; %#ok<AGROW>
end
nodes = [nodes findByType(node, type)]; %#ok<AGROW>
end
end

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by