LostTargetTrans.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_LostTargetTrans_h_
00003 #define INCLUDED_LostTargetTrans_h_
00004
00005 #include "Behaviors/Transitions/TimeOutTrans.h"
00006
00007
00008 class LostTargetTrans : public TimeOutTrans {
00009 public:
00010
00011
00012 LostTargetTrans(StateNode* destination, unsigned int source_id,
00013 unsigned int delay, int minframes=5) :
00014 TimeOutTrans("LostTargetTrans","LostTargetTrans",destination,delay),
00015 sid(source_id), minf(minframes), counter(0) {}
00016
00017
00018 LostTargetTrans(const std::string &name, StateNode* destination, unsigned int source_id,
00019 unsigned int delay, int minframes=5) :
00020 TimeOutTrans("LostTargetTrans",name,destination,delay),
00021 sid(source_id), minf(minframes), counter(0) {}
00022
00023
00024 virtual void preStart() {
00025 TimeOutTrans::preStart();
00026 erouter->addListener(this,EventBase::visObjEGID,sid);
00027 }
00028
00029 virtual void doEvent() {
00030 if (event->getGeneratorID()==EventBase::visObjEGID && event->getSourceID()==sid) {
00031 ++counter;
00032 if (counter > minf) resetTimer();
00033 }
00034 else
00035 TimeOutTrans::doEvent();
00036 }
00037
00038
00039 virtual void resetTimer() {
00040 TimeOutTrans::resetTimer();
00041 counter = 0;
00042 }
00043
00044
00045 virtual void set_minframes(int minframes) { minf = minframes; }
00046
00047 protected:
00048
00049 LostTargetTrans(const std::string &classname, const std::string &instancename,
00050 StateNode* destination, unsigned int source_id,
00051 unsigned int delay, int minframes=5) :
00052 TimeOutTrans(classname,instancename,destination,delay),
00053 sid(source_id), minf(minframes), counter(0) {}
00054
00055
00056 private:
00057 unsigned int sid;
00058 int minf;
00059 int counter;
00060 };
00061
00062 #endif
00063
00064
00065
00066
00067