Create and Select Custom Callbacks for Safety Analysis Manager Fault Tree Documents
R2026bYou can customize the code that executes in Safety Analysis Manager fault tree document callbacks by specifying custom callbacks. You create the callback, enable or disable it, and add the code.
Create Custom Callbacks
To create a custom callback that optionally executes when you analyze your fault tree documents:
Open or create a new Safety Analysis Manager fault tree document. For more information on creating fault tree documents, see the Create Fault Trees in the Safety Analysis Manager.
In the Analyze section, click Edit Callbacks. The Callbacks Editor window opens.
In the Callbacks Editor window, point to the AnalyzeFcn callback and click the Add a new custom callback button .
To edit the name, double-click the callback and enter the new name. You must use a name that follows the naming conventions for variables in MATLAB®.
Write the callback code. For more information on writing callbacks, see the Write Callbacks to Analyze Safety Analysis Manager Fault Tree Documents.
To execute the callback, expand Analyze Document and select the custom callback. When you click Analyze Document again, the Safety Analysis Manager runs the custom callbacks that you select.
Programmatically Create Custom Callbacks
You can also create and modify custom callbacks programmatically. To add a callback:
Retrieve the
FaultTreeDocumentobject from the Safety Analysis Manager by using thesafetyAnalysisMgr.getOpenDocumentsorsafetyAnalysisMgr.openDocumentfunctions, or use thesafetyAnalysisMgr.newDocumentfunction to create a newFaultTreeDocumentobject.Add the custom callback by using the
addCallbackfunction.Assign code to the custom callback by using the
setCallbackfunction.Enable or disable the callback by using the
enableCallbackfunction.
For example, to assign a callback to a fault tree document that simulates a model
named myModel, open only one fault tree document and then run this
code:
myFaultTreeDocument = safetyAnalysisMgr.getOpenDocuments; addCallback(myFaultTreeDocument,"myNewCallback") setCallback(myFaultTreeDocument,"myNewCallback","sim(""myModel"")")