Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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.
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::handleSelfMsg cMessage *  msg  )  [protected, virtual]
 

Called upon arrival of a self messages.

Reimplemented from BasicMobility.

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

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

Initializes mobility model parameters.

Reimplemented from BasicMobility.

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

void CircleMobility::move  )  [protected]
 

Move the host.

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


Member Data Documentation

double CircleMobility::angle [protected]
 

direction from the centre of the circle

double CircleMobility::cx [protected]
 

double CircleMobility::cy [protected]
 

double CircleMobility::omega [protected]
 

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

double CircleMobility::r [protected]
 

bool CircleMobility::stationary [protected]
 

if true, the host doesn't move

double CircleMobility::updateInterval [protected]
 

time interval to update the hosts position


The documentation for this class was generated from the following files:
Generated on Sat Apr 1 20:52:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1