Find name of MPT signal of input line

3 views (last 30 days)
Jeremy
Jeremy on 27 Aug 2012
I have a large Simulink model which includes many signals associated with mpt.Signal objects in the base workspace (so that these lines auto code to simple, non-structured variables). To create some ancillary information for this model, I need my script to find which mpt signals are used as inputs to some of my custom subsystem blocks.
Looking at one of these blocks, I can use "get_param" to get its inport "Port" and "Line" object handles, but I cannot find a way to retrieve the name of the associated MPT signal.
Alternatively, my script has a list of these signals available. If I could generate a list of every subsystem inport which uses a given MPT signal, then I could search that list for the subsystems which intrest me, and complete my script from there.
So is there any way for a script to find the uses of an MPT signal, even after it is routed through multiple subsystem levels of a complex madel? I could use a solution which either examines an inport and determinies the signal or finds all inports which use a given signal.

Answers (2)

Kaustubha Govind
Kaustubha Govind on 27 Aug 2012
This might help:
>> signals = find_system('modelname', 'FindAll', 'on', 'RegExp', 'on', 'Type', 'line', 'Name', '\w')
This should give you the list of all signals with a non-empty name.
Alternately, if you have the line handle, you should just have to call GET_PARAM to ask for the "Name" parameter:
>> get_param(signals(1), 'Name')
You can also use "get" instead of get_param. The following command will query for all public properties of the line:
>> get(signals(1))

Jeremy
Jeremy on 27 Aug 2012
Edited: Jeremy on 28 Aug 2012
Unfortunately, that only finds lines which are manually named with the signal name. I need to find where the signal goes from there, including through the use of "To-From" blocks and into and out of subsystems. If I select one of these "downstream" lines and enter a less-than sign (<) as the name, or if I set the line's "signalPropagation" property to "on", then the signal name appears in my Simulink screen, surronded by less-than/greater-than signs (<MySignalName>). However, using "get(get_signals(1))" in this condition, I can see that "signalPropagation" is on, but I still cannot see the actual signal name in any property ("Name" is just set to an empty string).
So I can see the signal name in my Simulink screen, and I have traced a few of these blocks in the auto-code to verify that the intended MPT variable is used directly (not written to a structure element then used by reference to the structure). But I still have no way for my script to access this signal name.

Tags

Products

Community Treasure Hunt

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

Start Hunting!