INET Framework for OMNeT++/OMNEST
|
Circle movement model. See NED file for more info. More...
#include <CircleMobility.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 | 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 |
Circle movement model. See NED file for more info.
void CircleMobility::handleSelfMsg | ( | cMessage * | msg | ) | [protected, virtual] |
Called upon arrival of a self messages.
Implements BasicMobility.
{ move(); updatePosition(); scheduleAt(simTime() + updateInterval, msg); }
void CircleMobility::initialize | ( | int | stage | ) | [protected, virtual] |
Initializes mobility model parameters.
Reimplemented from BasicMobility.
{ 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] |
double CircleMobility::angle [protected] |
direction from the centre of the circle
Referenced by initialize(), and move().
double CircleMobility::cx [protected] |
Referenced by initialize(), and move().
double CircleMobility::cy [protected] |
Referenced by initialize(), and move().
double CircleMobility::omega [protected] |
angular velocity [rad/s], derived from speed and radius
Referenced by initialize(), and move().
double CircleMobility::r [protected] |
Referenced by initialize(), and move().
bool CircleMobility::stationary [protected] |
if true, the host doesn't move
Referenced by initialize().
double CircleMobility::updateInterval [protected] |
time interval to update the hosts position
Referenced by handleSelfMsg(), initialize(), and move().