SimTracer.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        SimTracer.h
00003  *
00004  * author:      Jerome Rousselot
00005  *
00006  * copyright:   (C) 2007-2008 CSEM SA, Neuchatel, Switzerland
00007  *
00008  *              This program is free software; you can redistribute it
00009  *              and/or modify it under the terms of the GNU General Public
00010  *              License as published by the Free Software Foundation; either
00011  *              version 2 of the License, or (at your option) any later
00012  *              version.
00013  *              For further information see file COPYING
00014  *              in the top level directory
00015  *
00016  * Funding: This work was partially financed by the European Commission under the
00017  * Framework 6 IST Project "Wirelessly Accessible Sensor Populations"
00018  * (WASP) under contract IST-034963.
00019  ***************************************************************************
00020  * part of:    Modifications to the MF-2 framework by CSEM
00021  **************************************************************************/
00022 
00023 #ifndef SIMTRACER_H
00024 #define SIMTRACER_H
00025 
00026 #include <string>
00027 #include <sstream>
00028 #include <fstream>
00029 #include <vector>
00030 #include <map>
00031 #include <BaseWorldUtility.h>
00032 #include <BaseLayer.h>
00033 #include <ConnectionManager.h>
00034 #include "Packet.h"
00035 # include "ImNotifiable.h"
00036 
00037 using namespace std;
00038 
00044 class SimTracer:public cSimpleModule, ImNotifiable
00045 {
00046 
00047 public:
00048   SimTracer(): packet(100) {}
00049 
00051   virtual void initialize(int);
00052 
00054   virtual void finish();
00055 
00057   void namLog(string namString);
00058 
00059   void radioEnergyLog(unsigned long mac, int state, simtime_t duration,
00060           double power, double newPower);
00061 
00063   void logLink(int parent, int child);
00065   void logPosition(int node, double x, double y);
00066 
00068   virtual void receiveBBItem(int category, const BBItem * details, int scopeModuleId);
00069 
00070   double getAvgSensorPowerConsumption();
00071 
00072   double getSinkPowerConsumption();
00073 
00074 protected:
00075    ofstream namFile, radioEnergyFile, treeFile;;
00076    vector < string > packetsColors;
00077    cOutVector goodputVec;
00078    cOutVector pSinkVec;
00079    cOutVector pSensorVec;
00080    map < unsigned long, double >powerConsumptions;
00081    int catPacket;
00082    Packet packet;
00083    long nbApplPacketsSent;
00084    long nbApplPacketsReceived;
00085    int catEnergy;
00086    map < unsigned long, double >powerConsumptions2;
00087    map < unsigned long, double >currPower;
00088    map < unsigned long, simtime_t> lastUpdates;
00089    BaseWorldUtility* world;
00090 };
00091 
00092 
00093 #endif
00094