Get the port handle for the reference mode

10 vues (au cours des 30 derniers jours)
Mohamed Hamed
Mohamed Hamed le 1 Fév 2022
Commenté : Fangjun Jiang le 7 Fév 2022
Hello All
Is there anyway to get the port handler for the reference model and then for Inport/Outport read the resolved signal ?

Réponses (2)

Fangjun Jiang
Fangjun Jiang le 2 Fév 2022
I would think that you porbably need to follow the Model block, open the referenced model and then get the input and output port handels and then the resolved signal object/names.
The info is saved in the referenced model. The referenced model is not loaded when barely open the top-level model.
  1 commentaire
Mohamed Hamed
Mohamed Hamed le 7 Fév 2022
Thanks Fangjun
Could you check my reply

Connectez-vous pour commenter.


Mohamed Hamed
Mohamed Hamed le 6 Fév 2022
Thank you Fangjun for your answer
I tried the below code for get all Inputs( Name and port number)
simBlockH = get_param(BclkName, 'Handle');
handles = find_system(simBlockH, 'LookUnderMasks', 'on', 'FollowLinks', 'on', 'SearchDepth', 1, 'BlockType', 'Inport');
PortNameArray = get_param(handles, 'Name');
PortNumberArray = get_param(handles, 'Port');
And it's worked correctly.But when i tried to get the port handle for each inport i get an error, could you plese guide me how can i get the port handle for each port to read the Resolved signal name and if this port is connected to Goto/From block
I tried this code for read the port handle ( does not work for Model reference, but work normally for Subsyste)
ph=get_param(BclkName,'PortHandles');
  5 commentaires
Mohamed Hamed
Mohamed Hamed le 7 Fév 2022
This is done within the Modelreference itself
BclkName is the Bloxk handler for the model reference
Could you please correct my code?
Fangjun Jiang
Fangjun Jiang le 7 Fév 2022
See my original answer. Forget about the "Model" block. Open the model and start from there.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by