A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lora-radio-energy-model-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
7 */
8
10
11#include "ns3/lora-net-device.h"
12#include "ns3/lora-radio-energy-model.h"
13#include "ns3/lora-tx-current-model.h"
14
15namespace ns3
16{
17namespace lorawan
18{
19
21{
22 m_radioEnergy.SetTypeId("ns3::LoraRadioEnergyModel");
23}
24
28
29void
31{
32 m_radioEnergy.Set(name, v);
33}
34
35/*
36 * Private function starts here.
37 */
38
41{
42 NS_ASSERT(device);
43 NS_ASSERT(source);
44 // check if device is LoraNetDevice
45 std::string deviceName = device->GetInstanceTypeId().GetName();
46 if (deviceName != "ns3::LoraNetDevice")
47 {
48 NS_FATAL_ERROR("NetDevice type is not LoraNetDevice!");
49 }
50 Ptr<Node> node = device->GetNode();
52 NS_ASSERT(model);
53
55 Ptr<EndDeviceLoraPhy> loraPhy = DynamicCast<EndDeviceLoraPhy>(loraDevice->GetPhy());
56 // add model to device model list in energy source
57 source->AppendDeviceEnergyModel(model);
58 // set energy source pointer
59 model->SetEnergySource(source);
60 // create and register energy model PHY listener
61 loraPhy->RegisterListener(model->GetPhyListener());
62 //
63 if (m_txCurrentModel.GetTypeId().GetUid())
64 {
66 model->SetTxCurrentModel(txcurrent);
67 }
68 return model;
69}
70
71} // namespace lorawan
72} // namespace ns3
uint32_t v
Hold a value for an Attribute.
Definition attribute.h:59
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
void Set(std::string name, const AttributeValue &v) override
ObjectFactory m_txCurrentModel
transmit current model
Ptr< energy::DeviceEnergyModel > DoInstall(Ptr< NetDevice > device, Ptr< energy::EnergySource > source) const override
Model the transmit current as a function of the transmit power and mode.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643