Get signal name at inport of subsystem

조회 수: 28 (최근 30일)
Jes Jensen
Jes Jensen 2019년 5월 20일
댓글: Ralf 2019년 11월 21일
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?

채택된 답변

Fangjun Jiang
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
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
Ralf
Ralf 2019년 11월 21일
That is great!
Thank you very much. It solves my problem!
Ralf

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by