Connect Simulink PMIO Port to a referenced subsystem with a .m script

7 次查看(过去 30 天)
I want to connect a PMIO Port called "el_P_1" to the corresponding port inside a referenced subsystem. The referenced subsystem is called "cell_1" and includes the PMIO Port "el_P" (Port number 1). Per drag and drop with the cursor the connection can be made. However, if the same operation is tried with the "add_line()" command, there is the following error:
Error using TopDownPrinciple01
The points input cannot lie on objects that do not share the same Physical Modeling domain
With the set_param() command I already set the 'ConnectionType' property to 'Connection: foundation.electrical.electrical' (instead of the standard 'Inherit: auto'). After reading it back with the get_param() command, the connection types of both ports is set to the set connection type. When double clicking the blocks in Simulink, the connection type matches as well. If trying to run the program, the same error arises than before.
Does anyone know how this error can be solved?
That's the relevant code:
get_param('mymodel/Cell_Block_1/el_P_1', 'ConnectionType')
get_param('mymodel/Cell_Block_1/cell_1/el_P', 'ConnectionType')
add_line('mymodel/Cell_Block_1', 'el_P_1/RConn 1', 'cell_1/1', 'autorouting', 'smart')
  2 个评论
Angelo Yeo
Angelo Yeo 2024-1-25
Hi @Alex, it's preferred to have the model to better understand Simulink issues (I also understand how hard it is to describe what you see in text formats). If you do not want to share the model due to security reasons, you can consider creating a reproducible toy model with reproduction steps.
Alex
Alex 2024-1-29
Hi @Angelo Yeo, I built a dummy to show the problem. However, even if the code and model seem exactly the same to me, there is another error, which I am not able to solve. Instead of the error with the physical modeling domain, now there is an Invalid Simulink object name of my cell, every time I try to add lines between the components. The errors are in the lines 42, 85 and 104. I assume that if this error is resolved, the former error about the physical modeling domain should arise again.
I hope this code helps understanding my problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by