ifm3d
|
#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 | |
PCICClient & | operator= (PCICClient &&)=delete |
PCICClient (PCICClient &)=delete | |
PCICClient & | operator= (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 ¬ification)> 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... | |
The PCICClient is a class that, when given access to an ifm3d::Camera::Ptr, it provides unbuffered communication with the PCIC interface.
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.
[in] | cam | The Device instance to grab frames from |
[in] | nat_pcic_port | pcic port for NAT configuartion |
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.
[in] | request | String containing the plain command (without any header infomration, like ticket, length, etc.) |
NOTE: This Call can block and hang indefinitely depending upon PCIC response.
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.
[in] | request | String containing the plain command (without any header information, like ticket, length, etc.) |
[in] | callback | Function, called after receiving the response from the camera, providing the plain response data as string (without any header information, like ticket, length, etc.) |
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.
[in] | request | String containing the plain command (without any header infomration, like ticket, length, etc.) |
[in] | response | String containing the response from the camera providing the plain response data as string (without any header information, like ticket, length, etc.) |
[in] | timeout | in 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.
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.
[in] | callback_id | Callback id, returned by methods which take a callback as parameter. |
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.
Note: Since the PCICClient is unbuffered, the receiving thread will be blocked while the error callback has not returned.
[in] | callback | Function, called after receiving an error message from camera (without any header information, like ticket, length, etc.) |
long ifm3d::PCICClient::SetNotificationCallback | ( | std::function< void(const std::string ¬ification)> | callback | ) |
Sets the specified callback for receiving asynchronous notification messages until it is replaced by a new callback or canceled via.
Note: Since the PCICClient is unbuffered, the receiving thread will be blocked while the notification callback has not returned.
[in] | callback | Function, called after receiving an notification message from camera (without any header information, like ticket, length, etc.) |
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.