Relation between header and Simulin.bus objects

4 visualizaciones (últimos 30 días)
Jose Alejandro
Jose Alejandro el 26 de Feb. de 2013
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.

Respuesta aceptada

TAB
TAB el 26 de Feb. de 2013
Editada: TAB el 26 de Feb. de 2013
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 comentario
Jose Alejandro
Jose Alejandro el 26 de Feb. de 2013
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by