A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
basic-energy-harvester.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG),
4  * University of Rochester, Rochester, NY, USA.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Cristiano Tapparello <cristiano.tapparello@rochester.edu>
20  */
21 
22 #ifndef BASIC_ENERGY_HARVESTER
23 #define BASIC_ENERGY_HARVESTER
24 
25 #include <iostream>
26 
27 // include from ns-3
28 #include "ns3/traced-value.h"
29 #include "ns3/nstime.h"
30 #include "ns3/event-id.h"
31 #include "energy-harvester.h"
32 #include "ns3/random-variable-stream.h"
33 #include "ns3/device-energy-model.h"
34 
35 namespace ns3 {
36 
49 {
50 public:
51  static TypeId GetTypeId (void);
52 
54 
62  BasicEnergyHarvester (Time updateInterval);
63 
64  virtual ~BasicEnergyHarvester ();
65 
72  void SetHarvestedPowerUpdateInterval (Time updateInterval);
73 
81 
85  double GetTotalHarvestedEnergy (void) const;
86 
94  int64_t AssignStreams (int64_t stream);
95 
96 private:
98  void DoInitialize (void);
99 
101  void DoDispose (void);
102 
106  void CalculateHarvestedPower (void);
111  virtual double DoGetPower (void) const;
112 
118  void UpdateHarvestedPower (void);
119 
120 private:
121 
122  Ptr<RandomVariableStream> m_harvestablePower; // Random variable for the harvestable power
123 
124  TracedValue<double> m_harvestedPower; // current harvested power, in Watt
125  TracedValue<double> m_totalEnergyHarvestedJ; // total harvested energy, in Joule
126 
127  EventId m_energyHarvestingUpdateEvent; // energy harvesting event
128  Time m_lastHarvestingUpdateTime; // last harvesting time
129  Time m_harvestedPowerUpdateInterval; // harvestable energy update interval
130 
131 };
132 
133 } // namespace ns3
134 
135 #endif /* defined(BASIC_ENERGY_HARVESTER) */
Time GetHarvestedPowerUpdateInterval(void) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetHarvestedPowerUpdateInterval(Time updateInterval)
TracedValue< double > m_harvestedPower
void DoInitialize(void)
Defined in ns3::Object.
TracedValue< double > m_totalEnergyHarvestedJ
void CalculateHarvestedPower(void)
Calculates harvested Power.
void UpdateHarvestedPower(void)
This function is called every m_energyHarvestingUpdateInterval in order to update the amount of power...
Energy harvester base class.
virtual double DoGetPower(void) const
An identifier for simulation events.
Definition: event-id.h:53
Ptr< RandomVariableStream > m_harvestablePower
void DoDispose(void)
Defined in ns3::Object.
int64_t AssignStreams(int64_t stream)
BasicEnergyHarvester increases remaining energy stored in an associated Energy Source.
a unique identifier for an interface.
Definition: type-id.h:58
double GetTotalHarvestedEnergy(void) const
Get Total Harvested Energy.