libvisiontransfer  10.6.0
Classes | Public Member Functions | List of all members
visiontransfer::AsyncTransfer Class Reference

Detailed Description

Class for asynchronous transfer of image sets.

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

Definition at line 45 of file asynctransfer.h.

#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=16 *1048576, int maxUdpPacketSize=1472)
 Creates a new transfer object. More...
 
 AsyncTransfer (const DeviceInfo &device, int bufferSize=16 *1048576, int maxUdpPacketSize=1472)
 Creates a new transfer object by using the device information from device enumeration. More...
 
void sendImageSetAsync (const ImageSet &imageSet, bool deleteData=false)
 Starts an asynchronous transmission of the given image set. More...
 
bool collectReceivedImageSet (ImageSet &imageSet, 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...
 

Constructor & Destructor Documentation

◆ AsyncTransfer() [1/2]

visiontransfer::AsyncTransfer::AsyncTransfer ( const char *  address,
const char *  service = "7681",
ImageProtocol::ProtocolType  protType = ImageProtocol::PROTOCOL_UDP,
bool  server = false,
int  bufferSize = 16*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 113 of file asynctransfer.cpp.

◆ AsyncTransfer() [2/2]

visiontransfer::AsyncTransfer::AsyncTransfer ( const DeviceInfo device,
int  bufferSize = 16*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 119 of file asynctransfer.cpp.

Member Function Documentation

◆ collectReceivedImageSet()

bool visiontransfer::AsyncTransfer::collectReceivedImageSet ( ImageSet imageSet,
double  timeout = -1 
)

Collects the asynchronously received image.

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

If no image set has been received, this method might block or return false. Otherwise the returned image set 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 set is only valid until the next call of collectReceivedImageSet().

Definition at line 132 of file asynctransfer.cpp.

◆ disconnect()

void visiontransfer::AsyncTransfer::disconnect ( )

Terminates the current connection.

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

Definition at line 144 of file asynctransfer.cpp.

◆ getNumDroppedFrames()

int visiontransfer::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 136 of file asynctransfer.cpp.

◆ getRemoteAddress()

std::string visiontransfer::AsyncTransfer::getRemoteAddress ( ) const

Returns the address of the remote host.

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

Definition at line 148 of file asynctransfer.cpp.

◆ isConnected()

bool visiontransfer::AsyncTransfer::isConnected ( ) const

Returns true if a remote connection is established.

Definition at line 140 of file asynctransfer.cpp.

◆ sendImageSetAsync()

void visiontransfer::AsyncTransfer::sendImageSetAsync ( const ImageSet imageSet,
bool  deleteData = false 
)

Starts an asynchronous transmission of the given image set.

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

If deleteData is set to false, the pixel data contained in imageSet 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 128 of file asynctransfer.cpp.

◆ tryAccept()

bool visiontransfer::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 152 of file asynctransfer.cpp.


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