IDS peak genericC++ v1.11.0
Loading...
Searching...
No Matches
peak::core::EventController Class Reference

Encapsulates the GenTL event functionality associated with one GenTL EVENT_HANDLE. More...

#include <peak/event/peak_event_controller.hpp>

Public Member Functions

 EventController ()=delete
 Can not be created on its own, instead use EnableEvents.
 
 ~EventController ()
 Destroys the EventController and unregisters the event.
 
 EventController (const EventController &other)=delete
 
EventController & operator= (const EventController &other)=delete
 
 EventController (EventController &&other)=delete
 
EventController & operator= (EventController &&other)=delete
 
RawInformation Info (int32_t infoCommand) const
 Delivers information based on the given GenTL info command.
 
size_t NumEventsInQueue () const
 Returns the number of events in queue.
 
uint64_t NumEventsFired () const
 Returns the number of fired events.
 
size_t EventMaxSize () const
 Returns the maximum size of an event in bytes.
 
size_t EventDataMaxSize () const
 Returns the maximum size of the data of an event in bytes.
 
std::unique_ptr< Event > WaitForEvent (Timeout timeout_ms)
 Blocking wait for an event.
 
void KillWait ()
 Cancels a pending WaitForEvent call.
 
void FlushPendingKillWaits ()
 Flushes the KillWait queue.
 
void FlushEvents ()
 Discards all events in queue.
 
EventType ControlledEventType () const
 Returns the controlled event type.
 

Detailed Description

Encapsulates the GenTL event functionality associated with one GenTL EVENT_HANDLE.

This class is returned by EventSupportingModule::EnableEvents() and acts as a controller for events of the type given to EventSupportingModule::EnableEvents().

Note
When the EventController is destroyed, the EventType corresponding to the GenTL EVENT_HANDLE will be unregistered. This causes all waiting WaitForEvent calls to be aborted and pending events, including KillWaits, to be discarded.

Constructor & Destructor Documentation

◆ EventController() [1/3]

peak::core::EventController::EventController ( )
delete

Can not be created on its own, instead use EnableEvents.

◆ ~EventController()

peak::core::EventController::~EventController ( )
inline

Destroys the EventController and unregisters the event.

Note
When the EventController is destroyed, the EventType corresponding to the GenTL EVENT_HANDLE will be unregistered. This causes all waiting WaitForEvent calls to be aborted and pending events, including KillWaits, to be discarded.

◆ EventController() [2/3]

peak::core::EventController::EventController ( const EventController & other)
delete

◆ EventController() [3/3]

peak::core::EventController::EventController ( EventController && other)
delete

Member Function Documentation

◆ ControlledEventType()

EventType peak::core::EventController::ControlledEventType ( ) const
inline

Returns the controlled event type.

Returns
Controlled event type
Since
1.0

◆ EventDataMaxSize()

size_t peak::core::EventController::EventDataMaxSize ( ) const
inline

Returns the maximum size of the data of an event in bytes.

Returns
Maximum size of the data of an event in bytes.
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ EventMaxSize()

size_t peak::core::EventController::EventMaxSize ( ) const
inline

Returns the maximum size of an event in bytes.

Returns
Maximum size of an event in bytes.
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ FlushEvents()

void peak::core::EventController::FlushEvents ( )
inline

Discards all events in queue.

Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ FlushPendingKillWaits()

void peak::core::EventController::FlushPendingKillWaits ( )
inline

Flushes the KillWait queue.

This function clears all queued KillWaits, preventing subsequent calls to EventController::WaitForEvent from throwing a peak::core::AbortedException.

Calls to EventController::WaitForEvent that are currently waiting will be aborted and throw a peak::core::AbortedException.

Attention
Any pending events will be discarded.
Since
1.11
Exceptions
BadAccessExceptionThe acquisition is currently running and needs to be stopped first.
InternalErrorExceptionAn internal error has occurred.

◆ Info()

RawInformation peak::core::EventController::Info ( int32_t infoCommand) const
inline

Delivers information based on the given GenTL info command.

Parameters
[in]infoCommandThe GenTL info command.

This function can be used to query information going beyond the predefined info functions, based on the GenTL info commands of the corresponding module.

Example (error handling is omitted):

auto info = object->Info(GenTL::XX_INFO_XX);
// Cast depending on the delivered data type
if (info.dataType == GenTL::INFO_DATATYPE_UINT64)
{
uint64_t uint64Var = *reinterpret_cast<const uint64_t*>(info.data.data());
// Do something with the information
}
else if (infoDataTypeVar == GenTL::INFO_DATATYPE_INT64)
{
...
}
...
Returns
Raw information according to the passed info command
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ KillWait()

void peak::core::EventController::KillWait ( )
inline

Cancels a pending WaitForEvent call.

Calling KillWait will interrupt an ongoing WaitForEvent call, triggering an AbortedException.

If no WaitForEvent call is currently active, the cancellation request will be queued. The next call to WaitForEvent will then be aborted. Multiple invocations of KillWait will add multiple cancellation requests to the queue.

A pending KillWait takes precedence over regular events. This means that if both a regular event and a pending KillWait exist, a call to WaitForEvent will fail with an AbortedException.

Note
To clear the queued cancellations, you can re-register the event by reconstructing the EventController or calling FlushPendingKillWaits. This, however, will clear all pending events, including regular events, which cannot be retrieved after reconstructing the EventController.
Since
1.0
Exceptions
InternalErrorExceptionIf an internal error occurs.

◆ NumEventsFired()

uint64_t peak::core::EventController::NumEventsFired ( ) const
inline

Returns the number of fired events.

Returns
Number of fired events
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ NumEventsInQueue()

size_t peak::core::EventController::NumEventsInQueue ( ) const
inline

Returns the number of events in queue.

Returns
Number of events in queue
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ operator=() [1/2]

EventController & peak::core::EventController::operator= ( const EventController & other)
delete

◆ operator=() [2/2]

EventController & peak::core::EventController::operator= ( EventController && other)
delete

◆ WaitForEvent()

std::unique_ptr< Event > peak::core::EventController::WaitForEvent ( Timeout timeout_ms)
inline

Blocking wait for an event.

A call to WaitForEvent can be aborted immediately and at any time by calling KillWait from another thread, resulting in an AbortedException being thrown. This is especially useful when using INFINITE_TIMEOUT.

Parameters
[in]timeout_msThe maximum waiting time in milliseconds. When called with Timeout::INFINITE_TIMEOUT, the function will only return if the event is triggered or KillWait() is called.
Returns
Event
Since
1.0
Exceptions
AbortedExceptionThe wait was aborted, e.g. by a call to KillWait
TimeoutExceptionThe function call timed out
InternalErrorExceptionAn internal error has occurred.

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