我想做的是
M_type(redeclare package L=L2) m2_instance;但不起作用。相反,我可以写
model M2_type
extends M_type(redeclare package L=L2);
end M2_type;
M2_type m2_instance;这里有没有一种更简单的方法来做到这一点,并避免声明M2_type?
发布于 2021-02-26 18:05:24
必须将redeclare修饰符移动到实例名称。
M_type(redeclare package L=L2) m2_instance; // wrong syntax
M_type m2_instance(redeclare package L=L2); // correct下面是一个小包,它演示了一切,并在Dymola2021x和OpenModelica 1.16.2中模拟得很好。
package Redeclaration
package L1
constant Real x = 1;
end L1;
package L2
constant Real x = 2;
end L2;
model M_type
replaceable package L = L1;
Real x = L.x;
end M_type;
model Example
M_type m_instance(redeclare package L=L2);
end Example;
end Redeclaration;https://stackoverflow.com/questions/66382882
复制相似问题