A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-device-energy-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Andrea Sacco
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 * Author: Andrea Sacco <andrea.sacco85@gmail.com>
18 */
19
20#ifndef SIMPLE_DEVICE_ENERGY_MODEL_H
21#define SIMPLE_DEVICE_ENERGY_MODEL_H
22
23#include "device-energy-model.h"
24
25#include "ns3/nstime.h"
26#include "ns3/traced-value.h"
27
28namespace ns3
29{
30namespace energy
31{
32
33/**
34 * \ingroup energy
35 *
36 * A simple device energy model where current drain can be set by the user.
37 *
38 * It is supposed to be used as a testing model for energy sources.
39 *
40 */
42{
43 public:
44 /**
45 * \brief Get the type ID.
46 * \return The object TypeId.
47 */
48 static TypeId GetTypeId();
50 ~SimpleDeviceEnergyModel() override;
51
52 /**
53 * \brief Sets pointer to node.
54 *
55 * \param node Pointer to node.
56 *
57 * Implements DeviceEnergyModel::SetNode.
58 */
59 virtual void SetNode(Ptr<Node> node);
60
61 /**
62 * \brief Gets pointer to node.
63 *
64 * \returns Pointer to node.
65 *
66 * Implements DeviceEnergyModel::GetNode.
67 */
68 virtual Ptr<Node> GetNode() const;
69
70 /**
71 * \brief Sets pointer to EnergySource installed on node.
72 *
73 * \param source Pointer to EnergySource installed on node.
74 *
75 * Implements DeviceEnergyModel::SetEnergySource.
76 */
77 void SetEnergySource(Ptr<EnergySource> source) override;
78
79 /**
80 * \returns Total energy consumption of the vehicle.
81 *
82 * Implements DeviceEnergyModel::GetTotalEnergyConsumption.
83 */
84 double GetTotalEnergyConsumption() const override;
85
86 /**
87 * \param newState New state the device is in.
88 *
89 * Not implemented
90 */
91 void ChangeState(int newState) override
92 {
93 }
94
95 /**
96 * \brief Handles energy depletion.
97 *
98 * Not implemented
99 */
100 void HandleEnergyDepletion() override
101 {
102 }
103
104 /**
105 * \brief Handles energy recharged.
106 *
107 * Not implemented
108 */
109 void HandleEnergyRecharged() override
110 {
111 }
112
113 /**
114 * \brief Handles energy changed.
115 *
116 * Not implemented
117 */
118 void HandleEnergyChanged() override
119 {
120 }
121
122 /**
123 * \param current the current draw of device.
124 *
125 * Set the actual current draw of the device.
126 */
127 void SetCurrentA(double current);
128
129 private:
130 void DoDispose() override;
131
132 /**
133 * \returns Current draw of device, at current state.
134 *
135 * Implements DeviceEnergyModel::GetCurrentA.
136 */
137 double DoGetCurrentA() const override;
138
139 Time m_lastUpdateTime; //!< Last update time
140 double m_actualCurrentA; //!< actual curred (in Ampere)
141 Ptr<EnergySource> m_source; //!< Energy source
142 Ptr<Node> m_node; //!< Node
143 TracedValue<double> m_totalEnergyConsumption; //!< Total energy consumption trace
144};
145
146} // namespace energy
147} // namespace ns3
148
149#endif /* SIMPLE_DEVICE_ENERGY_MODEL_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Base class for device energy models.
A simple device energy model where current drain can be set by the user.
virtual Ptr< Node > GetNode() const
Gets pointer to node.
double m_actualCurrentA
actual curred (in Ampere)
void HandleEnergyRecharged() override
Handles energy recharged.
void HandleEnergyDepletion() override
Handles energy depletion.
void SetEnergySource(Ptr< EnergySource > source) override
Sets pointer to EnergySource installed on node.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
Ptr< EnergySource > m_source
Energy source.
void HandleEnergyChanged() override
Handles energy changed.
TracedValue< double > m_totalEnergyConsumption
Total energy consumption trace.
Every class exported by the ns3 library is enclosed in the ns3 namespace.