#include <CircleMobility.h>
Inheritance diagram for CircleMobility:
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 | |
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 |
|
Called upon arrival of a self messages.
Reimplemented from BasicMobility. 00060 { 00061 move(); 00062 updatePosition(); 00063 scheduleAt(simTime() + updateInterval, msg); 00064 }
|
|
Initializes mobility model parameters.
Reimplemented from BasicMobility. 00027 { 00028 BasicMobility::initialize(stage); 00029 00030 EV << "initializing CircleMobility stage " << stage << endl; 00031 00032 if (stage == 1) 00033 { 00034 // read parameters 00035 cx = par("cx"); 00036 cy = par("cy"); 00037 r = par("r"); 00038 ASSERT(r>0); 00039 angle = par("startAngle").doubleValue()/180.0*PI; 00040 updateInterval = par("updateInterval"); 00041 double speed = par("speed"); 00042 omega = speed/r; 00043 00044 // calculate initial position 00045 pos.x = cx + r * cos(angle); 00046 pos.y = cy + r * sin(angle); 00047 updatePosition(); 00048 00049 // if the initial speed is lower than 0, the node is stationary 00050 stationary = (speed == 0); 00051 00052 // host moves the first time after some random delay to avoid synchronized movements 00053 if (!stationary) 00054 scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move")); 00055 } 00056 }
|
|
Move the host.
00067 { 00068 angle += omega * updateInterval; 00069 pos.x = cx + r * cos(angle); 00070 pos.y = cy + r * sin(angle); 00071 00072 EV << " xpos= " << pos.x << " ypos=" << pos.y << endl; 00073 }
|
|
direction from the centre of the circle
|
|
|
|
|
|
angular velocity [rad/s], derived from speed and radius
|
|
|
|
if true, the host doesn't move
|
|
time interval to update the hosts position
|