Main Content

getChanges

Get changed artifacts linked to artifacts in Safety Analysis Manager

Since R2024b

Description

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

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 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);

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);

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.

Output Arguments

collapse all

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

Version History

Introduced in R2024b