A Discrete-Event Network Simulator
API
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 
28 namespace ns3
29 {
30 
56 {
57  public:
60 
63 
64  public:
69  static TypeId GetTypeId();
73  ~AcousticModemEnergyModel() override;
74 
80  virtual void SetNode(Ptr<Node> node);
81 
87  virtual Ptr<Node> GetNode() const;
88 
89  // Inherited methods.
90  void SetEnergySource(Ptr<EnergySource> source) override;
91  double GetTotalEnergyConsumption() const override;
92 
98  double GetTxPowerW() const;
99 
105  void SetTxPowerW(double txPowerW);
106 
112  double GetRxPowerW() const;
113 
119  void SetRxPowerW(double rxPowerW);
120 
126  double GetIdlePowerW() const;
127 
133  void SetIdlePowerW(double idlePowerW);
134 
140  double GetSleepPowerW() const;
141 
147  void SetSleepPowerW(double sleepPowerW);
148 
154  int GetCurrentState() const;
155 
162 
169 
175  void ChangeState(int newState) override;
176 
180  void HandleEnergyDepletion() override;
181 
185  void HandleEnergyRecharged() override;
186 
192  void HandleEnergyChanged() override;
193 
194  private:
195  void DoDispose() override;
196 
200  double DoGetCurrentA() const override;
201 
208  bool IsStateTransitionValid(const int destState);
209 
216  void SetMicroModemState(const int state);
217 
218  private:
221 
222  // Member variables for power consumption in different modem states.
223  double m_txPowerW;
224  double m_rxPowerW;
225  double m_idlePowerW;
226  double m_sleepPowerW;
227 
230 
231  // State variables.
234 
237 
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.
Base class for device energy models.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.