A Discrete-Event Network Simulator
API
basic-energy-source.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
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  * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
18  */
19 
20 #ifndef BASIC_ENERGY_SOURCE_H
21 #define BASIC_ENERGY_SOURCE_H
22 
23 #include "energy-source.h"
24 
25 #include "ns3/event-id.h"
26 #include "ns3/nstime.h"
27 #include "ns3/traced-value.h"
28 
29 namespace ns3
30 {
31 
39 {
40  public:
45  static TypeId GetTypeId();
47  ~BasicEnergySource() override;
48 
54  double GetInitialEnergy() const override;
55 
61  double GetSupplyVoltage() const override;
62 
68  double GetRemainingEnergy() override;
69 
75  double GetEnergyFraction() override;
76 
80  void UpdateEnergySource() override;
81 
89  void SetInitialEnergy(double initialEnergyJ);
90 
96  void SetSupplyVoltage(double supplyVoltageV);
97 
103  void SetEnergyUpdateInterval(Time interval);
104 
109 
110  private:
112  void DoInitialize() override;
113 
115  void DoDispose() override;
116 
123 
131 
141 
142  private:
145  double m_lowBatteryTh;
156 };
157 
158 } // namespace ns3
159 
160 #endif /* BASIC_ENERGY_SOURCE_H */
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
void HandleEnergyRechargedEvent()
Handles the remaining energy exceeding the high threshold after it went below the low threshold.
void SetEnergyUpdateInterval(Time interval)
double GetSupplyVoltage() const override
static TypeId GetTypeId()
Get the type ID.
Time m_energyUpdateInterval
energy update interval
double m_initialEnergyJ
initial energy, in Joules
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
double GetRemainingEnergy() override
double GetEnergyFraction() override
void HandleEnergyDrainedEvent()
Handles the remaining energy going to zero event.
Time m_lastUpdateTime
last update time
double GetInitialEnergy() const override
void SetSupplyVoltage(double supplyVoltageV)
void DoDispose() override
Defined in ns3::Object.
EventId m_energyUpdateEvent
energy update event
void DoInitialize() override
Defined in ns3::Object.
TracedValue< double > m_remainingEnergyJ
remaining energy, in Joules
bool m_depleted
set to true when the remaining energy goes below the low threshold, set to false again when the remai...
double m_highBatteryTh
high battery threshold, as a fraction of the initial energy
void UpdateEnergySource() override
Implements UpdateEnergySource.
void SetInitialEnergy(double initialEnergyJ)
double m_supplyVoltageV
supply voltage, in Volts
void CalculateRemainingEnergy()
Calculates remaining energy.
An identifier for simulation events.
Definition: event-id.h:55
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.