Skip to content

Commit

Permalink
mobility: Allow AssignStreams after construction for SteadyStateRwpMo…
Browse files Browse the repository at this point in the history
…bility

The SteadyStateRandomWaypointMobilityModel should support AssignStreams()
after object construction, but prior to this patch, it would cause a
segmentation fault until after initialization.  The initial benefit is
the prevention of test suite failures due to random stream assignment.
  • Loading branch information
tomhenderson committed Oct 2, 2018
1 parent 8127d79 commit 1e986d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ SteadyStateRandomWaypointMobilityModel::SteadyStateRandomWaypointMobilityModel (
m_u_r = CreateObject<UniformRandomVariable> ();
m_x = CreateObject<UniformRandomVariable> ();
m_y = CreateObject<UniformRandomVariable> ();
m_position = CreateObject<RandomBoxPositionAllocator> ();
}

void
Expand All @@ -115,7 +116,6 @@ SteadyStateRandomWaypointMobilityModel::DoInitializePrivate (void)
m_speed->SetAttribute ("Max", DoubleValue (m_maxSpeed));
NS_ASSERT (m_minX < m_maxX);
NS_ASSERT (m_minY < m_maxY);
m_position = CreateObject<RandomBoxPositionAllocator> ();
m_x->SetAttribute ("Min", DoubleValue (m_minX));
m_x->SetAttribute ("Max", DoubleValue (m_maxX));
m_y->SetAttribute ("Min", DoubleValue (m_minY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SteadyStateRandomWaypointTest::DoRun (void)
{
// Create a new mobility model.
Ptr<MobilityModel> model = mobilityFactory.Create ()->GetObject<MobilityModel> ();

model->AssignStreams (100 * (i + 1));
// Add this mobility model to the stack.
mobilityStack.push_back (model);
Simulator::Schedule (Seconds (0.0), &Object::Initialize, model);
Expand Down

0 comments on commit 1e986d4

Please sign in to comment.