1 | within ;
|
---|
2 | package TestEncapsulated
|
---|
3 | model MyModelWithEncapsulated
|
---|
4 | parameter Real m = 4.0;
|
---|
5 | encapsulated model myEncapsulated
|
---|
6 | import TestEncapsulated.Interface;
|
---|
7 | extends Interface;
|
---|
8 | equation
|
---|
9 | var = u;
|
---|
10 | end myEncapsulated;
|
---|
11 | myEncapsulated myEncapsulated1
|
---|
12 | annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
|
---|
13 | Modelica.Blocks.Interfaces.RealOutput y
|
---|
14 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
15 | Modelica.Blocks.Sources.Constant const(k=1)
|
---|
16 | annotation (Placement(transformation(extent={{-80,-10},{-60,10}})));
|
---|
17 | equation
|
---|
18 | connect(myEncapsulated1.y, y) annotation (Line(
|
---|
19 | points={{1,0},{100,0}},
|
---|
20 | color={0,0,127},
|
---|
21 | smooth=Smooth.None));
|
---|
22 | connect(const.y, myEncapsulated1.u) annotation (Line(
|
---|
23 | points={{-59,0},{-22,0}},
|
---|
24 | color={0,0,127},
|
---|
25 | smooth=Smooth.None));
|
---|
26 | annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
27 | -100},{100,100}}), graphics));
|
---|
28 | end MyModelWithEncapsulated;
|
---|
29 |
|
---|
30 | package Functions
|
---|
31 | function CalcSomething
|
---|
32 | input Real u;
|
---|
33 | output Real y;
|
---|
34 | algorithm
|
---|
35 | y:= u+3.2;
|
---|
36 | end CalcSomething;
|
---|
37 | end Functions;
|
---|
38 |
|
---|
39 | partial model Interface
|
---|
40 | extends Modelica.Blocks.Interfaces.SISO;
|
---|
41 | Real var;
|
---|
42 | equation
|
---|
43 | y = TestEncapsulated.Functions.CalcSomething(var);
|
---|
44 | end Interface;
|
---|
45 | annotation (uses(Modelica(version="3.2.1")));
|
---|
46 | end TestEncapsulated;
|
---|