问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/5992774/see-if-a-signal-originates-from-a-bus-in-simulink