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