#include <BasicMobility.h>
Inherits BasicModule.
Inherited by CircleMobility, ConstSpeedMobility, LinearMobility, LineSegmentsMobilityBase, MassMobility, and RectangleMobility.
Inheritance diagram for BasicMobility:
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 | |
ChannelControl * | cc |
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? |
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..
|
The kind field of messages. that are used internally by this class have one of these values |
|
Specifies which border actually has been reached.
|
|
Selects how a node should behave if it reaches the edge of the playground.
|
|
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. |
|
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.
Reimplemented in ANSimMobility, BonnMotionMobility, CircleMobility, LinearMobility, MassMobility, RectangleMobility, and TurtleMobility. |
|
Get a new random position for the host. You can redefine this function if you want to use another calculation |
|
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. |
|
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. |
|
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.
|
|
This modules should only receive self-messages. Dispatches border messages to handleBorderMsg() and all other self-messages to handleSelfMsg() |
|
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. |
|
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. |
|
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. |
|
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. |
|
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.
|
|
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! |
|
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.
|