API function definitions for events. More...
Functions | |
| MVLibExport MVCode_t | MV_TryGetEvent (MVPlugin_t handle, int32_t timeout, MVEvent_t *pEvent) |
| Attempts to retrieve a new event from this plug-in's event queue. More... | |
| MVLibExport MVEventType_t | MV_Event_GetType (MVEvent_t event) |
| Returns the type of a given event. More... | |
| MVLibExport void | MV_Event_Clear (MVEvent_t *pEvent) |
| Destroys the event. More... | |
| MVLibExport MVCode_t | MV_Event_GetParameter (MVEvent_t event, uint32_t parameter, MVValue_t *pValue) |
| Gets a parameter value of an event. More... | |
| MVLibExport MVCode_t | MV_Event_Tuple_GetParameter (MVEvent_t event, uint32_t parameter, MVTuple_t *pTuple) |
| Gets a parameter tuple of an event. More... | |
| MVLibExport MVCode_t | MV_Event_GetDataContainerDescriptor (MVEvent_t event, MVDataContainerDescriptor_t *pDescriptor) |
| Gets a data container descriptor for the data components of a ResultReady event. More... | |
API function definitions for events.
The communication between plug-ins inside the Communicator and the vision system (i.e. MERLIC) mainly utilizes two FIFO queues, one for either direction:
_____________________________________________
| Actions | |
V | |
________ ___________ ___________
/ \ / \ / \
| MERLIC | | Plug-in 2 | | Plug-in 1 |
\________/ \___________/ \___________/
| ^ ^
|_______________________________|_____________|
Events
The API functions to manipulate events are listed below.
Events can hold parameters. These are used, e.g., to transport the result data as part of the ResultReady event. Parameters are of type MVValue_t. The basic concepts and API functions for accessing the contained data are described below.
Refer to mv_event_def.h for an overview of available events and their respective parameters.
| MVLibExport void MV_Event_Clear | ( | MVEvent_t * | pEvent | ) |
Destroys the event.
Every successful retrieval of an event by MV_TryGetEvent() must be balanced by a call to MV_Event_Clear().
| [in,out] | pEvent | points to the event that is destroyed. |
| MVLibExport MVCode_t MV_Event_GetDataContainerDescriptor | ( | MVEvent_t | event, |
| MVDataContainerDescriptor_t * | pDescriptor | ||
| ) |
Gets a data container descriptor for the data components of a ResultReady event.
This function provides a data container descriptor which contains data component descriptors for each of the transferable data components (e.g. images) which are available as part of the ResultReady event. The data container descriptor does not hold any image data but simply references and describes the available data. The actual data can be fetched from the vision system by providing the descriptor to MV_FetchDataContainer() to obtain a data container.
The type and parameters of the contained data component descriptors reflect the "native" format, image size, etc., in which the data are present in the vision system. They can be overwritten using the functions provided in mv_data_component.h to request the data suitably to the plug-in.
| [in] | event | is the handle to the ResultReady event that is queried. |
| [out] | pDescriptor | points to the uninitialized data container descriptor that is initialized. |
pDescriptor has successfully initialized with the data container descriptor. result is not valid or the pointer pDescriptor is NULL. event is not properly initialized. event is not a ResultReady event. | MVLibExport MVCode_t MV_Event_GetParameter | ( | MVEvent_t | event, |
| uint32_t | parameter, | ||
| MVValue_t * | pValue | ||
| ) |
Gets a parameter value of an event.
Depending on the type of the event, it is parametrized in different ways. The parameter is identified by a numeric constant which is defined in mv_parameters.h. Refer to mv_event_def.h for a list of all available events and their respective valid identifiers.
Depending upon the parameter, it is either of type MVValue_t or MVTuple_t. This function is for retrieving value parameters; see MV_Event_Tuple_GetParameter() for the analogous function for tuples.
Refer to mv_value.h for the API functions for accessing values. The value type that is realized, as well as its dimensionality (scalar vs array), is dependent upon the given parameter. Refer to mv_event_def.h for a list of parameters and their value type.
| [in] | event | is the event whose parameter is retrieved. |
| [in] | parameter | identifies the parameter that is retrieved; must match one of the parameters supported by events of the given type. |
| [out] | pValue | points to a MVValue_t which is then initialized to a copy of the desired parameter contained in the event. |
parameter key applies to the provided event and the variable pointed to by pValue has been initialized with its corresponding value. event or pValue are NULL. Make sure event is properly initialized through a successful invocation of MV_TryGetEvent() and that pValue points to an uninitialized writable variable. event is not properly initialized. parameter key does not apply to the type of the provided event. parameter key does apply to the provided event, but the corresponding value is not set. | MVLibExport MVEventType_t MV_Event_GetType | ( | MVEvent_t | event | ) |
Returns the type of a given event.
| [in] | event | is the event whose type is determined. |
| MVLibExport MVCode_t MV_Event_Tuple_GetParameter | ( | MVEvent_t | event, |
| uint32_t | parameter, | ||
| MVTuple_t * | pTuple | ||
| ) |
Gets a parameter tuple of an event.
This function works analogous to MV_Event_GetParameter() but is used to get parameter tuples rather than individual values.
Refer to mv_tuple.h for the API functions for manipulating tuples.
| [in] | event | is the event whose parameter is retrieved. |
| [in] | parameter | identifies the parameter that is retrieved; must match one of the parameters supported by events of the given type. |
| [out] | pTuple | points to a MVTuple_t which is then initialized to a copy of the desired parameter contained in the event. |
parameter key applies to the provided event and the variable pointed to by pTuple has been initialized with its corresponding value. event or pTuple are NULL. Make sure event is properly initialized through a successful invocation of MV_TryGetEvent() and that pTuple points to an uninitialized writable variable. event is not properly initialized. parameter key does not apply to the type of the provided event. | MVLibExport MVCode_t MV_TryGetEvent | ( | MVPlugin_t | handle, |
| int32_t | timeout, | ||
| MVEvent_t * | pEvent | ||
| ) |
Attempts to retrieve a new event from this plug-in's event queue.
When the vision system publishes an event, it is enqueued to each plug-in's event queue. This function is used by the plug-ins to pop one event from this plug-in's event queue. If the latter contains at least one pending event, the function returns immediately and stores it into the variable of type MVEvent_t pointed to by the third argument. It lives until it is manually destroyed by way of call to MV_Event_Clear(), which becomes the plug-in's responsibility.
If the event queue is currently empty, the behavior is determined by the timeout argument. In case it is set to MV_TIME_NONE, the function immediately returns with error code MV_CODE_TIMEOUT. In case it is set to MV_TIME_INFINITE, the function blocks until a new event becomes available. It may also be set to a finite timeout (using macros MV_TIME_MILLISECOND(x) or MV_TIME_SECOND(x)) in which case it waits for at most the timeout's duration for an event to be enqueued. If so, it will pop it immediately; other it will return MV_CODE_TIMEOUT.
| [in] | handle | is the Communicator handle for the plug-in instance. |
| [in] | timeout | is measured in milliseconds; it is recommended to use the macros MV_TIME_MILLISECOND(x), MV_TIME_SECOND(x), or special values MV_TIME_NONE and MV_TIME_INFINITE, rather than specifying a numeric value directly. |
| [out] | pEvent | points to the event variable that is potentially initialized with a queued-up event. |
pEvent has been successfully initialized with it. It is the caller's responsibility to destroy the event using MV_Event_Clear() once they have finished processing it. handle is not valid. MVInfo and is granted access to it when adding the plug-in instance. timeout duration. Consequently, pEvent has not been initialized with an event and was set to NULL instead.