User Tools

Site Tools


eeros_architecture:control_system:available_blocks:socket

This is an old revision of the document!


Socket Data

A socket data block allows for sending or receiving signal values to or from a remote station over a socket connection. This can be used to gather signals from a sensor or send signals to an remote control unit. Upon instantiation the block will create a socket server (or socket client) which runs in its own thread. Any socket client can now connect to this server. After a connection is established the two can send or receive any type of signal.
A socket data block can have zero or one input. The first template parameter indicates the type of the input signal while the second parameter denotes the type of the output signal, e.g.:

SocketData<Vector3, int> socket1;

This blocks will have a signal input (a signal from another control system block) of type Vector3 and send this signal over the socket connection. Concurrently the block will receive single values of type int and write these values onto its output signal, where it can be consumed by other blocks. If the socket data blocks has only data to transmit but no data to receive use std::nullptr_ptr as template parameter.

SocketData<Matrix<6,1,double>, std::nullptr_t> socket2;	// send Matrix<6,1,double>, receive nothing
SocketData<Vector2, std::nullptr_t> socket3;	        // send nothing, receive Vector2

Parameters

When constructing a socket data block you can pass the ip-address, the port number, and the period of the internal thread as parameters. If you pass an empty string as ip-address, a socket server will be created. Setting the ip-address will cause a socket client to be created, which tries to connect to the given ip-address. The period of the internal thread determines the transceiver frequency.

SocketData<Matrix<10,2,double>, double> socket1("", 9876, 0.5);	

A socket server is established. Input and output signals will be transmitted twice per second. A remote client would have to connect to the ip-address of the machine running this application on port '9876'.

SocketData<Matrix<10,2,double>, double> socket2("146.136.36.102", 9876, 0.5);	

This creates a socket client. Input and output signals will be transmitted twice per second. The client connects to a server on the ip-address '146.136.36.102' with port number '9876'.

Miscellaneous

As soon as a client connects to a socket server a connection is up and running until either one of them stops. It is possible to stop the server or the client and restart it subsequently. In both cases a new connection will be established.

eeros_architecture/control_system/available_blocks/socket.1505309408.txt.gz · Last modified: 2017/09/13 15:30 by graf