Make MobilityHelper use an output stream wrapper
This commit is contained in:
@@ -378,9 +378,8 @@ RoutingExperiment::Run (int nSinks, double txp, std::string CSVfileName)
|
||||
//AsciiTraceHelper ascii;
|
||||
//Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (tr_name + ".tr").c_str());
|
||||
//wifiPhy.EnableAsciiAll (osw);
|
||||
std::ofstream os;
|
||||
os.open ((tr_name + ".mob").c_str ());
|
||||
MobilityHelper::EnableAsciiAll (os);
|
||||
AsciiTraceHelper ascii;
|
||||
MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (tr_name + ".mob"));
|
||||
|
||||
//Ptr<FlowMonitor> flowmon;
|
||||
//FlowMonitorHelper flowmonHelper;
|
||||
|
||||
@@ -190,9 +190,8 @@ int main (int argc, char *argv[])
|
||||
|
||||
if (writeMobility)
|
||||
{
|
||||
std::ofstream os;
|
||||
os.open ("wifi-wired-bridging.mob");
|
||||
MobilityHelper::EnableAsciiAll (os);
|
||||
AsciiTraceHelper ascii;
|
||||
MobilityHelper::EnableAsciiAll (ascii.CreateFileStream ("wifi-wired-bridging.mob"));
|
||||
}
|
||||
|
||||
Simulator::Stop (Seconds (5.0));
|
||||
|
||||
@@ -200,8 +200,9 @@ DoRound (double v)
|
||||
}
|
||||
}
|
||||
void
|
||||
MobilityHelper::CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility)
|
||||
MobilityHelper::CourseChanged (Ptr<OutputStreamWrapper> stream, Ptr<const MobilityModel> mobility)
|
||||
{
|
||||
std::ostream* os = stream->GetStream ();
|
||||
Ptr<Node> node = mobility->GetObject<Node> ();
|
||||
*os << "now=" << Simulator::Now ()
|
||||
<< " node=" << node->GetId ();
|
||||
@@ -225,25 +226,25 @@ MobilityHelper::CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobili
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::EnableAscii (std::ostream &os, uint32_t nodeid)
|
||||
MobilityHelper::EnableAscii (Ptr<OutputStreamWrapper> stream, uint32_t nodeid)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "/NodeList/" << nodeid << "/$ns3::MobilityModel/CourseChange";
|
||||
Config::ConnectWithoutContext (oss.str (),
|
||||
MakeBoundCallback (&MobilityHelper::CourseChanged, &os));
|
||||
MakeBoundCallback (&MobilityHelper::CourseChanged, stream));
|
||||
}
|
||||
void
|
||||
MobilityHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
MobilityHelper::EnableAscii (Ptr<OutputStreamWrapper> stream, NodeContainer n)
|
||||
{
|
||||
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
|
||||
{
|
||||
EnableAscii (os, (*i)->GetId ());
|
||||
EnableAscii (stream, (*i)->GetId ());
|
||||
}
|
||||
}
|
||||
void
|
||||
MobilityHelper::EnableAsciiAll (std::ostream &os)
|
||||
MobilityHelper::EnableAsciiAll (Ptr<OutputStreamWrapper> stream)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
EnableAscii (stream, NodeContainer::GetGlobal ());
|
||||
}
|
||||
int64_t
|
||||
MobilityHelper::AssignStreams (NodeContainer c, int64_t stream)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <vector>
|
||||
#include "ns3/object-factory.h"
|
||||
#include "ns3/attribute.h"
|
||||
#include "ns3/output-stream-wrapper.h"
|
||||
#include "ns3/position-allocator.h"
|
||||
#include "node-container.h"
|
||||
|
||||
@@ -221,31 +222,31 @@ public:
|
||||
void InstallAll (void);
|
||||
|
||||
/**
|
||||
* \param os output stream
|
||||
* \param stream an output stream wrapper
|
||||
* \param nodeid the id of the node to generate ascii output for.
|
||||
*
|
||||
* Enable ascii output on the mobility model associated to the
|
||||
* specified nodeid and dump that to the specified stdc++ output
|
||||
* stream.
|
||||
*/
|
||||
static void EnableAscii (std::ostream &os, uint32_t nodeid);
|
||||
static void EnableAscii (Ptr<OutputStreamWrapper> stream, uint32_t nodeid);
|
||||
/**
|
||||
* \param os output stream
|
||||
* \param stream an output stream wrapper
|
||||
* \param n node container
|
||||
*
|
||||
* Enable ascii output on the mobility model associated each of
|
||||
* the nodes in the input container and dump that to the
|
||||
* specified stdc++ output stream.
|
||||
*/
|
||||
static void EnableAscii (std::ostream &os, NodeContainer n);
|
||||
static void EnableAscii (Ptr<OutputStreamWrapper> stream, NodeContainer n);
|
||||
/**
|
||||
* \param os output stream
|
||||
* \param stream an output stream wrapper
|
||||
*
|
||||
* Enable ascii output on the mobility model associated
|
||||
* every node in the system and dump that to the specified
|
||||
* stdc++ output stream.
|
||||
*/
|
||||
static void EnableAsciiAll (std::ostream &os);
|
||||
static void EnableAsciiAll (Ptr<OutputStreamWrapper> stream);
|
||||
/**
|
||||
* Assign a fixed random variable stream number to the random variables
|
||||
* used by the mobility models (including any position allocators assigned
|
||||
@@ -264,7 +265,7 @@ private:
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
static void CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility);
|
||||
static void CourseChanged (Ptr<OutputStreamWrapper> stream, Ptr<const MobilityModel> mobility);
|
||||
std::vector<Ptr<MobilityModel> > m_mobilityStack;
|
||||
ObjectFactory m_mobility;
|
||||
Ptr<PositionAllocator> m_position;
|
||||
|
||||
Reference in New Issue
Block a user