General Page
1) The Main Thread
You can get the main thread using
OMThread* theMainThread = OMMainThread::instance();
You can then get its event queue with:
const OMEventQueue* eventQueue = theMainThread->getEventQueue();
2) Active Threads
OR you can get the event queue of a forked thread from within your active class using:
const OMEventQueue* eventQueue = OMThread::getEventQueue();
3) Using the OMEventQueue object
Now the process for obtaining the list of pending events in the queue is the same:
OMEventListType messageList;
eventQueue.getMessageList(messageList);
At this point it is good practice to check if the list is empty. We can do this with a call to:
messageList.isEmpty();
Finally we can iterate the list and print the ID of each event:
OMEventQueueIter iter(messageList);
for ( ; (*iter) != 0; ++iter)
{
IOxfEvent* ev = statsi_cast<IOxfEvent*>(*iter);
std::cout << ev->getId() << std::endl;
}
4) Checking event IDs
OXF Framework-defined events - such as timeouts and null-transition events - are defined in OXFEvents.h (located in the Share/LangCpp/oxf directory).
Note that these framework-defined IDs all have negative numbers.
User-defined events - those events created in the model and used in statecharts with the "GEN" macro calls - are defined in their package header file.
Note that user-defined events have large positive numbers.
For each IOxfEvent that is found in the event queue, we can use IOxfEvent::getId() to check if this is a known framework-defined event from the OXF or a user-defined event from the project:
Here is an example of a running executable that prints the contents of the event queue of the active class (the name of each event with its ID/Type).
Was this topic helpful?
Document Information
Modified date:
17 October 2018
UID
ibm10735535