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

MassMobility Class Reference

#include <MassMobility.h>

Inheritance diagram for MassMobility:

BasicMobility BasicModule INotifiable List of all members.

Detailed Description

Models the mobility of with mass, making random motions. See NED file for more info.

Author:
Emin Ilker Cetinbas, 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

cPar * changeInterval
cPar * changeAngleBy
cPar * speed
double currentSpeed
 speed of the host
double currentAngle
 angle of linear motion
double updateInterval
 time interval to update the hosts position
Coord step
 calculated from speed, angle and updateInterval


Member Function Documentation

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

Called upon arrival of a self messages.

The only self message possible is to indicate a new movement.

Reimplemented from BasicMobility.

00068 {
00069     switch (msg->kind())
00070     {
00071     case MK_UPDATE_POS:
00072         move();
00073         updatePosition();
00074         scheduleAt(simTime() + updateInterval, msg);
00075         break;
00076     case MK_CHANGE_DIR:
00077         currentAngle += changeAngleBy->doubleValue();
00078         currentSpeed = speed->doubleValue();
00079         step.x = currentSpeed * cos(PI * currentAngle / 180) * updateInterval;
00080         step.y = currentSpeed * sin(PI * currentAngle / 180) * updateInterval;
00081         scheduleAt(simTime() + changeInterval->doubleValue(), msg);
00082         break;
00083     default:
00084         opp_error("Unknown self message kind in MassMobility class");
00085         break;
00086     }
00087 
00088 }

void MassMobility::initialize int  stage  )  [protected, virtual]
 

Initializes mobility model parameters.

Reads the updateInterval and the velocity

If the host is not stationary it calculates a random position and schedules a timer to trigger the first movement

Reimplemented from BasicMobility.

00039 {
00040     BasicMobility::initialize(stage);
00041 
00042     EV << "initializing MassMobility stage " << stage << endl;
00043 
00044     if (stage == 0)
00045     {
00046         updateInterval = par("updateInterval");
00047 
00048         changeInterval = &par("changeInterval");
00049         changeAngleBy = &par("changeAngleBy");
00050         speed = &par("speed");
00051 
00052         // initial speed and angle
00053         currentSpeed = speed->doubleValue();
00054         currentAngle = uniform(0, 360);
00055         step.x = currentSpeed * cos(PI * currentAngle / 180) * updateInterval;
00056         step.y = currentSpeed * sin(PI * currentAngle / 180) * updateInterval;
00057 
00058         scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move", MK_UPDATE_POS));
00059         scheduleAt(simTime() + uniform(0, changeInterval->doubleValue()), new cMessage("turn", MK_CHANGE_DIR));
00060     }
00061 }

void MassMobility::move  )  [protected]
 

Move the host.

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

00095 {
00096     pos += step;
00097 
00098     // do something if we reach the wall
00099     Coord dummy;
00100     handleIfOutside(REFLECT, dummy, step, currentAngle);
00101 
00102     EV << " xpos= " << pos.x << " ypos=" << pos.y << " speed=" << currentSpeed << endl;
00103 }


Member Data Documentation

cPar* MassMobility::changeAngleBy [protected]
 

cPar* MassMobility::changeInterval [protected]
 

double MassMobility::currentAngle [protected]
 

angle of linear motion

double MassMobility::currentSpeed [protected]
 

speed of the host

cPar* MassMobility::speed [protected]
 

Coord MassMobility::step [protected]
 

calculated from speed, angle and updateInterval

double MassMobility::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:23 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1