FrameTimer.h

00001 #ifndef FRAME_TIMER_H
00002 #define FRAME_TIMER_H 1
00003 
00004 #include <omnetpp.h>
00005 #include "FrameTimerGenerator.h"
00006 #include "BaseModule.h"
00007 
00008 /* frame timers are repeating timers (ala TimeSync in TinyOS)
00009  * Frame timers can also be assumed to be firing at the same time on 
00010  * different nodes (i.e. global time is being used)
00011  * Default implementation of this cheats and uses simTime() to calculate
00012  * the global time points, but eventually this could be implemented using 
00013  * the standard timers and a proper global time implementation */
00014 
00015 class FrameTimer
00016 {
00017   friend class FrameTimerGenerator;
00018   protected:
00019     FrameTimerGenerator *tg;
00020     BaseModule *owner;
00021   public: 
00022     virtual ~FrameTimer(){delete tg;}
00023     virtual void init(BaseModule *parent);
00024     void setFrameTimer(unsigned int index, double period) {tg->setFrameTimer(index,period);}
00025     unsigned int setFrameTimer(double period) {return tg->setFrameTimer(period);}
00026     void cancelFrameTimer(unsigned int index){tg->cancelFrameTimer(index);}
00027     virtual void handleFrameTimer(unsigned int index)=0;
00028 };
00029 
00030 #endif