#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 |
void CircleMobility::initialize | ( | int | stage | ) | [protected, virtual] |
Initializes mobility model parameters.
Reimplemented from BasicMobility.
00026 { 00027 BasicMobility::initialize(stage); 00028 00029 EV << "initializing CircleMobility stage " << stage << endl; 00030 00031 if (stage == 1) 00032 { 00033 // read parameters 00034 cx = par("cx"); 00035 cy = par("cy"); 00036 r = par("r"); 00037 ASSERT(r>0); 00038 angle = par("startAngle").doubleValue()/180.0*PI; 00039 updateInterval = par("updateInterval"); 00040 double speed = par("speed"); 00041 omega = speed/r; 00042 00043 // calculate initial position 00044 pos.x = cx + r * cos(angle); 00045 pos.y = cy + r * sin(angle); 00046 updatePosition(); 00047 00048 // if the initial speed is lower than 0, the node is stationary 00049 stationary = (speed == 0); 00050 00051 // host moves the first time after some random delay to avoid synchronized movements 00052 if (!stationary) 00053 scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move")); 00054 } 00055 }
void CircleMobility::handleSelfMsg | ( | cMessage * | msg | ) | [protected, virtual] |
Called upon arrival of a self messages.
Implements BasicMobility.
00059 { 00060 move(); 00061 updatePosition(); 00062 scheduleAt(simTime() + updateInterval, msg); 00063 }
void CircleMobility::move | ( | ) | [protected, virtual] |
double CircleMobility::cx [protected] |
Referenced by initialize(), and move().
double CircleMobility::cy [protected] |
Referenced by initialize(), and move().
double CircleMobility::r [protected] |
Referenced by initialize(), and move().
double CircleMobility::omega [protected] |
double CircleMobility::updateInterval [protected] |
bool CircleMobility::stationary [protected] |
double CircleMobility::angle [protected] |