get values from rapid accelerator build summary
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ryan Caveney
am 3 Okt. 2024
Kommentiert: Ryan Caveney
am 4 Okt. 2024
I have a Simulink model I run routinely in rapid accelerator mode. The performance is great, but the build process sometimes encounters strange errors. To troubleshoot that, I would like my script to be able to extract information from the text build summary printed to the console. In particular, I want the three numbers from the line that says "1 of 16 models built (9 models already up to date)", so I can branch on them, like this:
try
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget("ModelName")
catch ME
[built, total, done] = something(?);
if done < total
if built > 0
call_self_again()
else
do_something_different()
end
else
report_success_anyway()
end
end
What something can I use to tell me the values of built, total, and done?
0 Kommentare
Akzeptierte Antwort
Sandeep Mishra
am 4 Okt. 2024
Bearbeitet: Sandeep Mishra
am 4 Okt. 2024
Hi Ryan,
I see that you are trying to extract the information from the text Build Summary section after build process.
To achieve this, you can utilize the 'sldiagviewer.diary' function in MATLAB, which allows you to log diagnostic messages and build information into a file. You can then extract the three numbers from the Build summary using a regular expression.
Refer to the following example code snippet to log the data into default ‘diary.txt’ file:
model = 'model_name';
open_system(model);
% Start logging diagnostics
sldiagviewer.diary('on');
% Clearing logfile content
logFile = 'diary.txt';
fileID = fopen(logFile, 'w');
fclose(fileID);
% Set simulation mode to Rapid Acceleration
set_param(model, 'SimulationMode', 'rapid');
% Building model
slbuild(model);
% Stop logging
sldiagviewer.diary('off');
% Closing the model
close_system(model, 0);
To extract the numbers from the Build summary, you can use the following approach with a regular expression:
fileContent = fileread(logFile);
% Regex expression definition
pattern = '(?<modelsBuilt>\d+) of (?<totalModels>\d+) models built \((?<upToDateModels>\d+) models already up to date\)';
% Checking for regex matching
buildSummaryMatch = regexp(fileContent, pattern, 'names');
if ~isempty(buildSummaryMatch)
% Extracting numbers
modelsBuilt = str2double(buildSummaryMatch.modelsBuilt);
totalModels = str2double(buildSummaryMatch.totalModels);
upToDateModels = str2double(buildSummaryMatch.upToDateModels);
end
Please refer to the following MathWorks Documentation to learn more about ‘sldiagviewer.diary’ function in MATLAB: https://www.mathworks.com/help/releases/R2024b/simulink/slref/sldiagviewer.diary.html
I hope this helps you in resolving the query
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!