Main Content

sltest.testmanager.SpecifiedFault Class

Namespace: sltest.testmanager

Create or modify faults added to fault sets in tests

Since R2024a

Description

Objects of the sltest.testmanager.SpecifiedFault class are faults added to fault sets in test cases. You must have Simulink® Fault Analyzer™ to use this class.

The sltest.testmanager.SpecifiedFault class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

To create sltest.testmanager.SpecifiedFault objects:

  • Use the addSpecifiedFault method.

  • Create a fault set interactively in a test case, then get the associated sltest.testmanager.SpecifiedFault object by using the getSpecifiedFaults function.

Properties

expand all

Fault name, specified as a string scalar or a character vector. You can change the name of this fault to another fault on the same model element.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: string | char

Whether the fault can be injected during test simulation, specified as a numeric or logical 1 (true) or 0 (false). You can only activate one fault on each model element.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: logical

Path of the model element, returned as a character vector. In Simulink models, this argument is the path to a block output or input port. In Simscape™ blocks, this argument is the path to a fault-capable model subelement. In System Composer™ models, this argument is the path to a component output or input port.

Attributes:

GetAccess
public
SetAccess
protected
Dependent
true
NonCopyable
true

Data Types: char

Fault trigger type and value, returned as a character vector. Faults can have these triggers:

Trigger typeDescription
Always OnThe fault is injected at the start of simulation.
TimedThe fault is injected when the simulation reaches a specified simulation time. The value is a real scalar.
ConditionalThe fault is injected when the specified conditional is true. See Create and Manage Conditionals (Simulink Fault Analyzer).
ManualYou control the injection status in the Fault Dashboard pane. See Manually Trigger Faults in Models (Simulink Fault Analyzer). The Simulink Test Manager uses the assigned status in the model, and you cannot change it while running tests.
BehavioralThe fault injects as a result of a fault parameter value during simulation. You can specify this trigger type only for faults on Simscape blocks.

The property displays the trigger type, followed by a colon, a space, and the trigger value.

For more information, see Trigger type (Simulink Fault Analyzer).

Example: 'Timed: 5' indicates that the fault has a timed trigger of five seconds.

Attributes:

GetAccess
public
SetAccess
protected
Dependent
true
NonCopyable
true

Data Types: char

Methods

expand all

Examples

collapse all

Suppose you have a test file named myTestFile that contains one test case. The test uses myModel as the model under test, and the model contains a fault named myFault on the output port of a Sine Wave block. Create a test case and fault set, and add the fault to the fault set.

tf = sltest.testmanager.TestFile("myTestFile.mldatx");
ts = sltest.testmanager.TestSuite(tf,"myTestSuite");
tc = sltest.testmanager.TestCase(ts,"simulation","myTestCase");
faultSet = addFaultSet(tc);
sltest.testmanager.refreshFaults("myModel")
testFault = addSpecifiedFault(faultSet,...
  "myModel/Sine Wave/Outport/1","myFault")

Version History

Introduced in R2024a

See Also

| | (Simulink Fault Analyzer)