1 | package temp
|
---|
2 | package Basic "TelSysPro Basic Components"
|
---|
3 | package Operators "low level operators"
|
---|
4 | model RealTransmission
|
---|
5 | // Parameters
|
---|
6 | parameter Integer samplingPeriod[nR] = zeros(nR) "sampling period (ms)";
|
---|
7 | parameter Integer nR "number of Reals to transmit";
|
---|
8 | parameter Real maxDelay = 1000 "maxDelay value required for OM";
|
---|
9 | // Connectors
|
---|
10 | Modelica.Blocks.Interfaces.RealOutput y[nR] annotation(
|
---|
11 | Placement(transformation(extent = {{100, -10}, {120, 10}})));
|
---|
12 | Modelica.Blocks.Interfaces.RealInput u[nR] annotation(
|
---|
13 | Placement(transformation(extent = {{-140, -20}, {-100, 20}})));
|
---|
14 | Interfaces.ToReceive u_UL annotation(
|
---|
15 | Placement(transformation(extent = {{-10, -120}, {10, -100}}), iconTransformation(extent = {{-10, -120}, {10, -100}})));
|
---|
16 | // Local variables
|
---|
17 | discrete Real ud1[nR](start=u) annotation(HideResult = true);
|
---|
18 | Real ud2[nR](start=u) annotation(HideResult = true);
|
---|
19 | //discrete Real ud1[nR] annotation(HideResult = true);
|
---|
20 | //Real ud2[nR] annotation(HideResult = true);
|
---|
21 |
|
---|
22 | equation
|
---|
23 | if cardinality(u_UL) == 0 then
|
---|
24 | u_UL.latency = 20;
|
---|
25 | u_UL.isWorking = true;
|
---|
26 | end if;
|
---|
27 | for i in 1:nR loop
|
---|
28 | if samplingPeriod[i] == 0 then
|
---|
29 | when u_UL.isWorking == false then
|
---|
30 | ud1[i] = pre(u[i]);
|
---|
31 | end when;
|
---|
32 | ud2[i] = if u_UL.isWorking then u[i] else ud1[i];
|
---|
33 | else
|
---|
34 | when sample(0, samplingPeriod[i] / 1000) then
|
---|
35 | ud1[i] = u[i];
|
---|
36 | ud2[i] = if u_UL.isWorking then ud1[i] else pre(ud2[i]);
|
---|
37 | end when;
|
---|
38 | end if;
|
---|
39 |
|
---|
40 | //y[i] = if u_UL.latency == 0 then ud2[i] else delay(ud2[i], u_UL.latency / 1000);
|
---|
41 | y[i] = if u_UL.latency == 0 then ud2[i] else delay(ud2[i], u_UL.latency / 1000, maxDelay);
|
---|
42 | end for;
|
---|
43 |
|
---|
44 | annotation(
|
---|
45 | Icon(coordinateSystem(preserveAspectRatio = false)),
|
---|
46 | Diagram(coordinateSystem(preserveAspectRatio = false)));
|
---|
47 | end RealTransmission;
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | end Operators;
|
---|
62 |
|
---|
63 | package Tests "unitary tests for basic Components"
|
---|
64 | model TestRealTransmission
|
---|
65 | //Basic.Operators.RealTransmission realTransmission(nR=6, samplingPeriod={10,10,10,10,10,10}) annotation (Placement(transformation(extent={{-4,-10},{34,8}})));
|
---|
66 | Basic.Operators.RealTransmission realTransmission(nR = 6, samplingPeriod = {10, 10, 10, 10, 10, 10}) annotation(
|
---|
67 | Placement(transformation(extent = {{-4, -10}, {34, 8}})));
|
---|
68 | Modelica.Blocks.Sources.Sine sine(freqHz = 2, phase = 0.78539816339745) annotation(
|
---|
69 | Placement(transformation(extent = {{-54, 2}, {-34, 22}})));
|
---|
70 | Modelica.Blocks.Sources.Constant const(k = 1.5) annotation(
|
---|
71 | Placement(transformation(extent = {{-88, 48}, {-68, 68}})));
|
---|
72 | Modelica.Blocks.Sources.Ramp ramp(duration = 4) annotation(
|
---|
73 | Placement(transformation(extent = {{-54, 32}, {-34, 52}})));
|
---|
74 | Modelica.Blocks.Sources.Exponentials exponentials(riseTime = 3, startTime = 1, offset = 0.5) annotation(
|
---|
75 | Placement(transformation(extent = {{-54, -30}, {-34, -10}})));
|
---|
76 | Modelica.Blocks.Sources.Pulse pulse(period = 1, offset = 0.2) annotation(
|
---|
77 | Placement(transformation(extent = {{-54, -60}, {-34, -40}})));
|
---|
78 | Modelica.Blocks.Sources.Trapezoid trapezoid(period = 1.5) annotation(
|
---|
79 | Placement(transformation(extent = {{-54, -92}, {-34, -72}})));
|
---|
80 | equation
|
---|
81 | connect(const.y, realTransmission.u[1]) annotation(
|
---|
82 | Line(points = {{-67, 58}, {-20, 58}, {-20, -2.5}, {-7.8, -2.5}}, color = {0, 0, 127}));
|
---|
83 | connect(ramp.y, realTransmission.u[2]) annotation(
|
---|
84 | Line(points = {{-33, 42}, {-20, 42}, {-20, -1.9}, {-7.8, -1.9}}, color = {0, 0, 127}));
|
---|
85 | connect(sine.y, realTransmission.u[3]) annotation(
|
---|
86 | Line(points = {{-33, 12}, {-20, 12}, {-20, -1.3}, {-7.8, -1.3}}, color = {0, 0, 127}));
|
---|
87 | connect(exponentials.y, realTransmission.u[4]) annotation(
|
---|
88 | Line(points = {{-33, -20}, {-20, -20}, {-20, -0.7}, {-7.8, -0.7}}, color = {0, 0, 127}));
|
---|
89 | connect(pulse.y, realTransmission.u[5]) annotation(
|
---|
90 | Line(points = {{-33, -50}, {-20, -50}, {-20, -0.1}, {-7.8, -0.1}}, color = {0, 0, 127}));
|
---|
91 | connect(trapezoid.y, realTransmission.u[6]) annotation(
|
---|
92 | Line(points = {{-33, -82}, {-20, -82}, {-20, 0.5}, {-7.8, 0.5}}, color = {0, 0, 127}));
|
---|
93 | annotation(
|
---|
94 | Icon(coordinateSystem(preserveAspectRatio = false)),
|
---|
95 | Diagram(coordinateSystem(preserveAspectRatio = false), graphics = {Text(extent = {{-60, 92}, {26, 64}}, lineColor = {0, 0, 0}, fontSize = 16, horizontalAlignment = TextAlignment.Left, textString = "Validate transmission of reals with respect to their initial value:
|
---|
96 | - default latency is 20 ms (default value when no network is connected)
|
---|
97 | - try no discretization (parameter samplingPeriod={0} in realTransmission)
|
---|
98 | and then with a sampling period (e.g. parameter samplingPeriod={10})
|
---|
99 |
|
---|
100 | Recommended time interval is [0, 6]"), Text(extent = {{-14, -72}, {72, -100}}, lineColor = {0, 0, 0}, fontSize = 16, horizontalAlignment = TextAlignment.Left, textString = "Expected results:
|
---|
101 | - no difference between const.y and realTransmission.y[1]
|
---|
102 | - correct shifting between ramp.y and realTransmission.y[2]
|
---|
103 | - correct shifting between sin.y and realTransmission.y[3]
|
---|
104 | - correct shifting between exponentials.y and realTransmission.y[4]
|
---|
105 | - correct shifting between pulse.y and realTransmission.y[5]
|
---|
106 | - correct shifting between trapezoid.y and realTransmission.y[6]
|
---|
107 |
|
---|
108 | - with discretization, the output signals are piecewise constant
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 |
|
---|
121 | ")}));
|
---|
122 | end TestRealTransmission;
|
---|
123 | end Tests;
|
---|
124 | annotation(
|
---|
125 | Icon(graphics = {Rectangle(lineColor = {200, 200, 200}, fillColor = {248, 248, 248}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-100.0, -100.0}, {100.0, 100.0}}, radius = 25.0), Rectangle(lineColor = {128, 128, 128}, extent = {{-100.0, -100.0}, {100.0, 100.0}}, radius = 25.0), Rectangle(origin = {0.0, 35.1488}, fillColor = {255, 255, 255}, extent = {{-30.0, -20.1488}, {30.0, 20.1488}}), Rectangle(origin = {0.0, -34.8512}, fillColor = {255, 255, 255}, extent = {{-30.0, -20.1488}, {30.0, 20.1488}}), Line(origin = {-51.25, 0.0}, points = {{21.25, -35.0}, {-13.75, -35.0}, {-13.75, 35.0}, {6.25, 35.0}}), Polygon(origin = {-40.0, 35.0}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{10.0, 0.0}, {-5.0, 5.0}, {-5.0, -5.0}}), Line(origin = {51.25, 0.0}, points = {{-21.25, 35.0}, {13.75, 35.0}, {13.75, -35.0}, {-6.25, -35.0}}), Polygon(origin = {40.0, -35.0}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-10.0, 0.0}, {5.0, 5.0}, {5.0, -5.0}})}),
|
---|
126 | Documentation(info = "<html>
|
---|
127 | <p><span style=\"font-family: MS Shell Dlg 2;\">This package contains basic TelSysPro components.</span></p>
|
---|
128 | </html>"),
|
---|
129 | Diagram(graphics = {Text(extent = {{116, 34}, {-114, 10}}, lineColor = {0, 0, 0}, fontSize = 17, textStyle = {TextStyle.Bold}, textString = "TelSysPro Basic Components")}));
|
---|
130 | end Basic;
|
---|
131 |
|
---|
132 | package Interfaces "TelSysPro Interfaces"
|
---|
133 | connector ToReceive = input Types.TelCoVars "System variables as input" annotation(
|
---|
134 | Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Rectangle(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, fillColor = {135, 135, 135}, fillPattern = FillPattern.Forward)}),
|
---|
135 | Diagram(graphics = {Rectangle(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, fillColor = {135, 135, 135}, fillPattern = FillPattern.Forward)}));
|
---|
136 | connector ToSend = output Types.TelCoVars "System variables as output" annotation(
|
---|
137 | Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Rectangle(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, fillColor = {135, 135, 135}, fillPattern = FillPattern.Forward)}),
|
---|
138 | Diagram(graphics = {Rectangle(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0}, fillColor = {135, 135, 135}, fillPattern = FillPattern.Forward)}));
|
---|
139 | annotation(
|
---|
140 | Icon(graphics = {Rectangle(lineColor = {200, 200, 200}, fillColor = {248, 248, 248}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-100, -100}, {100, 100}}, radius = 25.0), Rectangle(lineColor = {128, 128, 128}, fillPattern = FillPattern.None, extent = {{-100, -100}, {100, 100}}, radius = 25.0), Polygon(origin = {20, 0}, lineColor = {64, 64, 64}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, points = {{-10.0, 70.0}, {10.0, 70.0}, {40.0, 20.0}, {80.0, 20.0}, {80.0, -20.0}, {40.0, -20.0}, {10.0, -70.0}, {-10.0, -70.0}}), Polygon(fillColor = {102, 102, 102}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-100, 20}, {-60, 20}, {-30, 70}, {-10, 70}, {-10, -70}, {-30, -70}, {-60, -20}, {-100, -20}})}),
|
---|
141 | Documentation(info = "<html>
|
---|
142 | <p><span style=\"font-family: MS Shell Dlg 2;\">This package contains the input and output connectors required by TelSysPro.</span></p>
|
---|
143 | <p>Each connector is composed with two system variables:</p>
|
---|
144 | <ul>
|
---|
145 | <li>Boolean 'isWorking' as Operating Mode</li>
|
---|
146 | <li>Integer 'latency' as Latency</li>
|
---|
147 | </ul>
|
---|
148 | </html>"),
|
---|
149 | Diagram(graphics = {Text(extent = {{116, 34}, {-114, 10}}, lineColor = {0, 0, 0}, fontSize = 18, textStyle = {TextStyle.Bold}, textString = "TelSysPro Interfaces")}));
|
---|
150 | end Interfaces;
|
---|
151 |
|
---|
152 | package Types "TelSysPro Types"
|
---|
153 | record TelCoVars "System Variables to exchange"
|
---|
154 | Boolean isWorking "Current operationg mode";
|
---|
155 | Integer latency "Cuurent latency";
|
---|
156 | annotation(
|
---|
157 | Documentation(info = "<html>
|
---|
158 |
|
---|
159 | </html>"));
|
---|
160 | end TelCoVars;
|
---|
161 | annotation(
|
---|
162 | Icon(graphics = {Rectangle(lineColor = {200, 200, 200}, fillColor = {248, 248, 248}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-100, -100}, {100, 100}}, radius = 25.0), Rectangle(lineColor = {128, 128, 128}, extent = {{-100, -100}, {100, 100}}, radius = 25, lineThickness = 0.5), Polygon(origin = {-12.167, -23}, fillColor = {0, 0, 0}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{12.167, 65}, {14.167, 93}, {36.167, 89}, {24.167, 20}, {4.167, -30}, {14.167, -30}, {24.167, -30}, {24.167, -40}, {-5.833, -50}, {-15.833, -30}, {4.167, 20}, {12.167, 65}}, smooth = Smooth.Bezier, lineColor = {0, 0, 0}), Polygon(origin = {2.7403, 1.6673}, fillColor = {0, 0, 0}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{49.2597, 22.3327}, {31.2597, 24.3327}, {7.2597, 18.3327}, {-26.7403, 10.3327}, {-46.7403, 14.3327}, {-48.7403, 6.3327}, {-32.7403, 0.3327}, {-6.7403, 4.3327}, {33.2597, 14.3327}, {49.2597, 14.3327}, {49.2597, 22.3327}}, smooth = Smooth.Bezier, lineColor = {0, 0, 0})}),
|
---|
163 | Documentation(info = "<html>
|
---|
164 | <p><span style=\"font-family: MS Shell Dlg 2;\">This package defines the type to declare system varizbles.</span></p>
|
---|
165 | <p>This type is a record composed with two parts:</p>
|
---|
166 | <ul>
|
---|
167 | <li>a Boolean</li>
|
---|
168 | <li>an Integer</li>
|
---|
169 | </ul></html>"),
|
---|
170 | Diagram(graphics = {Text(extent = {{116, 34}, {-114, 10}}, lineColor = {0, 0, 0}, fontSize = 18, textStyle = {TextStyle.Bold}, textString = "TelSysPro Types")}));
|
---|
171 | end Types;
|
---|
172 | annotation(
|
---|
173 | uses(Modelica(version = "3.2.2"), ThermoSysPro(version = "3.3")),
|
---|
174 | Diagram(graphics = {Text(extent = {{116, 34}, {-114, 10}}, lineColor = {0, 0, 0}, fontSize = 18, textStyle = {TextStyle.Bold}, textString = "TelSysPro Library for Basic Modeling
|
---|
175 | of Telecom Networks")}),
|
---|
176 | Icon(graphics = {Rectangle(lineColor = {128, 128, 128}, extent = {{-100.0, -100.0}, {100.0, 100.0}}, radius = 25, lineThickness = 0.5), Text(extent = {{-120, -26}, {126, 30}}, lineColor = {128, 128, 128}, lineThickness = 0.5, textString = "TSP", fontName = "Century Gothic", textStyle = {TextStyle.Bold, TextStyle.Italic})}),
|
---|
177 | Documentation(info = "<html>
|
---|
178 | <p><b><span style=\"font-family: MS Shell Dlg 2;\">TelSysPro</span></b> is a Modelica library able to model telecommunication networks. This library is being developped and maintained by J.Ph. Tavella and A. Jardin at EDF R&D Saclay Lab in the frame of the project SIMSE (2016-19). </p>
|
---|
179 | <p><b><span style=\"font-family: MS Shell Dlg 2;\">Copyright © 2017-18, EDF</span></b> </p>
|
---|
180 | </html>"),
|
---|
181 | version = "2");
|
---|
182 | end temp;
|
---|