INET Framework for OMNeT++/OMNEST
CircleMobility Class Reference

Circle movement model. See NED file for more info. More...

#include <CircleMobility.h>

Inheritance diagram for CircleMobility:
BasicMobility BasicModule INotifiable

List of all members.

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

Detailed Description

Circle movement model. See NED file for more info.

Author:
Andras Varga

Definition at line 31 of file CircleMobility.h.


Member Function Documentation

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

Called upon arrival of a self messages.

Implements BasicMobility.

Definition at line 58 of file CircleMobility.cc.

{
    move();
    updatePosition();
    scheduleAt(simTime() + updateInterval, msg);
}
void CircleMobility::initialize ( int  stage) [protected, virtual]

Initializes mobility model parameters.

Reimplemented from BasicMobility.

Definition at line 25 of file CircleMobility.cc.

{
    BasicMobility::initialize(stage);

    EV << "initializing CircleMobility stage " << stage << endl;

    if (stage == 1)
    {
        // read parameters
        cx = par("cx");
        cy = par("cy");
        r = par("r");
        ASSERT(r>0);
        angle = par("startAngle").doubleValue()/180.0*PI;
        updateInterval = par("updateInterval");
        double speed = par("speed");
        omega = speed/r;

        // calculate initial position
        pos.x = cx + r * cos(angle);
        pos.y = cy + r * sin(angle);
        updatePosition();

        // if the initial speed is lower than 0, the node is stationary
        stationary = (speed == 0);

        // host moves the first time after some random delay to avoid synchronized movements
        if (!stationary)
            scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move"));
    }
}
void CircleMobility::move ( ) [protected, virtual]

Move the host.

Definition at line 65 of file CircleMobility.cc.

Referenced by handleSelfMsg().

{
    angle += omega * updateInterval;
    pos.x = cx + r * cos(angle);
    pos.y = cy + r * sin(angle);

    EV << " xpos= " << pos.x << " ypos=" << pos.y << endl;
}

Member Data Documentation

double CircleMobility::angle [protected]

direction from the centre of the circle

Definition at line 43 of file CircleMobility.h.

Referenced by initialize(), and move().

double CircleMobility::cx [protected]

Definition at line 35 of file CircleMobility.h.

Referenced by initialize(), and move().

double CircleMobility::cy [protected]

Definition at line 36 of file CircleMobility.h.

Referenced by initialize(), and move().

double CircleMobility::omega [protected]

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

Definition at line 38 of file CircleMobility.h.

Referenced by initialize(), and move().

double CircleMobility::r [protected]

Definition at line 37 of file CircleMobility.h.

Referenced by initialize(), and move().

bool CircleMobility::stationary [protected]

if true, the host doesn't move

Definition at line 40 of file CircleMobility.h.

Referenced by initialize().

double CircleMobility::updateInterval [protected]

time interval to update the hosts position

Definition at line 39 of file CircleMobility.h.

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


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