Impact Acquire SDK C++
|
A helper class that can be used to implement a simple continuous acquisition from a device. More...
#include <mvIMPACT_acquire_helper.h>
Public Member Functions | |
template<typename FUNC , typename ... PARAMS> | |
void | acquisitionStart (FUNC pFn, PARAMS ...params) |
Starts the acquisition. | |
void | acquisitionStart (void) |
Starts the acquisition. | |
void | acquisitionStop (void) |
Stops the acquisition. | |
void | endThreadExecution (void) |
Signaling the acquisition thread to terminate. | |
bool | isAcquisitionRunning (void) const |
Returns the current state of the acquisition engine. | |
RequestProvider & | operator= (const RequestProvider &rhs)=delete |
assignment operator (deleted) | |
RequestProvider (const RequestProvider &src)=delete | |
Copy-constructor (deleted) | |
RequestProvider (Device *pDev, RequestFactory *pRequestFactory=nullptr) | |
Creates a new mvIMPACT::acquire::helper::RequestProvider instance. | |
void | terminateWaitForNextRequest (void) |
Terminates a single wait operation currently pending from another thread without delivering data. | |
std::shared_ptr< Request > | waitForNextRequest (unsigned int ms) |
Waits for the next request to become ready and will return a shared_ptr instance to it. | |
bool | waitForNextRequest (unsigned int ms, std::shared_ptr< Request > *ppRequest) |
Waits for the next request to become ready and will return a shared_ptr instance to it. | |
std::shared_ptr< Request > | waitForNextRequest (void) |
Waits for the next request to become ready and will return a shared_ptr instance to it. | |
void | waitForThreadTermination (void) |
Waits for the acquisition thread to terminate. | |
A helper class that can be used to implement a simple continuous acquisition from a device.
This class is meant to provide a very convenient way of capturing data continuously from a device. All buffer handling is done internally. An application simply needs to start and stop the acquisition and can pick up data in between.
Picking up data can be done in 2 ways:
Both methods internally create a thread. When passing the function pointer and parameters the function is invoked from this internal thread context. So an application should not spend much time here in order not to block the acquisition engine. When using the mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest approach the internal thread pushes it's data into an instance of mvIMPACT::acquire::helper::ThreadSafeQueue so capturing can continue if an application does not immediately pick up the data.
std::shared_ptr
objects! This would jeopardize auto-unlocking of request and thus more or less the purpose of this class. Instead always store the std::shared_ptr
objects directly. When no longer needed simply dump them. Keeping them all will result in the acquisition engine to run out of buffers. It can only re-use mvIMPACT::acquire::Request when no more std::shared_ptr
references to it exist. On the other hand make sure you did drop all references to requests before the mvIMPACT::acquire::helper::RequestProvider instance that did return them goes out of scope. Not doing this will result in undefined behavior!a more complex example using the function pointer approach can be found in the description of the corresponding overload of mvIMPACT::acquire::helper::RequestProvider::acquisitionStart.
|
inlineexplicit |
Creates a new mvIMPACT::acquire::helper::RequestProvider instance.
[in] | pDev | A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. |
[in] | pRequestFactory | A pointer to a request factory. By supplying a custom request factory the user can control the type of request objects that will be created by the function interface. |
|
delete |
Copy-constructor (deleted)
Objects of this type shall not be copy-constructed!
|
inline |
Starts the acquisition.
Will start the acquisition by creating an internal thread. To get access to the data that will be acquired from the device an application passes a callback function and a variable list of arbitrary parameters to this function. Whenever a request becomes ready this function then will be called (from within the internal thread's context!). What kind of function is passed is completely up to the application. The only restriction for the functions signature is that the first parameter must be std::shared_ptr<Request> pRequest
.
std::shared_ptr
goes out of scope. As a consequence do NOT store the raw pointer to the mvIMPACT::acquire::Request object stored by the std::shared_ptr
but always the std::shared_ptr<Request>
itself in order not to break reference counting. Do not call mvIMPACT::acquire::Request::unlock for requests returned wrapped in a std::shared_ptr<Request>
(you can but it is not necessary).If the acquisition is already running then calling this function will raise an exception of type mvIMPACT::acquire::ImpactAcquireException.
[in] | pFn | An arbitrary function that shall be called from the internal thread context whenever a mvIMPACT::acquire::Request object becomes ready |
[in] | params | A variable number of arbitrary arguments that shall be passed to the thread callback function passed as the previous argument. |
|
inline |
Starts the acquisition.
Will start the acquisition by creating an internal thread. To get access to captured blocks of data (typically images) an application can periodically call mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest afterwards.
If the acquisition is already running then calling this function will raise an exception of type mvIMPACT::acquire::ImpactAcquireException.
|
inline |
Stops the acquisition.
Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart.
|
inline |
Signaling the acquisition thread to terminate.
Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart.
To wait for the acquisition thread to terminate mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination has to be called afterwards! To combine mvIMPACT::acquire::helper::RequestProvider::endThreadExecution and mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination use mvIMPACT::acquire::helper::RequestProvider::acquisitionStop.
|
inline |
Returns the current state of the acquisition engine.
|
delete |
assignment operator (deleted)
Objects of this type shall not be assigned!
|
inline |
Terminates a single wait operation currently pending from another thread without delivering data.
If one or multiple thread(s) are currently executing a mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest operation ONE of these threads will get signaled and the call will return.
|
inline |
Waits for the next request to become ready and will return a shared_ptr instance to it.
Waits for the next request to become ready and will return a std::shared_ptr<Request>
instance to it effectively removing it from the internal queue. This is a blocking function. It will return not unless either a mvIMPACT::acquire::Request object became ready, the specified timeout did elapse or mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a different thread.
std::shared_ptr<Request>
either holding a valid pointer to a mvIMPACT::acquire::Request object or nullptr
if no data became ready and either mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from another thread or the specified timeout has elapsed. [in] | ms | A timeout in milliseconds specifying the maximum time this function shall wait for a request to become ready |
|
inline |
Waits for the next request to become ready and will return a shared_ptr instance to it.
Waits for the next request to become ready and will return a std::shared_ptr<Request>
instance to it effectively removing it from the internal queue. This is a blocking function. It will return not unless either a mvIMPACT::acquire::Request object became ready, the specified timeout did elapse or mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a different thread.
[in] | ms | A timeout in milliseconds specifying the maximum time this function shall wait for a request to become ready |
[in,out] | ppRequest | A pointer to the storage location that shall receive a pointer to the next mvIMPACT::acquire::Request object that becomes ready or the oldest element already available. An application can pass nullptr if a caller just wants to remove an element from the queue but is not actually interested in it. |
|
inline |
Waits for the next request to become ready and will return a shared_ptr instance to it.
Waits for the next request to become ready and will return a std::shared_ptr<Request>
instance to it effectively removing it from the internal queue. This is a blocking function. It will return not unless either a mvIMPACT::acquire::Request object became ready or mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a different thread.
std::shared_ptr<Request>
either holding a valid pointer to a mvIMPACT::acquire::Request object or nullptr
if no data became ready and mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from another thread.
|
inline |
Waits for the acquisition thread to terminate.
Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart.
In order to make this function return successfully mvIMPACT::acquire::helper::RequestProvider::endThreadExecution has to be called before or after(from a different thread then)! To combine mvIMPACT::acquire::helper::RequestProvider::endThreadExecution and mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination use mvIMPACT::acquire::helper::RequestProvider::acquisitionStop.