Multiple Istances of Referenced Model and its Effect on S-Function Builder Block

22 views (last 30 days)
I want to be able to use multiple instances of my model. This model has got a legacy C function (which uses static variables) that is causing issues. I get the following error message when using multiple instances.
The S-Function block 'Elec_Pmp_Ctrl_ChA/Pulse_Desc/S-Function Builder' is not supported in multi-instance Normal mode because it does not declare that it supports multiple execution instances. If the S-Function satisfies the multiple execution instances requirements, you can declare this using the SimStruct function 'ssSupportsMultipleExecInstances' in the 'mdlSetWorkWidths' method.
I tried to add those macros and functions suggested in the error message, but nothing improved.
Does anyone know how to solve this?

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 9 Dec 2013
Hi Mohammed,
there are two issues here: first, to get rid of the error message. This can be done indeed by doing what the error message suggests. What was wrong with your change, I don't know.
But: this does not solve the problem! If your legacy code contains static variables, you will not be able to use it (correctly) twice within your model, because, the static variables will be shared between the two instances of your S-Function. Only in trivial cases this will not fail.
So: you either can use the S-function only once, or you will need to change the legacy code to remove the static variables. Once this is done, we can take another look why the multiple instance support you tried failed.
Titus
  1 Comment
Mohammed Manna
Mohammed Manna on 9 Dec 2013
To your confusion as in what went wrong when I did the suggested changes:
I added the definition of mdlSetWorksWidth function and called ssSupportMultipleExecInstances function from there. I then added mdlSetWorksWidth function call in mdlIntializeSizes function. I don't know what is wrong.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!