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 
61 public:
66  static TypeId GetTypeId (void);
70  virtual ~AcousticModemEnergyModel ();
71 
77  virtual void SetNode (Ptr<Node> node);
78 
84  virtual Ptr<Node> GetNode (void) const;
85 
86  // Inherited methods.
87  virtual void SetEnergySource (Ptr<EnergySource> source);
88  virtual double GetTotalEnergyConsumption (void) const;
89 
95  double GetTxPowerW (void) const;
96 
102  void SetTxPowerW (double txPowerW);
103 
109  double GetRxPowerW (void) const;
110 
116  void SetRxPowerW (double rxPowerW);
117 
123  double GetIdlePowerW (void) const;
124 
130  void SetIdlePowerW (double idlePowerW);
131 
137  double GetSleepPowerW (void) const;
138 
144  void SetSleepPowerW (double sleepPowerW);
145 
151  int GetCurrentState (void) const;
152 
158  void SetEnergyDepletionCallback (AcousticModemEnergyDepletionCallback callback);
159 
165  virtual void ChangeState (int newState);
166 
170  virtual void HandleEnergyDepletion (void);
171 
177  virtual void HandleEnergyRecharged (void)
178  {
179  }
180 
181 
182 private:
183  void DoDispose (void);
184 
188  virtual double DoGetCurrentA (void) const;
189 
196  bool IsStateTransitionValid (const int destState);
197 
204  void SetMicroModemState (const int state);
205 
206 private:
209 
210  // Member variables for power consumption in different modem states.
211  double m_txPowerW;
212  double m_rxPowerW;
213  double m_idlePowerW;
214  double m_sleepPowerW;
215 
218 
219  // State variables.
222 
224  AcousticModemEnergyDepletionCallback m_energyDepletionCallback;
225 
226 }; // class AcousticModemEnergyModel
227 
228 } // namespace ns3
229 
230 #endif /* ACOUSTIC_MODEM_ENERGY_MODEL_H */
double GetRxPowerW(void) const
Get the recieving power.
virtual void ChangeState(int newState)
Changes state of the AcousticModemEnergyModel.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual ~AcousticModemEnergyModel()
Dummy destructor, see DoDispose.
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
virtual double DoGetCurrentA(void) const
double m_idlePowerW
The idle power, in watts.
Base class for device energy models.
virtual double GetTotalEnergyConsumption(void) const
double m_rxPowerW
The receiver power, in watts.
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
void SetIdlePowerW(double idlePowerW)
Set the idle state power of the modem.
bool IsStateTransitionValid(const int destState)
Ptr< Node > m_node
The node hosting this transducer.
void SetEnergyDepletionCallback(AcousticModemEnergyDepletionCallback callback)
WHOI micro-modem energy model.
double m_sleepPowerW
The sleep power, in watts.
Callback< void > AcousticModemEnergyDepletionCallback
Callback type for energy depletion handling.
void SetTxPowerW(double txPowerW)
Set the transmission power of the modem.
void SetRxPowerW(double rxPowerW)
Set the receiving power of the modem.
virtual void SetEnergySource(Ptr< EnergySource > source)
static TypeId GetTypeId(void)
Register this type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void HandleEnergyRecharged(void)
Handles energy recharged.
Ptr< EnergySource > m_source
The energy source.
void DoDispose(void)
Destructor implementation.
double GetSleepPowerW(void) const
Get the sleep state power of the modem.
double GetTxPowerW(void) const
Get the transmission power of the modem.
virtual Ptr< Node > GetNode(void) const
Gets pointer to node.
Time m_lastUpdateTime
Time stamp of previous energy update.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
void SetSleepPowerW(double sleepPowerW)
Set the sleep power of the modem.
int GetCurrentState(void) const
Get the current state of the modem.
double m_txPowerW
The transmitter power, in watts.
double GetIdlePowerW(void) const
Get the idle power of the modem.
a unique identifier for an interface.
Definition: type-id.h:58
TracedValue< double > m_totalEnergyConsumption
The total energy consumed by this model.