Assess Temporal Logic by Using Temporal Assessments
Hybrid systems with discrete and continuous time behavior can require complex
timing-dependent signal logic. Simulink®
Test™ enables you to assess model timing and event ordering by authoring and
including temporal assessments with test cases in the Test Manager. After you create a
temporal assessment, you can use the API to modify the assessment, add the assessment to
another test case, or remove the assessment from a test case. For more information, see
To work with temporal assessments in the Test Manager:
Select an assessment template.
Enter the assessment conditions.
Map symbols to model elements, such as signals, time series, or constants.
View the assessment summary.
Run the test case.
Use the results to assess the system under test (SUT) against your requirements.
For example, consider a forced oscillation damping problem that has this requirement:
For a signal
S, if the signal magnitude exceeds
P, then within
d seconds, it must settle below value
Q and stay below
Create a Temporal Assessment
To create a temporal assessment:
Create or open a test case in the Test Manager.
Navigate to the Logical and Temporal Assessments Editor.
Click Add Assessment. These assessment templates are available:
Logical Assessment Templates
Bounds Check — Check maximum and minimum bounds for signals and expressions.
Custom — Check if a logical expression holds true for all time steps.
Temporal Assessment Template
Trigger-Response — Check for a signal response when a trigger is detected.
For this example, select Trigger-Response.
The Trigger-Response template appears. To finish creating the assessment, you define temporal assessment conditions in the context of the SUT.
Define Temporal Assessment Conditions
A Trigger-response assessment requires a:
For the forced oscillation damping problem:
Select whenever is true as the trigger and enter
abs(S) > Pas the
condition. The trigger condition is the condition pattern after which the response signal is evaluated. The response condition is triggered when the magnitude of signal
Select must stay true for at least as the response and enter
abs(S) < Qand
min-timerespectively. The response condition describes the behavior of the SUT in response to the trigger condition. The response condition is that the magnitude of signal
Smust settle below value
Qand stay below
Qfor at least
Select with a delay of at most as the delay type and set
max-timeparameter. The delay is an optional time interval that starts from a time reference parameter and continues to the point where the response condition is expected to be satisfied. The delay is at most
All time units are seconds.
When you add a symbol as part of a temporal assessment parameter in the Logical and Temporal Assessments Editor, it is added to the list of symbols as an unresolved symbol. Resolve symbols by using the Symbols pane in the editor.
Resolve Assessment Parameter Symbols
To resolve a symbol, right-click the symbol. Two options are available:
Map to model element – Use the mapping dialog box to map symbols to a signal, parameter, or block in the SUT.
Select a symbol to map from the drop-down list at the top of the mapping dialog box.
After you finish mapping symbols to model elements, the Symbols pane displays metadata that corresponds to the model element.
Signals that are mapped to a symbol used by an assessment in the editor are logged when you run the test case.
If you map a bus or an array to a symbol, use the Field/Element row in the Symbols pane to select a scalar signal from the bus or array. For example:
To map a symbol to a bus signal containing a bus element
To map a symbol to the signal element that corresponds to index (5,5) in a signal array, enter
To combine both expressions, enter
Map to expression – Assign a scalar constant value or variable to a symbol.
When you select Map to expression, you must enter an expression in the Expression field. You can assign a scalar constant value or a variable that you define in the Assessment Callback section. See Define Variables in the Assessment Callback Section for more information on defining variables.
tsymbol is automatically bound to the simulation time, you do not need to map it to an expression.
tis not visible in the Symbols pane.
sig = sltest_simout.logsout.get('mySignal')in the Assessment Callback section and using Map to expression to map a symbol to the
sigvariable is equivalent to using Map to model element to map a symbol to the
mySignalsignal. However, the Assessment Callback allows you to define variables as a function of test, model, and simulation data. See Define Variables in the Assessment Callback Section for more information on defining variables.
If you map a symbol to a discrete data signal that is linearly interpolated, the interpolation is automatically changed to zero-order hold during the assessment evaluation. Additionally, an information icon () appears next to the symbol name in the Symbols pane. Point to the icon and a tooltip appears which indicates that the linear interpolation was overridden.
Review the Temporal Assessment Summary
After you enter the assessment parameters, click the arrow to the left of the assessment description to view the assessment summary.
The Visual Representation pane provides a graphical illustration of a passing case for the assessment.
View passing and failing cases for the assessment by clicking the Explore Pattern icon. Select the type of case you want to view from the drop-down list and click to view different passing and failing cases.
Evaluate the SUT
Run the test case to evaluate the SUT. Temporal assessments are evaluated after simulation by using logged signal data. Use the test case results to review the SUT against your requirements.
You can run test cases that contain logical or temporal assessments in multiple releases. For more information, see Assess Temporal Logic in Multiple Releases.
View Assessment Results
View the results of the assessment evaluation from the Results and Artifacts pane of the Test Manager. Select the test case and click the assessment in the Results tree to open a new Assessment Result tab. Simulink Test evaluates the assessment and displays the expected behavior and the actual result of the assessment execution with a description of the assessment failures at different time steps.
The assessment result figures cannot be exported to a Simulink Test report.
Investigate the SUT behavior using the and buttons and the textual descriptions at points of failure.
For a more detailed investigation, expand the Expression Tree to view results for every individual element of the assessment.
Use the zoom, pan, and data cursor functionalities to analyze assessment evaluation results in the Expression Tree.
Link Temporal Assessments to Requirements
If you have a Requirements Toolbox™ license, you can establish traceability between temporal assessments and requirements by linking assessments to requirements. To create links to requirements, select the assessment in the Logical and Temporal Assessments Editor and click the Requirements column to open the Requirement Editor dialog box. See Link to Requirements for more information.