Modelica - '延伸'有下拉菜单

时间:2017-04-13 13:19:37

标签: inheritance modelica

我认为这是可能的,但我不确定,因为我找不到任何例子。我希望能够在参数面板中直接选择要继承的模型。

我可以想象两种解决方案:

extends model1 annotation(choices(choice(model1 "Ref"),choice(model2 "New")));

extends replaceable model1 annotation(choices(choice(redeclare model1 "Ref"),choice(redeclare model2 "New")));

更新:示例以更好地解释我想要做的事情:我想从' Final'的参数面板中进行选择。要扩展哪种模式,在Data1'和' Data2'。

package test

 partial model Data1
  parameter Real a=1;
  parameter Real b=2;
 end Data1;

 partial model Data2
  parameter Real a=1.1;
  parameter Real b=1.8;
 end Data1;

 model Final
  extends Data1; //(or Data2)
  Real y;
 equation
  y = a*time+b;
 end Final;

end test;

1 个答案:

答案 0 :(得分:1)

无法更换select t1.* from ( select t1.server_id, t2.job_id from (select distinct server_id from yourTable) t1 cross join (select distinct job_id from yourTable) t2 ) t1 left join yourTable t2 on t2.server_id = t1.server_id and t2.job_id = t1.job_id where t2.job_id is null; 。您可以在要扩展的模型中使用extends的可替换模型,但不能扩展模型本身。例如:

redeclared

您应该能够重组您的结构,以便不必使用可替换的扩展。