FrameTimerGenerator.h

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