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

22 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Titus Edelhofer
Titus Edelhofer il 9 Dic 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 Commento
Mohammed Manna
Mohammed Manna il 9 Dic 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by