入力/出力コネクタをインターフェイスとして構築し、モデルをラップするラッパー クラスに追加しようとしています。コネクタの変数は、条件宣言を使用して定義されます。ラッパー クラスで出力コネクタをインスタンス化すると、「式」セクションを使用すると、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;
誰でもこの問題を解決できますか? どうもありがとう!