Question

We have an S-Function that does not support bus signals in Simulink, so programmatically I am trying to find a way to determine if the signal type of an inport/outport originates from/is going to a bus so I can demux and mux the signal automatically as needed. Unfortunately, the only block property I can find that reliably tells if the port comes from or goes to a bus is if it inherits properties from the bus, which might not be true in all cases. Any idea on how to figure this out?

Was it helpful?

Solution

Well, I got an answer back from Matlab support, I have tried this and tested this and it works, the only thing is that Mathworks recommends using a Bus Selector instead of a DEMUX block. In a nutshell, here is what you do:

  1. Find the handles of all signal lines in the model.
  2. Get the names if you need to, however, I did this using handles and it worked fine.
  3. Compile the model to create the 'CompiledBusType' property.
  4. Obtain the 'CompiledBusType' property of each signal line in the model. Then terminate the compilation mode of the model.

'CompiledBusType' returns 'NOT_BUS', 'VIRTUAL_BUS', and 'NON_VIRTUAL_BUS'.

Hope this question helps someone else out, had to wait a week for Matlab to get back to me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top