MATLAB Answers

How can I get the error message from sldvrun when programmatically using Simulink Design Verifier?

3 ビュー (過去 30 日間)
Monika Jaskolka
Monika Jaskolka 2021 年 5 月 12 日
編集済み: Monika Jaskolka 2021 年 5 月 24 日
I am using sldvrun in a script to run design error checking analyses on several models. When models encounter issues during the analysis, I want to record these errors so I can go back later after all the models are processed, and see if they can be addressed.
The sldvrun function will output the result of the analysis as 0 if there is an error, however, as far as I can see, the actual error is shown in the UI only. The information I am looking for is in green in the image below. Is there a way to get this information programmatically? A try/catch with sldvrun did not work.

採用された回答

Pat Canny
Pat Canny 2021 年 5 月 20 日
編集済み: Pat Canny 2021 年 5 月 21 日
Hi Monika,
Apologies for the delay.
You can use the ERRMSGS return field with sldvcompat:
[STATUS, ERRMSGS] = sldvcompat(MODEL)
returns 1 (true) if the Simulink model MODEL is compatible with Simulink Design Verifier and 0 (false) otherwise, and also returns a list of incompatibilities.
For example, if your model uses 'variable step solver' then the returned error msg has following format.
struct with fields:
source: 'solver_sel'
sourceFullName: 'solver_sel'
objH: 0.0033
reportedBy: 'simulink'
msg: 'Simulink Design Verifier cannot be used with a variable-step solver. You must configure the solver options for a fixed-step solver. ?See documentation.'
msgid: 'Sldv:Compatibility:UnsupSolver'
Note: this is available in the "help sldvcompat" documentation, but not in the Documentation page for sldvcompat. I have passed this discrepancy along to our Documentation team.
Another option is to use the Simulink Diagnostic Viewer API's diary method.
An example:
model = 'sldvdemo_flipflop'
open_system(model)
set_param(model,'SolverType','Variable-step')
sldiagviewer.diary('errorlog.txt')
sldvrun(model,[],true)
sldiagviewer.diary('off')
edit errorlog.txt
This will capture every message (as plain text) sent to the Diagnostic Viewer while logging is on, whether or not it is produced by Simulink Design Verifier.
  1 件のコメント
Monika Jaskolka
Monika Jaskolka 2021 年 5 月 24 日
Hi Pat,
The first option isn't ideal for me because I don't want to run sldvcompat. The reason being that subsequently running sldvrun performs the compatibility check a second time, which isn't time efficient. I have larger models where the compatibility check takes quite some time.
The second option worked, but I had to add in
sldiagviewer.diary('on');

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by