Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SensorMonitorBehavior.cc

Go to the documentation of this file.
00001 #include "Behaviors/BehaviorBase.h"
00002 #include "Events/EventRouter.h"
00003 
00004 class SensorMonitorBehavior : public BehaviorBase, public EventTrapper {
00005 public:
00006   SensorMonitorBehavior() : BehaviorBase("SensorMonitorBehavior") {}
00007   virtual void doStart() {
00008     BehaviorBase::doStart();
00009     erouter->addTrapper(this,EventBase::sensorEGID);
00010     erouter->addTimer(this, 0, 2000, true);  // initial warning should come after just 2 secs.
00011   }
00012   
00013   virtual void doStop() {
00014     erouter->removeTrapper(this);
00015     BehaviorBase::doStop();
00016   }
00017   
00018   virtual void doEvent() {
00019     std::cout
00020     << "********************************\n"
00021     << "Warning: sensor events don't seem to be "
00022     << "occurring normally.\n"
00023     << "********************************\n";
00024     erouter->addTimer(this, 0, 30000, true);  // don't repeat more frequently than every 30 secs.
00025   }
00026   
00027   virtual bool trapEvent(const EventBase& ev) {
00028     if(ev.getGeneratorID()==EventBase::sensorEGID) {
00029       erouter->addTimer(this, 0, 30000, true); // reset timer
00030     }
00031     return false;
00032   }
00033 };
00034 
00035 REGISTER_BEHAVIOR_MENU_OPT(SensorMonitorBehavior,"Background Behaviors/System Daemons",BEH_NONEXCLUSIVE|BEH_START);

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:50 2016 by Doxygen 1.6.3