21 #include "ns3/simulator.h"
22 #include "ns3/boolean.h"
23 #include "ns3/config.h"
24 #include "ns3/waypoint-mobility-model.h"
33 :
TestCase (lazy ?
"Check Waypoint Mobility Model LAZY notification accuracy"
34 :
"Check Waypoint Mobility Model NON-LAZY notification accuracy"),
49 virtual void DoRun (
void);
50 virtual void DoTeardown (
void);
51 void ForceUpdates (
void);
58 mobilityStack.clear();
69 mobilityFactory.
SetTypeId (
"ns3::WaypointMobilityModel");
73 for (uint32_t i = 0; i < mobilityCount; i++)
79 mobilityStack.push_back (model);
86 for ( uint32_t iw = 0; iw < waypointCount; ++iw )
89 waypoints.push_back (wpt);
93 std::vector<Ptr<MobilityModel> >::iterator i;
94 for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
99 for ( std::deque<Waypoint>::iterator
w = waypoints.begin ();
w != waypoints.end (); ++
w )
106 for (
double updateTime = 0.5; updateTime <= ((double)waypointCount + 1.5); updateTime += 1.0 )
118 std::vector<Ptr<MobilityModel> >::iterator i;
119 for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
138 "Course didn't change on one second time boundary with NON-LAZY notifications");
144 "Course didn't change between waypoints with LAZY notifications");
152 :
TestCase (
"Check Waypoint Mobility Model waypoint add")
165 virtual void DoRun (
void);
166 virtual void DoTeardown (
void);
180 m_waypointCount = 10;
181 m_waypointCounter = 1;
184 mobilityFactory.
SetTypeId (
"ns3::WaypointMobilityModel");
195 Waypoint m_nextWaypoint (
Seconds (m_waypointCounter), Vector (0.0, 0.0, 0.0));
209 std::cout << now <<
" CourseChangeCallback" << std::endl;
213 if (now <
Seconds ((
double)m_waypointCount) )
215 m_waypointCounter ++;
216 m_nextWaypoint =
Waypoint (
Seconds (m_waypointCounter), Vector (0.0, 0.0, 0.0));
Simulation virtual time values and global simulation resolution.
Time time
The waypoint time.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
WaypointMobilityModelTestSuite g_waypointMobilityModelTestSuite
void CourseChangeCallback(Ptr< const MobilityModel > model)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void AddWaypoint(const Waypoint &waypoint)
virtual void DoRun(void)
Implementation to actually run this TestCase.
static void Run(void)
Run the simulation.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
static void CourseChangeCallback(std::string path, Ptr< const MobilityModel > model)
virtual ~WaypointMobilityModelNotifyTest()
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
WaypointMobilityModelAddWaypointTest()
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Ptr< MobilityModel > m_mobilityModel
void Update(void) const
Update the underlying state corresponding to the stored waypoints.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual ~WaypointMobilityModelAddWaypointTest()
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void CourseChangeCallback(Ptr< const MobilityModel > model)
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
static Time Now(void)
Return the current simulation virtual time.
Instantiate subclasses of ns3::Object.
WaypointMobilityModelNotifyTest(bool lazy)
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
Waypoint m_current
The ns3::Waypoint currently being used.
Waypoint-based mobility model.
std::deque< Waypoint > waypoints
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
WaypointMobilityModelTestSuite()
uint32_t m_waypointCounter
std::vector< Ptr< MobilityModel > > mobilityStack
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.