Main Content

Manage Faults in Referenced Models

You can add faults to referenced models by using Simulink® Fault Analyzer™ or access the faults in the referenced model from the parent model. When you use a Model block to add a reference model that has faults, Simulink Fault Analyzer copies the fault information from the referenced model to the parent model.

Add Faults to Referenced Models

You can add faults to a referenced model or access the faults in a referenced model from the parent model.

To add a fault to a single instance of a referenced model from a top model:

  1. Open a model that contains a referenced model.

  2. Open the referenced model from the parent model by double-clicking the Model block.

  3. Add a fault to the referenced model. Select a signal and, in the Fault Analyzer tab, in the Prepare Faults section, click Add Fault. In the Add Fault window, specify the fault properties, then click OK.

  4. Save the model. The fault appears only in that instance of the referenced model. The software adjusts the fault information file of only the parent XML file.

To access the faults in a referenced model from the parent model:

  1. Open the referenced model as the standalone model.

  2. Add a fault to the referenced model. Select a signal and, in the Fault Analyzer tab, in the Prepare Faults section, click Add Fault. In the Add Fault window, specify the fault properties, then click OK.

  3. Save and exit the model. The software stores the fault information in the fault information file of the model. If you reference the model, the software copies the referenced model fault information to the XML file of the parent model.

When you access the faults created in a referenced model from a parent model, Simulink Fault Analyzer appends the names of the referenced faults with the name of the Model block.

Synchronize Faults from Referenced Models

When you first add a referenced model to a parent model, Simulink Fault Analyzer copies the fault information of referenced models to the fault information file of the parent model. If you make changes to the faults in the referenced model, you must synchronize the information files of the parent and referenced models. To synchronize the fault information files, open the parent model. In the Fault Analyzer tab, in the Prepare Faults section, click Resync Faults. If you synchronize faults in a parent model that does not have faults, Simulink Fault Analyzer creates the fault information file for the parent model in the working folder.

Configure Referenced Model Fault Properties

You can access the fault properties of the faults in a referenced model from the parent model. To access the properties:

  1. Open the Fault Table pane. In the Fault Analyzer tab, in the Prepare Faults section, click Fault Table. The faults appear in the table. The path includes the name of the referenced model.

  2. Right-click the fault and click Properties to view the properties in the Property Inspector.

This image shows the Fault Table pane for a parent model with two faults. The parent model contains a referenced model. The parent model contains one fault, Sine_Wave_Outport1_fault, and the referenced model contains another fault, Model_Inport_Outport1_fault. The Fault Table pane displays the faults available to the parent model.

This image shows the fault table for an example containing a referenced model. The fault in the referenced model, Model_Inport_Outport1_fault originates from the referenced model. The parent model contains the fault from the reference.

The model element path corresponds to the name of the Model block that contains the referenced model. If you update the name of the Model block that contains the referenced faults, the model element path updates automatically. To update the names of the referenced faults after updating the Model block name, synchronize the fault information files.

Example Referenced Model with a Fault

This example shows how a referenced model that contains a fault interacts with a top model. The reference model also contains a fault that only appears in this instance of the model. To view the parent model, open the mdlref_basic_1 model.

The parent model contains two faults. One of the faults originates from the referenced model, and the other originates in the parent model. From the top model, open the ModelA subsystem to view the faults.

The fault information file of the parent model, mdlref_basic_1_faultInfo, stores information from both models. In the Simulink model, the Fault Table pane indicates whether the faults originate in the referenced model or the top model. Open the Fault Table pane and expand the model element lists to view the faults.

The faulted_counter model has its own fault information file, as does the parent model mdlref_basic_1. If you open mdlref_basic_1 and change the fault in faulted_counter, the changes do not propagate to faulted_counter when opened as a standalone model.

Store and Use Faults from Multiple Instances of a Referenced Model

If the top model contains more than one instance of a referenced model that contains faults, you can synchronize the faults and access them in each instance. A fault behavior can only be assigned to one fault. To manage this for referenced models, Simulink Fault Analyzer stores the associated fault behaviors in different fault models depending on the order that the referenced model is added to the parent model after synchronizing faults.

  • For the first instance of the referenced model, the associated fault behaviors are stored in the original fault model.

  • For the following instances of the referenced model, Simulink Fault Analyzer copies the fault behaviors and stores them in a new fault model. This fault model ends with the text, FaultRefModel.

For example, suppose a parent model contains two Model blocks, Model1 and Model2, that both reference the model myRefModel. myRefModel contains faults and uses the fault model myRefModel_faultModel to store the fault behavior. When you synchronize the faults in the parent model, the fault behaviors that the parent model uses for Model1 are stored in myRefModel_faultModel, and the fault behaviors that the parent model uses for Model2 are copied into a fault model called myRefModel_FaultRefModel.

If you create additional faults after synchronizing, you can store the fault behaviors in any of the fault models.

Example with Multiple Instances of a Referenced Model with a Fault

This example shows how a model with multiple instances of a model reference stores faults. To view the parent model, open the mdlref_basic_2 model.

The parent model contains one fault, and is not synchronized with the referenced model. The fault originates in the parent model and is contained in ModelA.

Because the model is not synchronized, the fault information file of the parent model, mdlref_basic_2_faultInfo, currently contains only one fault. Open the Fault Table pane to view the fault.

Synchronize the faults to create the new fault model and retrieve the faults from the referenced model. Because this example uses two instances of the same referenced model, the top model copies the fault behavior of the second referenced model, ModelB, and stores it in a separate fault model, mdlref_basic_2_FaultRefModel. The faults now appear in the Fault Table pane.

If you create new faults with behaviors in either the parent or the referenced model, you can store the fault behavior in any of the fault models. Save the fault information and fault behaviors. In the Fault Analyzer tab, in the File section, click Save All.

See Also

Related Topics