我正在尝试将输入/输出连接器构建为接口,并将它们添加到包装模型的包装器类中。连接器的变量使用条件声明定义。当我在包装类中实例化输出连接器时,我可以在Dymola中使用“方程式”部分成功编译类。但当我将其更改为“算法”部分时,我收到了一个错误:
It has 2 scalar unknowns and 5 scalar equations.
The Real part has 2 unknowns and 2 equations.
The Integer part has 0 unknowns and 2 equations.
The Boolean part has 0 unknowns and 0 equations.
The String part has 0 unknowns and 1 equations.
我无法理解这个错误。我知道算法部分和方程部分之间的一般区别,但不能将我的知识与我得到的错误联系起来。我创建了一个我想要编译的小例子:
以下是连接器定义:
connector DO
/**/
parameter String Type;
parameter input Integer[:] Dim;
discrete output Real ScalarReal if Type == "Real" and size(Dim, 1) == 1 and Dim[1] == 1 "Scalar Real";
discrete output Real[Dim[1],Dim[2]] MatrixReal if Type == "Real" and size(Dim, 1) > 1 "Matrix Real";
end DO;
connector DI
parameter String Type;
parameter input Integer[:] Dim;
discrete input Real ScalarReal if Type == "Real" and size(Dim, 1) == 1 and Dim[1] == 1 "Scalar Real";
discrete input Real[Dim[1],Dim[2]] MatrixReal if Type == "Real" and size(Dim, 1) > 1 "Matrix Real";
end DI;
connector Conn
parameter input Integer nOut(min = 0) = 0;
parameter input Integer nIn(min = 0) = 0;
DI[nIn] InConn if nIn > 0;
DO[nOut] OutConn if nOut > 0;
end Conn;
和包装模型
model Wrapper
Conn testConn(nIn = 0, nOut = 1, OutConn(Type = {"Real"}, Dim = {{2,1}}));
equation
when sample(0,10) then
testConn.OutConn[1].MatrixReal = [2; 3];
end when;
end Wrapper;
任何人都可以帮我解决这个问题吗? 非常感谢!