A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
acoustic-modem-energy-model.h
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: Andrea Sacco <andrea.sacco85@gmail.com>
7 */
8
9#ifndef ACOUSTIC_MODEM_ENERGY_MODEL_H
10#define ACOUSTIC_MODEM_ENERGY_MODEL_H
11
12#include "ns3/device-energy-model.h"
13#include "ns3/event-id.h"
14#include "ns3/nstime.h"
15#include "ns3/traced-value.h"
16
17namespace ns3
18{
19
20/**
21 * \ingroup uan
22 *
23 * WHOI micro-modem energy model.
24 *
25 * Basing on the Device Energy Model interface, has been implemented a specific
26 * energy model for the WHOI micro modem. The class follows pretty closely the
27 * RadioEnergyModel class as the transducer behaviour is pretty close to the one
28 * of a wifi radio, with identical states (rx, tx, idle, sleep).
29 *
30 * The power consumption values implemented into the model are as follows [1]:
31 *
32 * Modem State Power Consumption
33 * TX 50 W
34 * RX 158 mW
35 * Idle 158 mW
36 * Sleep 5.8 mW
37 *
38 * References:
39 * [1] Freitag et al., The whoi micro-modem: an acoustic communications
40 * and navigation system for multiple platforms,
41 * in In Proc. IEEE OCEANS05 Conf, 2005.
42 * URL: http://ieeexplore.ieee.org/iel5/10918/34367/01639901.pdf
43 */
45{
46 public:
47 /** Callback type for energy depletion handling. */
49
50 /** Callback type for energy recharge handling. */
52
53 public:
54 /**
55 * Register this type.
56 * \return The object TypeId.
57 */
58 static TypeId GetTypeId();
59 /** Constructor. */
61 /** Dummy destructor, see DoDispose */
63
64 /**
65 * Sets pointer to node.
66 *
67 * \param node Pointer to node.
68 */
69 virtual void SetNode(Ptr<Node> node);
70
71 /**
72 * Gets pointer to node.
73 *
74 * \return Pointer to node.
75 */
76 virtual Ptr<Node> GetNode() const;
77
78 // Inherited methods.
79 void SetEnergySource(Ptr<energy::EnergySource> source) override;
80 double GetTotalEnergyConsumption() const override;
81
82 /**
83 * Get the transmission power of the modem.
84 *
85 * \return The transmission power in Watts.
86 */
87 double GetTxPowerW() const;
88
89 /**
90 * Set the transmission power of the modem.
91 *
92 * \param txPowerW Transmission power in watts.
93 */
94 void SetTxPowerW(double txPowerW);
95
96 /**
97 * Get the receiving power.
98 *
99 * \return The receiving power in Watts
100 */
101 double GetRxPowerW() const;
102
103 /**
104 * Set the receiving power of the modem.
105 *
106 * \param rxPowerW Receiving power in watts
107 */
108 void SetRxPowerW(double rxPowerW);
109
110 /**
111 *Get the idle power of the modem.
112 *
113 * \return The idle power in Watts
114 */
115 double GetIdlePowerW() const;
116
117 /**
118 * Set the idle state power of the modem.
119 *
120 * \param idlePowerW Idle power of the modem in watts.
121 */
122 void SetIdlePowerW(double idlePowerW);
123
124 /**
125 * Get the sleep state power of the modem.
126 *
127 * \return Sleep power of the modem in Watts
128 */
129 double GetSleepPowerW() const;
130
131 /**
132 * Set the sleep power of the modem.
133 *
134 * \param sleepPowerW Sleep power of the modem in watts.
135 */
136 void SetSleepPowerW(double sleepPowerW);
137
138 /**
139 * Get the current state of the modem.
140 *
141 * \return Current state.
142 */
143 int GetCurrentState() const;
144
145 /**
146 * \param callback Callback function.
147 *
148 * Sets callback for energy depletion handling.
149 */
151
152 /**
153 * \param callback Callback function.
154 *
155 * Sets callback for energy recharge handling.
156 */
158
159 /**
160 * Changes state of the AcousticModemEnergyModel.
161 *
162 * \param newState New state the modem is in.
163 */
164 void ChangeState(int newState) override;
165
166 /**
167 * \brief Handles energy depletion.
168 */
169 void HandleEnergyDepletion() override;
170
171 /**
172 * \brief Handles energy recharged.
173 */
174 void HandleEnergyRecharged() override;
175
176 /**
177 * \brief Handles energy changed.
178 *
179 * Not implemented
180 */
181 void HandleEnergyChanged() override;
182
183 private:
184 void DoDispose() override;
185
186 /**
187 * \return Current draw of device, at current state.
188 */
189 double DoGetCurrentA() const override;
190
191 /**
192 * \param destState Modem state to switch to.
193 * \return True if the transition is allowed.
194 *
195 * This function checks if a given modem state transition is allowed.
196 */
197 bool IsStateTransitionValid(const int destState);
198
199 /**
200 * \param state New state the modem is currently in.
201 *
202 * Sets current state. This function is private so that only the energy model
203 * can change its own state.
204 */
205 void SetMicroModemState(const int state);
206
207 private:
208 Ptr<Node> m_node; //!< The node hosting this transducer.
209 Ptr<energy::EnergySource> m_source; //!< The energy source.
210
211 // Member variables for power consumption in different modem states.
212 double m_txPowerW; //!< The transmitter power, in watts.
213 double m_rxPowerW; //!< The receiver power, in watts.
214 double m_idlePowerW; //!< The idle power, in watts.
215 double m_sleepPowerW; //!< The sleep power, in watts.
216
217 /** The total energy consumed by this model. */
219
220 // State variables.
221 int m_currentState; //!< Current modem state.
222 Time m_lastUpdateTime; //!< Time stamp of previous energy update.
223
224 /** Energy depletion callback. */
226
227 /** Energy recharge callback. */
229
230}; // class AcousticModemEnergyModel
231
232} // namespace ns3
233
234#endif /* ACOUSTIC_MODEM_ENERGY_MODEL_H */
WHOI micro-modem energy model.
double GetTotalEnergyConsumption() const override
Callback< void > AcousticModemEnergyDepletionCallback
Callback type for energy depletion handling.
void SetEnergyRechargeCallback(AcousticModemEnergyRechargeCallback callback)
double m_rxPowerW
The receiver power, in watts.
double m_idlePowerW
The idle power, in watts.
void SetRxPowerW(double rxPowerW)
Set the receiving power of the modem.
Time m_lastUpdateTime
Time stamp of previous energy update.
void HandleEnergyRecharged() override
Handles energy recharged.
static TypeId GetTypeId()
Register this type.
double m_txPowerW
The transmitter power, in watts.
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.
void SetEnergySource(Ptr< energy::EnergySource > source) override
Callback< void > AcousticModemEnergyRechargeCallback
Callback type for energy recharge handling.
virtual Ptr< Node > GetNode() const
Gets pointer to node.
void HandleEnergyDepletion() override
Handles energy depletion.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
~AcousticModemEnergyModel() override
Dummy destructor, see DoDispose.
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
double GetTxPowerW() const
Get the transmission power of the modem.
void ChangeState(int newState) override
Changes state of the AcousticModemEnergyModel.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
Ptr< energy::EnergySource > m_source
The energy source.
void DoDispose() override
Destructor implementation.
double m_sleepPowerW
The sleep power, in watts.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
double GetRxPowerW() const
Get the receiving power.
double GetSleepPowerW() const
Get the sleep state power of the modem.
double GetIdlePowerW() const
Get the idle power of the modem.
int GetCurrentState() const
Get the current state of the modem.
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
Energy recharge callback.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
void HandleEnergyChanged() override
Handles energy changed.
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
Callback template class.
Definition callback.h:422
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
Base class for device energy models.
Every class exported by the ns3 library is enclosed in the ns3 namespace.