以编程方式连接两个子系统

以编程方式连接两个子系统

本文介绍了以编程方式连接两个子系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式重用我之前开发的一些自定义模块/模型来构建复杂的模型,但是我无法连接两个PMC_Port

I'm trying to build a complex model programmatically reusing some custom blocks/models I have developed before, but I cannot manage to connect two PMC_Port

这就是我所拥有的:

% Main system
sys_name = 'model';
sys = new_system(sys_name)
open_system(sys_name)

load_system('circuit_cell') % Subsystem with 6 PMC_Port elements
                            % stored in circuit_cell.mdl file
% Add cell #1
add_block('built-in/Subsystem', [sys_name '/cell1'])
Simulink.BlockDiagram.copyContentsToSubSystem('circuit_cell', [sys_name '/cell1']);

% Add cell #2
add_block('built-in/Subsystem', [sys_name '/cell2'])
Simulink.BlockDiagram.copyContentsToSubSystem('circuit_cell', [sys_name '/cell2']);

% And now I want to connect one cell with the other
add_line('model', 'cell1/1', 'cell2/1', 'autorouting', 'on')

...但是我总是收到无效的Simulink对象名称:cell1/1"错误消息.

...but I always get a 'Invalid Simulink object name: cell1/1' error message.

编辑.-这是circuit_cell.mdl文件: http://pastebin.com/mXuVFtM3

EDIT.- Here it is circuit_cell.mdl file: http://pastebin.com/mXuVFtM3

推荐答案

感谢@ am304注释,我设法解决了此问题.

Thanks to @am304 comments I manage to solve this issue.

通过物理端口的连接必须通过RConn1LConn1键名进行,因此命令add_line的执行方式如下:

Connection through physical ports must be made through RConn1 and LConn1 keynames, so the command add_line should be executed as follows:

add_line('model', 'cell1/RConn1', 'cell2/LConn1', 'autorouting', 'on')

经过测试:

  • Matlab版本7.12.0.635(R2011a)

谢谢!

编辑.-正如@ am304所说,该文件尚未记录,因此可以更改.如果检查了更多版本,请发表评论,我将更新答案.

Edit.- As @am304 says it's not documented so it can be changed. If more versions are checked, please post a comment and I will update the answer.

这篇关于以编程方式连接两个子系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 03:51