Relation between header and Simulin.bus objects

조회 수: 4 (최근 30일)
Jose Alejandro
Jose Alejandro 2013년 2월 26일
Hello,
I am considering to use the legacy code tool as suggested in
to compile a large bunch of code into an S-Function on Matlab 2007b. I would like to use buses and I am folliwing the example in sldemo_lct_bus_script.m, the problem is that I DO have the header files with the typedef structs definition of the buses, but I DONT have the simulink.bus object files. It seems that I will have to manually build these objects making sure they are coherent with the typedef struct definitions on the header.
My questions are:
  • why does LCT needs the redundant simulink.bus object in the workspace if this information is already contained in the header files as a typedef struct?
  • is my responsibility to guarantee that the headers and the simulink.bus objects are coherent with each other? this is error prone, time-expensive and must be done each time the header files changes (game stopper probably).
  • is there a way to convert from the header files to simulink.bus objects automatically?
thanks for your feedback on these matters.

채택된 답변

TAB
TAB 2013년 2월 26일
편집: TAB 2013년 2월 26일
Q: why does LCT needs the redundant simulink.bus object in the workspace if this information is already contained in the header files as a typedef struct?
A: Header files are used by c compilers. Matlab can not import or understand the struct definitions in c format. So it need a equivalent declaration in the form of Simulink.Bus object.
----------
Q: is my responsibility to guarantee that the headers and the simulink.bus objects are coherent with each other?
A: Yes you have to take care if you want to import the structure declaration from external header. OR simply do not use external header for defining structure. Instead generate the structure definition header from simulink (See last heading).
----------
Q: is there a way to convert from the header files to simulink.bus objects automatically?
A: You can write a matlab script to read the header file and generate the equivalent Simulink.Bus object.
----------
Best option for you:
If you do not want to write the definition at two places, simply set the DataScope field of Simulink.Bus object to Exported. This will force simulink to generate the structure definition header file from Simulink.Bus object.
See Data Scope in this page.
  댓글 수: 1
Jose Alejandro
Jose Alejandro 2013년 2월 26일
So, to be clear:
either I do the header parser myself to automatically build the Simulink.bus objects, or I use only the Simulink.bus objects and forget about the headers.
Ok, saying that it is not possible to do what I want is also an answer. Thank you.
I will consider to write the parse script myself.
best regrads, Jose

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by