#include <BonnMotionMobility.h>
Protected Member Functions | |
virtual | ~BonnMotionMobility () |
virtual void | initialize (int) |
Initializes mobility model parameters. | |
virtual void | setTargetPosition () |
Overridden from LineSegmentsMobilityBase. | |
virtual void | fixIfHostGetsOutside () |
Overridden from LineSegmentsMobilityBase. | |
Protected Attributes | |
const BonnMotionFile::Line * | vecp |
int | vecpos |
BonnMotionMobility::~BonnMotionMobility | ( | ) | [protected, virtual] |
void BonnMotionMobility::initialize | ( | int | stage | ) | [protected, virtual] |
Initializes mobility model parameters.
Reimplemented from LineSegmentsMobilityBase.
00027 { 00028 LineSegmentsMobilityBase::initialize(stage); 00029 00030 EV << "initializing BonnMotionMobility stage " << stage << endl; 00031 00032 if (stage == 1) 00033 { 00034 int nodeId = par("nodeId"); 00035 if (nodeId == -1) 00036 nodeId = getParentModule()->getIndex(); 00037 00038 const char *fname = par("traceFile"); 00039 const BonnMotionFile *bmFile = BonnMotionFileCache::getInstance()->getFile(fname); 00040 00041 vecp = bmFile->getLine(nodeId); 00042 if (!vecp) 00043 error("invalid nodeId %d -- no such line in file '%s'", nodeId, fname); 00044 vecpos = 0; 00045 00046 // obtain initial position 00047 const BonnMotionFile::Line& vec = *vecp; 00048 if (vec.size()>=3) 00049 { 00050 pos.x = vec[1]; 00051 pos.y = vec[2]; 00052 targetPos = pos; 00053 } 00054 updatePosition(); 00055 } 00056 }
void BonnMotionMobility::setTargetPosition | ( | ) | [protected, virtual] |
Overridden from LineSegmentsMobilityBase.
Implements LineSegmentsMobilityBase.
00064 { 00065 const BonnMotionFile::Line& vec = *vecp; 00066 00067 if (vecpos+2 >= (int)vec.size()) 00068 { 00069 stationary = true; 00070 return; 00071 } 00072 00073 targetTime = vec[vecpos]; 00074 targetPos.x = vec[vecpos+1]; 00075 targetPos.y = vec[vecpos+2]; 00076 vecpos += 3; 00077 00078 EV << "TARGET: t=" << targetTime << " (" << targetPos.x << "," << targetPos.y << ")\n"; 00079 }
void BonnMotionMobility::fixIfHostGetsOutside | ( | ) | [protected, virtual] |
Overridden from LineSegmentsMobilityBase.
Implements LineSegmentsMobilityBase.
00082 { 00083 raiseErrorIfOutside(); 00084 }
const BonnMotionFile::Line* BonnMotionMobility::vecp [protected] |
Referenced by initialize(), and setTargetPosition().
int BonnMotionMobility::vecpos [protected] |
Referenced by initialize(), and setTargetPosition().