Battery source added for apNode in Wireless-animation example
authorEvgeny Kalishenko <ydginster@gmail.com>
Tue, 10 Dec 2013 09:12:38 +0400
changeset 10489 8777dbe55576
parent 10488 72386c711369
child 10490 c7db6722e980
Battery source added for apNode in Wireless-animation example
src/netanim/examples/wireless-animation.cc
--- a/src/netanim/examples/wireless-animation.cc	Tue Dec 10 09:12:38 2013 +0400
+++ b/src/netanim/examples/wireless-animation.cc	Tue Dec 10 09:12:38 2013 +0400
@@ -26,6 +26,8 @@
 #include "ns3/mobility-module.h"
 #include "ns3/internet-module.h"
 #include "ns3/netanim-module.h"
+#include "ns3/basic-energy-source.h"
+#include "ns3/simple-device-energy-model.h"
 
 
 
@@ -115,6 +117,17 @@
   AnimationInterface::SetConstantPosition (p2pNodes.Get (1), 10, 30); 
   AnimationInterface::SetConstantPosition (csmaNodes.Get (1), 10, 33); 
 
+  Ptr<BasicEnergySource> energySource = CreateObject<BasicEnergySource>();
+  Ptr<SimpleDeviceEnergyModel> energyModel = CreateObject<SimpleDeviceEnergyModel>();
+
+  energySource->SetInitialEnergy(300);
+  energyModel->SetEnergySource (energySource);
+  energySource->AppendDeviceEnergyModel (energyModel);
+  energyModel->SetCurrentA(20);
+
+  // aggregate energy source to node
+  wifiApNode.Get (0)->AggregateObject (energySource);
+
   // Install internet stack
 
   InternetStackHelper stack;
@@ -152,7 +165,7 @@
   Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
   Simulator::Stop (Seconds (15.0));
   AnimationInterface::SetNodeDescription (wifiApNode, "AP"); // Optional
-  AnimationInterface::SetNodeDescription (wifiStaNodes, "STA"); // Optional
+  AnimationInterface::SetNodeDescription (wifiStaNodes, "STA"); //b Optional
   AnimationInterface::SetNodeDescription (csmaNodes, "CSMA"); // Optional
   AnimationInterface::SetNodeColor (wifiApNode, 0, 255, 0); // Optional
   AnimationInterface::SetNodeColor (wifiStaNodes, 255, 0, 0); // Optional