필터 지우기
필터 지우기

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

조회 수: 8 (최근 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;
};
  댓글 수: 1
Tim
Tim 2020년 9월 1일
I'm having the same issue and am eager to see a proper solution for this.

댓글을 달려면 로그인하십시오.

채택된 답변

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