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 class LostTargetTrans : public TimeOutTrans {
00011 public:
00012
00013
00014 LostTargetTrans(StateNode* destination, unsigned int source_id,
00015 unsigned int delay, int minframes=5) :
00016 TimeOutTrans("LostTargetTrans","LostTargetTrans",destination,delay),
00017 sid(source_id), minf(minframes), counter(0) {}
00018
00019
00020 LostTargetTrans(const std::string &name, StateNode* destination, unsigned int source_id,
00021 unsigned int delay, int minframes=5) :
00022 TimeOutTrans("LostTargetTrans",name,destination,delay),
00023 sid(source_id), minf(minframes), counter(0) {}
00024
00025
00026 virtual void DoStart() {
00027 TimeOutTrans::DoStart();
00028 erouter->addListener(this,EventBase::visObjEGID,sid);
00029 }
00030
00031 virtual void processEvent(const EventBase &e) {
00032 if (e.getGeneratorID()==EventBase::visObjEGID && e.getSourceID()==sid) {
00033 ++counter;
00034 if (counter > minf) resetTimer();
00035 }
00036 else
00037 TimeOutTrans::processEvent(e);
00038 }
00039
00040
00041 virtual void resetTimer() {
00042 TimeOutTrans::resetTimer();
00043 counter = 0;
00044 }
00045
00046
00047 virtual void set_minframes(int minframes) { minf = minframes; }
00048
00049 protected:
00050
00051 LostTargetTrans(const std::string &classname, const std::string &instancename,
00052 StateNode* destination, unsigned int source_id,
00053 unsigned int delay, int minframes=5) :
00054 TimeOutTrans(classname,instancename,destination,delay),
00055 sid(source_id), minf(minframes), counter(0) {}
00056
00057
00058 private:
00059 unsigned int sid;
00060 int minf;
00061 int counter;
00062 };
00063
00064 #endif
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075