Homepage Demos Overview Downloads Tutorials Reference
Credits

EventTranslator Class Reference

#include <EventTranslator.h>

Inheritance diagram for EventTranslator:

Inheritance graph
[legend]
List of all members.

Detailed Description

EventTranslator receives events from EventRouters in non-Main processes and adds them into a SharedQueue for Main to pick up.

The SharedQueue which the processes should set up and then pass to this object is defined by TranslatorSharedQueue_t - it allows 100 entries totalling 3KB of space. You can modify the type to change the capacity, but if you're making that many events that between Main's calls to translateEvents() you might want to rethink a few things...

EventTranslator only handles LocomotionEvent, VisionObjectEvent, and TextMsgEvent subtypes for the moment. Anything else is only handled as an EventBase class. (so extra fields aren't going to be stored) It's easy to add more types if you need to send them from other processes (that's the whole point of this class!)

Reason for doing it this way: Avoids OPENR message lag time (4-8ms in our testing), also avoids problems with RTTI stored in classes from different processes.

Definition at line 21 of file EventTranslator.h.

Public Types

typedef SharedQueue< 3 *1024, 100 > Queue_t
 Use this type to set up the shared queue between processes.

enum  TypeID_t { EventBase_ID, LocomotionEvent_ID, VisionObjectEvent_ID, TextMsgEvent_ID }
 an ID is inserted before the event data in the queue so we can tell which subclass it is More...


Public Member Functions

 EventTranslator ()
 constructor

void setQueue (Queue_t *q)
 sets the SharedQueue which should be used

virtual bool trapEvent (const EventBase &event)
 called by the event router when something in this process sends an event

void translateEvents ()
 called whenever Main gets some processor time to check for events from other processes


Static Public Member Functions

void enqueue (const EventBase &event, Queue_t *q)
 called by trapEvent to do all the work, needed so MotionCommands can enqueue directly


Static Protected Member Functions

void sendEvent (const void *buf, unsigned int size)
 called by translateEvents for each event to be sent


Protected Attributes

Queue_tqueue
 pointer to queue of events to be sent


Private Member Functions

 EventTranslator (const EventTranslator &)
 don't call

EventTranslator operator= (const EventTranslator &)
 don't call


Member Typedef Documentation

typedef SharedQueue<3*1024,100> EventTranslator::Queue_t
 

Use this type to set up the shared queue between processes.

Definition at line 27 of file EventTranslator.h.

Referenced by MMCombo::DoInit(), enqueue(), MMCombo::GotEventTranslatorQueue(), MotionCommand::setQueue(), and setQueue().


Member Enumeration Documentation

enum EventTranslator::TypeID_t
 

an ID is inserted before the event data in the queue so we can tell which subclass it is

(quickly, could look at the creator code which is stored, but that's a text string)

Enumeration values:
EventBase_ID 
LocomotionEvent_ID 
VisionObjectEvent_ID 
TextMsgEvent_ID 

Definition at line 31 of file EventTranslator.h.

Referenced by enqueue(), and sendEvent().


Constructor & Destructor Documentation

EventTranslator::EventTranslator  )  [inline]
 

constructor

Definition at line 24 of file EventTranslator.h.

EventTranslator::EventTranslator const EventTranslator  )  [private]
 

don't call


Member Function Documentation

void EventTranslator::enqueue const EventBase event,
Queue_t q
[static]
 

called by trapEvent to do all the work, needed so MotionCommands can enqueue directly

Definition at line 16 of file EventTranslator.cc.

Referenced by MotionCommand::postEvent(), and trapEvent().

EventTranslator EventTranslator::operator= const EventTranslator  )  [private]
 

don't call

void EventTranslator::sendEvent const void *  buf,
unsigned int  size
[static, protected]
 

called by translateEvents for each event to be sent

Definition at line 51 of file EventTranslator.cc.

Referenced by translateEvents().

void EventTranslator::setQueue Queue_t q  )  [inline]
 

sets the SharedQueue which should be used

Definition at line 34 of file EventTranslator.h.

Referenced by MMCombo::DoInit(), SoundPlay::GotEventTranslatorQueue(), and MMCombo::GotEventTranslatorQueue().

void EventTranslator::translateEvents  ) 
 

called whenever Main gets some processor time to check for events from other processes

Definition at line 42 of file EventTranslator.cc.

Referenced by MMCombo::GotImage(), MMCombo::GotPowerEvent(), and MMCombo::GotSensorFrame().

bool EventTranslator::trapEvent const EventBase event  )  [virtual]
 

called by the event router when something in this process sends an event

Implements EventTrapper.

Definition at line 10 of file EventTranslator.cc.


Member Data Documentation

Queue_t* EventTranslator::queue [protected]
 

pointer to queue of events to be sent

Definition at line 50 of file EventTranslator.h.

Referenced by EventTranslator(), setQueue(), translateEvents(), and trapEvent().


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

Tekkotsu v2.1
Generated Tue Mar 16 23:22:07 2004 by Doxygen 1.3.5