Ticket #3737: Rpkg.mo

File Rpkg.mo, 2.5 KB (added by massimo ceraolo, 10 years ago)
Line 
1encapsulated package Rpkg
2 import Modelica;
3
4 model ER
5 Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage(V = 1, freqHz = 50) annotation(Placement(visible = true, transformation(origin = {-42, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 270)));
6 Modelica.Electrical.Analog.Basic.Resistor resistor(R = 1) annotation(Placement(visible = true, transformation(origin = {2, 2}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
7 Modelica.Electrical.Analog.Basic.Ground ground annotation(Placement(visible = true, transformation(extent = {{-52, -50}, {-32, -30}}, rotation = 0)));
8 equation
9 connect(resistor.p, sineVoltage.p) annotation(Line(points = {{2, 12}, {3, 12}, {3, 28}, {-42, 28}, {-42, 12}}, color = {0, 0, 255}));
10 connect(sineVoltage.n, resistor.n) annotation(Line(points = {{-42, -8}, {-42, -20}, {2, -20}, {2, -8}}, color = {0, 0, 255}));
11 connect(ground.p, sineVoltage.n) annotation(Line(points = {{-42, -30}, {-42, -8}}, color = {0, 0, 255}));
12 annotation(experiment(StopTime = 0.1), experimentSetupOutput, Diagram(coordinateSystem(extent = {{-100, -60}, {100, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -60}, {100, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
13 end ER;
14
15model SimpleR "Ideal resistor"
16 parameter Modelica.SIunits.Resistance R(start = 1) "Resistance";
17 extends Modelica.Electrical.Analog.Interfaces.OnePort;
18equation
19 v = R * i;
20 annotation(
21 Icon(coordinateSystem(initialScale = 0.1),
22 graphics = {Rectangle(lineColor = {0, 0, 255}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-70, 30}, {70, -30}}), Line(points = {{-90, 0}, {-70, 0}}, color = {0, 0, 255}), Line(points = {{70, 0}, {90, 0}}, color = {0, 0, 255}), Text(origin = {0, 6}, extent = {{-144, -40}, {142, -72}}, textString = "R=%R"), Text(origin = {-2, -6},lineColor = {0, 0, 255}, extent = {{-152, 87}, {148, 47}}, textString = "%name")}),
23 Diagram(coordinateSystem(initialScale = 0.1),
24 graphics = {Rectangle(lineColor = {0, 0, 255},
25 fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid,
26 extent = {{-70, 30}, {70, -30}}), Line(points = {{-96, 0}, {-70, 0}}, color = {0, 0, 255}),
27 Line(points = {{70, 0}, {96, 0}}, color = {0, 0, 255}),
28 Text(origin = {-13, 64}, lineColor = {0, 0, 255},
29 fillColor = {0, 0, 255}, extent = {{-71, 20}, {87, -14}}, textString = "&name")}));
30end SimpleR;
31 annotation(uses(Modelica(version = "3.2.1")));
32end Rpkg;