src/netanim/model/animation-interface.cc
changeset 7564 642fa0627ba6
parent 7561 64aa3a5c3774
child 7595 0f5dc03da4b1
--- a/src/netanim/model/animation-interface.cc	Wed Oct 19 07:00:15 2011 -0400
+++ b/src/netanim/model/animation-interface.cc	Wed Oct 19 14:25:39 2011 -0400
@@ -32,6 +32,7 @@
 #include "ns3/animation-interface-helper.h"
 #include "ns3/wifi-mac-header.h"
 #include "ns3/wimax-mac-header.h"
+#include "ns3/constant-position-mobility-model.h"
 
 #include <stdio.h>
 #include <sstream>
@@ -58,6 +59,7 @@
     OutputFileSet (false), ServerPortSet (false), gAnimUid (0),randomPosition (true),
     m_writeCallback (0)
 {
+  StartAnimation ();
 }
 
 AnimationInterface::AnimationInterface (const std::string fn, bool usingXML)
@@ -66,6 +68,7 @@
     OutputFileSet (false), ServerPortSet (false), gAnimUid (0), randomPosition (true),
     m_writeCallback (0)
 {
+  StartAnimation ();
 }
 
 AnimationInterface::AnimationInterface (const uint16_t port, bool usingXML)
@@ -74,6 +77,7 @@
     OutputFileSet (false), ServerPortSet (false), gAnimUid (0), randomPosition (true),
     m_writeCallback (0)
 {
+  StartAnimation ();
 }
 
 AnimationInterface::~AnimationInterface ()
@@ -931,6 +935,21 @@
   WriteN (m_fHandle, oss.str ());
 }
 
+void AnimationInterface::SetConstantPosition (Ptr <Node> n, double x, double y, double z)
+{
+  NS_ASSERT (n);
+  Ptr<ConstantPositionMobilityModel> hubLoc =  n->GetObject<ConstantPositionMobilityModel> ();
+  if (hubLoc == 0)
+    {
+      hubLoc = CreateObject<ConstantPositionMobilityModel> ();
+      n->AggregateObject (hubLoc);
+    }
+  Vector hubVec (x, y, z);
+  hubLoc->SetPosition (hubVec);
+  NS_LOG_INFO ("Node:" << n->GetId () << " Position set to:(" << x << "," << y << "," << z << ")");
+
+}
+
 
 // XML Private Helpers