Yes, you either need to call push() from your run_timer method, or you need to schedule a task, and have the task call push(). However, you can only call push if you have a packet, so one of those methods would need to create a packet first (either by pulling from a pull input, or by creating a packet). You can look at elements/standard/ratedunqueue.cc or elements/standard/timedsource.cc for examples. (if you initialize a Timer object with a task, then the timer automatically reschedules the task whenever the timer fires)
Cliff On Sun, Feb 6, 2011 at 11:14 PM, <[email protected]> wrote: > Hi, > i wrote a pull processed element with timer to periodically reset a > integer counter (the no. of packets encountered) to zero. The problem is > that the push() method is never executed. the code is as follows > > Time::Time() > : _interval(0, Timestamp::subsec_per_sec / 2), > _count(0), _active(true), _timer(this) > { > } > > Time::~Time() > { > } > > int > Time::configure(Vector<String> &conf, ErrorHandler *errh) > { > if (cp_va_kparse(conf, this, errh, > "INTERVAL", cpkP, cpTimestamp, &_interval, > "ACTIVE", 0, cpBool, &_active, > cpEnd) < 0) > return -1; > > } > > int > Time::initialize(ErrorHandler *) > { > _timer.initialize(this); > if (_active) > _timer.schedule_after(_interval); > return 0; > } > > void > Time::run_timer(Timer *) > { > click_chatter("Timer activated and count=%d\ncounter reset",counter); > counter=0; > _timer.reschedule_after(_interval); > //do i need to call push() again here?. If so how?. this.push();??? > } > > void > Time::push(int , Packet *p) > { > click_chatter("push() executer"); > counter+=1; > output(0).push(p); > } > > output goes like this (one iteration every _interval seconds) > Timer activated and count=0 > counter reset > Timer activated and count=0 > counter reset > Timer activated and count=0 > counter reset > Timer activated and count=0 > counter reset > Timer activated and count=0 > counter reset > Timer activated and count=0 > counter reset > > I really need the push() method to be executed BETWEEN each run_timer() > schedule. > > how do i do that?. > > Thanks in advance. > Murali Dharan > > > ----------------------------------------- > This email was sent using TCEMail Service. > Thiagarajar College of Engineering > Madurai-625 015, India > > _______________________________________________ > click mailing list > [email protected] > https://amsterdam.lcs.mit.edu/mailman/listinfo/click > _______________________________________________ click mailing list [email protected] https://amsterdam.lcs.mit.edu/mailman/listinfo/click
