Simulink custom S-Function dynamic Bus types

1 visualización (últimos 30 días)
Rob
Rob el 2 de Jun. de 2014
Editada: Rob el 11 de Jun. de 2014
Hi, I'm implementing a custom block as C-function with one Bus input port and no output (it's meant as an interface sending messages to another system). The Bus can contain everything from one single number over some strings up to several nested buses. There are many different types of messages to be transferred via that bus, all represented by MATLAB structures. Therefor, I'd like to have a dynamic type of bus determined when the simulation starts rather than having to build a different block for each message type.
What I've done so far: I created both a block for creating and handling a Bus based on a nested MATLAB structure.
What I'd like to do now: Make the Bus handling block dynamic, so that a user can pass a pre-defined MATLAB structure name as parameter and the block logic automatically expects the corresponding Bus.
I am able to resolve the structure from its name and build a Bus object corresponding to it. What's missing is the dynamic exchangeability for the bus object that is expected by the block.
  2 comentarios
Kaustubha Govind
Kaustubha Govind el 10 de Jun. de 2014
Rob: Would it suffice to have an S-function parameter that the user can set to pass on the bus name to the underlying code? It seems to me like that should do it, but I'm not sure if I understand your usecase completely.
Rob
Rob el 11 de Jun. de 2014
Editada: Rob el 11 de Jun. de 2014
Thanks for your comment! Yes, absolutely correct, I specified a parameter that the user passes over to the S-Function. But I cannot just simply exchange the bus name dynamically with the parameter's value, because I have to determine how the bus object is structured in order to a) preserve the right amount of memory and b) to correctly parse the values of the bus. For example, I have several bus objects (up to 100). Now one of them consists only of three double values, while another one is a nested bus containing three buses of the first kind plus another double value. As you can imagine, I need to allocate over three times more space for the second bus than for the first one. Plus I must be able to get the structure of the bus objects dynamically to properly work with the values stored in both buses. I posted another question here: http://www.mathworks.com/matlabcentral/answers/133542-iterate-through-custom-bus-datatype-fields-cmex. Maybe it helps to better understand the problem.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Functions 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