A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
acoustic-modem-energy-model-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Andrea Sacco
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Author: Andrea Sacco <andrea.sacco85@gmail.com>
7 */
8
10
11#include "ns3/basic-energy-source-helper.h"
12#include "ns3/config.h"
13#include "ns3/names.h"
14#include "ns3/uan-net-device.h"
15#include "ns3/uan-phy.h"
16
17namespace ns3
18{
19
25
29
30void
32{
33 m_modemEnergy.Set(name, v);
34}
35
36void
42
43/*
44 * Private function starts here.
45 */
46
49 Ptr<energy::EnergySource> source) const
50{
51 NS_ASSERT(device);
52 NS_ASSERT(source);
53 // check if device is UanNetDevice
54 std::string deviceName = device->GetInstanceTypeId().GetName();
55 if (deviceName != "ns3::UanNetDevice")
56 {
57 NS_FATAL_ERROR("NetDevice type is not UanNetDevice!");
58 }
59 Ptr<Node> node = device->GetNode();
61 NS_ASSERT(model);
62 // set node pointer
63 model->SetNode(node);
64 // set energy source pointer
65 model->SetEnergySource(source);
66 // get phy layer
68 Ptr<UanPhy> uanPhy = uanDevice->GetPhy();
69 // set energy depletion callback
70 model->SetEnergyDepletionCallback(m_depletionCallback);
71 // add model to device model list in energy source
72 source->AppendDeviceEnergyModel(model);
73 // set node pointer
74 source->SetNode(node);
75 // create and install energy model callback
78 uanPhy->SetEnergyModelCallback(cb);
79
80 return model;
81}
82
83} // namespace ns3
AcousticModemEnergyModel::AcousticModemEnergyDepletionCallback m_depletionCallback
Callback for energy depletion.
void SetDepletionCallback(AcousticModemEnergyModel::AcousticModemEnergyDepletionCallback callback)
Sets the callback to be invoked when energy is depleted.
Ptr< energy::DeviceEnergyModel > DoInstall(Ptr< NetDevice > device, Ptr< energy::EnergySource > source) const override
Implements DeviceEnergyModel::Install.
~AcousticModemEnergyModelHelper() override
Destroy an AcousticModemEnergy Helper.
AcousticModemEnergyModelHelper()
Construct a helper which is used to add a radio energy model to a node.
void Set(std::string name, const AttributeValue &v) override
Sets an attribute of the underlying energy model object.
WHOI micro-modem energy model.
Hold a value for an Attribute.
Definition attribute.h:59
void Nullify()
Discard the implementation, set it to null.
Definition callback.h:561
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
virtual void ChangeState(int newState)=0
#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.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580