INET Framework for OMNeT++/OMNEST
|
Linear movement model. See NED file for more info. More...
#include <LinearMobility.h>
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 |
Linear movement model. See NED file for more info.
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.
{ move(); updatePosition(); if (!stationary) scheduleAt(simTime() + updateInterval, msg); }
void LinearMobility::initialize | ( | int | stage | ) | [protected, virtual] |
Initializes mobility model parameters.
Reimplemented from BasicMobility.
{ BasicMobility::initialize(stage); EV << "initializing LinearMobility stage " << stage << endl; if (stage == 0) { updateInterval = par("updateInterval"); speed = par("speed"); angle = par("angle"); acceleration = par("acceleration"); angle = fmod(angle,360); // 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 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().
{ pos.x += speed * cos(PI * angle / 180) * updateInterval; pos.y += speed * sin(PI * angle / 180) * updateInterval; // do something if we reach the wall Coord dummy; handleIfOutside(REFLECT, dummy, dummy, angle); // accelerate speed += acceleration * updateInterval; if (speed <= 0) { speed = 0; stationary = true; } EV << " xpos= " << pos.x << " ypos=" << pos.y << " speed=" << speed << endl; }
double LinearMobility::acceleration [protected] |
acceleration of linear motion
Referenced by initialize(), and move().
double LinearMobility::angle [protected] |
angle of linear motion
Referenced by initialize(), and move().
double LinearMobility::speed [protected] |
speed of the host
Referenced by initialize(), and move().
bool LinearMobility::stationary [protected] |
if true, the host doesn't move
Referenced by handleSelfMsg(), initialize(), and move().
double LinearMobility::updateInterval [protected] |
time interval to update the hosts position
Referenced by handleSelfMsg(), initialize(), and move().