Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
sick::communication::AsyncTCPClient Class Reference

A asynchronous tcp client. More...

#include <AsyncTCPClient.h>

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. More...
 

Public Member Functions

 AsyncTCPClient (const 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. More...
 
void doConnect ()
 Establishes a connection from the host to the sensor. More...
 
void doDisconnect ()
 Disconnects the host from the sensor. More...
 
void doSendAndReceive (const std::vector< uint8_t > &sendBuffer)
 Start a cycle of sensing a command and waiting got the return. More...
 
void initiateReceive ()
 Initiates the listening for a message from the server. More...
 
void setPacketHandler (const PacketHandler &packet_handler)
 Sets the packet handler function. More...
 
virtual ~AsyncTCPClient ()
 The destructor of the asynchronous tcp client. More...
 

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 ( const 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.

sick::communication::AsyncTCPClient::~AsyncTCPClient ( )
virtual

The destructor of the asynchronous tcp client.

Definition at line 61 of file AsyncTCPClient.cpp.

sick::communication::AsyncTCPClient::AsyncTCPClient ( AsyncTCPClient )
private

Member Function Documentation

void sick::communication::AsyncTCPClient::doConnect ( )

Establishes a connection from the host to the sensor.

Definition at line 88 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::doDisconnect ( )

Disconnects the host from the sensor.

Definition at line 63 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::doSendAndReceive ( const std::vector< uint8_t > &  sendBuffer)

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 108 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 157 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 140 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::initiateReceive ( )

Initiates the listening for a message from the server.

Definition at line 122 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::setPacketHandler ( const PacketHandler packet_handler)

Sets the packet handler function.

Parameters
packet_handlerThe new packet handler function.

Definition at line 135 of file AsyncTCPClient.cpp.

void sick::communication::AsyncTCPClient::startReceive ( )
private

Definition at line 155 of file AsyncTCPClient.cpp.

Member Data Documentation

boost::condition sick::communication::AsyncTCPClient::m_connect_condition
private

Definition at line 129 of file AsyncTCPClient.h.

boost::mutex sick::communication::AsyncTCPClient::m_connect_mutex
private

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.

PacketHandler sick::communication::AsyncTCPClient::m_packet_handler
private

Definition at line 121 of file AsyncTCPClient.h.

datastructure::PacketBuffer::ArrayBuffer sick::communication::AsyncTCPClient::m_recv_buffer
private

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.

std::thread sick::communication::AsyncTCPClient::m_service_thread
private

Definition at line 127 of file AsyncTCPClient.h.

boost::mutex sick::communication::AsyncTCPClient::m_socket_mutex
private

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 Fri Apr 2 2021 02:45:42