Azzera filtri
Azzera filtri

Controlling access to External Inputs/Outputs with Simulink Coder

4 visualizzazioni (ultimi 30 giorni)
I have two different simulink models that have been developed by others. When I use the simulink coder on them (to crete C++) they produce different ways of accessing the inports/outports in the model. One way creates an instance of the ExtU and ExtY structs as a public variable in the model class, the other way creates the ExtU and ExtY structs as private variables and generates a public get and set function. Which coder setting changes this behaviour? I am using 2020a, but I see the same behavior in 2019a.
Here's the C++ code that generates the get/set functions and private ExtU and ExtY:
class Model1ModelClass {
/* public data and function members */
public:
...
/* Root inports set method */
void setExternalInputs(const ExtU_Model1_T* pExtU_Model1_T)
{
Model1_U = *pExtU_Model1_T;
}
/* Root-level structure-based outputs get method */
/* Root outports get method */
const ExtY_Model1_T & getExternalOutputs() const
{
return Model1_Y;
}
/* Real-Time Model get method */
RT_MODEL_Model1_T * getRTM();
/* private data and function members */
private:
/* Tunable parameters */
static P_Model1_T Model1_P;
/* Block signals */
B_Model1_T Model1_B;
X_Model1_T Model1_X; /* Block continuous states */
/* External inputs */
ExtU_Model1_T Model1_U;
/* External outputs */
ExtY_Model1_T Model1_Y;
...
Here's the C++ code generatare with ExtU and ExtY as public variables:
class GuidanceMainModelClass {
/* public data and function members */
public:
/* Tunable parameters */
static P_GuidanceMain_T GuidanceMain_P;
/* External inputs */
ExtU_GuidanceMain_T GuidanceMain_U;
/* External outputs */
ExtY_GuidanceMain_T GuidanceMain_Y;
...
  1 Commento
Michael Herman
Michael Herman il 24 Feb 2021
If I use the quick start wizard that will change the setting External I/O visability to Public which does the trick, but that setting doesn't appear in the settings window when grt.tlc is selected, but only when ert.tlc is selected. But it must be set behind the scenese somewhere as I can get both behaviors when grt.tlc is set; I just can't easily switch between them. The default behavior seems to be private and the quick start wizard will change it to public (but I can't change it back easily ...). Maybe setting it programatically is the only way.

Accedi per commentare.

Risposte (0)

Categorie

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

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by