Created
April 27, 2015 07:45
-
-
Save tbeu/6a10c5b94bd4cea091c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e19c423f133518498582236fc6bd55cf6112ed79 Mon Sep 17 00:00:00 2001 | |
From: tbeu <[email protected]> | |
Date: Mon, 27 Apr 2015 09:42:58 +0200 | |
Subject: [PATCH] Fix execution order | |
--- | |
Modelica_DeviceDrivers/Blocks/Communication.mo | 23 +++++++++++++++++++--- | |
.../Blocks/Examples/TestSerialPackager_UDP.mo | 10 ++++++++-- | |
2 files changed, 28 insertions(+), 5 deletions(-) | |
diff --git a/Modelica_DeviceDrivers/Blocks/Communication.mo b/Modelica_DeviceDrivers/Blocks/Communication.mo | |
index ad08061..3c167a6 100644 | |
--- a/Modelica_DeviceDrivers/Blocks/Communication.mo | |
+++ b/Modelica_DeviceDrivers/Blocks/Communication.mo | |
@@ -109,12 +109,17 @@ provided by the parameter <b>memoryID</b>. If the shared memory partition does n | |
parameter Integer port_recv=10001 | |
"Listening port number of the server. Must be unique on the system" | |
annotation (Dialog(group="Incoming data")); | |
- Modelica_DeviceDrivers.Blocks.Interfaces.PackageOut pkgOut(pkg = SerialPackager(if autoBufferSize then bufferSize else userBufferSize)) | |
+ parameter Boolean defineExecOrder = false | |
+ "true, if input package is used to define a deterministic execution order"; | |
+ Interfaces.PackageIn pkgIn if defineExecOrder annotation (Placement(transformation( | |
+ extent={{-20,-20},{20,20}}, | |
+ rotation=270, | |
+ origin={-108,0}))); | |
+ Interfaces.PackageOut pkgOut(pkg = SerialPackager(if autoBufferSize then bufferSize else userBufferSize)) | |
annotation (Placement(transformation( | |
extent={{-20,-20},{20,20}}, | |
rotation=90, | |
origin={108,0}))); | |
- | |
protected | |
Integer bufferSize; | |
UDPSocket socket = UDPSocket(port_recv, if autoBufferSize then bufferSize else userBufferSize); | |
@@ -127,7 +132,7 @@ provided by the parameter <b>memoryID</b>. If the shared memory partition does n | |
pkgOut.dummy = Modelica_DeviceDrivers.Blocks.Communication.Internal.DummyFunctions.readUDP( | |
socket, | |
pkgOut.pkg, | |
- time); | |
+ if defineExecOrder then pkgIn.dummy else time); | |
end when; | |
annotation (preferredView="info", | |
@@ -155,10 +160,16 @@ provided by the parameter <b>memoryID</b>. If the shared memory partition does n | |
annotation (Dialog(group="Outgoing data")); | |
parameter Integer port_send=10002 "Target port of the receiving UDP server" | |
annotation (Dialog(group="Outgoing data")); | |
+ parameter Boolean defineExecOrder = false | |
+ "true, if input package is forwarded to define a deterministic execution order"; | |
Interfaces.PackageIn pkgIn annotation (Placement(transformation( | |
extent={{-20,-20},{20,20}}, | |
rotation=270, | |
origin={-108,0}))); | |
+ Interfaces.PackageOut pkgOut if defineExecOrder annotation (Placement(transformation( | |
+ extent={{-20,-20},{20,20}}, | |
+ rotation=90, | |
+ origin={108,0}))); | |
protected | |
UDPSocket socket = UDPSocket(0); | |
Integer bufferSize; | |
@@ -179,6 +190,11 @@ provided by the parameter <b>memoryID</b>. If the shared memory partition does n | |
bufferSize, | |
pkgIn.dummy); | |
end when; | |
+ if defineExecOrder then | |
+ pkgOut.pkg = pkgIn.pkg; | |
+ pkgOut.trigger = pkgIn.trigger; | |
+ pkgOut.dummy = dummy; | |
+ end if; | |
annotation (preferredView="info", | |
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100, | |
-100},{100,100}}), graphics={Text(extent={{-150,136},{150,96}}, | |
@@ -825,6 +841,7 @@ See <a href=\"modelica://Modelica_DeviceDrivers.Blocks.Examples.TestSerialPackag | |
output Real dummy2; | |
algorithm | |
Modelica_DeviceDrivers.Communication.UDPSocket_.sendTo(socket, ipAddress, port, pkg, dataSize); | |
+ Modelica_DeviceDrivers.Packaging.SerialPackager_.resetPointer(pkg); | |
dummy2 := dummy; | |
end sendToUDP; | |
diff --git a/Modelica_DeviceDrivers/Blocks/Examples/TestSerialPackager_UDP.mo b/Modelica_DeviceDrivers/Blocks/Examples/TestSerialPackager_UDP.mo | |
index 8057ad9..5965fe6 100644 | |
--- a/Modelica_DeviceDrivers/Blocks/Examples/TestSerialPackager_UDP.mo | |
+++ b/Modelica_DeviceDrivers/Blocks/Examples/TestSerialPackager_UDP.mo | |
@@ -9,7 +9,8 @@ model TestSerialPackager_UDP "Example for combining UDP and SerialPackager block | |
Modelica_DeviceDrivers.Blocks.Communication.UDPSend uDPSend( | |
autoBufferSize=false, | |
userBufferSize=36, | |
- port_send=10002) annotation(Placement(transformation( | |
+ port_send=10002, | |
+ defineExecOrder=true) annotation(Placement(transformation( | |
origin={-30,-44}, | |
extent={{-10,-10},{10,10}}, | |
rotation=270))); | |
@@ -19,7 +20,8 @@ model TestSerialPackager_UDP "Example for combining UDP and SerialPackager block | |
Modelica_DeviceDrivers.Blocks.Communication.UDPReceive uDPReceive( | |
autoBufferSize=false, | |
userBufferSize=36, | |
- port_recv=10002) annotation(Placement(transformation( | |
+ port_recv=10002, | |
+ defineExecOrder=true) annotation(Placement(transformation( | |
origin={40,50}, | |
extent={{-10,-10},{10,10}}, | |
rotation=270))); | |
@@ -58,6 +60,10 @@ model TestSerialPackager_UDP "Example for combining UDP and SerialPackager block | |
points={{40,9.2},{40,2.8}})); | |
connect(getInteger.pkgIn, getFloat.pkgOut[1]) annotation (Line( | |
points={{40,-27.2},{40,-18.8}})); | |
+ connect(uDPSend.pkgOut,uDPReceive.pkgIn) annotation(Line( | |
+ points={{-30,-54.7},{-30,-59.7},{5,-59.7},{5,65.7},{40,65.7},{40,60.7}}, | |
+ pattern = LinePattern.Dash, | |
+ arrow={Arrow.None, Arrow.Open})); | |
annotation( | |
Documentation(info="<html> | |
<p> | |
-- | |
1.9.5.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment