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.
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 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.
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
with transitions happening after each step has been active for 1 sec.
When decomposition sequences are analogous to switch
statements in programming. Your sequence can act based on specific
conditions occurring in your model. In a
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.
In this example, you create a simple test sequence for a transmission shift logic controller.
Open the model. At the command line, enter
shift_controller subsystem and select Test Harness > Create for ‘shift_controller’.
In the Create Test Harness dialog box, under Sources and Sinks:
Under Sources and Sinks, select
Test Sequence from the source
Under Sources and Sinks, select Add separate assessment block.
Select Open harness after creation.
Click OK. The test harness for the
shift_controller subsystem opens.
Double-click the Test Sequence block. The Test Sequence Editor opens.
Create the test sequence.
Rename the first step
Accelerate and add the step
speed = 10*ramp(et); throttle = 100;
Accelerate step and select
Add step after. Rename this step
Stop, and add the step actions:
throttle = 0; speed = 0;
Enter the transition condition for the
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
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.
Limit and click the edit button. In the
Constant value field, enter
2. Click OK.
Continuing the example, in the test harness, double-click the Test Assessment block to open the editor. The editor displays a When decmposition sequence.
Rename the first step
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
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)
The fourth step
simulation conditions outside of the preceding
Add a scope to the harness and connect the
gear signals to the
Set the model simulation time to 15 seconds and simulate the test harness. View the signal data by opening the scope.
View the results of the
verify statements in the Simulation