A Discrete-Event Network Simulator
API
basic-energy-source.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
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  * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
19  */
20 
21 #ifndef BASIC_ENERGY_SOURCE_H
22 #define BASIC_ENERGY_SOURCE_H
23 
24 #include "ns3/traced-value.h"
25 #include "ns3/nstime.h"
26 #include "ns3/event-id.h"
27 #include "energy-source.h"
28 
29 namespace ns3 {
30 
38 {
39 public:
40  static TypeId GetTypeId (void);
42  virtual ~BasicEnergySource ();
43 
49  virtual double GetInitialEnergy (void) const;
50 
56  virtual double GetSupplyVoltage (void) const;
57 
63  virtual double GetRemainingEnergy (void);
64 
70  virtual double GetEnergyFraction (void);
71 
75  virtual void UpdateEnergySource (void);
76 
84  void SetInitialEnergy (double initialEnergyJ);
85 
91  void SetSupplyVoltage (double supplyVoltageV);
92 
98  void SetEnergyUpdateInterval (Time interval);
99 
103  Time GetEnergyUpdateInterval (void) const;
104 
105 
106 private:
108  void DoInitialize (void);
109 
111  void DoDispose (void);
112 
118  void HandleEnergyDrainedEvent (void);
119 
126  void HandleEnergyRechargedEvent (void);
127 
136  void CalculateRemainingEnergy (void);
137 
138 private:
139  double m_initialEnergyJ; // initial energy, in Joules
140  double m_supplyVoltageV; // supply voltage, in Volts
141  double m_lowBatteryTh; // low battery threshold, as a fraction of the initial energy
142  double m_highBatteryTh; // high battery threshold, as a fraction of the initial energy
143  bool m_depleted; // set to true when the remaining energy goes below the low threshold,
144  // set to false again when the remaining energy exceeds the high threshold
145  TracedValue<double> m_remainingEnergyJ; // remaining energy, in Joules
146  EventId m_energyUpdateEvent; // energy update event
147  Time m_lastUpdateTime; // last update time
148  Time m_energyUpdateInterval; // energy update interval
149 
150 };
151 
152 } // namespace ns3
153 
154 #endif /* BASIC_ENERGY_SOURCE_H */
void CalculateRemainingEnergy(void)
Calculates remaining energy.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time GetEnergyUpdateInterval(void) const
virtual double GetSupplyVoltage(void) const
Introspection did not find any typical Config paths.
Definition: energy-source.h:81
virtual double GetRemainingEnergy(void)
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
virtual double GetInitialEnergy(void) const
void DoDispose(void)
Defined in ns3::Object.
TracedValue< double > m_remainingEnergyJ
void HandleEnergyRechargedEvent(void)
Handles the remaining energy exceeding the high threshold after it went below the low threshold...
static TypeId GetTypeId(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DoInitialize(void)
Defined in ns3::Object.
void SetSupplyVoltage(double supplyVoltageV)
An identifier for simulation events.
Definition: event-id.h:53
void SetEnergyUpdateInterval(Time interval)
void SetInitialEnergy(double initialEnergyJ)
a unique identifier for an interface.
Definition: type-id.h:58
virtual double GetEnergyFraction(void)