Remove code deprecated in ns-3.40

This commit is contained in:
Eduardo Almeida
2025-03-12 13:51:53 +00:00
parent 0ef77eab92
commit 09910c9c76
9 changed files with 1 additions and 759 deletions

View File

@@ -2304,8 +2304,7 @@ EXPAND_AS_DEFINED = ATTRIBUTE_ACCESSOR_DEFINE \
NS_DEPRECATED_3_44 \
NS_DEPRECATED_3_43 \
NS_DEPRECATED_3_42 \
NS_DEPRECATED_3_41 \
NS_DEPRECATED_3_40
NS_DEPRECATED_3_41
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
# remove all references to function-like macros that are alone on a line, have

View File

@@ -125,11 +125,4 @@
*/
#define NS_DEPRECATED_3_41(msg) NS_DEPRECATED("Deprecated in ns-3.41: " msg)
/**
* @ingroup deprecation
* @def NS_DEPRECATED_3_40
* Tag for things deprecated in version ns-3.40.
*/
#define NS_DEPRECATED_3_40(msg) NS_DEPRECATED("Deprecated in ns-3.40: " msg)
#endif /* NS3_DEPRECATED_H */

View File

@@ -17,7 +17,6 @@ build_lib(
model/energy-harvester.cc
model/energy-source.cc
model/generic-battery-model.cc
model/li-ion-energy-source.cc
model/rv-battery-model.cc
model/simple-device-energy-model.cc
HEADER_FILES
@@ -37,10 +36,8 @@ build_lib(
model/energy-harvester.h
model/energy-source.h
model/generic-battery-model.h
model/li-ion-energy-source.h
model/rv-battery-model.h
model/simple-device-energy-model.h
LIBRARIES_TO_LINK ${libnetwork}
TEST_SOURCES test/basic-energy-harvester-test.cc
test/li-ion-energy-source-test.cc
)

View File

@@ -17,13 +17,6 @@ build_lib_example(
${libwifi}
)
build_lib_example(
NAME li-ion-energy-source-example
SOURCE_FILES li-ion-energy-source-example.cc
LIBRARIES_TO_LINK ${libcore}
${libenergy}
)
build_lib_example(
NAME rv-battery-model-test
SOURCE_FILES rv-battery-model-test.cc

View File

@@ -1,106 +0,0 @@
/*
* Copyright (c) 2010 Andrea Sacco
*
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Andrea Sacco <andrea.sacco85@gmail.com>
*/
#include "ns3/command-line.h"
#include "ns3/energy-source-container.h"
#include "ns3/li-ion-energy-source.h"
#include "ns3/log.h"
#include "ns3/simple-device-energy-model.h"
#include "ns3/simulator.h"
using namespace ns3;
using namespace ns3::energy;
/**
* In this simple example, we show how to create and drain energy from a
* LiIonEnergySource.
* We make a series of discharge calls to the energy source class with
* different current drain and duration until all the energy is depleted
* from the cell.
*
* Every 20 seconds it is printed out the actual cell voltage to verify
* that it follows the discharge curve of the datasheet [1].
*
* At the end of the example it is verified that after the energy depletion
* call, the cell voltage is below the threshold voltage.
*
* References:
* [1] Panasonic CGR18650DA Datasheet,
* http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf
*/
// NS_DEPRECATED_3_43() - tag for future removal
// LiIonEnergySource was deprecated in commit
// https://gitlab.com/nsnam/ns-3-dev/-/commit/086913b0
//
// The new battery model is illustrated in
// `src/energy/examples/generic-battery-discharge-example.cc`
NS_WARNING_PUSH_DEPRECATED;
static void
PrintCellInfo(Ptr<LiIonEnergySource> es)
{
NS_WARNING_POP;
std::cout << "At " << Simulator::Now().As(Time::S)
<< " Cell voltage: " << es->GetSupplyVoltage()
<< " V Remaining Capacity: " << es->GetRemainingEnergy() / (3.6 * 3600) << " Ah"
<< std::endl;
if (!Simulator::IsFinished())
{
Simulator::Schedule(Seconds(20), &PrintCellInfo, es);
}
}
int
main(int argc, char** argv)
{
CommandLine cmd(__FILE__);
cmd.Parse(argc, argv);
// uncomment below to see the energy consumption details
// LogComponentEnable ("LiIonEnergySource", LOG_LEVEL_DEBUG);
Ptr<Node> node = CreateObject<Node>();
Ptr<SimpleDeviceEnergyModel> sem = CreateObject<SimpleDeviceEnergyModel>();
Ptr<EnergySourceContainer> esCont = CreateObject<EnergySourceContainer>();
NS_WARNING_PUSH_DEPRECATED;
Ptr<LiIonEnergySource> es = CreateObject<LiIonEnergySource>();
NS_WARNING_POP;
esCont->Add(es);
es->SetNode(node);
sem->SetEnergySource(es);
es->AppendDeviceEnergyModel(sem);
sem->SetNode(node);
node->AggregateObject(esCont);
Time now = Simulator::Now();
// discharge at 2.33 A for 1700 seconds
sem->SetCurrentA(2.33);
now += Seconds(1701);
// discharge at 4.66 A for 628 seconds
Simulator::Schedule(now, &SimpleDeviceEnergyModel::SetCurrentA, sem, 4.66);
now += Seconds(600);
PrintCellInfo(es);
Simulator::Stop(now);
Simulator::Run();
Simulator::Destroy();
// the cell voltage should be under 3.3v
DoubleValue v;
es->GetAttribute("ThresholdVoltage", v);
NS_ASSERT(es->GetSupplyVoltage() <= v.Get());
return 0;
}

View File

@@ -1,312 +0,0 @@
/*
* Copyright (c) 2010 Andrea Sacco
*
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Andrea Sacco <andrea.sacco85@gmail.com>
*/
#include "li-ion-energy-source.h"
#include "ns3/assert.h"
#include "ns3/double.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/trace-source-accessor.h"
#include <cmath>
namespace ns3
{
namespace energy
{
NS_LOG_COMPONENT_DEFINE("LiIonEnergySource");
NS_OBJECT_ENSURE_REGISTERED(LiIonEnergySource);
TypeId
LiIonEnergySource::GetTypeId()
{
static TypeId tid =
TypeId("ns3::energy::LiIonEnergySource")
.AddDeprecatedName("ns3::LiIonEnergySource")
.SetParent<EnergySource>()
.SetGroupName("Energy")
.AddConstructor<LiIonEnergySource>()
.AddAttribute("LiIonEnergySourceInitialEnergyJ",
"Initial energy stored in basic energy source.",
DoubleValue(31752.0), // in Joules
MakeDoubleAccessor(&LiIonEnergySource::SetInitialEnergy,
&LiIonEnergySource::GetInitialEnergy),
MakeDoubleChecker<double>())
.AddAttribute("LiIonEnergyLowBatteryThreshold",
"Low battery threshold for LiIon energy source.",
DoubleValue(0.10), // as a fraction of the initial energy
MakeDoubleAccessor(&LiIonEnergySource::m_lowBatteryTh),
MakeDoubleChecker<double>())
.AddAttribute("InitialCellVoltage",
"Initial (maximum) voltage of the cell (fully charged).",
DoubleValue(4.05), // in Volts
MakeDoubleAccessor(&LiIonEnergySource::SetInitialSupplyVoltage,
&LiIonEnergySource::GetSupplyVoltage),
MakeDoubleChecker<double>())
.AddAttribute("NominalCellVoltage",
"Nominal voltage of the cell.",
DoubleValue(3.6), // in Volts
MakeDoubleAccessor(&LiIonEnergySource::m_eNom),
MakeDoubleChecker<double>())
.AddAttribute("ExpCellVoltage",
"Cell voltage at the end of the exponential zone.",
DoubleValue(3.6), // in Volts
MakeDoubleAccessor(&LiIonEnergySource::m_eExp),
MakeDoubleChecker<double>())
.AddAttribute("RatedCapacity",
"Rated capacity of the cell.",
DoubleValue(2.45), // in Ah
MakeDoubleAccessor(&LiIonEnergySource::m_qRated),
MakeDoubleChecker<double>())
.AddAttribute("NomCapacity",
"Cell capacity at the end of the nominal zone.",
DoubleValue(1.1), // in Ah
MakeDoubleAccessor(&LiIonEnergySource::m_qNom),
MakeDoubleChecker<double>())
.AddAttribute("ExpCapacity",
"Cell Capacity at the end of the exponential zone.",
DoubleValue(1.2), // in Ah
MakeDoubleAccessor(&LiIonEnergySource::m_qExp),
MakeDoubleChecker<double>())
.AddAttribute("InternalResistance",
"Internal resistance of the cell",
DoubleValue(0.083), // in Ohms
MakeDoubleAccessor(&LiIonEnergySource::m_internalResistance),
MakeDoubleChecker<double>())
.AddAttribute("TypCurrent",
"Typical discharge current used to fit the curves",
DoubleValue(2.33), // in A
MakeDoubleAccessor(&LiIonEnergySource::m_typCurrent),
MakeDoubleChecker<double>())
.AddAttribute("ThresholdVoltage",
"Minimum threshold voltage to consider the battery depleted.",
DoubleValue(3.3), // in Volts
MakeDoubleAccessor(&LiIonEnergySource::m_minVoltTh),
MakeDoubleChecker<double>())
.AddAttribute("PeriodicEnergyUpdateInterval",
"Time between two consecutive periodic energy updates.",
TimeValue(Seconds(1)),
MakeTimeAccessor(&LiIonEnergySource::SetEnergyUpdateInterval,
&LiIonEnergySource::GetEnergyUpdateInterval),
MakeTimeChecker())
.AddTraceSource("RemainingEnergy",
"Remaining energy at BasicEnergySource.",
MakeTraceSourceAccessor(&LiIonEnergySource::m_remainingEnergyJ),
"ns3::TracedValueCallback::Double");
return tid;
}
LiIonEnergySource::LiIonEnergySource()
: m_drainedCapacity(0.0),
m_lastUpdateTime()
{
NS_LOG_FUNCTION(this);
}
LiIonEnergySource::~LiIonEnergySource()
{
NS_LOG_FUNCTION(this);
}
void
LiIonEnergySource::SetInitialEnergy(double initialEnergyJ)
{
NS_LOG_FUNCTION(this << initialEnergyJ);
NS_ASSERT(initialEnergyJ >= 0);
m_initialEnergyJ = initialEnergyJ;
// set remaining energy to be initial energy
m_remainingEnergyJ = m_initialEnergyJ;
}
double
LiIonEnergySource::GetInitialEnergy() const
{
NS_LOG_FUNCTION(this);
return m_initialEnergyJ;
}
void
LiIonEnergySource::SetInitialSupplyVoltage(double supplyVoltageV)
{
NS_LOG_FUNCTION(this << supplyVoltageV);
m_eFull = supplyVoltageV;
m_supplyVoltageV = supplyVoltageV;
}
double
LiIonEnergySource::GetSupplyVoltage() const
{
NS_LOG_FUNCTION(this);
return m_supplyVoltageV;
}
void
LiIonEnergySource::SetEnergyUpdateInterval(Time interval)
{
NS_LOG_FUNCTION(this << interval);
m_energyUpdateInterval = interval;
}
Time
LiIonEnergySource::GetEnergyUpdateInterval() const
{
NS_LOG_FUNCTION(this);
return m_energyUpdateInterval;
}
double
LiIonEnergySource::GetRemainingEnergy()
{
NS_LOG_FUNCTION(this);
// update energy source to get the latest remaining energy.
UpdateEnergySource();
return m_remainingEnergyJ;
}
double
LiIonEnergySource::GetEnergyFraction()
{
NS_LOG_FUNCTION(this);
// update energy source to get the latest remaining energy.
UpdateEnergySource();
return m_remainingEnergyJ / m_initialEnergyJ;
}
void
LiIonEnergySource::DecreaseRemainingEnergy(double energyJ)
{
NS_LOG_FUNCTION(this << energyJ);
NS_ASSERT(energyJ >= 0);
m_remainingEnergyJ -= energyJ;
// check if remaining energy is 0
if (m_supplyVoltageV <= m_minVoltTh)
{
HandleEnergyDrainedEvent();
}
}
void
LiIonEnergySource::IncreaseRemainingEnergy(double energyJ)
{
NS_LOG_FUNCTION(this << energyJ);
NS_ASSERT(energyJ >= 0);
m_remainingEnergyJ += energyJ;
}
void
LiIonEnergySource::UpdateEnergySource()
{
NS_LOG_FUNCTION(this);
NS_LOG_DEBUG("LiIonEnergySource:Updating remaining energy at node #" << GetNode()->GetId());
// do not update if simulation has finished
if (Simulator::IsFinished())
{
return;
}
m_energyUpdateEvent.Cancel();
CalculateRemainingEnergy();
m_lastUpdateTime = Simulator::Now();
if (m_remainingEnergyJ <= m_lowBatteryTh * m_initialEnergyJ)
{
HandleEnergyDrainedEvent();
return; // stop periodic update
}
m_energyUpdateEvent =
Simulator::Schedule(m_energyUpdateInterval, &LiIonEnergySource::UpdateEnergySource, this);
}
/*
* Private functions start here.
*/
void
LiIonEnergySource::DoInitialize()
{
NS_LOG_FUNCTION(this);
UpdateEnergySource(); // start periodic update
}
void
LiIonEnergySource::DoDispose()
{
NS_LOG_FUNCTION(this);
BreakDeviceEnergyModelRefCycle(); // break reference cycle
}
void
LiIonEnergySource::HandleEnergyDrainedEvent()
{
NS_LOG_FUNCTION(this);
NS_LOG_DEBUG("LiIonEnergySource:Energy depleted at node #" << GetNode()->GetId());
NotifyEnergyDrained(); // notify DeviceEnergyModel objects
}
void
LiIonEnergySource::CalculateRemainingEnergy()
{
NS_LOG_FUNCTION(this);
double totalCurrentA = CalculateTotalCurrent();
Time duration = Simulator::Now() - m_lastUpdateTime;
NS_ASSERT(duration.GetSeconds() >= 0);
// energy = current * voltage * time
double energyToDecreaseJ = totalCurrentA * m_supplyVoltageV * duration.GetSeconds();
if (m_remainingEnergyJ < energyToDecreaseJ)
{
m_remainingEnergyJ = 0; // energy never goes below 0
}
else
{
m_remainingEnergyJ -= energyToDecreaseJ;
}
m_drainedCapacity += (totalCurrentA * duration).GetHours();
// update the supply voltage
m_supplyVoltageV = GetVoltage(totalCurrentA);
NS_LOG_DEBUG("LiIonEnergySource:Remaining energy = " << m_remainingEnergyJ);
}
double
LiIonEnergySource::GetVoltage(double i) const
{
NS_LOG_FUNCTION(this << i);
// integral of i in dt, drained capacity in Ah
double it = m_drainedCapacity;
// empirical factors
double A = m_eFull - m_eExp;
double B = 3 / m_qExp;
// slope of the polarization curve
double K = std::abs((m_eFull - m_eNom + A * (std::exp(-B * m_qNom) - 1)) * (m_qRated - m_qNom) /
m_qNom);
// constant voltage
double E0 = m_eFull + K + m_internalResistance * m_typCurrent - A;
double E = E0 - K * m_qRated / (m_qRated - it) + A * std::exp(-B * it);
// cell voltage
double V = E - m_internalResistance * i;
NS_LOG_DEBUG("Voltage: " << V << " with E: " << E);
return V;
}
} // namespace energy
} // namespace ns3

View File

@@ -1,215 +0,0 @@
/*
* Copyright (c) 2010 Andrea Sacco
*
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Andrea Sacco <andrea.sacco85@gmail.com>
*/
#ifndef LI_ION_ENERGY_SOURCE_H
#define LI_ION_ENERGY_SOURCE_H
#include "energy-source.h"
#include "ns3/deprecated.h"
#include "ns3/event-id.h"
#include "ns3/nstime.h"
#include "ns3/traced-value.h"
namespace ns3
{
namespace energy
{
/**
* @ingroup energy
* @brief Model a generic Lithium Ion Battery basing on [1][2].
*
* The model can be fitted to any type of Li-Ion Battery, simply changing the
* model parameters.
* The default values are fitted for the Panasonic CGR18650DA Li-Ion Battery [3].
*
* The energy is drained as defined from the EnergySource interface but, this class
* consider the non-linear behaviour of Li-Ion cell. Each time energy is drained from
* the cell, the class evaluates the discharge curve to get the actual cell's voltage,
* accordingly to State of Charge (SOC) and current's drain.
*
* If the actual voltage of the cell goes below the minimum threshold voltage, the
* cell is considered depleted and the energy drained event fired up.
*
*
* The model requires several parameters to approximates the discharge curves:
* - InitialCellVoltage, maximum voltage of the fully charged cell
* - NominalCellVoltage, nominal cell's voltage, is used to determine the end of the
* nominal zone.
* - ExpCellVoltage, cell's voltage at the end of the exponential zone
* - RatedCapacity, rated capacity of the cell, in Ah
* - NomCapacity, cell's capacity at the end of the nominal zone, in Ah
* - ExpCapacity, cell's capacity at the end of the exponential zone, in Ah
* - InternalResistance, internal resistance of the cell, in Ohms
* - TypCurrent, typical discharge current value, used during the fitting process, in Ah
* - ThresholdVoltage, minimum threshold voltage below which the cell is considered
* depleted
*
* For a complete reference of the energy source model and model's fitting please refer
* to <a href="http://www.nsnam.org/wiki/GSOC2010UANFramework">UAN Framework</a>
* page and <a href="http://www.nsnam.org/wiki/Li-Ion_model_fitting">Li-Ion model
* fitting</a> page.
*
* References:
* [1] C. M. Shepherd, "Design of Primary and Secondary Cells - Part 3. Battery discharge equation,"
* U.S. Naval Research Laboratory, 1963 [2] Tremblay, O.; Dessaint, L.-A.; Dekkiche, A.-I., "A
* Generic Battery Model for the Dynamic Simulation of Hybrid Electric Vehicles," Ecole de
* Technologie Superieure, Universite du Quebec, 2007 [3]
* http://www.panasonic.com/industrial/includes/pdf/Panasonic_LiIon_CGR18650DA.pdf
*/
// clang-format off
class
NS_DEPRECATED_3_40("The LiIonEnergySource was deprecated in ns-3.40 "
"in favor of GenericBatteryModel, and will be removed "
"in a future release.")
LiIonEnergySource : public EnergySource
// clang-format on
{
public:
/**
* @brief Get the type ID.
* @return The object TypeId.
*/
static TypeId GetTypeId();
LiIonEnergySource();
~LiIonEnergySource() override;
/**
* @return Initial energy stored in energy source, in Joules.
*
* Implements GetInitialEnergy.
*/
double GetInitialEnergy() const override;
/**
* @param initialEnergyJ Initial energy, in Joules
*
* Implements SetInitialEnergy. Note that initial energy is assumed to be set
* before simulation starts and is set only once per simulation.
*/
void SetInitialEnergy(double initialEnergyJ);
/**
* @returns Supply voltage at the energy source.
*
* Implements GetSupplyVoltage.
*/
double GetSupplyVoltage() const override;
/**
* @param supplyVoltageV Initial Supply voltage at the energy source, in Volts.
*
* Sets the initial supply voltage of the energy source.
* To be called only once.
*/
void SetInitialSupplyVoltage(double supplyVoltageV);
/**
* @return Remaining energy in energy source, in Joules
*
* Implements GetRemainingEnergy.
*/
double GetRemainingEnergy() override;
/**
* @returns Energy fraction.
*
* Implements GetEnergyFraction.
*/
double GetEnergyFraction() override;
/**
* @param energyJ Amount of energy (in Joules) to decrease from energy source.
*
* Implements DecreaseRemainingEnergy.
*/
NS_DEPRECATED_3_40("Use GenericBatteryModel instead")
virtual void DecreaseRemainingEnergy(double energyJ);
/**
* @param energyJ Amount of energy (in Joules) to increase from energy source.
*
* Implements IncreaseRemainingEnergy.
*/
NS_DEPRECATED_3_40("Use GenericBatteryModel instead")
virtual void IncreaseRemainingEnergy(double energyJ);
/**
* Implements UpdateEnergySource.
*/
void UpdateEnergySource() override;
/**
* @param interval Energy update interval.
*
* This function sets the interval between each energy update.
*/
void SetEnergyUpdateInterval(Time interval);
/**
* @returns The interval between each energy update.
*/
Time GetEnergyUpdateInterval() const;
private:
void DoInitialize() override;
void DoDispose() override;
/**
* Handles the remaining energy going to zero event. This function notifies
* all the energy models aggregated to the node about the energy being
* depleted. Each energy model is then responsible for its own handler.
*/
void HandleEnergyDrainedEvent();
/**
* Calculates remaining energy. This function uses the total current from all
* device models to calculate the amount of energy to decrease. The energy to
* decrease is given by:
* energy to decrease = total current * supply voltage * time duration
* This function subtracts the calculated energy to decrease from remaining
* energy.
*/
void CalculateRemainingEnergy();
/**
* Get the cell voltage in function of the discharge current.
* It consider different discharge curves for different discharge currents
* and the remaining energy of the cell.
*
* @param current the actual discharge current value.
* @return the cell voltage
*/
double GetVoltage(double current) const;
private:
double m_initialEnergyJ; //!< initial energy, in Joules
TracedValue<double> m_remainingEnergyJ; //!< remaining energy, in Joules
double m_drainedCapacity; //!< capacity drained from the cell, in Ah
double m_supplyVoltageV; //!< actual voltage of the cell
double m_lowBatteryTh; //!< low battery threshold, as a fraction of the initial energy
EventId m_energyUpdateEvent; //!< energy update event
Time m_lastUpdateTime; //!< last update time
Time m_energyUpdateInterval; //!< energy update interval
double m_eFull; //!< initial voltage of the cell, in Volts
double m_eNom; //!< nominal voltage of the cell, in Volts
double m_eExp; //!< cell voltage at the end of the exponential zone, in Volts
double m_internalResistance; //!< internal resistance of the cell, in Ohms
double m_qRated; //!< rated capacity of the cell, in Ah
double m_qNom; //!< cell capacity at the end of the nominal zone, in Ah
double m_qExp; //!< capacity value at the end of the exponential zone, in Ah
double m_typCurrent; //!< typical discharge current used to fit the curves
double m_minVoltTh; //!< minimum threshold voltage to consider the battery depleted
};
} // namespace energy
} // namespace ns3
#endif /* LI_ION_ENERGY_SOURCE_H */

View File

@@ -7,7 +7,6 @@
#
# See test.py for more information.
cpp_examples = [
("li-ion-energy-source", "True", "True"),
("rv-battery-model-test", "True", "True"),
("basic-energy-model-test", "True", "True"),
]

View File

@@ -1,106 +0,0 @@
/*
* Copyright (c) 2010 Andrea Sacco
*
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Andrea Sacco <andrea.sacco85@gmail.com>
*/
#include "ns3/li-ion-energy-source.h"
#include "ns3/log.h"
#include "ns3/node.h"
#include "ns3/simple-device-energy-model.h"
#include "ns3/simulator.h"
#include "ns3/test.h"
using namespace ns3;
using namespace ns3::energy;
// NS_DEPRECATED_3_43() - tag for future removal
// LiIonEnergySource was deprecated in commit
// https://gitlab.com/nsnam/ns-3-dev/-/commit/086913b0
//
// The new battery model is illustrated in
// `src/energy/examples/generic-battery-discharge-example.cc`
//
// A GenericBatteryModelTestCase is being developed in MR 2181
// https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/2181
// which will be in
// `src/energy/test/generic-battery-model-test.cc`
NS_LOG_COMPONENT_DEFINE("LiIonEnergySourceTestSuite");
/**
* @ingroup energy-tests
*
* @brief LiIon battery Test
*/
class LiIonEnergyTestCase : public TestCase
{
public:
LiIonEnergyTestCase();
~LiIonEnergyTestCase() override;
void DoRun() override;
Ptr<Node> m_node; //!< Node to aggreagte the source to.
};
LiIonEnergyTestCase::LiIonEnergyTestCase()
: TestCase("Li-Ion energy source test case")
{
}
LiIonEnergyTestCase::~LiIonEnergyTestCase()
{
m_node = nullptr;
}
void
LiIonEnergyTestCase::DoRun()
{
m_node = CreateObject<Node>();
Ptr<SimpleDeviceEnergyModel> sem = CreateObject<SimpleDeviceEnergyModel>();
NS_WARNING_PUSH_DEPRECATED;
Ptr<LiIonEnergySource> es = CreateObject<LiIonEnergySource>();
NS_WARNING_POP;
es->SetNode(m_node);
sem->SetEnergySource(es);
es->AppendDeviceEnergyModel(sem);
m_node->AggregateObject(es);
Time now = Simulator::Now();
// discharge at 2.33 A for 1700 seconds
sem->SetCurrentA(2.33);
now += Seconds(1701);
Simulator::Stop(now);
Simulator::Run();
Simulator::Destroy();
NS_TEST_ASSERT_MSG_EQ_TOL(es->GetSupplyVoltage(), 3.6, 1.0e-3, "Incorrect consumed energy!");
}
/**
* @ingroup energy-tests
*
* @brief LiIon battery TestSuite
*/
class LiIonEnergySourceTestSuite : public TestSuite
{
public:
LiIonEnergySourceTestSuite();
};
LiIonEnergySourceTestSuite::LiIonEnergySourceTestSuite()
: TestSuite("li-ion-energy-source", Type::UNIT)
{
AddTestCase(new LiIonEnergyTestCase, TestCase::Duration::QUICK);
}
/// create an instance of the test suite
static LiIonEnergySourceTestSuite g_liIonEnergySourceTestSuite;