ifm3d
ifm3d::PCICClient Class Reference

#include <ifm3d/pcicclient/pcicclient.h>

Public Types

using Ptr = std::shared_ptr< PCICClient >
 

Public Member Functions

 PCICClient (ifm3d::LegacyDevice::Ptr cam, const std::uint16_t pcic_port=ifm3d::PCIC_PORT)
 Stores reference to the passed in camera and starts connect/receive thread. More...
 
virtual ~PCICClient ()
 Cleans up any resources held by the receive thread object and blocks until the operating system thread stops.
 
 PCICClient (PCICClient &&)=delete
 
PCICClientoperator= (PCICClient &&)=delete
 
 PCICClient (PCICClient &)=delete
 
PCICClientoperator= (const PCICClient &)=delete
 
void Stop ()
 Interrupts the running thread by throwing an ifm3d::error_t with code IFM3D_THREAD_INTERRUPTED. More...
 
long Call (const std::string &request, std::function< void(const std::string &response)> callback)
 Sends a PCIC command to the camera and returns the response asynchronously through a callback (, which is automatically removed internally after the callback returns). More...
 
std::string Call (const std::string &request)
 Sends a PCIC command to the camera and returns the response as soon as it has been received. More...
 
bool Call (const std::string &request, std::string &response, long timeout_millis)
 Similar to the Call function above. More...
 
long SetErrorCallback (std::function< void(const std::string &error)> callback)
 Sets the specified callback for receiving asynchronous error messages until it is replaced by a new callback or canceled via. More...
 
long SetNotificationCallback (std::function< void(const std::string &notification)> callback)
 Sets the specified callback for receiving asynchronous notification messages until it is replaced by a new callback or canceled via. More...
 
void CancelCallback (long callback_id)
 Cancels registered callbacks. More...
 

Detailed Description

The PCICClient is a class that, when given access to an ifm3d::Camera::Ptr, it provides unbuffered communication with the PCIC interface.

Constructor & Destructor Documentation

◆ PCICClient()

ifm3d::PCICClient::PCICClient ( ifm3d::LegacyDevice::Ptr  cam,
const std::uint16_t  pcic_port = ifm3d::PCIC_PORT 
)

Stores reference to the passed in camera and starts connect/receive thread.

Parameters
[in]camThe Device instance to grab frames from
[in]nat_pcic_portpcic port for NAT configuartion

Member Function Documentation

◆ Call() [1/3]

std::string ifm3d::PCICClient::Call ( const std::string &  request)

Sends a PCIC command to the camera and returns the response as soon as it has been received.

In the meanwhile, this call is blocked.

Parameters
[in]requestString containing the plain command (without any header infomration, like ticket, length, etc.)
Returns
Copy of received plain response data as string (without any header information, like ticket, length, etc.)

NOTE: This Call can block and hang indefinitely depending upon PCIC response.

◆ Call() [2/3]

long ifm3d::PCICClient::Call ( const std::string &  request,
std::function< void(const std::string &response)>  callback 
)

Sends a PCIC command to the camera and returns the response asynchronously through a callback (, which is automatically removed internally after the callback returns).

Note: Since the PCICClient is unbuffered, the calling thread will be blocked while the request is not completely sent. Also, the receiving thread will be blocked while the response callback has not returned.

Parameters
[in]requestString containing the plain command (without any header information, like ticket, length, etc.)
[in]callbackFunction, called after receiving the response from the camera, providing the plain response data as string (without any header information, like ticket, length, etc.)
Returns
Callback id, which can be used to cancel this Call before receiving the response.

◆ Call() [3/3]

bool ifm3d::PCICClient::Call ( const std::string &  request,
std::string &  response,
long  timeout_millis 
)

Similar to the Call function above.

Sends a PCIC command to the camera and returns the response as soon as it has been received. In the meanwhile, this call is blocked.

Parameters
[in]requestString containing the plain command (without any header infomration, like ticket, length, etc.)
[in]responseString containing the response from the camera providing the plain response data as string (without any header information, like ticket, length, etc.)
[in]timeoutin milliseconds, in case, the PCIC fails to come through.

NOTE: This Call can fail with no response if supplied with an unsuitable "timeout_millis" value. Providing timeout_millis value as 0 results in behaviour similar to the above Call method.

Returns
true if Call succeeded, false if failed.

◆ CancelCallback()

void ifm3d::PCICClient::CancelCallback ( long  callback_id)

Cancels registered callbacks.

Must be called in case references/pointers provided through callbacks get invalid. If callback id isn't present internally anymore, i.e. if callback was replaced, already canceled or automatically removed (in case of the Call method), it is simply ignored.

Parameters
[in]callback_idCallback id, returned by methods which take a callback as parameter.

◆ SetErrorCallback()

long ifm3d::PCICClient::SetErrorCallback ( std::function< void(const std::string &error)>  callback)

Sets the specified callback for receiving asynchronous error messages until it is replaced by a new callback or canceled via.

See also
CancelCallback.

Note: Since the PCICClient is unbuffered, the receiving thread will be blocked while the error callback has not returned.

Parameters
[in]callbackFunction, called after receiving an error message from camera (without any header information, like ticket, length, etc.)
Returns
Callback id, which can be used to cancel receiving errors.

◆ SetNotificationCallback()

long ifm3d::PCICClient::SetNotificationCallback ( std::function< void(const std::string &notification)>  callback)

Sets the specified callback for receiving asynchronous notification messages until it is replaced by a new callback or canceled via.

See also
CancelCallback.

Note: Since the PCICClient is unbuffered, the receiving thread will be blocked while the notification callback has not returned.

Parameters
[in]callbackFunction, called after receiving an notification message from camera (without any header information, like ticket, length, etc.)
Returns
Callback id, which can be used to cancel receiving notifications.

◆ Stop()

void ifm3d::PCICClient::Stop ( )

Interrupts the running thread by throwing an ifm3d::error_t with code IFM3D_THREAD_INTERRUPTED.

While this is (currently) part of the public interface, clients should be aware that there is really no way to restart a stopped PCICClient instance. To do that, you would need to instantiate a new PCICClient.


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