How to programmatically find the port types of the blocks

According to the documentation , "PortConnectivity" parameter of the block has a field "type" which should either return the type (enable, state ...) or number(if it is a data port).
However testing it on Enabled Delay block from Simulink library, the input ports "type" field is 1 and 2 instead of 1 and "enable". Is this a documentation error, api error or my misunderstanding?
get_param(block_name_fp,"PortConnectivity")

6 Comments

Here "2" is the default value for a delay length (^-2).
To enable a port, you should look at the control tab and put a tick mark on [Show enable port].
It sure looks like it would be reasonable to expect the type of the second input port to be 'enable.'
It is if we look specifically at EnabledDelay block. But if we were to look at Variable Integer Delay block, it becomes tricky as for both Enabled Delay and Variable Integer Delay, the block type is returned as Delay but the ports are different.
I can't find the Variable Integer Delay block. Which library is that in?
I'm not sure what is becoming tricky.
It is under Simulink/Discrete. I want to know which source block's port is connected to a destination block port. For example, says there are two constant block connected to enabled delay block. I want to know if ConstantA is conncted to data port and ConstantB is connceted to Enable port.
In my particular scenario, I also have to know the block type of the each of the block. Given different variation of the Delay block is returned as Delay by
get_param(<BLOCK>,"blocktype")
I was just confused how to know the port connection between blocks programatically.
Well, it does appear that there are several blocks in the Discrete library that all have BlockType == 'Delay'
As far as I can tell, and I might be wrong, the only way to distinguish how each is configured is to interrogate other parameters of the block, like
get_param(gcb,'ShowEnablePort')
to determine which input ports are "active" (I can't think of a better word) and go from there.

Sign in to comment.

 Accepted Answer

This clarifies the confusion.
https://www.mathworks.com/matlabcentral/answers/1618400-how-to-programmatically-distinguish-between-different-block-type?s_tid=srchtitle

More Answers (0)

Products

Release

R2020a

Tags

Community Treasure Hunt

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

Start Hunting!