INET Framework for OMNeT++/OMNEST
inet::StaticConcentricMobility Class Reference

Mobility model which places all hosts on concenctric circles. More...

#include <StaticConcentricMobility.h>

Inheritance diagram for inet::StaticConcentricMobility:
inet::StationaryMobility inet::MobilityBase inet::IMobility

Public Member Functions

 StaticConcentricMobility ()
 
- Public Member Functions inherited from inet::StationaryMobility
 StationaryMobility ()
 
 StationaryMobility (Coord position)
 
virtual Coord getCurrentPosition () override
 Returns the current position at the current simulation time. More...
 
virtual Coord getCurrentSpeed () override
 Returns the current speed at the current simulation time. More...
 
virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
virtual Coord getConstraintAreaMax () const override
 Returns the current angular acceleration at the current simulation time. More...
 
virtual Coord getConstraintAreaMin () const override
 
- Public Member Functions inherited from inet::MobilityBase
virtual EulerAngles getCurrentAngularPosition () override
 Returns the current acceleration at the current simulation time. More...
 
virtual EulerAngles getCurrentAngularSpeed () override
 Returns the current angular speed at the current simulation time. More...
 
- Public Member Functions inherited from inet::IMobility
virtual ~IMobility ()
 

Protected Member Functions

virtual void setInitialPosition () override
 Initializes the position according to the mobility model. More...
 
- Protected Member Functions inherited from inet::StationaryMobility
virtual void handleSelfMessage (cMessage *message) override
 Never happens. More...
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
virtual int numInitStages () const override
 Returns the required number of initialize stages. More...
 
virtual void initialize (int stage) override
 Initializes mobility model parameters. More...
 
virtual void initializePosition ()
 Initializes mobility position. More...
 
virtual void checkPosition ()
 Checks whether the position is valid or not. More...
 
virtual void initializeOrientation ()
 Initializes the orientation from module parameters. More...
 
virtual void handleMessage (cMessage *msg) override
 This modules should only receive self-messages. More...
 
virtual void updateVisualRepresentation ()
 Moves the visual representation module's icon to the new position on the screen. More...
 
virtual void emitMobilityStateChangedSignal ()
 Emits a signal with the updated mobility state. More...
 
virtual Coord getRandomPosition ()
 Returns a new random position satisfying the constraint area. More...
 
virtual cModule * findVisualRepresentation ()
 Returns the module that represents the object moved by this mobility module. More...
 
virtual bool isOutside ()
 Returns true if the mobility is outside of the constraint area. More...
 
virtual void reflectIfOutside (Coord &targetPosition, Coord &speed, double &angle)
 Utility function to reflect the node if it goes outside the constraint area. More...
 
virtual void wrapIfOutside (Coord &targetPosition)
 Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area. More...
 
virtual void placeRandomlyIfOutside (Coord &targetPosition)
 Utility function to place the node randomly if it goes outside the constraint area. More...
 
virtual void raiseErrorIfOutside ()
 Utility function to raise an error if the node gets outside the constraint area. More...
 
virtual void handleIfOutside (BorderPolicy policy, Coord &targetPosition, Coord &speed, double &angle)
 Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the given border policy. More...
 

Additional Inherited Members

- Public Types inherited from inet::MobilityBase
enum  BorderPolicy { REFLECT, WRAP, PLACERANDOMLY, RAISEERROR }
 Selects how a mobility module should behave if it reaches the edge of the constraint area. More...
 
- Static Public Attributes inherited from inet::IMobility
static simsignal_t mobilityStateChangedSignal = cComponent::registerSignal("mobilityStateChanged")
 A signal used to publish mobility state changes. More...
 
- Protected Attributes inherited from inet::MobilityBase
cModule * visualRepresentation
 Pointer to visual representation module, to speed up repeated access. More...
 
const CanvasProjectioncanvasProjection
 The 2D projection used on the canvas. More...
 
Coord constraintAreaMin
 3 dimensional position and size of the constraint area (in meters). More...
 
Coord constraintAreaMax
 
Coord lastPosition
 The last position that was reported. More...
 
EulerAngles lastOrientation
 The last position that was reported. More...
 

Detailed Description

Mobility model which places all hosts on concenctric circles.

Author
Florian Meier

Constructor & Destructor Documentation

inet::StaticConcentricMobility::StaticConcentricMobility ( )
inline
46 {};

Member Function Documentation

void inet::StaticConcentricMobility::setInitialPosition ( )
overrideprotectedvirtual

Initializes the position according to the mobility model.

Reimplemented from inet::MobilityBase.

31 {
32  unsigned int numHosts = par("numHosts");
33  double distance = par("distance");
34 
35  unsigned int index = visualRepresentation->getIndex();
36 
37  unsigned int totalCircles = 0;
38  unsigned int totalNodesOnInnerCircles = 0;
39  unsigned int nodesOnThisCircle = 1;
40 
41  unsigned int myCircle = 0;
42  unsigned int nodesOnInnerCircles = 0;
43 
44  for(unsigned int i = 0; i < numHosts; i++) {
45  if(i - totalNodesOnInnerCircles >= nodesOnThisCircle) {
46  // start new circle
47  totalCircles++;
48  totalNodesOnInnerCircles += nodesOnThisCircle;
49  nodesOnThisCircle = (int)(2*M_PI*totalCircles);
50  }
51 
52  if(i == index) {
53  myCircle = totalCircles;
54  nodesOnInnerCircles = totalNodesOnInnerCircles;
55  }
56  }
57 
58  lastPosition.x = distance*totalCircles;
59  lastPosition.y = distance*totalCircles;
60 
63  }
64 
67  }
68 
69  if(index > 0) {
70  double radius = distance*myCircle;
71  double angularStep = 2.0*M_PI/(int)(2*M_PI*myCircle);
72  double angle = angularStep*(index-nodesOnInnerCircles);
73  lastPosition.x += radius*cos(angle);
74  lastPosition.y += radius*sin(angle);
75  }
76 
77  lastPosition.z = par("initialZ");
78  recordScalar("x", lastPosition.x);
79  recordScalar("y", lastPosition.y);
80  recordScalar("z", lastPosition.z);
81 }
#define INFINITY
Definition: Topology.h:29
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
#define M_PI
Definition: PlotFigure.cc:27
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195

The documentation for this class was generated from the following files: