Controlling access to External Inputs/Outputs with Simulink Coder
古いコメントを表示
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;
...
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Simulink Coder についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!