class LostTargetTrans : public TimeOutTrans {
public:
LostTargetTrans(StateNode* destination, unsigned int source_id,
unsigned int timeLimit, int minframes=5) :
TimeOutTrans("LostTargetTrans","LostTargetTrans",destination,timeLimit),
sid(source_id), minf(minframes), counter(0) {}
LostTargetTrans(const std::string &name, StateNode* destination, unsigned int source_id,
unsigned int timeLimit, int minframes=5) :
TimeOutTrans("LostTargetTrans",name,destination,timeLimit),
sid(source_id), minf(minframes), counter(0) {}
virtual void start() {
TimeOutTrans::start();
erouter->addListener(this,EventBase::visObjEGID,sid);
}
virtual void doEvent() {
if (event->getGeneratorID()==EventBase::visObjEGID && event->getSourceID()==sid) {
++counter;
if (counter > minf) resetTimer();
}
else
TimeOutTrans::doEvent();
}
virtual void resetTimer() {
TimeOutTrans::resetTimer();
counter = 0;
}
virtual void set_minframes(int minframes) { minf = minframes; }
protected:
LostTargetTrans(const std::string &classname, const std::string &instancename,
StateNode* destination, unsigned int source_id,
unsigned int timeLimit, int minframes=5) :
TimeOutTrans(classname,instancename,destination,timeLimit),
sid(source_id), minf(minframes), counter(0) {}
private:
unsigned int sid;
int minf; // number of frames that target must be seen before resetting the timer
int counter; // number of frames target has been seen so far
};
|