Main Content

getChanges

R2026b

Get changed artifacts linked to artifacts in Safety Analysis Manager

Since R2024b

Description

Spreadsheets

detectedChanges = getChanges(spreadsheet) returns the detected changes in the specified Safety Analysis Manager spreadsheet. The spreadsheet must be in a project.

This function requires Requirements Toolbox™.

example

detectedChanges = getChanges(spreadsheetRow) returns the detected changes in the specified spreadsheet row.

example

detectedChanges = getChanges(spreadsheetCell) returns the detected changes in the specified spreadsheet cell.

example

Fault Tree Documents

Since R2026b

detectedChanges = getChanges(faultTreeDocument) returns the detected changes in the specified Safety Analysis Manager fault tree document. The fault tree document must be in a project.

detectedChanges = getChanges(event) returns the detected changes in the specified fault tree document event.

detectedChanges = getChanges(gate) returns the detected changes in the specified fault tree document gate.

detectedChanges = getChanges(failureModel) returns the detected changes in the specified fault tree document failure model.

Examples

collapse all

This example shows how to get detected changes in Safety Analysis Manager spreadsheets. You make a change to the fault linked to two cells in the spreadsheet, then detect and return the change information in the linked cells. The model represents a fuel control system for a gasoline engine, and is a modified version of the model in Evaluate Fault Combinations on a Fault-Tolerant Fuel System.

Open the project.

openProject("EvaluateFaultsFuelSystemProject/");

Next, open the sldemo_fuelsys_fault_analyzer model and the FuelSysFMEA.mldatx spreadsheet. Create the faults and the links between the faults and the spreadsheet by using the fuelSysFaultSetupProject function.

mdl = "sldemo_fuelsys_fault_analyzer";
open_system(mdl);
FMEAName = safetyAnalysisMgr.openDocument("FuelSysFMEA.mldatx");
fuelSysFaultSetupProject

Get the fault on the third input port of the To Controller subsystem by using the Simulink.fault.findFaults function.

myFault = Simulink.fault.findFaults(...
mdl,ModelElement=mdl + "/To Controller/Inport/3");

Set the trigger time of the fault to 10 by changing the Fault object property values. Save the fault information by using the Simulink.fault.save function.

myFault.StartTime = 10;
Simulink.fault.save(mdl)

Detect the changes to the linked fault in the FuelSysFMEA.mldatx spreadsheet by using the detectChanges function.

detectChanges(FMEAName)

Each artifact that links to the fault detects the change. Get the detected changes from each linked artifact as an array of ChangeInformation objects.

myChanges = getChanges(FMEAName);

You can access the object of the linked spreadsheet artifact, or the linked changed artifact. In this example, the fault is linked to two artifacts. To retrieve the Fault object from a ChangeInformation object, get the structure for one of the changes by retrieving the ChangedArtifact property of the ChangeInformation object.

myStruct = myChanges(1).ChangedArtifact;

Then use the slreq.structToObj function on the structure.

myFault = slreq.structToObj(myStruct);

This example shows how to detect, get, and accept changes in a Safety Analysis Manager spreadsheet that links rows to faults in a model. The model represents a fuel control system for a gasoline engine, and is a modified version of the model in Evaluate Fault Combinations on a Fault-Tolerant Fuel System.

The example project contains a model and a Safety Analysis Manager spreadsheet. Open the sldemo_fuelsys_fault_analyzer model and the FuelSysFMEA.mldatx spreadsheet. Run the fuelSysFaultSetupNoLinksProject function to add faults to the model.

mdlName = "sldemo_fuelsys_fault_analyzer";
FMEAName = safetyAnalysisMgr.openDocument("FuelSysFMEA.mldatx");
open_system(mdlName)
fuelSysFaultSetupNoLinksProject

Get the first row from the spreadsheet by using the getRow function.

myRow = getRow(FMEAName,1);

Retrieve the faults from the model by using the Simulink.fault.findFaults function.

myFaults = Simulink.fault.findFaults("sldemo_fuelsys_fault_analyzer");

Link the fault on the ego signal to the row and save the link set.

myLink = slreq.createLink(myRow,myFaults(1));
myLinkSet = linkSet(myLink);
save(myLinkSet);

Detect the changes by using the detectChanges function.

detectChanges(FMEAName)

The row that links to the fault detects the change. Get the detected change in the first row.

myChanges = getChanges(myRow)
myChanges = 
  ChangeInformation with properties:

    AffectedElement: [1×1 safetyAnalysisMgr.SpreadsheetRow]
               Type: 'linkCreated'
           Relation: []
    ChangedArtifact: [1×1 slreq.Link]

Accept the changes in the spreadsheet row. Accepting the changes updates the baseline for the row.

acceptAllChanges(myRow)

This example shows how to get detected changes in a Safety Analysis Manager spreadsheet cell. You make a change to the fault linked to two cells in the spreadsheet, then detect and return the change information in one of the linked cells. The model represents a fuel control system for a gasoline engine, and is a modified version of the model in Evaluate Fault Combinations on a Fault-Tolerant Fuel System.

Open the sldemo_fuelsys_fault_analyzer model and the FuelSysFMEA.mldatx spreadsheet. Create the faults and the links between the faults and the spreadsheet by using the fuelSysFaultSetupProject function.

mdl = "sldemo_fuelsys_fault_analyzer";
open_system(mdl);
FMEAName = safetyAnalysisMgr.openDocument("FuelSysFMEA.mldatx");
fuelSysFaultSetupProject

Get the fault on the third input port of the To Controller subsystem by using the Simulink.fault.findFaults function.

myFault = Simulink.fault.findFaults(...
mdl,ModelElement=mdl + "/To Controller/Inport/3");

Set the trigger time of the fault to 10 by changing the Fault object property values. Save the fault information by using the Simulink.fault.save function.

myFault.StartTime = 10;
Simulink.fault.save(mdl)

Detect the changes to the linked artifact in the FuelSysFMEA.mldatx spreadsheet by using the detectChanges function.

detectChanges(FMEAName)

Each cell in the spreadsheet that links to the fault detects the change, including the first cell in the first column. Get the first cell in the first column by using the getCell function and get the detected change from the cell.

myCell = getCell(FMEAName,1,1);
myChange = getChanges(myCell);

Since R2026b

Suppose you have an open project that contains a model and a fault tree document, and both files are open. You delete two faults that are linked to artifacts in the fault tree document. Detect and get the changes in the fault tree document.

Save the fault information by using the Simulink.fault.save function.

mdl = gcs;
Simulink.fault.save(mdl)

Detect the changes in the fault tree document by retrieving the FaultTreeDocument object. Use the detectChanges function on the object.

faultTreeDoc = safetyAnalysisMgr.getCurrentDocument;
detectChanges(faultTreeDoc)

Get the detected changes in the fault tree.

myChanges = getChanges(faultTreeDoc)

Since R2026b

Suppose that you have an open project that contains a model and an open fault tree document. You delete a fault that is linked to the Event object myEvent1. Detect and get the changes in myEvent1.

Save the fault information by using the Simulink.fault.save function.

mdl = gcs;
Simulink.fault.save(mdl)

Detect the changes by using the detectChanges function on the fault tree document.

faultTreeDoc = safetyAnalysisMgr.getCurrentDocument;
detectChanges(faultTreeDoc)

Get the change in myEvent1.

myChanges = getChanges(myEvent1);

Since R2026b

Suppose that you have an open project that contains a model and an open fault tree document. You delete a fault that is linked to the Gate object myGate1. Detect and get the changes in the gate.

Save the fault information by using the Simulink.fault.save function.

mdl = gcs;
Simulink.fault.save(mdl)

Detect the changes by using the detectChanges function on the fault tree document.

faultTreeDoc = safetyAnalysisMgr.getCurrentDocument;
detectChanges(faultTreeDoc)

Get the changes in the gate.

myChanges = getChanges(myGate1);

Since R2026b

Suppose that you have an open project that contains an open fault tree document and a requirement set. You delete a requirement that is linked to the FailureModel object myFailureModel. Detect and get the change in the failure model.

Save the link set and requirement set by using the function.

myReqSet = slreq.find(Type="ReqSet");
myLinkSet = slreq.find(Type="LinkSet");
save(myReqSet)
save(myLinkSet)

Detect the changes by using the detectChanges function on the fault tree document.

faultTreeDoc = safetyAnalysisMgr.getCurrentDocument;
detectChanges(faultTreeDoc)

Get the change in the failure model.

myChanges = getChanges(myFailureModel)

Input Arguments

collapse all

Spreadsheet in the Safety Analysis Manager, specified as a Spreadsheet object.

Row in the Safety Analysis Manager spreadsheet, specified as a SpreadsheetRow object.

Cell in the Safety Analysis Manager spreadsheet, specified as a SpreadsheetCell object.

Fault tree document in the Safety Analysis Manager, specified as a FaultTreeDocument object.

Event in the Safety Analysis Manager fault tree document, specified as an Event object.

Gate in the Safety Analysis Manager fault tree document, specified as a Gate object.

Failure model in the Safety Analysis Manager fault tree document, specified as a FailureModel object.

Output Arguments

collapse all

Detected changes in the Safety Analysis Manager artifact, returned as an array of ChangeInformation objects.

Version History

Introduced in R2024b

expand all