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{
30
31/**
32 * \ingroup energy
33 *
34 * A simple device energy model where current drain can be set by the user.
35 *
36 * It is supposed to be used as a testing model for energy sources.
37 *
38 */
40{
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return The object TypeId.
45 */
46 static TypeId GetTypeId();
48 ~SimpleDeviceEnergyModel() override;
49
50 /**
51 * \brief Sets pointer to node.
52 *
53 * \param node Pointer to node.
54 *
55 * Implements DeviceEnergyModel::SetNode.
56 */
57 virtual void SetNode(Ptr<Node> node);
58
59 /**
60 * \brief Gets pointer to node.
61 *
62 * \returns Pointer to node.
63 *
64 * Implements DeviceEnergyModel::GetNode.
65 */
66 virtual Ptr<Node> GetNode() const;
67
68 /**
69 * \brief Sets pointer to EnergySource installed on node.
70 *
71 * \param source Pointer to EnergySource installed on node.
72 *
73 * Implements DeviceEnergyModel::SetEnergySource.
74 */
75 void SetEnergySource(Ptr<EnergySource> source) override;
76
77 /**
78 * \returns Total energy consumption of the vehicle.
79 *
80 * Implements DeviceEnergyModel::GetTotalEnergyConsumption.
81 */
82 double GetTotalEnergyConsumption() const override;
83
84 /**
85 * \param newState New state the device is in.
86 *
87 * Not implemented
88 */
89 void ChangeState(int newState) override
90 {
91 }
92
93 /**
94 * \brief Handles energy depletion.
95 *
96 * Not implemented
97 */
98 void HandleEnergyDepletion() override
99 {
100 }
101
102 /**
103 * \brief Handles energy recharged.
104 *
105 * Not implemented
106 */
107 void HandleEnergyRecharged() override
108 {
109 }
110
111 /**
112 * \brief Handles energy changed.
113 *
114 * Not implemented
115 */
116 void HandleEnergyChanged() override
117 {
118 }
119
120 /**
121 * \param current the current draw of device.
122 *
123 * Set the actual current draw of the device.
124 */
125 void SetCurrentA(double current);
126
127 private:
128 void DoDispose() override;
129
130 /**
131 * \returns Current draw of device, at current state.
132 *
133 * Implements DeviceEnergyModel::GetCurrentA.
134 */
135 double DoGetCurrentA() const override;
136
137 Time m_lastUpdateTime; //!< Last update time
138 double m_actualCurrentA; //!< actual curred (in Ampere)
139 Ptr<EnergySource> m_source; //!< Energy source
140 Ptr<Node> m_node; //!< Node
141 TracedValue<double> m_totalEnergyConsumption; //!< Total energy consumption trace
142};
143
144} // namespace ns3
145
146#endif /* SIMPLE_DEVICE_ENERGY_MODEL_H */
Base class for device energy models.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A simple device energy model where current drain can be set by the user.
void ChangeState(int newState) override
void HandleEnergyChanged() override
Handles energy changed.
static TypeId GetTypeId()
Get the type ID.
virtual Ptr< Node > GetNode() const
Gets pointer to node.
TracedValue< double > m_totalEnergyConsumption
Total energy consumption trace.
double GetTotalEnergyConsumption() const override
void DoDispose() override
Destructor implementation.
virtual void SetNode(Ptr< Node > node)
Sets pointer to node.
void HandleEnergyDepletion() override
Handles energy depletion.
double m_actualCurrentA
actual curred (in Ampere)
void SetEnergySource(Ptr< EnergySource > source) override
Sets pointer to EnergySource installed on node.
Ptr< EnergySource > m_source
Energy source.
void HandleEnergyRecharged() override
Handles energy recharged.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.