英文:
Using expandable connector to build control bus in Dymola
问题
我正在学习如何在Dymola中使用可扩展连接器。
我想知道如何确保两个控制总线之间的兼容性。我猜想,如果我在一个控制总线中定义一个名为X的输入变量,那么在另一个控制总线中,我需要定义一个名为X的输出变量。这样,当连接这两个控制总线时,它们就是一致的。
基于上述想法,我定义了两个表示控制总线的可扩展连接器,以下是屏幕截图。
这是我在测试我的想法时使用的设置。
但是在翻译模型时,我收到了以下错误消息。似乎我的逻辑有问题。我的问题是,我应该如何使用可扩展连接器使它们保持一致。
英文:
I am learning about how to use the expandable connector in dymola.
I am wondering how to ensure the compatibility between two control buses. My guess is that if I define an input variable called X in one control bus, then in the other one, I need to define an output variable also called X. So that when connecting these two control buses, they are coherent.
Based on the above idea, I define the two expandable connectors which represent the control buses, here is the screenshot.
Here is the setting I used when testing my ideas.
But when translating the model, I got an error message like the following. It seems I got the logic wrong. My question is that how should I use the expandable connectors so that they are coherent.
答案1
得分: 2
问题的根本在于模型顶部有两个公共的可扩展连接器(总线),理论上两者都可以从外部连接。
最佳选择是在模型顶部不要有两个公共总线,例如:
- 移除其中一个总线
- 将其中一个总线设为受保护的
- (或者使用更复杂的分层变体。)
VehicleInterfaces库以一种良好的方式实现了这一点(或者您可以查看一些商业库)。
然而,使这个工作最简单的方法是在总线中不声明任何内容,即移除对两个'x'变量的声明。
英文:
The underlying problem is that there are two public expandable connectors (buses) at the top of the model; and both could in theory be connected from the outside.
The best option would be to not have two public buses at the top of model, e.g.:
- Remove one of the two buses
- Make one of the two buses protected
- (Or more complicated hierarchical variants.)
The VehicleInterfaces library does this in a good way (alternatively you can look some of the commercial libraries).
However, simplest way of making this work is to not declare anything in the buses, i.e. remove the declaration of both 'x' variables.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论