Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
EventBase Class Reference#include <EventBase.h>
Inheritance diagram for EventBase:
![]() Detailed DescriptionForms the basis of communication between modules/behaviors in the framework.Events are defined by a 3-tuple:
Each of these is represented by an ID, the EventGeneratorID_t (EGID) and EventTypeID_t (ETID) are defined here in EventBase. Source IDs (SID) are defined separately by each generator, so the documentation in each entry of EventGeneratorID_t describes how to interpret the source field. So for example, the button event which results from initially pressing the head button on an ERS-7 robot would be: While the button is held down, additional statusETID events are used to report varying pressure values (if the button is pressure sensitive), and an event with deactivateETID is sent when the button is released. Alternatively, an SID value from a vision detector (say visObjEGID) refers to seeing a particular object, a completely different domain, values of which may overlap with other generators' source IDs. Thus, interpreting the source field requires knowing the generator as well. When the generator doesn't have groups of activity with a 'begin' or 'end', it will use statusETID for all of its events. (in other words, not all generators necessarily have to use activate or deactivate) For example, sensor updates are continuously occuring, so you will only ever see The duration field is also generator specific - some may refer to the time since the last activation event (e.g. button events) where as others refer to time since last status (e.g. sensors updates) If you want to make a new generator, all you have to do is add a new entry to the ID list (EventGeneratorID_t) and then put its name in the EventGeneratorNames[] array. Alternatively, there is an 'unlicensed spectrum' available under unknownEGID. You can send out events from that generator just like any other, but it should only be used for quick tests and hacking around... The generator ID number is only that -- an ID number. Events can be posted to the EventRouter anywhere, anytime, and do not require anything of the sender. However, there is an EventGeneratorBase which can simplify some aspects of behaviors whose sole purpose is processing information and generating events. If more information needs to be sent along with the event, the cleanest solution is to create a subclass of EventBase to hold the additional information. For example, you can see the existing subclasses in the inheritance diagram above. If you want to use a quick hack however, you could just pass a pointer to data as the SID if you don't need that field for something else, or use a DataEvent.
Definition at line 75 of file EventBase.h.
Member Typedef Documentation
type used for class ids in the type registry (see getTypeRegistry())
Definition at line 138 of file EventBase.h.
Member Enumeration DocumentationLists all possible event generator ids. An event generator is a abstract source of events, used for listening to and parsing certain classes of events IF YOU ADD AN EVENT GENERATOR, DON'T FORGET TO NAME IT (EventBase::EventGeneratorNames, actual names are in EventBase.cc)
Definition at line 81 of file EventBase.h. an event type id is used to denote whether it's the first in a sequence (button down), in a sequence (button still down), or last (button up)
Definition at line 124 of file EventBase.h. values to pass to setSaveFormat()
Definition at line 265 of file EventBase.h.
Constructor & Destructor Documentation
constructor
Definition at line 67 of file EventBase.cc. Referenced by clone().
Member Function Documentation
returns a FamilyFactory with which you can look up classTypeID_t's to make new instances from serialized data
Definition at line 62 of file EventBase.cc. Referenced by EventTranslator::decodeEvent(), and DataEvent< T, TID >::registerDataType().
allows a copy to be made of an event, supporting polymorphism Must be overridden by all subclasses to allow this to happen I would like to switch this over to the cloneable interface once the compiler gets updated out of the 3.3 branch... see Cloneable::clone() for a discussion of the issue and implementation notes. Reimplemented in DataEvent< T, TID >, FilterBankEvent, LocomotionEvent, LookoutPointAtEvent, LookoutSketchEvent, LookoutIREvent, LookoutScanEvent, PitchEvent, SegmentedColorFilterBankEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 162 of file EventBase.h.
gets the name of the event - useful for debugging output, see also getDescription()
Definition at line 166 of file EventBase.h. Referenced by getDescription(), EventRouter::PostingStatus::process(), SensorObserverControl::processEvent(), RegionGenerator::processEvent(), PostureEditor::processEvent(), EchoBehavior::processEvent(), BatteryMonitorBehavior::processEvent(), BallDetectionGenerator::processEvent(), EventLogger::processStateMachineEvent(), and EventRouter::processTimers().
sets name to a given string, prevents overwriting by generated names
Definition at line 102 of file EventBase.cc. Referenced by BallDetectionGenerator::createEvent(), EventBase(), genName(), and loadXML().
gets "strength" of event - by default 1 for activate and status events, 0 for deactivate events
Definition at line 169 of file EventBase.h. Referenced by getDescription(), and Controller::trapEvent().
sets "strength" of event - you may want to override the default values (see getMagnitude())
Definition at line 170 of file EventBase.h. Referenced by EventBase().
time event was created
Definition at line 172 of file EventBase.h. Referenced by getDescription(), WorldStateVelDaemon::processEvent(), WorldStateSerializerBehavior::processEvent(), WalkCalibration::processEvent(), DeadReckoningBehavior< ParticleT >::processEvent(), EventLogger::processStateMachineEvent(), WorldStateVelDaemon::trapEvent(), RawCamBehavior::writeColor(), RegionCamBehavior::writeRegions(), SegCamBehavior::writeRLE(), SegCamBehavior::writeSeg(), and RawCamBehavior::writeSingleChannel().
gets the generator ID for this event
Definition at line 175 of file EventBase.h. Referenced by EventRouter::addListener(), EventRouter::addRemoteListener(), EventRouter::addTrapper(), getDescription(), EventRouter::EventMapper::getMapping(), EventRouter::hasListeners(), EventRouter::isListening(), EventRouter::isTrapping(), TorqueCalibrate::TakeMeasurementControl::processEvent(), TimeOutTrans::processEvent(), SensorObserverControl::processEvent(), SegmentedColorGenerator::processEvent(), SegCamBehavior::processEvent(), RLEGenerator::processEvent(), RemoteRouter::processEvent(), RegionGenerator::processEvent(), RawCameraGenerator::processEvent(), PostureEditor::processEvent(), PNGGenerator::processEvent(), PitchDetector::processEvent(), MotionSequenceNode< SIZE >::processEvent(), MicrophoneServer::processEvent(), LostTargetTrans::processEvent(), JPEGGenerator::processEvent(), InterleavedYUVGenerator::processEvent(), FreeMemReportControl::processEvent(), FilterBankGenerator::processEvent(), EventProxy::processEvent(), EventGeneratorBase::processEvent(), DeadReckoningBehavior< ParticleT >::processEvent(), CDTGenerator::processEvent(), CameraStreamBehavior::processEvent(), BufferedImageGenerator::processEvent(), BatteryMonitorBehavior::processEvent(), BallDetectionGenerator::processEvent(), AutoGetupBehavior::processEvent(), EventLogger::processStateMachineEvent(), EventRouter::removeListener(), EventRouter::removeRemoteListener(), EventRouter::removeTimer(), EventRouter::removeTrapper(), EventRouter::EventMapper::verifyMapping(), RawCamBehavior::writeColor(), and RawCamBehavior::writeSingleChannel().
sets the generator ID for this event
Definition at line 176 of file EventBase.h.
gets the source ID for this event
Definition at line 178 of file EventBase.h. Referenced by EventRouter::addListener(), EventRouter::addRemoteListener(), EventRouter::addTimer(), EventRouter::addTrapper(), getDescription(), EventRouter::EventMapper::getMapping(), EventRouter::hasListeners(), EventRouter::isListening(), EventRouter::isTrapping(), WorldStateVelDaemon::processEvent(), WMMonitorBehavior::processEvent(), RemoteRouter::processEvent(), PostureEditor::processEvent(), LostTargetTrans::processEvent(), FreeMemReportControl::processEvent(), EventTrans::processEvent(), EventProxy::processEvent(), CompletionTrans::processEvent(), BufferedImageGenerator::processEvent(), BatteryMonitorBehavior::processEvent(), BatteryCheckControl::processEvent(), BallDetectionGenerator::processEvent(), EventLogger::processStateMachineEvent(), EventRouter::removeListener(), EventRouter::removeRemoteListener(), EventRouter::removeTimer(), EventRouter::removeTrapper(), Controller::trapEvent(), and EventRouter::EventMapper::verifyMapping().
gets the type ID
Definition at line 181 of file EventBase.h. Referenced by EventRouter::addListener(), EventRouter::addRemoteListener(), EventRouter::addTrapper(), getDescription(), EventRouter::EventMapper::getMapping(), EventRouter::hasListeners(), EventRouter::isListening(), EventRouter::isTrapping(), WorldStateVelDaemon::processEvent(), WalkToTargetNode::processEvent(), VisualTargetTrans::processEvent(), RLEGenerator::processEvent(), RawCameraGenerator::processEvent(), PostureEditor::processEvent(), EventTrans::processEvent(), EStopControllerBehavior::processEvent(), Controller::processEvent(), CDTGenerator::processEvent(), BufferedImageGenerator::processEvent(), EventLogger::processStateMachineEvent(), EventRouter::removeListener(), EventRouter::removeRemoteListener(), EventRouter::removeTrapper(), setName(), Controller::trapEvent(), and EventRouter::EventMapper::verifyMapping().
sets the type ID
Definition at line 182 of file EventBase.h. Referenced by SegmentedColorGenerator::processEvent(), RegionGenerator::processEvent(), PNGGenerator::processEvent(), JPEGGenerator::processEvent(), and InterleavedYUVGenerator::processEvent().
Definition at line 185 of file EventBase.h.
Definition at line 186 of file EventBase.h.
gets the time since the beginning of this sequence (the timestamp of the activate event)
Definition at line 188 of file EventBase.h. Referenced by EventRouter::addTimer(), getDescription(), and Controller::trapEvent().
sets the time since the beginning of this sequence (the timestamp of the activate event)
Definition at line 189 of file EventBase.h.
resets name to generated form, overwriting any previous name
Definition at line 191 of file EventBase.h.
generates a description of the event with variable verbosity
Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 128 of file EventBase.cc. Referenced by VisionObjectEvent::getDescription(), TimerEvent::getDescription(), TextMsgEvent::getDescription(), PitchEvent::getDescription(), LookoutPointAtEvent::getDescription(), LocomotionEvent::getDescription(), EventLogger::processEvent(), and EventLogger::processStateMachineEvent().
Definition at line 204 of file EventBase.h.
tests to see if events have the same generator and source IDs
Definition at line 211 of file EventBase.h. Referenced by Controller::trapEvent().
compares event duration and ensures same event generator, source, and type - useful for event masks
Definition at line 213 of file EventBase.h.
compares event duration and ensures same event generator, source, and type - useful for event masks
Definition at line 214 of file EventBase.h.
compares event duration and ensures same event generator, source, and type - useful for event masks
Definition at line 215 of file EventBase.h.
compares event duration and ensures same event generator, source, and type - useful for event masks
Definition at line 216 of file EventBase.h.
Definition at line 218 of file EventBase.h.
All subclasses should override this and return a unique ID for their class. All IDs corresponding to all-capital letters are reserved for future framework expansion. (Thus, user subclasses should contain at least one lower-case letter.) This code can be used when serializing to allow quick identification of the class type by the receiver. Reimplemented in DataEvent< T, TID >, FilterBankEvent, LocomotionEvent, LookoutPointAtEvent, LookoutSketchEvent, LookoutIREvent, LookoutScanEvent, PitchEvent, SegmentedColorFilterBankEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 229 of file EventBase.h.
should return the minimum size needed if using binary format (i.e. not XML)
Reimplemented from XMLLoadSave. Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 141 of file EventBase.cc. Referenced by VisionObjectEvent::getBinSize(), TimerEvent::getBinSize(), TextMsgEvent::getBinSize(), PitchEvent::getBinSize(), LookoutPointAtEvent::getBinSize(), and LocomotionEvent::getBinSize().
load from binary format
Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 159 of file EventBase.cc. Referenced by RemoteRouter::forwardEvent(), VisionObjectEvent::loadBinaryBuffer(), TimerEvent::loadBinaryBuffer(), TextMsgEvent::loadBinaryBuffer(), PitchEvent::loadBinaryBuffer(), LookoutPointAtEvent::loadBinaryBuffer(), LocomotionEvent::loadBinaryBuffer(), and loadBuffer().
save to binary format
Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 180 of file EventBase.cc. Referenced by EventProxy::processEvent(), VisionObjectEvent::saveBinaryBuffer(), TimerEvent::saveBinaryBuffer(), TextMsgEvent::saveBinaryBuffer(), PitchEvent::saveBinaryBuffer(), LookoutPointAtEvent::saveBinaryBuffer(), LocomotionEvent::saveBinaryBuffer(), and saveBuffer().
load from XML format
Implements XMLLoadSave. Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 195 of file EventBase.cc. Referenced by VisionObjectEvent::loadXML(), TimerEvent::loadXML(), TextMsgEvent::loadXML(), PitchEvent::loadXML(), LookoutPointAtEvent::loadXML(), and LocomotionEvent::loadXML().
save to XML format
Implements XMLLoadSave. Reimplemented in LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, and VisionObjectEvent. Definition at line 258 of file EventBase.cc. Referenced by VisionObjectEvent::saveXML(), TimerEvent::saveXML(), TextMsgEvent::saveXML(), PitchEvent::saveXML(), LookoutPointAtEvent::saveXML(), and LocomotionEvent::saveXML().
no longer need to override this -- will automatically call either loadXML() or loadBinaryBuffer() based on saveFormat tries to be smart so if the load based on the current saveFormat fails, retries with the alternative format Reimplemented from XMLLoadSave. Definition at line 239 of file EventBase.h. Referenced by EventTranslator::decodeEvent().
no longer need to override this -- will automatically call either saveXML() or saveBinaryBuffer() based on saveFormat
Reimplemented from XMLLoadSave. Definition at line 246 of file EventBase.h.
automatically calls either XMLLoadSave::loadFile or LoadSave::loadFile based on saveFormat tries to be smart so if the load based on the current saveFormat fails, retries with the alternative format Reimplemented from XMLLoadSave. Definition at line 250 of file EventBase.h.
automatically calls either XMLLoadSave::saveFile or LoadSave::saveFile based on saveFormat
Reimplemented from XMLLoadSave. Definition at line 257 of file EventBase.h.
automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat
Reimplemented from XMLLoadSave. Definition at line 260 of file EventBase.h.
automatically calls either XMLLoadSave::loadFileStream or LoadSave::loadFileStream based on saveFormat
Reimplemented from XMLLoadSave. Definition at line 262 of file EventBase.h.
set saveFormat
Definition at line 269 of file EventBase.h. Referenced by EventTranslator::decodeEvent().
converts the first 4 characters of str to an unsigned int, should ensure consistent byte ordering across platforms
Definition at line 275 of file EventBase.h.
calls setName() with a string version of sourceID, decimal notation
Definition at line 287 of file EventBase.cc. Referenced by EventBase(), loadBinaryBuffer(), loadXML(), resetName(), setGeneratorID(), setHostID(), and setSourceID().
Member Data Documentation
Holds string versions of each of the generator's names, handy for debugging so you can output the events as readable strings (you'll find this in EventBase.cc since it can't go in the header or we get multiply-defined errors during linking).
Definition at line 121 of file EventBase.h. Referenced by EventRouter::addListener(), EventRouter::addTrapper(), EventLogger::EventLogger(), loadXML(), EventRouter::removeListener(), EventRouter::removeTrapper(), saveXML(), setName(), and Controller::takeLine().
Initial value: { "activate", "status", "deactivate" }
Definition at line 132 of file EventBase.h. Referenced by loadXML(), and Controller::takeLine().
holds abbreviated string versions of EventTypeID_t
Definition at line 135 of file EventBase.h. Referenced by loadXML(), saveXML(), setName(), setTypeID(), and Controller::takeLine().
the name of the event, use the same name consistently or else will be seen as different stimuli
Definition at line 285 of file EventBase.h. Referenced by getBinSize(), getName(), loadBinaryBuffer(), resetName(), saveBinaryBuffer(), saveXML(), setName(), and setTypeID().
the current "strength" of the event/stimuli... MAKE SURE this gets set to ZERO IF event is DEACTIVATE
Definition at line 286 of file EventBase.h. Referenced by getBinSize(), getMagnitude(), loadBinaryBuffer(), loadXML(), saveBinaryBuffer(), saveXML(), and setMagnitude().
the time the event was created - set automatically by constructor
Definition at line 287 of file EventBase.h. Referenced by getBinSize(), getTimeStamp(), loadBinaryBuffer(), loadXML(), operator<(), saveBinaryBuffer(), saveXML(), and setTimeStamp().
controls the format used during the next call to saveBuffer() (packed binary or XML)
Definition at line 289 of file EventBase.h. Referenced by VisionObjectEvent::getBinSize(), TimerEvent::getBinSize(), TextMsgEvent::getBinSize(), PitchEvent::getBinSize(), LookoutIREvent::getBinSize(), LookoutPointAtEvent::getBinSize(), LocomotionEvent::getBinSize(), getBinSize(), getSaveFormat(), loadBuffer(), loadFile(), loadFileStream(), saveBuffer(), saveFile(), saveFileStream(), and setSaveFormat().
tracks whether the current name (stim_id) was generated by genName() (true) or setName() (false)
Definition at line 291 of file EventBase.h. Referenced by genName(), getBinSize(), isCustomName(), loadBinaryBuffer(), resetName(), saveBinaryBuffer(), saveXML(), and setName().
generator ID, see EventGeneratorID_t
Definition at line 294 of file EventBase.h. Referenced by getGeneratorID(), loadBinaryBuffer(), loadXML(), operator==(), PitchEvent::PitchEvent(), sameGenSource(), saveBinaryBuffer(), saveXML(), setGeneratorID(), and setName().
type ID, see EventTypeID_t
Definition at line 295 of file EventBase.h. Referenced by getTypeID(), loadBinaryBuffer(), loadXML(), operator==(), saveBinaryBuffer(), saveXML(), and setTypeID().
the source ID for this event Source IDs are defined by the generator that made it. This should give authors flexibility to design their modules without having to worry about ID space collision
Definition at line 296 of file EventBase.h. Referenced by genName(), getBinSize(), getSourceID(), loadBinaryBuffer(), loadXML(), operator==(), sameGenSource(), saveBinaryBuffer(), saveXML(), and setSourceID().
Definition at line 300 of file EventBase.h. Referenced by getBinSize(), getHostID(), loadBinaryBuffer(), loadXML(), saveBinaryBuffer(), saveXML(), setHostID(), and setName().
the time since this sequence started (like, how long the button has been pressed); not all generators will set this; Typically, this would be 0 for activate, (activate.timestamp-get_time()) for status and deactivate
Definition at line 301 of file EventBase.h. Referenced by equalOrLongerThan(), equalOrShorterThan(), getBinSize(), getDuration(), loadBinaryBuffer(), loadXML(), longerThan(), saveBinaryBuffer(), saveXML(), setDuration(), and shorterThan().
causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
Definition at line 307 of file EventBase.h. Referenced by getClassTypeID().
The documentation for this class was generated from the following files: |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:18 2007 by Doxygen 1.5.4 |