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