Working with callbacks

There are four different callback functions:

Assign the names of the MATLAB® functions you have created to the corresponding properties in the export configuration to call them.

By default, the ProjectExporter object is passed to the function, so that you have access to all data of the current project in the callback function.

For example, an m-file MyCallback.m can be created in the workspace with the following content:

function MyCallback(obj)
…
return

The Callback function can then be passed to Target for MATLAB® as follows:

exportCfg.Project.PreCodeGenerationCallbackFcn = 'MyCallback';
exportCfg.Project.PostCodeGenerationCallbackFcn = 'MyCallback';
exportCfg.Project.PostPublishCallbackFcn = 'MyCallback';
exportCfg.Project.PostDeployCallbackFcn = 'MyCallback';
Working with callbacks 1:

Available example in MATLAB®

Run the following command in the MATLAB® command line to open the example:
TwinCAT.ModuleGenerator.Samples.Start("Callbacks")