--- a/src/helper/mobility-helper.cc Mon Jul 28 08:59:05 2008 -0700
+++ b/src/helper/mobility-helper.cc Mon Jul 28 09:03:10 2008 -0700
@@ -23,6 +23,8 @@
#include "ns3/hierarchical-mobility-model.h"
#include "ns3/log.h"
#include "ns3/pointer.h"
+#include "ns3/config.h"
+#include "ns3/simulator.h"
namespace ns3 {
@@ -153,4 +155,38 @@
Install (NodeContainer::GetGlobal ());
}
+void
+MobilityHelper::CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility)
+{
+ Ptr<Node> node = mobility->GetObject<Node> ();
+ *os << "now=" << Simulator::Now ()
+ << " node=" << node->GetId ()
+ << " pos=" << mobility->GetPosition ()
+ << " vel=" << mobility->GetVelocity ()
+ << std::endl;
+}
+
+void
+MobilityHelper::EnableAscii (std::ostream &os, uint32_t nodeid)
+{
+ std::ostringstream oss;
+ oss << "/NodeList/" << nodeid << "/$ns3::MobilityModel/CourseChange";
+ Config::ConnectWithoutContext (oss.str (),
+ MakeBoundCallback (&MobilityHelper::CourseChanged, &os));
+}
+void
+MobilityHelper::EnableAscii (std::ostream &os, NodeContainer n)
+{
+ for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
+ {
+ EnableAscii (os, (*i)->GetId ());
+ }
+}
+void
+MobilityHelper::EnableAsciiAll (std::ostream &os)
+{
+ EnableAscii (os, NodeContainer::GetGlobal ());
+}
+
+
} // namespace ns3
--- a/src/helper/mobility-helper.h Mon Jul 28 08:59:05 2008 -0700
+++ b/src/helper/mobility-helper.h Mon Jul 28 09:03:10 2008 -0700
@@ -163,8 +163,36 @@
* exist in the simulation.
*/
void InstallAll (void);
+
+ /**
+ * \param os output stream
+ * \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);
+ /**
+ * \param os output stream
+ * \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);
+ /**
+ * \param os output stream
+ *
+ * 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);
+
private:
-
+ static void CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility);
std::vector<Ptr<MobilityModel> > m_mobilityStack;
ObjectFactory m_mobility;
Ptr<PositionAllocator> m_position;