diff --git a/src/node/mobility-model.h b/src/node/mobility-model.h index f483378ad..4c4cf9000 100644 --- a/src/node/mobility-model.h +++ b/src/node/mobility-model.h @@ -43,16 +43,19 @@ public: /** * \returns the current position - * Unit is meters */ Position Get (void) const; + /** + * \param position the position to set. + */ void Set (const Position &position); + /** + * \returns the current position. + */ Speed GetSpeed (void) const; /** - * \param position a reference to another position object instance - * \returns the distance between the two objects. - * - * Unit is meters + * \param position a reference to another mobility model + * \returns the distance between the two objects. Unit is meters. */ double GetDistanceFrom (const MobilityModel &position) const; protected: @@ -63,17 +66,25 @@ protected: void NotifyCourseChange (void) const; private: /** - * \param x reference to floating-point variable for x coordinate. - * \param y reference to floating-point variable for y coordinate. - * \param z reference to floating-point variable for z coordinate. + * \returns the current position. * - * Store in the x, y, and z variables the current coordinates - * managed by this position object. Concrete subclasses of this - * base class must implement this method. - * Unit is meters + * Concrete subclasses of this base class must + * implement this method. */ virtual Position DoGet (void) const = 0; + /** + * \param position the position to set. + * + * Concrete subclasses of this base class must + * implement this method. + */ virtual void DoSet (const Position &position) = 0; + /** + * \returns the current speed. + * + * Concrete subclasses of this base class must + * implement this method. + */ virtual Speed DoGetSpeed (void) const = 0; }; diff --git a/src/node/random-walk-2d-mobility-model.cc b/src/node/random-walk-2d-mobility-model.cc index b8530ce4f..158a32244 100644 --- a/src/node/random-walk-2d-mobility-model.cc +++ b/src/node/random-walk-2d-mobility-model.cc @@ -84,6 +84,36 @@ RandomWalk2dMobilityModelParameters::~RandomWalk2dMobilityModelParameters () m_direction = 0; } +void +RandomWalk2dMobilityModelParameters::SetSpeed (const RandomVariable &speed) +{ + delete m_speed; + m_speed = speed.Copy (); +} +void +RandomWalk2dMobilityModelParameters::SetDirection (const RandomVariable &direction) +{ + delete m_direction; + m_direction = direction.Copy (); +} +void +RandomWalk2dMobilityModelParameters::SetModeDistance (double distance) +{ + m_mode = RandomWalk2dMobilityModelParameters::MODE_DISTANCE; + m_modeDistance = distance; +} +void +RandomWalk2dMobilityModelParameters::SetModeTime (Time time) +{ + m_mode = RandomWalk2dMobilityModelParameters::MODE_TIME; + m_modeTime = time; +} +void +RandomWalk2dMobilityModelParameters::SetBounds (const Rectangle &bounds) +{ + m_bounds = bounds; +} + Ptr RandomWalk2dMobilityModelParameters::GetCurrent (void) { diff --git a/src/node/random-walk-2d-mobility-model.h b/src/node/random-walk-2d-mobility-model.h index d1cbd9aef..2e921216b 100644 --- a/src/node/random-walk-2d-mobility-model.h +++ b/src/node/random-walk-2d-mobility-model.h @@ -34,7 +34,10 @@ namespace ns3 { class RandomVariable; /** - * \brief parameters to control a random walk model + * \brief parameters to control a random walk 2d model + * + * A single parameter object can be shared by multiple random + * walk models. */ class RandomWalk2dMobilityModelParameters : public Object { @@ -46,21 +49,37 @@ class RandomWalk2dMobilityModelParameters : public Object RandomWalk2dMobilityModelParameters (); virtual ~RandomWalk2dMobilityModelParameters (); /** + * \param speed the random variable used to pick a new + * speed when the direction is changed. + * */ void SetSpeed (const RandomVariable &speed); + /** + * \param direction the random variable used to pick a new + * direction. + */ void SetDirection (const RandomVariable &direction); /** * \param distance the distance before a direction change * - * Unit is meters + * Unit is meters. + * "time" mode is incompatible with "distance" mode. */ void SetModeDistance (double distance); /** * \param time the delay before a direction change. + * + * "time" mode is incompatible with "distance" mode. */ void SetModeTime (Time time); + /** + * \param bounds the bounds of the random walk + */ + void SetBounds (const Rectangle &bounds); + + // needed public for internal default value code. enum Mode { MODE_DISTANCE, MODE_TIME @@ -81,13 +100,13 @@ class RandomWalk2dMobilityModelParameters : public Object * \brief a 2D random walk position model * * Each instance moves with a speed and direction choosen at random - * in the intervals [minspeed,maxspeed] and [0,2pi] until + * with the user-provided random variables until * either a fixed distance has been walked or until a fixed amount * of time. * * The parameters of the model can be specified either with the ns3::Bind - * function and the variables "RandomWalk2dMinSpeed", "RandomWalk2dMaxSpeed", - * "RandomWalk2dMode", "RandomWalk2dModeDistance", and, "RandomWalk2dModeTime" or + * function and the variables "RandomWalk2dSpeed", "RandomWalk2dMode", + * "RandomWalk2dDistance", "RandomWalk2dTime", and, "RandomWalk2dBounds" or * with an instance of the RandomWalk2dMobilityModelParameters class which * must be fed to the RandomWalk2dMobilityModel constructors. */ @@ -100,7 +119,11 @@ class RandomWalk2dMobilityModel : public MobilityModel */ RandomWalk2dMobilityModel (); /** - * Create a new position object located at position (0,0,0) + * \param parameters the parameters to use to control + * the movement of this mobile object. + * + * Create a new position object located at position (0,0,0) with + * the specified parameters. */ RandomWalk2dMobilityModel (Ptr parameters);