Get signal name at inport of subsystem
33 次查看(过去 30 天)
显示 更早的评论
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:
And how I would get the value from the callback.
Do you have any ideas how the callback would look?
0 个评论
采纳的回答
Fangjun Jiang
2019-5-20
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 个评论
Fangjun Jiang
2019-11-19
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!