Simulink custom S-Function dynamic Bus types

조회 수: 1 (최근 30일)
Rob
Rob 2014년 6월 2일
편집: Rob 2014년 6월 11일
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
Kaustubha Govind
Kaustubha Govind 2014년 6월 10일
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 2014년 6월 11일
편집: Rob 2014년 6월 11일
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.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by