Which settings make Input/Output structs of generated code public again?

4 次查看(过去 30 天)
Hi!
I used the simulink coder to generate c++ code of a simscape models. The resulting MyModel.h contains a class called <MyModel>ModelClass. Usually this class has has public members for input and output data structs: <MyModel_U> and <MyModel_Y> respectively.
Now I generated code, but in the resulting .h file the <MyModel_U> and <MyModel_Y> are private members and there are a getter and a setter function.
Which settings do I need to get back the old behavior? Getter/Setter are not bad, but for compatibility reasons need the structs to be public.
Thanks in advance!
Christian
Edit:
I compared every settings entry of the new and the old models. I can't find anything that differs anymore. Are there other settings than the "Configuration Settings" window?
To make it more visual here is the generated code section I get with the new model:
/* Class declaration for model MyModel */
class MyModelModelClass {
/* public data and function members */
public:
/* model initialize function */
void initialize();
/* model step function */
void step();
/* model terminate function */
void terminate();
/* Constructor */
MyModelModelClass();
/* Destructor */
~MyModelModelClass();
/* Root-level structure-based inputs set method */
/* Root inports set method */
void setExternalInputs(const ExtU_MyModel_T
* pExtU_MyModel_T)
{
MyModel_U = *pExtU_MyModel_T;
}
/* Root-level structure-based outputs get method */
/* Root outports get method */
const ExtY_MyModel_T & getExternalOutputs() const
{
return MyModel_Y;
}
/* Real-Time Model get method */
RT_MODEL_MyModel_T * getRTM();
/* private data and function members */
private:
/* Block signals */
B_MyModel_T MyModel_B;
/* Block states */
DW_MyModel_T MyModel_DW;
//
// The next two members are the ones of interest !!!
//
/* External inputs */
ExtU_MyModel_T MyModel_U;
/* External outputs */
ExtY_MyModel_T MyModel_Y;
/* Real-Time Model */
RT_MODEL_MyModel_T MyModel_M;
};
And here is the generated code section how I used to get it (that's what I want):
/* Class declaration for model MyOldModel */
class MyOldModelModelClass {
/* public data and function members */
public:
//
// The next two members are the ones of interest !!!
//
/* External inputs */
ExtU_MyOldModel_T MyOldModel_U;
/* External outputs */
ExtY_MyOldModel_T MyOldModel_Y;
/* model initialize function */
void initialize();
/* model step function */
void step();
/* model terminate function */
void terminate();
/* Constructor */
MyOldModelModelClass();
/* Destructor */
~MyOldModelModelClass();
/* Real-Time Model get method */
RT_MODEL_MyOldModel_T * getRTM();
/* private data and function members */
private:
/* Block signals */
B_MyOldModel_T MyOldModel_B;
/* Block states */
DW_MyOldModel_T MyOldModel_DW;
/* Real-Time Model */
RT_MODEL_MyOldModel_T MyOldModel_M;
};

采纳的回答

Christian
Christian 2020-6-29
I found a way which is not really satisfying, but which leads to the solution I wanted:
The way to go was to use the Quickstart button which is located in the C++ CODE tab under ASSISTANCE. After some questions the assistant even shows the settings it wants to change. Even knowing them didn't help me to find them in the settings window, but the changes are saved and the generated code is as expected.
  3 个评论
Michael Herman
Michael Herman 2021-2-24
Did you ever have luck finding the right setting for this (outside of the quick start) or a programatic way of setting it?
Christian
Christian 2021-3-11
No, sorry. This is still the way to go. I didn't spend any more time on this though.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by