This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Test Sequence Basics

You can use the Test Sequence block to specify test steps, actions, and transitions. With timeseries inputs, you supply time-defined test vectors. However, the test sequences you create can react to signal and temporal conditions. You can also use them to assess simulation.

Structure of a Test Sequence

A test sequence consists of test steps arranged in a hierarchy. A test step contains actions that execute at the beginning of the step. A test step can also contain transitions that define when the step stops executing, and which test step executes next. Action and transition syntax uses MATLAB® as the action language.

Test Sequence Hierarchy

Test sequences can have parent steps and substeps. Substeps can activate only if the parent step is active. A group of steps in the same hierarchy level shares a common transition type. When you create a test step, the step becomes a transition option for other steps in the same group.

Transition Types

Test sequences transition from one step to another in two ways:

  • Standard transition: You can define a sequence of actions that react to simulation conditions using a standard transition sequence. Standard transition sequences start with the first step and progress according to transition conditions and next steps.

    This test sequence sets the value of Boolean outputs RedButtonIn and GreenButtonIn, with transitions happening after each step has been active for 1 sec.

  • When decomposition: When decomposition sequences are analogous to switch statements in programming. Your sequence can act based on specific conditions occurring in your model. In a When decomposition sequence, steps activate based on a condition that you define after the step name. Transitions are not used between steps. This sequence is a series of assessments. Each assessment is active when the signal gear is equal to a different value. For more information, see Test Sequence Editor.

Create a Basic Test Sequence

In this example, you create a simple test sequence for a transmission shift logic controller.

  1. Open the model. At the command line, enter

    openExample('simulinktest/TransmissionDownshiftTestSequenceExample')
  2. Right-click the shift_controller subsystem and select Test Harness > Create for ‘shift_controller’.

  3. In the Create Test Harness dialog box, under Sources and Sinks:

    • Under Sources and Sinks, select Test Sequence from the source drop-down menu.

    • Under Sources and Sinks, select Add separate assessment block.

    • Select Open harness after creation.

  4. Click OK. The test harness for the shift_controller subsystem opens.

  5. Double-click the Test Sequence block. The Test Sequence Editor opens.

  6. Create the test sequence.

    1. Rename the first step Accelerate and add the step actions:

      speed = 10*ramp(et);
      throttle = 100;
    2. Right-click the Accelerate step and select Add step after. Rename this step Stop, and add the step actions:

      throttle = 0;
      speed = 0;
    3. Enter the transition condition for the Accelerate step. In this example, Accelerate transitions to Stop when the system is in fourth gear for 2 seconds. In the Transition column, enter:

      duration(gear == 4) >= Limit

      In the Next Step column, select Stop.

    4. Add a constant to define Limit. In the Symbols pane, hover over Constant and click the add data button. Enter Limit for the constant name.

    5. Hover over Limit and click the edit button. In the Constant value field, enter 2. Click OK.

Create Basic Test Assessments

  1. Continuing the example, in the test harness, double-click the Test Assessment block to open the editor. The editor displays a When decmposition sequence.

  2. Rename the first step Assessments.

  3. Add two steps to Assessments. Right-click the Assessments step and select Add sub-step. Do this a second time. There should be four steps under Assessments.

  4. Enter the names and actions for the four substeps.

    Check1st when gear == 1
    verify(speed < 45)
    Check2nd when gear == 2
    verify(speed < 75)
    Check3rd when gear == 3
    verify(speed < 105)
    Else

    The fourth step Else has no actions. Else handles simulation conditions outside of the preceding when conditions.

  5. Add a scope to the harness and connect the speed, throttle, and gear signals to the scope.

  6. Set the model simulation time to 15 seconds and simulate the test harness. View the signal data by opening the scope.

  7. View the results of the verify statements in the Simulation Data Inspector.

See Also

| |