ThermoSysPro库中的StodolaTurbine组件有一个自定义参数,在涡轮机组件的图表视图中,我可以看到该自定义参数属于一条记录。但是此记录没有参数,在这种情况下如何添加一个自定义参数?
您设置的每个修饰符都会显示在参数窗口中。您不仅可以设置参数的修饰符,还可以设置或多或少的非最终修饰符:还可以为所有变量和组件实例设置修饰符,无论它们在参数窗口中是否可见。Dymola将在“自定义参数”部分中显示此类修饰符。
有几种设置此类修饰符的方法:
在较旧的Dymola版本中,这些修饰符仅显示在常规参数组中,这会引起混淆。因此,他们将其移至“自定义参数”部分。
让我们使用下面的简单代码来演示这三种不同的方法。
package Demo
model StepSine
Modelica.Blocks.Sources.Step step annotation (Placement(transformation(extent={{-20,20},{20,60}})));
Modelica.Blocks.Interfaces.RealOutput y annotation (Placement(transformation(extent={{100,-10},{120,10}})));
Modelica.Blocks.Math.Add add annotation (Placement(transformation(extent={{60,-10},{80,10}})));
Modelica.Blocks.Sources.Sine sine annotation (Placement(transformation(extent={{-20,-60},{20,-20}})));
equation
connect(add.y, y) annotation (Line(points={{81,0},{110,0}}, color={0,0,127}));
connect(step.y, add.u1) annotation (Line(points={{22,40},{40,40},{40,6},{58,6}}, color={0,0,127}));
connect(sine.y, add.u2) annotation (Line(points={{22,-40},{40,-40},{40,-6},{58,-6}}, color={0,0,127}));
end StepSine;
model Example
StepSine stepSine annotation (Placement(transformation(extent={{-8,-10},{12,10}})));
end Example;
end Demo;
Run Code Online (Sandbox Code Playgroud)
在这里,我们创建了类StepSine,它仅向正弦信号添加了一个步骤。没有传播组件的任何参数,但是使用上述方法,我们仍然可以在中设置它们Example。
使用文字层
StepSine stepSine(add.k1=-1)stepSine。您获得了第一个自定义参数。使用“添加修饰符”
stepSine中Examplestep.height=1并单击确定使用“显示组件”
stepSine使用右键单击->显示组件打开sine并输入例如3作为幅度。stepSine再次检查的参数窗口。您获得了第三个自定义参数。