A Discrete-Event Network Simulator
API
acoustic-modem-energy-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Andrea Sacco
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Andrea Sacco <andrea.sacco85@gmail.com>
19  */
20 
21 #ifndef ACOUSTIC_MODEM_ENERGY_MODEL_H
22 #define ACOUSTIC_MODEM_ENERGY_MODEL_H
23 
24 #include "ns3/device-energy-model.h"
25 #include "ns3/nstime.h"
26 #include "ns3/event-id.h"
27 #include "ns3/traced-value.h"
28 
29 namespace ns3 {
30 
56 {
57 public:
60 
63 
64 public:
69  static TypeId GetTypeId (void);
73  virtual ~AcousticModemEnergyModel ();
74 
80  virtual void SetNode (Ptr<Node> node);
81 
87  virtual Ptr<Node> GetNode (void) const;
88 
89  // Inherited methods.
90  virtual void SetEnergySource (Ptr<EnergySource> source);
91  virtual double GetTotalEnergyConsumption (void) const;
92 
98  double GetTxPowerW (void) const;
99 
105  void SetTxPowerW (double txPowerW);
106 
112  double GetRxPowerW (void) const;
113 
119  void SetRxPowerW (double rxPowerW);
120 
126  double GetIdlePowerW (void) const;
127 
133  void SetIdlePowerW (double idlePowerW);
134 
140  double GetSleepPowerW (void) const;
141 
147  void SetSleepPowerW (double sleepPowerW);
148 
154  int GetCurrentState (void) const;
155 
162 
169 
175  virtual void ChangeState (int newState);
176 
180  virtual void HandleEnergyDepletion (void);
181 
185  virtual void HandleEnergyRecharged (void);
186 
192  virtual void HandleEnergyChanged (void);
193 
194 
195 private:
196  void DoDispose (void);
197 
201  virtual double DoGetCurrentA (void) const;
202 
209  bool IsStateTransitionValid (const int destState);
210 
217  void SetMicroModemState (const int state);
218 
219 private:
222 
223  // Member variables for power consumption in different modem states.
224  double m_txPowerW;
225  double m_rxPowerW;
226  double m_idlePowerW;
227  double m_sleepPowerW;
228 
231 
232  // State variables.
235 
238 
241 
242 }; // class AcousticModemEnergyModel
243 
244 } // namespace ns3
245 
246 #endif /* ACOUSTIC_MODEM_ENERGY_MODEL_H */
WHOI micro-modem energy model.
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 GetRxPowerW(void) const
Get the receiving power.
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 DoDispose(void)
Destructor implementation.
double m_txPowerW
The transmitter power, in watts.
double GetIdlePowerW(void) const
Get the idle power of the modem.
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.
Callback< void > AcousticModemEnergyRechargeCallback
Callback type for energy recharge handling.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
virtual double DoGetCurrentA(void) const
virtual ~AcousticModemEnergyModel()
Dummy destructor, see DoDispose.
static TypeId GetTypeId(void)
Register this type.
virtual double GetTotalEnergyConsumption(void) const
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
double GetSleepPowerW(void) const
Get the sleep state power of the modem.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
virtual void HandleEnergyRecharged(void)
Handles energy recharged.
double m_sleepPowerW
The sleep power, in watts.
virtual void ChangeState(int newState)
Changes state of the AcousticModemEnergyModel.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
Energy recharge callback.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
virtual void SetEnergySource(Ptr< EnergySource > source)
int GetCurrentState(void) const
Get the current state of the modem.
bool IsStateTransitionValid(const int destState)
double GetTxPowerW(void) const
Get the transmission power of the modem.
virtual void HandleEnergyChanged(void)
Handles energy changed.
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:103
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.