#include <LinearMobility.h>
Inheritance diagram for LinearMobility:

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 | 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 | |
|
|
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. Reimplemented from BasicMobility. 00056 {
00057 move();
00058 updatePosition();
00059 if (!stationary)
00060 scheduleAt(simTime() + updateInterval, msg);
00061 }
|
|
|
Initializes mobility model parameters.
Reimplemented from BasicMobility. 00028 {
00029 BasicMobility::initialize(stage);
00030
00031 EV << "initializing LinearMobility stage " << stage << endl;
00032
00033 if (stage == 0)
00034 {
00035 updateInterval = par("updateInterval");
00036 speed = par("speed");
00037 angle = par("angle");
00038 acceleration = par("acceleration");
00039 angle = fmod(angle,360);
00040
00041 // if the initial speed is lower than 0, the node is stationary
00042 stationary = (speed == 0);
00043
00044 // host moves the first time after some random delay to avoid synchronized movements
00045 if (!stationary)
00046 scheduleAt(simTime() + uniform(0, updateInterval), new cMessage("move"));
00047 }
00048 }
|
|
|
Move the host. Move the host if the destination is not reached yet. Otherwise calculate a new random position 00068 {
00069 pos.x += speed * cos(PI * angle / 180) * updateInterval;
00070 pos.y += speed * sin(PI * angle / 180) * updateInterval;
00071
00072 // do something if we reach the wall
00073 Coord dummy;
00074 handleIfOutside(REFLECT, dummy, dummy, angle);
00075
00076 // accelerate
00077 speed += acceleration * updateInterval;
00078 if (speed <= 0)
00079 {
00080 speed = 0;
00081 stationary = true;
00082 }
00083
00084 EV << " xpos= " << pos.x << " ypos=" << pos.y << " speed=" << speed << endl;
00085 }
|
|
|
acceleration of linear motion
|
|
|
angle of linear motion
|
|
|
speed of the host
|
|
|
if true, the host doesn't move
|
|
|
time interval to update the hosts position
|
1.4.1