Public Types | Public Member Functions | Private Member Functions | Private Attributes
sick::communication::AsyncTCPClient Class Reference

A asynchronous tcp client. More...

#include <AsyncTCPClient.h>

List of all members.

Public Types

typedef boost::function< void(const
sick::datastructure::PacketBuffer &)> 
PacketHandler
 Typedef to a function referencing a packet handler. This can be passed to the class and therefore be called on processing the data.

Public Member Functions

 AsyncTCPClient (PacketHandler packet_handler, boost::asio::io_service &io_service, const boost::asio::ip::address_v4 &server_ip, const uint16_t &server_port)
 Constructor of the asynchronous tcp client.
void doConnect ()
 Establishes a connection from the host to the sensor.
void doDisconnect ()
 Disconnects the host from the sensor.
void doSendAndReceive (const sick::datastructure::PacketBuffer::VectorBuffer &sendBuffer)
 Start a cycle of sensing a command and waiting got the return.
void initiateReceive ()
 Initiates the listening for a message from the server.
void setPacketHandler (const PacketHandler &packet_handler)
 Sets the packet handler function.
virtual ~AsyncTCPClient ()
 The destructor of the asynchronous tcp client.

Private Member Functions

 AsyncTCPClient (AsyncTCPClient &)
void handleReceive (const boost::system::error_code &error, const std::size_t &bytes_transferred)
void handleSendAndReceive (const boost::system::error_code &error, const std::size_t &bytes_transferred)
void startReceive ()

Private Attributes

boost::condition m_connect_condition
boost::mutex m_connect_mutex
boost::asio::io_service & m_io_service
std::shared_ptr
< boost::asio::io_service::work > 
m_io_work_ptr
PacketHandler m_packet_handler
datastructure::PacketBuffer::ArrayBuffer m_recv_buffer
boost::asio::ip::tcp::endpoint m_remote_endpoint
std::thread m_service_thread
boost::mutex m_socket_mutex
std::shared_ptr
< boost::asio::ip::tcp::socket > 
m_socket_ptr

Detailed Description

A asynchronous tcp client.

Responsible to handle the connection to an IP-address and a port. Transfers the data to the specified target and receives the answer. The answer will be passed to a packet handler.

Definition at line 62 of file AsyncTCPClient.h.


Member Typedef Documentation

Typedef to a function referencing a packet handler. This can be passed to the class and therefore be called on processing the data.

Definition at line 69 of file AsyncTCPClient.h.


Constructor & Destructor Documentation

sick::communication::AsyncTCPClient::AsyncTCPClient ( PacketHandler  packet_handler,
boost::asio::io_service &  io_service,
const boost::asio::ip::address_v4 &  server_ip,
const uint16_t &  server_port 
)

Constructor of the asynchronous tcp client.

Parameters:
packet_handlerFunction which handles the packets on processing.
io_serviceThe boost io_service instance.
server_ipThe IP address of the server to connect to.
server_portThe port on the server to connect to.

Definition at line 39 of file AsyncTCPClient.cpp.

The destructor of the asynchronous tcp client.

Definition at line 62 of file AsyncTCPClient.cpp.


Member Function Documentation

Establishes a connection from the host to the sensor.

Definition at line 89 of file AsyncTCPClient.cpp.

Disconnects the host from the sensor.

Definition at line 64 of file AsyncTCPClient.cpp.

Start a cycle of sensing a command and waiting got the return.

Parameters:
sendBufferThe telegram which will be sent to the server.

Definition at line 109 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::handleReceive ( const boost::system::error_code &  error,
const std::size_t &  bytes_transferred 
) [private]

Definition at line 159 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::handleSendAndReceive ( const boost::system::error_code &  error,
const std::size_t &  bytes_transferred 
) [private]

Definition at line 142 of file AsyncTCPClient.cpp.

Initiates the listening for a message from the server.

Definition at line 124 of file AsyncTCPClient.cpp.

Sets the packet handler function.

Parameters:
packet_handlerThe new packet handler function.

Definition at line 137 of file AsyncTCPClient.cpp.

Definition at line 157 of file AsyncTCPClient.cpp.


Member Data Documentation

Definition at line 129 of file AsyncTCPClient.h.

Definition at line 130 of file AsyncTCPClient.h.

boost::asio::io_service& sick::communication::AsyncTCPClient::m_io_service [private]

Definition at line 124 of file AsyncTCPClient.h.

std::shared_ptr<boost::asio::io_service::work> sick::communication::AsyncTCPClient::m_io_work_ptr [private]

Definition at line 123 of file AsyncTCPClient.h.

Definition at line 121 of file AsyncTCPClient.h.

Definition at line 119 of file AsyncTCPClient.h.

boost::asio::ip::tcp::endpoint sick::communication::AsyncTCPClient::m_remote_endpoint [private]

Definition at line 126 of file AsyncTCPClient.h.

Definition at line 127 of file AsyncTCPClient.h.

Definition at line 131 of file AsyncTCPClient.h.

std::shared_ptr<boost::asio::ip::tcp::socket> sick::communication::AsyncTCPClient::m_socket_ptr [private]

Definition at line 125 of file AsyncTCPClient.h.


The documentation for this class was generated from the following files:


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Tue May 7 2019 03:27:37