1
で入れ子に交換可能なクラスからクラスを拡張し、私は不思議では特定の例ではすなわち、ネストされた交換可能なモデルからモデルを拡張するために準拠:それはModelicaだ場合Modelica
package ReplaceableBaseClass
model ExampleUseReplaceable
ModelWithReplaceableExtend replaceableExtend1(
redeclare model LocalModelBase = Extend1,
input1 = time)
"Instance with one input and one output";
ModelWithReplaceableExtend replaceableExtend2(
redeclare model LocalModelBase = Extend2,
input1 = Modelica.Math.sin(4*time + 0.3))
"Instance with one input and two output";
end ExampleUseReplaceable;
model ModelWithReplaceableExtend
"Model which extends from its nested replaceable class"
extends LocalModelBase;
replaceable model LocalModelBase = Extend1
constrainedby PartialToBeExtended;
end ModelWithReplaceableExtend;
partial model PartialToBeExtended
input Real input1;
output Real output1;
end PartialToBeExtended;
model Extend1
extends PartialToBeExtended;
equation
output1 = 3*input1;
end Extend1;
model Extend2
extends PartialToBeExtended;
output Real output2;
equation
output1 = input1 + 0.2;
output2 = input1 * input1;
end Extend2;
end ReplaceableBaseClass;
この事実にDymolaはで動作しますが、Iそれについて奇妙な気持ちがあり、本当にそれを使うのが良いのかどうかは分かりません。