Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

BasicMobility Class Reference
[mobility - modules handling the mobility of the hostsbasicModules - basic module classes of the MF]

Basic module for all mobility modules. More...

#include <BasicMobility.h>

Inherits BasicModule.

Inherited by CircleMobility, ConstSpeedMobility, LinearMobility, LineSegmentsMobilityBase, MassMobility, and RectangleMobility.

Inheritance diagram for BasicMobility:

Inheritance graph
[legend]
Collaboration diagram for BasicMobility:

Collaboration graph
[legend]
List of all members.

Public Types

enum  BorderPolicy { REFLECT, WRAP, PLACERANDOMLY, RAISEERROR }
 Selects how a node should behave if it reaches the edge of the playground. More...
enum  BasicMobilityMsgKinds { MOVE_HOST = 1050198237, MOVE_TO_BORDER, LAST_BASIC }
 The kind field of messages. More...
enum  BorderHandling {
  NOWHERE, X_SMALLER, X_BIGGER, Y_SMALLER,
  Y_BIGGER
}
 Specifies which border actually has been reached. More...

Public Member Functions

 Module_Class_Members (BasicMobility, BasicModule, 0)
void handleMessage (cMessage *msg)
 This modules should only receive self-messages.
virtual void initialize (int)
 Initializes mobility model parameters.
virtual void finish ()
 Delete dynamically allocated objects.

Protected Member Functions

virtual void handleSelfMsg (cMessage *)
 Called upon arrival of a self messages.
virtual void handleBorderMsg (cMessage *)
 Called upon arrival of a border messages.
virtual void makeMove ()
 Moves the host.
virtual Coord getRandomPosition ()
 Get a new random position for the host.
void updatePosition ()
 Update the position information for this node.
double playgroundSizeX () const
 Returns the width of the playground.
double playgroundSizeY () const
 Returns the height of the playground.
Border handling
Utility functions to handle hosts that move outside the playground

bool handleIfOutside (BorderPolicy, Coord &, Coord &, Coord &, double &)
 Main border handling function.
virtual void fixIfHostGetsOutside ()
 Should be redefined in subclasses.
BorderHandling checkIfOutside (Coord, Coord &)
 Checks whether the host is outside the playground and returns where.
void goToBorder (BorderPolicy, BorderHandling, Coord &, Coord &)
 calculate the step to reach the border
void reflectIfOutside (BorderHandling, Coord &, Coord &, Coord &, double &)
 Utility function to reflect the node if it goes outside the playground.
void wrapIfOutside (BorderHandling, Coord &, Coord &)
 Utility function to wrap the node to the opposite edge (torus) if it goes outside the playground.
void placeRandomlyIfOutside (Coord &)
 Utility function to place the node randomly if it goes outside the playground.

Protected Attributes

ChannelControlcc
 Pointer to ChannelControl -- these two must know each other.
cModule * hostPtr
 Pointer to host module, to speed up repeated access.
int hostId
HostMove move
 Stores the current position and move pattern of the host.
int moveCategory
 Store the category of HostMove.
double updateInterval
 Time interval to update the hosts position.
cMessage * moveMsg
 Self message to trigger movement.
bool coreDebug
 debug this core module?

Detailed Description

Basic module for all mobility modules.

It does not provide mobility at all, so you can use it if you only want to simulate static networks.

BasicMobility provides random placement of hosts and display updates as well as registering with the ChannelControl module. Change notifications about position changes are also posted to the Blackboard.

Another service provided by BasicMobility is bordfer handling. If a host wants to move outside the playground, this situation has to be handled somehow. BasicMobility provides handling for the 4 most common ways for that: reflection, wrapping, random placement and raising an error. The only thing you have to do is to specify your desired border handling in fixIfHostGetsOutside and call it in makeMove.

For most mobility modules the only two functions you need to implement to define your own mobility module are makeMove and fixIfHostGetsOutside..

Author:
Daniel Willkomm, Andras Varga


Member Enumeration Documentation

enum BasicMobility::BasicMobilityMsgKinds
 

The kind field of messages.

that are used internally by this class have one of these values

enum BasicMobility::BorderHandling
 

Specifies which border actually has been reached.

Enumerator:
NOWHERE  not outside the playground
X_SMALLER  x smaller than 0
X_BIGGER  x bigger than playground size
Y_SMALLER  y smaller than 0
Y_BIGGER  y bigger than playground size

enum BasicMobility::BorderPolicy
 

Selects how a node should behave if it reaches the edge of the playground.

See also:
handleIfOutside()
Enumerator:
REFLECT  reflect off the wall
WRAP  reappear at the opposite edge (torus)
PLACERANDOMLY  placed at a randomly chosen position on the playground
RAISEERROR  stop the simulation with error


Member Function Documentation

BasicMobility::BorderHandling BasicMobility::checkIfOutside Coord  targetPos,
Coord borderStep
[protected]
 

Checks whether the host is outside the playground and returns where.

Checks whether the host moved outside and return the border it crossed.

Additionally the calculation of the step to reach the border is started.

virtual void BasicMobility::fixIfHostGetsOutside  )  [inline, protected, virtual]
 

Should be redefined in subclasses.

Should invoke handleIfOutside() and pass the references to the parameters to be modified.

Additional action after border handling (such as choosing a new target position if the BorderPolicy is PLACERANDOMLY) should be implemented here.

See also:
HandleIfOutside

Reimplemented in ANSimMobility, BonnMotionMobility, CircleMobility, LinearMobility, MassMobility, RectangleMobility, and TurtleMobility.

Coord BasicMobility::getRandomPosition  )  [protected, virtual]
 

Get a new random position for the host.

You can redefine this function if you want to use another calculation

void BasicMobility::goToBorder BorderPolicy  policy,
BorderHandling  wo,
Coord borderStep,
Coord borderStart
[protected]
 

calculate the step to reach the border

Calculate the step to reach the border. Additionally for the WRAP policy the new start position after reaching the border is calculated.

void BasicMobility::handleBorderMsg cMessage *  msg  )  [protected, virtual]
 

Called upon arrival of a border messages.

The host actually reached the border, so the startPos has to be updated.

Additionally fixIfHostGetsOutside has to be called again to catch cases where the host moved in both (x and y) direction outside the playground.

bool BasicMobility::handleIfOutside BorderPolicy  policy,
Coord stepTarget,
Coord targetPos,
Coord step,
double &  angle
[protected]
 

Main border handling function.

This function takes the BorderPolicy and all varaibles to be modified in case a border is reached and invokes the appropriate action. Pass dummy variables if you do not need them.

The supproted border policies are REFLECT, WRAP, PLACERANOMLY, and RAISEERROR.

The policy and stepTarget are mandatory parameters to pass. stepTarget is used to check whether the host actually moved outside the playground.

Additional parameters to pass (in case of non atomic movements) can be targetPos (the target the host is moving to) and step (the size of a step).

Angle is the direction in which the host is moving.

Parameters:
policy BorderPolicy to use
stepTarget target position of the next step of the host
targetPos target position of the host (for non atomic movement)
step step size of the host (for non atomic movement)
angle direction in which the host is moving
Returns:
true if host was outside, false otherwise.

void BasicMobility::handleMessage cMessage *  msg  ) 
 

This modules should only receive self-messages.

Dispatches border messages to handleBorderMsg() and all other self-messages to handleSelfMsg()

void BasicMobility::handleSelfMsg cMessage *  msg  )  [protected, virtual]
 

Called upon arrival of a self messages.

The only self message possible is to indicate a new movement. If the host is stationary this function is never called.

every time a self message arrives makeMove is called to handle the movement. Afterward updatePosition updates the position with the blackboard and the display.

Reimplemented in LineSegmentsMobilityBase, and MassMobility.

void BasicMobility::initialize int  stage  )  [virtual]
 

Initializes mobility model parameters.

Assigns a pointer to ChannelControl and gets a pointer to its host.

Creates a random position for a host if the position is not given as a parameter in "omnetpp.ini".

Additionally the registration with ChannelControl is done and it is assured that the position display string tag (p) exists and contains the exact (x) tag.

If the speed of the host is bigger than 0 a first MOVE_HOST self message is scheduled in stage 1

Reimplemented from BasicModule.

Reimplemented in ANSimMobility, BonnMotionMobility, CircleMobility, ConstSpeedMobility, LinearMobility, MassMobility, RectangleMobility, and TurtleMobility.

virtual void BasicMobility::makeMove  )  [inline, protected, virtual]
 

Moves the host.

This function is called every time a MOVE_HOST self message arrives. Here you can define the movement pattern for your host.

You should call fixIfHostGetsOutside here for border handling

Reimplemented in CircleMobility, ConstSpeedMobility, LinearMobility, MassMobility, and RectangleMobility.

void BasicMobility::placeRandomlyIfOutside Coord targetPos  )  [protected]
 

Utility function to place the node randomly if it goes outside the playground.

Start the host at a new random position. Here the target position is set to the new start position.

You have to define a new target postion in fixIfHostGetsOutside to keep the host moving.

void BasicMobility::reflectIfOutside BorderHandling  wo,
Coord stepTarget,
Coord targetPos,
Coord step,
double &  angle
[protected]
 

Utility function to reflect the node if it goes outside the playground.

Reflects the host from the playground border.

This function can update the target position, the step (for non atomic movements) and the angle.

Parameters:
stepTarget target position of the current step of the host
targetPos target position of the host (for non atomic movements)
step step size and direction of the host (for non atomic movements)
angle direction to which the host is moving

void BasicMobility::updatePosition  )  [protected]
 

Update the position information for this node.

This function tells the Blackboard that the position has changed, and it also moves the host's icon to the new position on the screen.

This function has to be called every time the position of the host changes!

void BasicMobility::wrapIfOutside BorderHandling  wo,
Coord stepTarget,
Coord targetPos
[protected]
 

Utility function to wrap the node to the opposite edge (torus) if it goes outside the playground.

Wraps the host to the other playground size. Updates the target position.

Parameters:
stepTarget target position of the current step of the host
targetPos target position of the host (for non atomic movements)


The documentation for this class was generated from the following files:
Generated on Fri Jan 12 08:29:41 2007 for Mobility Framework by  doxygen 1.4.4