modelExampleClientLoop

Example to include TCP communication to simple test server in the control loop

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

This is a very simple example to show the TCP communication functionality. A feedback control is modeled where a gain controller controls a first order system. The signal is send to a server which returns the send message unaltered back to the client.

TCP/IP-server for testing

A server to test ExampleClientLoop is provided both as a source code *.cpp-file and as an executable *.exe-file. The server simply echoes the received character message and sends it back to the sender (i.e. client). The code may be compiled and executed from the console. This code is taken from Microsoft's Winsock documentation pages: Link to MSDN

The server performs the following tasks:
  • Initialise Winsock;
  • Create a socket;
  • Bind the socket;
  • Wait and listen on the socket if a client connects;
  • Accept incoming connection from client;
  • Receive messages from client as long as it sends and return the received messages unaltered;
  • Terminate connection and shut down.

Usage

Open a console in Windows (Start -> Run -> insert: "cmd"), change folder to .../AixLib/Resources/SocketCommunicationServer, run ExampleServer.exe. The Server is now ready to operate. Now simulate ExampleClientLoop.

Verification of IP address

Note: Depending on your network settings it may be required to change the IP address in ExampleClientLoop.tCPCommunicatorExample. Set the IP address to the IP address of your local machine. (You may retrieve your local IP address in Windows from the console (Start -> Run -> insert: "cmd" -> ipconfig)).

Requirements

This example and the executable have been tested on Windows 7 64-bit using Dymola 2015 32-bit.

Components

TypeNameDefaultDescription
Modelica.Blocks.Continuous.FirstOrdersystemSimple first order system to be controlled
Modelica.Blocks.Math.Feedbackfeedback
Modelica.Blocks.Nonlinear.Limiterlimiterlimits output of controller
Modelica.Blocks.Math.GaingainOnly gain controller
Modelica.Blocks.Sources.PulsepulsePulse of set point
Components.TCPCommunicatorExampletCPCommunicatorExampleTCP block which sends values and receives values, has no impact on signal

Revisions

  • August 25, 2018  by Thomas Beutlich:
    Changed data type of port from String to Integer. This is for:#277
  • September 03, 2013  by Georg Ferdinand Schneider:
    Revised documented
  • June 01, 2013  by Georg Ferdinand Schneider:
    Implemented