energy: allow use of deprecated LiIonEnergySource in example and test

This commit is contained in:
Peter D. Barnes, Jr
2024-10-07 09:26:50 -10:00
parent efff75fe4f
commit 2a335d968a
3 changed files with 35 additions and 5 deletions

View File

@@ -34,9 +34,19 @@ using namespace ns3::energy;
* 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"
@@ -61,7 +71,9 @@ main(int argc, char** argv)
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);

View File

@@ -25,9 +25,6 @@ namespace energy
* \ingroup energy
* \brief Model a generic Lithium Ion Battery basing on [1][2].
*
* \deprecated The LiIonEnergySource was deprecated in ns-3.40 in favor of GenericBatteryModel, and
* will be removed in a future release.
*
* 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].
@@ -65,9 +62,15 @@ namespace energy
* 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
*
*/
class LiIonEnergySource : public EnergySource
// 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:
/**

View File

@@ -16,6 +16,18 @@
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");
/**
@@ -50,7 +62,10 @@ 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);