libvisiontransfer  6.1.1
Classes | Public Member Functions | List of all members
AsyncTransfer Class Reference

Class for asynchronous transfer of image pairs. More...

#include <visiontransfer/asynctransfer.h>

Classes

class  Pimpl
 

Public Member Functions

 AsyncTransfer (const char *address, const char *service="7681", ImageProtocol::ProtocolType protType=ImageProtocol::PROTOCOL_UDP, bool server=false, int bufferSize=1048576, int maxUdpPacketSize=1472)
 Creates a new transfer object. More...
 
 AsyncTransfer (const DeviceInfo &device, int bufferSize=1048576, int maxUdpPacketSize=1472)
 Creates a new transfer object by using the device information from device enumeration. More...
 
void sendImagePairAsync (const ImagePair &imagePair, bool deleteData=false)
 Starts an asynchronous transmission of the given image pair. More...
 
bool collectReceivedImagePair (ImagePair &imagePair, double timeout=-1)
 Collects the asynchronously received image. More...
 
int getNumDroppedFrames () const
 Returns the number of frames that have been dropped since connecting to the current remote host. More...
 
bool tryAccept ()
 Tries to accept a client connection. More...
 
bool isConnected () const
 Returns true if a remote connection is established. More...
 
void disconnect ()
 Terminates the current connection. More...
 
std::string getRemoteAddress () const
 Returns the address of the remote host. More...
 

Detailed Description

Class for asynchronous transfer of image pairs.

This class opens a network socket for delivering or receiving image pairs. All operations are performed asynchronously, which means that they do not block. The class encapsulates ImageTransfer.

Definition at line 31 of file asynctransfer.h.

Constructor & Destructor Documentation

◆ AsyncTransfer() [1/2]

AsyncTransfer::AsyncTransfer ( const char *  address,
const char *  service = "7681",
ImageProtocol::ProtocolType  protType = ImageProtocol::PROTOCOL_UDP,
bool  server = false,
int  bufferSize = 1048576,
int  maxUdpPacketSize = 1472 
)

Creates a new transfer object.

Parameters
addressAddress of the remote host to which a connection should be established. In server mode this can be a local interface address or NULL.
serviceThe port number that should be used as string or as textual service name.
protTypeSpecifies whether the UDP or TCP transport protocol shall be used.
serverIf set to true, this object will be a communication server.
bufferSizeBuffer size for sending / receiving network data.
maxUdpPacketSizeMaximum allowed size of a UDP packet when sending data.

Please see ImageTransfer::ImageTransfer() for further details.

Definition at line 106 of file asynctransfer.cpp.

◆ AsyncTransfer() [2/2]

AsyncTransfer::AsyncTransfer ( const DeviceInfo device,
int  bufferSize = 1048576,
int  maxUdpPacketSize = 1472 
)

Creates a new transfer object by using the device information from device enumeration.

Parameters
deviceInformation on the device to which a connection should be established.
bufferSizeBuffer size for sending / receiving network data.
maxUdpPacketSizeMaximum allowed size of a UDP packet when sending data.

Definition at line 112 of file asynctransfer.cpp.

Member Function Documentation

◆ collectReceivedImagePair()

bool AsyncTransfer::collectReceivedImagePair ( ImagePair imagePair,
double  timeout = -1 
)

Collects the asynchronously received image.

Parameters
imagePairThe received image pair.
timeoutThe maximum time in seconds for which to wait if no image pair has been received yet.
Returns
True if an image pair has been received before the timeout.

If no image pair has been received, this method might block or return false. Otherwise the returned image pair is valid until the next call.

If timeout is set to a value < 0, the function will block indefinitely. If timeout = 0, the function will return immediately, and if timeout is > 0 then the function will block for the given amount of time in seconds. The received image pair is only valid until the next call of collectReceivedImagePair().

Definition at line 125 of file asynctransfer.cpp.

◆ disconnect()

void AsyncTransfer::disconnect ( )

Terminates the current connection.

If connected to a remote host this connection will be closed.

Definition at line 137 of file asynctransfer.cpp.

◆ getNumDroppedFrames()

int AsyncTransfer::getNumDroppedFrames ( ) const

Returns the number of frames that have been dropped since connecting to the current remote host.

Dropped frames are caused by dropped packets due to a poor network connection

Definition at line 129 of file asynctransfer.cpp.

◆ getRemoteAddress()

std::string AsyncTransfer::getRemoteAddress ( ) const

Returns the address of the remote host.

Returns
Remote address or "" if no connection has been established.

Definition at line 141 of file asynctransfer.cpp.

◆ isConnected()

bool AsyncTransfer::isConnected ( ) const

Returns true if a remote connection is established.

Definition at line 133 of file asynctransfer.cpp.

◆ sendImagePairAsync()

void AsyncTransfer::sendImagePairAsync ( const ImagePair imagePair,
bool  deleteData = false 
)

Starts an asynchronous transmission of the given image pair.

Parameters
imagePairThe image pair that shall be transmitted.
deleteDataIf set to true, the pointers to the pixel data that are contained in imagePair, will be deleted after the image pair has been transmitted.

If deleteData is set to false, the pixel data contained in imagePair must not be freed before the data has been transmitted. As transmission happens asynchronously, it is recommended to let AsyncTransfer delete the data pointers.

Definition at line 121 of file asynctransfer.cpp.

◆ tryAccept()

bool AsyncTransfer::tryAccept ( )

Tries to accept a client connection.

Returns
True if a client has connected..

This method can only be used in TCP server mode. It shall be called in regular intervals to allow for client connections. The method is non-blocking.

Definition at line 145 of file asynctransfer.cpp.


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