How can I access simulation output signals in custom criteria callbacks for real-time tests in Simulink Test R2018b?
9 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2019-4-29
编辑: MathWorks Support Team
2024-2-29
How can I access simulation output signals in custom criteria callbacks for real-time tests in Simulink Test R2018b?
I am running real-time test cases on a Speedgoat target machine, and I would like to assess some conditions in a custom criteria callback.
Please run the below command in the MATLAB R2018b command window to get the release specific documentation for custom criteria-
web(fullfile(docroot, 'sltest/ug/define-custom-criteria-for-test-case-results.html'))
For normal desktop simulations, the "STMCustomCriteria" object has an "sltest_simout" property where I can access simulation output signals. However, this property is empty when I look at a "STMCustomCriteria" object for real-time tests. How can I access simulation output signals in this case?
test =
STMCustomCriteria with properties:
TestResult: [1×1 sltest.testmanager.TestIterationResult]sltest_simout: {1x0 cell}sltest_testCase: [1×1 sltest.testmanager.TestCase]
sltest_bdroot: {'RollReference_Requirement1_3'}
sltest_sut: {'RollAutopilotMdlRef/Roll Reference'}
sltest_isharness: 1
sltest_iterationName: ''
Please follow the below link to search for the required information regarding the current release:
采纳的回答
MathWorks Support Team
2024-1-18
编辑:MathWorks Support Team
2024-2-29
The "STMCustomCriteria" object for real-time tests has a "TestResult" property, which is a 'TestIterationResult' object.
Please run the below command in the MATLAB R2018b command window to get the release specific documentation of 'TestIterationResult' class-
web(fullfile(docroot, 'sltest/ref/sltest.testmanager.testiterationresult-class.html'))
The simulation output signals can be accesses using the 'getOutputRuns' method of 'TestIterationResult' object.
Please run the below command in the MATLAB R2018b command window to get the release specific documentation of 'getOutputRuns'-
web(fullfile(docroot, 'sltest/ref/sltest.testmanager.testiterationresult.getoutputruns.html'))
-
test =
STMCustomCriteria with properties:
TestResult: [1×1 sltest.testmanager.TestCaseResult]
sltest_simout: [1×1 Simulink.SimulationOutput]
sltest_testCase: [1×1 sltest.testmanager.TestCase]
sltest_bdroot: {'RollReference_Requirement1_3'}
sltest_sut: {'RollAutopilotMdlRef/Roll Reference'}
sltest_isharness: 1
sltest_iterationName: ''
testResults = test.TestResult;
simOutResult = getOutputRuns(testResults);
Please follow the below link to search for the required information regarding the current release:
1 个评论
Pablo Romero
2022-10-28
编辑:Pablo Romero
2024-2-16
Please find below an extended example of how customCriteria can be written to get data access following the previous suggestion.
% Extract Run object from TestResult
simOutResult = getOutputRuns(TestResult);
% Example of extracting signal objects from Run objects
mySignal1 = simOutResult.getSignalByIndex(1);
mySignal2 = simOutResult.getSignalsByName('mySignal2');
% Example of verifications to append to the test object
test.verifyGreaterThan(mySignal1.Values.Data,3);
test.verifyEqual(mySignal2.Values.Data(end),0);
More information about writing your own customCriteria at Process Test Results with Custom Scripts - MATLAB & Simulink (mathworks.com) and find possible verifications to use at Table of Verifications, Assertions, and Other Qualifications - MATLAB & Simulink (mathworks.com).
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!