A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
EnergyDepletionTest Class Reference

It tests that LoRa device correctly turning OFF on energy depletion. More...

Inheritance diagram for EnergyDepletionTest:
Collaboration diagram for EnergyDepletionTest:

Public Member Functions

 EnergyDepletionTest ()
 Default constructor.
 ~EnergyDepletionTest () override
 Destructor.
void Reset (double energyJ, double batteryTh, Time rxTime=Time())
 Reset device for new sub test case.
Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 Caller graph was not generated because of its size.
virtual ~TestCase ()
 Destructor.
std::string GetName () const
TestCase & operator= (const TestCase &)=delete

Private Types

using State = EndDeviceLoraPhy::State
 PHY state.

Private Member Functions

void DoRun () override
 Implementation to actually run this TestCase.
void OnEndDeviceStateChange (State prev, State curr)
 Callback for tracing changes in the LoRa PHY state.
void OnTotalEnergyConsumptionChange (double prev, double curr)
 Callback for tracing a device PHY's energy model energy consumption.

Private Attributes

size_t m_currentDeviceStateIndex
 Track current PHY state of the device.
std::vector< State > m_expectedStates
 States the PHY must go through.
Ptr< Node > m_node
 LoRaWAN end device node used in tests.
double m_totalEnergyConsumption
 Track PHY energy consumption in Joules.

Additional Inherited Members

Public Types inherited from ns3::TestCase
enum class  Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor.
void AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK)
 Add an individual child TestCase to this test suite.
TestCase * GetParent () const
 Get the parent of this TestCase.
bool IsStatusFailure () const
 Check if any tests failed.
bool IsStatusSuccess () const
 Check if all tests passed.
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found.
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase.
bool MustAssertOnFailure () const
 Check if this run should assert on failure.
bool MustContinueOnFailure () const
 Check if this run should continue on failure.
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory.
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory.

Detailed Description

It tests that LoRa device correctly turning OFF on energy depletion.

Definition at line 3237 of file lorawan-test-suite.cc.

Member Typedef Documentation

◆ State

PHY state.

Definition at line 3239 of file lorawan-test-suite.cc.

Constructor & Destructor Documentation

◆ EnergyDepletionTest()

EnergyDepletionTest::EnergyDepletionTest ( )

Default constructor.

Definition at line 3281 of file lorawan-test-suite.cc.

References ns3::TestCase::TestCase().

Here is the call graph for this function:

◆ ~EnergyDepletionTest()

EnergyDepletionTest::~EnergyDepletionTest ( )
override

Destructor.

Definition at line 3286 of file lorawan-test-suite.cc.

References m_node.

Member Function Documentation

◆ DoRun()

void EnergyDepletionTest::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

See also
LinearLoraTxCurrentModel

Implements ns3::TestCase.

Definition at line 3413 of file lorawan-test-suite.cc.

References ns3::lorawan::DbmToW(), ns3::lorawan::LoraRadioEnergyModel::ENERGY_EPSILON_J, ns3::lorawan::LoraPhy::GetTimeOnAir(), ns3::lorawan::LoraPhy::GetTSym(), m_currentDeviceStateIndex, m_expectedStates, m_totalEnergyConsumption, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, NS_TEST_EXPECT_MSG_GT_OR_EQ, NS_TEST_EXPECT_MSG_LT, Reset(), ns3::Simulator::Run(), and ns3::Seconds().

Here is the call graph for this function:

◆ OnEndDeviceStateChange()

void EnergyDepletionTest::OnEndDeviceStateChange ( State prev,
State curr )
private

Callback for tracing changes in the LoRa PHY state.

Parameters
prevold PHY state
currnew PHY state

Definition at line 3398 of file lorawan-test-suite.cc.

References m_currentDeviceStateIndex, m_expectedStates, NS_TEST_EXPECT_MSG_EQ, and NS_TEST_EXPECT_MSG_LT.

Referenced by Reset().

Here is the caller graph for this function:

◆ OnTotalEnergyConsumptionChange()

void EnergyDepletionTest::OnTotalEnergyConsumptionChange ( double prev,
double curr )
private

Callback for tracing a device PHY's energy model energy consumption.

Parameters
prevold value of total energy consumption in Joules
currnew value of total energy consumption in Joules

Definition at line 3392 of file lorawan-test-suite.cc.

References m_totalEnergyConsumption, and prev.

Referenced by Reset().

Here is the caller graph for this function:

◆ Reset()

void EnergyDepletionTest::Reset ( double energyJ,
double batteryTh,
Time rxTime = Time() )

Reset device for new sub test case.

Parameters
energyJInitial battery energy in Joule
batteryThBattery depletion threshold (0-1 percentage)
rxTime(optional) Schedule a PHY RX at provided time > 0

Definition at line 3292 of file lorawan-test-suite.cc.

References ns3::Create(), ns3::CreateObject(), ns3::Simulator::Destroy(), ns3::lorawan::DOWN, ns3::DynamicCast(), ns3::lorawan::LorawanMacHelper::ED_A, ns3::lorawan::LorawanMacHelper::EU, ns3::energy::DeviceEnergyModelContainer::Get(), ns3::energy::EnergySourceContainer::Get(), ns3::lorawan::LoraPhy::GetTimeOnAir(), ns3::DeviceEnergyModelHelper::Install(), ns3::EnergySourceHelper::Install(), ns3::lorawan::LorawanMacHelper::Install(), ns3::Time::IsStrictlyPositive(), m_currentDeviceStateIndex, m_node, m_totalEnergyConsumption, ns3::MakeCallback(), ns3::Time::Max(), OnEndDeviceStateChange(), OnTotalEnergyConsumptionChange(), ns3::Simulator::ScheduleWithContext(), ns3::Seconds(), ns3::BasicEnergySourceHelper::Set(), ns3::lorawan::LoraRadioEnergyModelHelper::Set(), ns3::lorawan::LoraFrameHeader::SetAsDownlink(), ns3::lorawan::LorawanMacHelper::SetDeviceType(), ns3::lorawan::LorawanMacHeader::SetFType(), ns3::lorawan::LorawanMacHelper::SetRegion(), ns3::lorawan::LoraRadioEnergyModelHelper::SetTxCurrentModel(), ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive(), ns3::Simulator::Stop(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_DOWN.

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_currentDeviceStateIndex

size_t EnergyDepletionTest::m_currentDeviceStateIndex
private

Track current PHY state of the device.

Definition at line 3278 of file lorawan-test-suite.cc.

Referenced by DoRun(), OnEndDeviceStateChange(), and Reset().

◆ m_expectedStates

std::vector<State> EnergyDepletionTest::m_expectedStates
private

States the PHY must go through.

Definition at line 3275 of file lorawan-test-suite.cc.

Referenced by DoRun(), and OnEndDeviceStateChange().

◆ m_node

Ptr<Node> EnergyDepletionTest::m_node
private

LoRaWAN end device node used in tests.

Definition at line 3273 of file lorawan-test-suite.cc.

Referenced by ~EnergyDepletionTest(), and Reset().

◆ m_totalEnergyConsumption

double EnergyDepletionTest::m_totalEnergyConsumption
private

Track PHY energy consumption in Joules.

Definition at line 3277 of file lorawan-test-suite.cc.

Referenced by DoRun(), OnTotalEnergyConsumptionChange(), and Reset().


The documentation for this class was generated from the following file: