LinearMobility Class Reference

#include <LinearMobility.h>

Inheritance diagram for LinearMobility:

BasicMobility BasicModule INotifiable

List of all members.


Detailed Description

Linear movement model. See NED file for more info.

Author:
Emin Ilker Cetinbas

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 speed
 speed of the host
double angle
 angle of linear motion
double acceleration
 acceleration of linear motion
double updateInterval
 time interval to update the hosts position
bool stationary
 if true, the host doesn't move

Member Function Documentation

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

Initializes mobility model parameters.

Reimplemented from BasicMobility.

00027 {
00028     BasicMobility::initialize(stage);
00029 
00030     EV << "initializing LinearMobility stage " << stage << endl;
00031 
00032     if (stage == 0)
00033     {
00034         updateInterval = par("updateInterval");
00035         speed = par("speed");
00036         angle = par("angle");
00037         acceleration = par("acceleration");
00038         angle = fmod(angle,360);
00039 
00040         // if the initial speed is lower than 0, the node is stationary
00041         stationary = (speed == 0);
00042 
00043         // host moves the first time after some random delay to avoid synchronized movements
00044         if (!stationary)
00045             scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move"));
00046     }
00047 }

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

Called upon arrival of a self messages.

The only self message possible is to indicate a new movement. If host is stationary this function is never called.

Implements BasicMobility.

00055 {
00056     move();
00057     updatePosition();
00058     if (!stationary)
00059         scheduleAt(simTime() + updateInterval, msg);
00060 }

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

Move the host.

Move the host if the destination is not reached yet. Otherwise calculate a new random position

Referenced by handleSelfMsg().

00067 {
00068     pos.x += speed * cos(PI * angle / 180) * updateInterval;
00069     pos.y += speed * sin(PI * angle / 180) * updateInterval;
00070 
00071     // do something if we reach the wall
00072     Coord dummy;
00073     handleIfOutside(REFLECT, dummy, dummy, angle);
00074 
00075     // accelerate
00076     speed += acceleration * updateInterval;
00077     if (speed <= 0)
00078     {
00079         speed = 0;
00080         stationary = true;
00081     }
00082 
00083     EV << " xpos= " << pos.x << " ypos=" << pos.y << " speed=" << speed << endl;
00084 }


Member Data Documentation

double LinearMobility::speed [protected]

speed of the host

Referenced by initialize(), and move().

double LinearMobility::angle [protected]

angle of linear motion

Referenced by initialize(), and move().

double LinearMobility::acceleration [protected]

acceleration of linear motion

Referenced by initialize(), and move().

double LinearMobility::updateInterval [protected]

time interval to update the hosts position

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

bool LinearMobility::stationary [protected]

if true, the host doesn't move

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


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

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