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);
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);
00025 }
00026
00027 virtual bool trapEvent(const EventBase& ev) {
00028 if(ev.getGeneratorID()==EventBase::sensorEGID) {
00029 erouter->addTimer(this, 0, 30000, true);
00030 }
00031 return false;
00032 }
00033 };
00034
00035 REGISTER_BEHAVIOR_MENU_OPT(SensorMonitorBehavior,"Background Behaviors/System Daemons",BEH_NONEXCLUSIVE|BEH_START);