See if a signal originates from a bus in Simulink
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?
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:
- Find the handles of all signal lines in the model.
- Get the names if you need to, however, I did this using handles and it worked fine.
- Compile the model to create the 'CompiledBusType' property.
- 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.
精彩评论