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

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.
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::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.

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

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

Initializes mobility model parameters.

Reimplemented from BasicMobility.

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

void LinearMobility::move  )  [protected]
 

Move the host.

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

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


Member Data Documentation

double LinearMobility::acceleration [protected]
 

acceleration of linear motion

double LinearMobility::angle [protected]
 

angle of linear motion

double LinearMobility::speed [protected]
 

speed of the host

bool LinearMobility::stationary [protected]
 

if true, the host doesn't move

double LinearMobility::updateInterval [protected]
 

time interval to update the hosts position


The documentation for this class was generated from the following files:
Generated on Thu Oct 19 18:22:26 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.0