Hello Ludo,
I understand you want to access a method from an instance of a class in Simulink. To do so, you can use a MATLAB Function block. Here's how you can call the `mAddRecord` method from the instance `fbTriggerBuffer` of the class `FB_TriggerBuffer`:
1. Open your Simulink model and locate the location where you want to call the method.
2. Add a MATLAB Function block to your model. You can find it in the Simulink Library Browser under "User-Defined Functions" or by searching for "MATLAB Function" in the search bar.
3. Double-click on the MATLAB Function block to open the block editor.
4. In the block editor, write the following code to call the method:
function y = fcn(u)
persistent fbTriggerBuffer; % Declare the persistent variable
if isempty(fbTriggerBuffer) % Create the instance on the first call
fbTriggerBuffer = FB_TriggerBuffer(); % Create the instance
end
if u(1) > 0 && u(1) < 1 % Check for rising edge on input 1
returnValue = fbTriggerBuffer.mAddRecord(u(2)); % Call the method
end
y = u; % Pass the input to the output
end
Make sure to replace `FB_TriggerBuffer` with the actual class name, and `u(2)` with the appropriate input argument for the `mAddRecord` method.
5. Save and close the MATLAB Function block.
6. Connect the input and output ports of the MATLAB Function block to the rest of your Simulink model as needed.
Now, whenever the input 1 of the MATLAB Function block has a rising edge (i.e., goes from 0 to 1), the `mAddRecord` method will be called with the appropriate argument.
Hope this helps!