ConnectivityProbeApp Class Reference

#include <ConnectivityProbeApp.h>

List of all members.

Public Member Functions

void initialize ()
void handleMessage (cMessage *msg)
 ~ConnectivityProbeApp ()

Private Member Functions

void extractTopology ()

Private Attributes

simtime_t probeIntervall
cMessage * probeTimer
GlobalStatisticsglobalStatistics
std::map< NodeHandle,
SimpleGameClient * > 
Topology
cOutVector cOV_NodeCount
cOutVector cOV_ZeroMissingNeighbors
cOutVector cOV_AverageMissingNeighbors
cOutVector cOV_MaxMissingNeighbors
cOutVector cOV_AverageDrift

Detailed Description

Definition at line 34 of file ConnectivityProbeApp.h.


Constructor & Destructor Documentation

ConnectivityProbeApp::~ConnectivityProbeApp (  ) 

Definition at line 124 of file ConnectivityProbeApp.cc.

00125 {
00126     // destroy self timer messages
00127     cancelAndDelete(probeTimer);
00128 }


Member Function Documentation

void ConnectivityProbeApp::extractTopology (  )  [private]

Definition at line 110 of file ConnectivityProbeApp.cc.

Referenced by handleMessage().

00111 {
00112     for(int i=0; i<=simulation.getLastModuleId(); i++) {
00113         cModule* module = simulation.getModule(i);
00114         SimpleGameClient* client;
00115         if((client = dynamic_cast<SimpleGameClient*>(module))) {
00116 
00117             if(client->isOverlayReady()) {
00118                 Topology.insert(std::make_pair(client->getThisNode(), client));
00119             }
00120         }
00121     }
00122 }

void ConnectivityProbeApp::handleMessage ( cMessage *  msg  ) 

Definition at line 47 of file ConnectivityProbeApp.cc.

00048 {
00049     // fill topology with all modules
00050     extractTopology();
00051 
00052     if(Topology.size() == 0) {
00053         return;
00054     }
00055 
00056     // catch self timer messages
00057     if(msg->isName("probeTimer")) {
00058         //reset timer
00059         cancelEvent(probeTimer);
00060         scheduleAt(simTime() + probeIntervall, msg);
00061 
00062         int mnMax = 0;
00063         int mnZero = 0;
00064         int driftCount = 0;
00065         double mnAverage = 0.0;
00066         double drift = 0.0;
00067 
00068         for(std::map<NodeHandle, SimpleGameClient*>::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00069             int missing = 0;
00070             Vector2D pos = itTopology->second->getPosition();
00071             double AOIWidth = itTopology->second->getAOI();
00072             for(std::map<NodeHandle, SimpleGameClient*>::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
00073                 if(itI != itTopology && pos.distanceSqr(itI->second->getPosition()) <= AOIWidth*AOIWidth) {
00074                     NeighborMap::iterator currentSite = itTopology->second->Neighbors.find(itI->second->getThisNode());
00075                     if(currentSite == itTopology->second->Neighbors.end()) {
00076                         ++missing;
00077                     }
00078                     else {
00079                         drift += sqrt(currentSite->second.position.distanceSqr(itI->second->getPosition()));
00080                         ++driftCount;
00081                     }
00082                 }
00083             }
00084 
00085             mnAverage += missing;
00086             if(mnMax < missing) {
00087                 mnMax = missing;
00088             }
00089             if(missing == 0) {
00090                 ++mnZero;
00091             }
00092         }
00093         mnAverage /= (double)Topology.size();
00094         if(driftCount > 0) {
00095             drift /= (double)driftCount;
00096         }
00097 
00098         cOV_ZeroMissingNeighbors.record((double)mnZero);
00099         RECORD_STATS (
00100             globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size());
00101             globalStatistics->addStdDev("ConnectivityProbe: average drift", drift);
00102         );
00103         cOV_AverageMissingNeighbors.record(mnAverage);
00104         cOV_MaxMissingNeighbors.record((double)mnMax);
00105         cOV_AverageDrift.record(drift);
00106     }
00107     Topology.clear();
00108 }

void ConnectivityProbeApp::initialize (  ) 

Definition at line 29 of file ConnectivityProbeApp.cc.

00030 {
00031     globalStatistics = GlobalStatisticsAccess().get();
00032     probeIntervall = par("connectivityProbeIntervall");
00033     probeTimer = new cMessage("probeTimer");
00034 
00035     if(probeIntervall > 0.0) {
00036         scheduleAt(simTime() + probeIntervall, probeTimer);
00037 
00038         cOV_NodeCount.setName("total node count");
00039         cOV_ZeroMissingNeighbors.setName("neighbor-error free nodes");
00040         cOV_AverageMissingNeighbors.setName("average missing neighbors per node");
00041         cOV_MaxMissingNeighbors.setName("largest missing neighbors count");
00042         cOV_AverageDrift.setName("average drift");
00043     }
00044 
00045 }


Member Data Documentation

Definition at line 54 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

Definition at line 52 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

Definition at line 53 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

Definition at line 50 of file ConnectivityProbeApp.h.

Referenced by initialize().

Definition at line 51 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

Definition at line 44 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

Definition at line 42 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

cMessage* ConnectivityProbeApp::probeTimer [private]

Definition at line 43 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), initialize(), and ~ConnectivityProbeApp().

Definition at line 45 of file ConnectivityProbeApp.h.

Referenced by extractTopology(), and handleMessage().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3