| Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
EventRouter Class Reference#include <EventRouter.h>
Inheritance diagram for EventRouter: ![]() Detailed DescriptionThis class will handle distribution of events as well as management of timers.Classes must inherit from EventListener and/or EventTrapper in order to receive events. Use the global erouter instance of EventRouter to both send (post) and receive (subscribe/listen) to events. (except if you are posting from within a MotionCommand, in which case you should use MotionCommand::postEvent() so that it can correctly handle inter-process communication issues under Aperios (the Aibo's OS) -- under a Unix-based OS, this wouldn't be necessary.) The events available for processing are listed in EventBase::EventGeneratorID_t. Each generator ID's documentation specifies how to interpret the source ID field, and whether you can expect events with that generator ID to be of a subclass of EventBase, such as TextMsgEvent or LocomotionEvent. Many generators send plain EventBase instances. When multiple listeners are subscribed, the order in which an event is distributed among them is:
...but if you're relying on that ordering, there probably should be a cleaner way to do whatever you're doing. TimerEvents are generally only sent to the generator which requested them. So if EventListener A requests a timer (see addTimer()) with ID 0 at two second intervals, and B requests a timer with ID 0 at three second intervals, each will still only receive the timers they requested - no cross talk. The timer generator is unique in this regard, which is why it is built in as an integral component of the EventRouter. However, EventListener A can receive B's timers if it specifically wants to, via addListener(). See "Timers" below.
If an EventListener/EventTrapper subscribes to the same event source multiple times, it will receive multiple copies of the event. However, the first call to removeListener for a source will remove all subscriptions to that source.
TimersaddTimer() allows you to request an TimerEvent to be sent at some later point in time, possibly on a repeating basis. Timers are specific to the behavior which requests them, and you do not (and usually should not) call addListener() in order to receive a timer event. There is an important different between addTimer() and addListener(timerEGID,...)! addTimer will "create" the timer, and will send the timer to the listener which created it when the timer expires. This means that as long as the listener in question does not call addListener(timerEGID), it will only receive its own timers. In other words, with this usage there is no confusion with timer cross-talk between listeners, because each listener is only receiving its own timers. However, if a listener calls addListener(timerEGID), it will begin receiving all timer events from throughout the system. This allows you to have one behavior "eavesdrop" on another's timers. In order to determine which listener requested/created the timer, you can use the TimerEvent::getTarget() value. So beware that if you call both addTimer() and addListener(foo,timerEGID), 'foo' will get two calls to processEvent() for its own timers, and one call for all other timers, and will have to know to call TimerEvent::getTarget() to distinguish its timers from other listener's timers (if it cares about the difference...) Timers are sent to the requesting listener before being broadcast -- EventTrappers cannot filter a listener's own timers, but can prevent the timer from being broadcast to other listeners.
Event processing examples:Posting events: //method A: basic event posting (EventBase instance is sent) erouter->postEvent(EventBase::aiEGID, 1234, EventBase::statusETID); //method B: specific event instance is posted (have to use this style to post a subclass) TextMsgEvent txt("hello world"); erouter->postEvent(txt); // or can be done in one line: erouter->postEvent(TextMsgEvent("hello world")) Receiving events: //given an EventListener subclass: class YourListener : public EventListener { public: virtual void processEvent(const EventBase& e) { std::cout << "Got: " << e.getName() << std::endl; } }; YourListener yourList; // subscribes it to all EventBase::aiEGID events: erouter->addListener(&yourList, EventBase::aiEGID); // subscribes only to button activity from the head, but not other buttons: erouter->addListener(&yourList, EventBase::buttonEGID, ERS7Info::HeadButOffset);
Timer processing examples:Requesting/Creating timers: YourListener yourList; // (any EventListener subclass) // sends a timer with source ID 123 every 5 seconds to yourList: erouter->addTimer(&yourList, 123, 5000); // sends a timer with ID 456 after 1 second, *no repeat, one time only* erouter->addTimer(&yourList, 456, 1000, false); // cancels the first timer erouter->removeTimer(&yourList, 123); // postpone/update the second timer's settings (*doesn't* create two timers with the same ID) erouter->addTimer(&yourList, 456, 2500, false);
Definition at line 151 of file EventRouter.h.
Member Typedef Documentation
Constructor & Destructor Documentation
Member Function Documentation
Uses the generator, source, and type fields of e to add a listener for that specific tuple.
Definition at line 144 of file EventRouter.cc.
Adds a listener for a specific source id and type from a given event generator.
Definition at line 136 of file EventRouter.cc.
Adds a listener for all types from a specific source and generator.
Definition at line 127 of file EventRouter.cc.
Adds a listener for all events from a given event generator.
Definition at line 119 of file EventRouter.cc. Referenced by WalkCalibration::activate(), BatteryCheckControl::activate(), EventGeneratorBase::addSrcListener(), SensorObserverControl::doSelect(), EventLogger::doSelect(), WorldStateVelDaemon::DoStart(), WorldStateSerializerBehavior::DoStart(), WMMonitorBehavior::DoStart(), WalkToTargetNode::DoStart(), VisualTargetTrans::DoStart(), VisualTargetCloseTrans::DoStart(), TimeOutTrans::DoStart(), TextMsgTrans::DoStart(), SpiderMachineBehavior::DoStart(), SoundNode::DoStart(), SignalTrans< T >::DoStart(), SegCamBehavior::DoStart(), RegionCamBehavior::DoStart(), RawCamBehavior::DoStart(), MotionSequenceNode< SIZE >::DoStart(), MicrophoneServer::DoStart(), MCNodeBase::DoStart(), LostTargetTrans::DoStart(), FlashIPAddrBehavior::DoStart(), EventTrans::DoStart(), EventGeneratorBase::DoStart(), EStopControllerBehavior::DoStart(), EchoBehavior::DoStart(), Controller::DoStart(), CompletionTrans::DoStart(), CompareTrans< T >::DoStart(), BatteryMonitorBehavior::DoStart(), AutoGetupBehavior::DoStart(), ValueEditControl< T >::pause(), FlashIPAddrBehavior::processEvent(), AutoGetupBehavior::processEvent(), CameraStreamBehavior::receiveData(), EventLogger::runCommand(), RunSequenceControl< SequenceSize >::selectedFile(), LoadPostureControl::selectedFile(), and EventGeneratorBase::setAutoListen().
calls the other addTimer() with the event's source id and duration, doesn't check to see if the generator is timerEGID
Definition at line 222 of file EventRouter.h.
adds a timer if it doesn't exist, or resets the timer if it already exists.
timers are unique by EventListener and source ID - can't have two timers for the same el and sid
Definition at line 74 of file EventRouter.cc. Referenced by addTimer(), NullTrans::DoStart(), ConnectionMadeTrans::DoStart(), PostureEditor::processEvent(), FlashIPAddrBehavior::processEvent(), BatteryMonitorBehavior::processEvent(), SensorObserverControl::RTViewControl::refresh(), PostureEditor::refresh(), NetworkStatusControl::refresh(), TimeOutTrans::resetTimer(), FreeMemReportControl::resetTimerFreq(), WalkControllerBehavior::runCommand(), UPennWalkControllerBehavior::runCommand(), FlashIPAddrBehavior::setupSequence(), and BatteryMonitorBehavior::startWarning().
adds a trapper for ALL events Note that since timers are not broadcast, they cannot be trapped. Only the EventListener which requested the timer will receive that timer. Definition at line 243 of file EventRouter.cc.
Adds a trapper for a specific source id and type from a given event generator. Note that since timers are not broadcast, they cannot be trapped. Only the EventListener which requested the timer will receive that timer. Definition at line 233 of file EventRouter.cc.
Adds a trapper for all types from a specific source and generator. Note that since timers are not broadcast, they cannot be trapped. Only the EventListener which requested the timer will receive that timer. Definition at line 223 of file EventRouter.cc.
Adds a trapper for all events from a given event generator. Note that since timers are not broadcast, they cannot be trapped. Only the EventListener which requested the timer will receive that timer. Definition at line 214 of file EventRouter.cc.
Adds a trapper for a specific source id and type from a given event generator. Note that only the broadcasted timers can be trapped. The EventListener which requested the timer will receive that timer before any trapping is done. Definition at line 205 of file EventRouter.cc. Referenced by Controller::activate(), addTrapper(), WorldStateVelDaemon::DoStart(), and Controller::takeLine().
counts both listeners and trappers, so generators can tell if it even needs to bother generating an event...
Definition at line 214 of file EventRouter.h.
counts both listeners and trappers, so generators can tell if it even needs to bother generating an event...
Definition at line 213 of file EventRouter.h.
counts both listeners and trappers, so generators can tell if it even needs to bother generating an event...
Definition at line 212 of file EventRouter.h.
counts both listeners and trappers, so generators can tell if it even needs to bother generating an event...
Definition at line 211 of file EventRouter.h. Referenced by addListener(), addTrapper(), hasListeners(), EventGeneratorBase::hasListeners(), removeListener(), and removeTrapper().
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 191 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 190 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 189 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 188 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 187 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 186 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 197 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 196 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 195 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 194 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 193 of file EventRouter.h.
returns true if the specified listener/trapper would receive any events that match the specified criteria
Definition at line 192 of file EventRouter.h.
posts the specified event, but doesn't delete it at the end -- equivalent to processEvent(e)
Definition at line 169 of file EventRouter.h.
deprecated -- pass by reference instead; this version posts the specified event and then deletes it after processing is complete moving to pass by reference instead of pass by pointer to avoid questions about who deletes the event and the event's scope, also keeping the event on the stack is faster by avoiding unnecessary heap operations. Definition at line 14 of file EventRouter.cc.
recommended to create and post an event using current buffer setting
Definition at line 163 of file EventRouter.h.
recommended to create and post an event using current buffer setting
Definition at line 162 of file EventRouter.h. Referenced by addListener(), addTrapper(), WMitem< T >::announce(), Controller::console_callback(), BallDetectionGenerator::createEvent(), MotionManager::doAddMotion(), NoOpEventTranslator::encodeEvent(), SoundManager::endPlay(), Transition::fire(), StateNode::postCompletionEvent(), MotionCommand::postEvent(), StateNode::postStartEvent(), StateNode::postStopEvent(), WorldStateVelDaemon::processEvent(), SegmentedColorGenerator::processEvent(), RLEGenerator::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), PNGGenerator::processEvent(), PitchDetector::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), CDTGenerator::processEvent(), SoundManager::ProcessMsg(), MotionManager::processMsg(), processTimers(), WorldState::read(), removeListener(), removeTrapper(), SoundManager::stopPlay(), Controller::takeLine(), WMitem_base::unwatch(), and WMitem_base::watch().
sends event to its trappers & listeners, but doesn't delete the event at the end (see also postEvent()) this posting method is supplied to allow an EventRouter to behave as a listener as well -- the 'routers' really can form a sort of network, if desired. postEvent() is probably a more memnomic interface to use in direct function calls however, so that is the one you should call. Implements EventListener. Definition at line 294 of file EventRouter.cc. Referenced by postEvent().
determines if timers need to be posted, and posts them if so. Call this often to ensure accurate timers. Definition at line 17 of file EventRouter.cc.
stops all events and timers, shorthand for removeListener(el) and removeTimer(el); Note that trappers are separate, removeTrapper() is not called
Definition at line 249 of file EventRouter.h. Referenced by BehaviorBase::DoStop().
clears all timers for all listeners
Definition at line 113 of file EventRouter.cc. Referenced by reset(), and ~EventRouter().
Uses the generator, source, and type fields of e to remove a listener for that specific tuple.
Definition at line 195 of file EventRouter.cc.
stops sending specified events from the generator to the listener.
Definition at line 186 of file EventRouter.cc.
stops sending specified events from the generator to the listener.
Definition at line 174 of file EventRouter.cc.
stops sending specified events from the generator to the listener.
Definition at line 165 of file EventRouter.cc.
stops sending ALL events to the listener -- does not remove pending timers however (may need to call removeTimer(el) as well); see remove()
Definition at line 153 of file EventRouter.cc. Referenced by ValueEditControl< T >::activate(), EventLogger::clearSlots(), WalkCalibration::deactivate(), PostureEditor::deactivate(), NetworkStatusControl::deactivate(), BatteryCheckControl::deactivate(), SensorObserverControl::doSelect(), EventLogger::doSelect(), WorldStateVelDaemon::DoStop(), WorldStateSerializerBehavior::DoStop(), WMMonitorBehavior::DoStop(), WalkToTargetNode::DoStop(), WalkControllerBehavior::DoStop(), VisualTargetTrans::DoStop(), VisualTargetCloseTrans::DoStop(), UPennWalkControllerBehavior::DoStop(), TimeOutTrans::DoStop(), TextMsgTrans::DoStop(), StewartPlatformBehavior::DoStop(), SpiderMachineBehavior::DoStop(), SoundNode::DoStop(), SegCamBehavior::DoStop(), RegionCamBehavior::DoStop(), RawCamBehavior::DoStop(), NullTrans::DoStop(), MotionSequenceNode< SIZE >::DoStop(), MicrophoneServer::DoStop(), MCNodeBase::DoStop(), HeadPointControllerBehavior::DoStop(), FreeMemReportControl::DoStop(), FlashIPAddrBehavior::DoStop(), EventTrans::DoStop(), EventGeneratorBase::DoStop(), EStopControllerBehavior::DoStop(), EchoBehavior::DoStop(), Controller::DoStop(), ConnectionMadeTrans::DoStop(), CompletionTrans::DoStop(), CompareTrans< T >::DoStop(), BatteryMonitorBehavior::DoStop(), AutoGetupBehavior::DoStop(), NetworkStatusControl::pause(), BatteryCheckControl::pause(), RunSequenceControl< SequenceSize >::processEvent(), LoadPostureControl::processEvent(), FlashIPAddrBehavior::processEvent(), AutoGetupBehavior::processEvent(), CameraStreamBehavior::receiveData(), remove(), EventGeneratorBase::removeSrcListener(), EventLogger::runCommand(), BehaviorBase::~BehaviorBase(), LoadPostureControl::~LoadPostureControl(), and RunSequenceControl< SequenceSize >::~RunSequenceControl().
clears any pending timers with source id sid for listener el
Definition at line 104 of file EventRouter.cc.
clears all pending timers for listener el; see remove()
Definition at line 95 of file EventRouter.cc. Referenced by addTimer(), SensorObserverControl::RTViewControl::deactivate(), PostureEditor::deactivate(), SensorObserverControl::RTViewControl::pause(), PostureEditor::pause(), PostureEditor::processEvent(), FlashIPAddrBehavior::processEvent(), remove(), FreeMemReportControl::resetTimerFreq(), WalkControllerBehavior::runCommand(), UPennWalkControllerBehavior::runCommand(), FlashIPAddrBehavior::setupSequence(), and BatteryMonitorBehavior::stopWarning().
stops sending specified events from the generator to the trapper.
Definition at line 279 of file EventRouter.cc.
stops sending specified events from the generator to the trapper.
Definition at line 267 of file EventRouter.cc.
stops sending specified events from the generator to the trapper.
Definition at line 258 of file EventRouter.cc.
stops sending specified events from the generator to the trapper.
Definition at line 249 of file EventRouter.cc. Referenced by Controller::deactivate(), WorldStateVelDaemon::DoStop(), removeTrapper(), and Controller::takeLine().
erases all listeners, trappers and timers, resets EventRouter
Definition at line 156 of file EventRouter.h. Referenced by ~EventRouter().
Member Data Documentation
A mapping of which EventListener's should receive events.
Definition at line 412 of file EventRouter.h. Referenced by addListener(), hasListeners(), isListening(), isListeningAll(), isListeningAny(), processEvent(), removeListener(), and reset().
stores calls to post() currently in progress -- may grow if one postEvent() triggers another; this allows us to finish processing of the original postEvent() before starting the second.
Definition at line 433 of file EventRouter.h. Referenced by processEvent().
the list of timer entries being maintained, kept sorted by time they go active
Definition at line 304 of file EventRouter.h. Referenced by addTimer(), chkTimers(), dispTimers(), getNextTimer(), processTimers(), removeAllTimers(), and removeTimer().
A mapping of which EventTrapper's should get a chance to trap the event.
Definition at line 411 of file EventRouter.h. Referenced by addTrapper(), hasListeners(), isTrapping(), isTrappingAll(), isTrappingAny(), processEvent(), removeTrapper(), and reset().
The documentation for this class was generated from the following files: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tekkotsu v3.0 |
Generated Wed Oct 4 00:05:00 2006 by Doxygen 1.4.7 |