25 #include "ns3/simulator.h"
26 #include "ns3/double.h"
27 #include "ns3/config.h"
28 #include "ns3/string.h"
29 #include "ns3/basic-energy-harvester.h"
30 #include "ns3/basic-energy-source.h"
58 :
TestCase (
"Basic Energy Harvester test case")
86 harvester->SetHarvestedPowerUpdateInterval (
Seconds (
m_timeS + 1.0));
89 harvester->SetNode (node);
90 harvester->SetEnergySource (source);
100 &BasicEnergySource::UpdateEnergySource, source);
102 double timeDelta = 0.000000001;
110 estRemainingEnergy += harvester->GetPower () *
m_timeS;
114 NS_LOG_DEBUG (
"Remaining energy is " << remainingEnergy);
115 NS_LOG_DEBUG (
"Estimated remaining energy is " << estRemainingEnergy);
116 NS_LOG_DEBUG (
"Difference is " << estRemainingEnergy - remainingEnergy);
118 Simulator::Destroy ();
122 "Incorrect Remaining energy!");
138 :
TestSuite (
"basic-energy-harvester", UNIT)
static BasicEnergyHarvesterTestSuite g_basicEnergyHarvesterTestSuite
create an instance of the test suite
void DoRun(void)
Implementation to actually run this TestCase.
ObjectFactory m_energySource
Energy source factory.
ObjectFactory m_energyHarvester
Energy harvester factory.
double m_timeS
Time, in seconds.
~BasicEnergyHarvesterTestCase()
double m_tolerance
Tolerance for energy estimation.
BasicEnergyHarvesterTestCase()
Energy harvester TestSuite.
BasicEnergyHarvesterTestSuite()
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
virtual double GetRemainingEnergy(void)
virtual double GetInitialEnergy(void) const
void ConnectEnergyHarvester(Ptr< EnergyHarvester > energyHarvesterPtr)
Instantiate subclasses of ns3::Object.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.