MATLAB Answers

Get signal name at inport of subsystem

9 views (last 30 days)
Jes Jensen
Jes Jensen on 20 May 2019
Commented: Ralf on 21 Nov 2019
Hi,
I would like a subsystem to know the name of its input so that it can be used for a custom logging solution. I expect a callback on the subsystem which defines a variable could be one way to realize it. I just can't figure out how the callback should obtain the name.
Here is an illustration from the top level:
Capture.PNG
And how I would get the value from the callback.
in_subsys.PNG
Do you have any ideas how the callback would look?

  0 Comments

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 20 May 2019
The first case truely has the signal name. You can get it like below. In second case, you need to get the name of the Constant.
ph=get_param(SysBlockPath,'PortHandles');
sp=ph.Inport(1);
SignalName=get(sp,'Name');

  5 Comments

Show 2 older comments
Ralf
Ralf on 19 Nov 2019
Hi Fangjun,
Thank you for your suggestion. But in my case it did not work out. I tried it in R2017b and R2019b. Same result.
Ralf
Fangjun Jiang
Fangjun Jiang on 19 Nov 2019
You are right. This could be a workaround for both cases, assuming the lines are connected and labeled.
LineHandles=get_param(SysBlockPath,'LineHandles');
hLine=LineHandles.Inport(1)
SrcPortHandle=get(hLine,'SrcPortHandle');
if isequal('on',get(SrcPortHandle,'SignalPropagation'))
signal=get(SrcPortHandle,'PropagatedSignals')
else
signal=get(SrcPortHandle,'Name')
end
Ralf
Ralf on 21 Nov 2019
That is great!
Thank you very much. It solves my problem!
Ralf

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2019a