CircleMobility Class Reference

#include <CircleMobility.h>

Inheritance diagram for CircleMobility:

BasicMobility BasicModule INotifiable

List of all members.


Detailed Description

Circle movement model. See NED file for more info.

Author:
Andras Varga

Protected Member Functions

virtual void initialize (int)
 Initializes mobility model parameters.
virtual void handleSelfMsg (cMessage *msg)
 Called upon arrival of a self messages.
virtual void move ()
 Move the host.

Protected Attributes

double cx
double cy
double r
double omega
 angular velocity [rad/s], derived from speed and radius
double updateInterval
 time interval to update the hosts position
bool stationary
 if true, the host doesn't move
double angle
 direction from the centre of the circle

Member Function Documentation

void CircleMobility::initialize ( int  stage  )  [protected, virtual]

Initializes mobility model parameters.

Reimplemented from BasicMobility.

00026 {
00027     BasicMobility::initialize(stage);
00028 
00029     EV << "initializing CircleMobility stage " << stage << endl;
00030 
00031     if (stage == 1)
00032     {
00033         // read parameters
00034         cx = par("cx");
00035         cy = par("cy");
00036         r = par("r");
00037         ASSERT(r>0);
00038         angle = par("startAngle").doubleValue()/180.0*PI;
00039         updateInterval = par("updateInterval");
00040         double speed = par("speed");
00041         omega = speed/r;
00042 
00043         // calculate initial position
00044         pos.x = cx + r * cos(angle);
00045         pos.y = cy + r * sin(angle);
00046         updatePosition();
00047 
00048         // if the initial speed is lower than 0, the node is stationary
00049         stationary = (speed == 0);
00050 
00051         // host moves the first time after some random delay to avoid synchronized movements
00052         if (!stationary)
00053             scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move"));
00054     }
00055 }

void CircleMobility::handleSelfMsg ( cMessage *  msg  )  [protected, virtual]

Called upon arrival of a self messages.

Implements BasicMobility.

00059 {
00060     move();
00061     updatePosition();
00062     scheduleAt(simTime() + updateInterval, msg);
00063 }

void CircleMobility::move (  )  [protected, virtual]

Move the host.

Referenced by handleSelfMsg().

00066 {
00067     angle += omega * updateInterval;
00068     pos.x = cx + r * cos(angle);
00069     pos.y = cy + r * sin(angle);
00070 
00071     EV << " xpos= " << pos.x << " ypos=" << pos.y << endl;
00072 }


Member Data Documentation

double CircleMobility::cx [protected]

Referenced by initialize(), and move().

double CircleMobility::cy [protected]

Referenced by initialize(), and move().

double CircleMobility::r [protected]

Referenced by initialize(), and move().

double CircleMobility::omega [protected]

angular velocity [rad/s], derived from speed and radius

Referenced by initialize(), and move().

double CircleMobility::updateInterval [protected]

time interval to update the hosts position

Referenced by handleSelfMsg(), initialize(), and move().

bool CircleMobility::stationary [protected]

if true, the host doesn't move

Referenced by initialize().

double CircleMobility::angle [protected]

direction from the centre of the circle

Referenced by initialize(), and move().


The documentation for this class was generated from the following files:

Generated on Fri Mar 20 18:51:18 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5