Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

SlottedAloha.cpp

Go to the documentation of this file.
00001 #include <list>
00002 
00003 #include "SlottedAloha.h"
00004 
00026 SysSAloha::SysSAloha(ParamManager* _Param, GlobalProbeManager* _Results, ProbeManager* _ProbeMgr)
00027 : DESystem(_Param, 
00028            _Results,
00029            _ProbeMgr,
00030            get<IntParameter,int>(_Param, "TimeResolution",  "SAloha", ""), 
00031            stringToULL( get<StringParameter,string>(_Param, "SlotTime",  "SAloha", ""),
00032                 get<IntParameter,int>(_Param, "TimeResolution",  "SAloha",  "") ),
00033            1,
00034            1)
00035 {
00036   // remember to clean the pointers to dynamical objects AND 
00037   // to instantiate them in the Initialize() function, NOT here!
00038   ap = 0;
00039   PktGen = 0;
00040 }
00041 
00050 void SysSAloha::setup(ParamManager *Param, GlobalProbeManager *Results)
00051 {
00052   // general parameters, remember that the division between classes is only for your own convenience,
00053   // as you can read any parameter from any class if you want.
00054   Param->addClass ("SAloha", "SAloha system");
00055 
00056   Param->addParameter ("SAloha", new IntParameter("TimeResolution",  "Risoluzione temporale", "-6", "(0,inf)" ));
00057   Param->addParameter ("SAloha", new StringParameter("SlotTime",  "Length of a slot", "1", "(0,inf)" ));
00058   Param->addParameter ("SAloha", new DETimeParameter("RoundTripDelay",  "Round trip delay", "1.1", "(0,inf)" ));
00059   
00060   // remember to call you classes Setup() functions !
00061   DevPkt::setup(Param, Results);
00062   DevPktGen::setup(Param, Results);
00063   DevAP::setup(Param, Results);
00064 
00065   // this is optional, but sometimes very useful :)
00066   Param->setDefault("BaseFileName", "results/");
00067   Param->setDefault("TimeResolution", "-6");
00068   Param->setDefault("SimulationTime", "100000");
00069   Param->setDefault("WriteStatsInterval", "10000");
00070   Param->setDefault("DebugPrintInterval", "10000");
00071 }
00072 
00073 
00080 void SysSAloha::Initialize()
00081 {
00082   DESystem::Initialize();
00083   
00084   // the Access Point is created here. Remember that Initialize() could be called multiple times,
00085   // so you need to destroy old objects before creating a new one.
00086   if( ap )
00087     delete ap;
00088   ap = new DevAP(this);
00089   ap->Initialize();
00090   
00091   // the Packets Manager. 
00092   // Since Pkts are created dynamically, a manager is the obvious choice.
00093   if( PktGen )
00094     delete PktGen;
00095   PktGen = new DevPktGen(this, ap);
00096   PktGen->Initialize();
00097 }
00098 
00102 SysSAloha::~SysSAloha()
00103 {
00104   if( ap )
00105     delete ap;
00106   
00107   if( PktGen )
00108     delete PktGen;
00109 }
00110 
00112 // main
00114 
00120 void DEMain()
00121 {
00122   RunSimul<SysSAloha>();
00123 }
00124 

Generated on Wed Dec 22 23:26:43 2004 for NePSing Slotted Aloha example by doxygen 1.3.9.1 ---- Hosted by SourceForge.net Logo