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.
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.
you can copy, paste, and delete assessments by selecting the summary and right-clicking to display the context menu or by using keyboard shortcuts. when you copy and paste an assessment, it is added to the end of the assessments. if you delete an assessment, you cannot paste it even if you copied it before deleting it.
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
value p
, then within
d
seconds, it must settle below value
q
and stay below
q
for
u
seconds.
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:
trigger
parameterresponse
parameteroptional
delay
parameter
for the forced oscillation damping problem:
select whenever is true as the trigger and enter
abs(s) > p
as thecondition
. the trigger condition is the condition pattern after which the response signal is evaluated. the response condition is triggered when the magnitude of signals
exceeds valuep
.select must stay true for at least as the response and enter
abs(s) < q
andu
as thecondition
andmin-time
respectively. the response condition describes the behavior of the sut in response to the trigger condition. the response condition is that the magnitude of signals
must settle below valueq
and stay belowq
for at leastu
seconds.select with a delay of at most as the delay type and set
d
as themax-time
parameter. 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 mostd
seconds.
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
fielda
, enter.fielda
.to map a symbol to the signal element that corresponds to index (5,5) in a signal array, enter
(5,5)
.to combine both expressions, enter
.fielda(5,5)
.
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. the expression must be in matlab® code and evaluate to a scalar literal or a
timeseries
object. if the expression is long or complicated, you can use the assessment callback section to write matlab code that retrieves the model, test, and simulation data and assigns the data to variables, then assign the variable to the symbol expression. see for more information on defining variables.to retrieve data stored in workspace variables, use the function. for example, to assign the workspace variable
var
to a symbol, enterevalin("base","var")
in the symbol expression directly, or enterv = evalin("base","var")
in the assessment callback section and enterv
in the symbol expression.because the
t
symbol is automatically bound to the simulation time, you do not need to map it to an expression.t
is not visible in the symbols pane.tip
entering
sig = sltest_simout.logsout.get('mysignal')
in the assessment callback section and using map to expression to map a symbol to thesig
variable is equivalent to using map to model element to map a symbol to themysignal
signal.
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.
note
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 for more information.
see also
| |