Main Content

评估使用时间一个时序逻辑ssessments

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:

  1. Select an assessment template.

  2. 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.

  3. Run the test case.

  4. 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 signalS, if the signal magnitude exceeds valueP, then withindseconds, it must settle below valueQand stay belowQforuseconds.

Oscillation damping signal

创建一个时间评估

To create a temporal assessment:

  1. Create or open a test case in the Test Manager.

  2. Navigate to theLogical and Temporal AssessmentsEditor.

  3. ClickAdd 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.

    Logical and Temporal Assessments menu options

    For this example, selectTrigger-Response.

    Trigger response template

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:

  • Triggerparameter

  • Responseparameter

  • OptionalDelayparameter

For the forced oscillation damping problem:

  1. Selectwhenever is trueas the trigger and enterabs(S) > Pas thecondition. The trigger condition is the condition pattern after which the response signal is evaluated. The response condition is triggered when the magnitude of signalSexceeds valueP.

  2. Selectmust stay true for at leastas the response and enterabs(S) < Qanduas theconditionandmin-timerespectively. The response condition describes the behavior of the SUT in response to the trigger condition. The response condition is that the magnitude of signalSmust settle below valueQand stay belowQfor at leastuseconds.

  3. Selectwith a delay of at mostas the delay type and setdas themax-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 mostdseconds.

All time units are seconds.

When you add a symbol as part of a temporal assessment parameter in theLogical and Temporal AssessmentsEditor, it is added to the list of symbols as an unresolved symbol. Resolve symbols by using theSymbolspane in the editor.

Resolve Assessment Parameter Symbols

To resolve a symbol, right-click the symbol. Two options are available:

  1. Map to model element –Use the mapping dialog box to map symbols to a signal, parameter, or block in the SUT.

    Selected signal and mapping dialog box

    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, theSymbolspane displays metadata that corresponds to the model element.

    Mapped symbol name, path, port index, and field

    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 theField/Elementrow in theSymbolspane to select a scalar signal from the bus or array. For example:

    • To map a symbol to a bus signal containing a bus elementfieldA, 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).

  2. Map to expression –Assign a scalar constant value or variable to a symbol.

    When you selectMap to expression, you must enter an expression in theExpressionfield. The expression must be in MATLAB®code and evaluate to a scalar literal or atimeseriesobject. If the expression is long or complicated, you can use theAssessment Callbacksection 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. SeeDefine Variables in the Assessment Callback Sectionfor more information on defining variables.

    To retrieve data stored in workspace variables, use theevalinfunction. For example, to assign the workspace variablevarto a symbol, enterevalin("base","var")in the symbol expression directly, or enterv = evalin("base","var")in theAssessment Callbacksection and entervin the symbol expression.

    Because thetsymbol is automatically bound to the simulation time, you do not need to map it to an expression.tis not visible in theSymbolspane.

    Tip

    Enteringsig = sltest_simout.logsout.get('mySignal')in theAssessment Callbacksection and usingMap to expressionto map a symbol to thesigvariable is equivalent to usingMap to model elementto map a symbol to themySignalsignal.

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 theSymbolspane. 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.

TheVisual Representationpane provides a graphical illustration of a passing case for the assessment.

View passing and failing cases for the assessment by clicking the Explore Patternicon. Select the type of case you want to view from the drop-down list and clickto view different passing and failing cases.Triggers versus time for 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, seeAssess Temporal Logic in Multiple Releases.

View Assessment Results

View the results of the assessment evaluation from theResults and Artifactspane of the Test Manager. Select the test case and click the assessment in theResultstree to open a newAssessment Resulttab.Simulink Testevaluates 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.

Expected results and actual results

Note

The assessment result figures cannot be exported to aSimulink Testreport.

Investigate the SUT behavior using theandbuttons and the textual descriptions at points of failure.

对于一个更详细的调查,扩大Expression Tree to view results for every individual element of the assessment.

Expanded expression tree with results for all assessments

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 aRequirements Toolbox™许可,你可以问好blish traceability between temporal assessments and requirements by linking assessments to requirements. To create links to requirements, select the assessment in theLogical and Temporal AssessmentsEditor and click theRequirementscolumn to open theRequirement Editordialog box. SeeLink to Requirementsfor more information.

See Also

||

Related Topics

Baidu
map