next up previous
Next: Mobility models Up: MIRACLE How-To Previous: MIRACLE

Position Class

This class manages informations about position of nodes whithin the simulation field. The two particular mobility models we'll see afterwards inherit from Position Class. This class exchanges with Node Core informations which characterize the whole node and can be used at every layer of the protocol stack. Node Core has the rule of provide and maintain node position informations. Every Module or PlugIn refers to Node Core for this kind of data. Position infos are managed by Position class.

In order to be able to operate on Position class objects, you have to declare class in the header file (*.h). So add:

#include "node-core.h"
which tells to compiler where class is defined, and then explicitly recall the class name
 Class Position;
at the beginning of the header file. Now your module knows how to manage this kind of data. Then insert the following lines in the *.cc file, when methods are defined:

Position* pos = getPosition();
printf("Position: %f %f\n", pos->getX(), pos->getY());
There you call getPosition() methods which immediately asks Node Core for position datas. The rest of code allows you to print the current coordinates of your node. Methods getX() getY() return respectively the x and the y coordinate in the field. We stress that what we presented above refers to the getPosition() method. This belongs to PlugIn class, so only these kind of objects (e.g. Modules) can manage such data.

next up previous
Next: Mobility models Up: MIRACLE How-To Previous: MIRACLE
nsmiracle-users mailing list