A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
device-energy-model.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 DEVICE_ENERGY_MODEL_H
21#define DEVICE_ENERGY_MODEL_H
22
23#include "ns3/node.h"
24#include "ns3/object.h"
25#include "ns3/ptr.h"
26#include "ns3/type-id.h"
27
28namespace ns3
29{
30namespace energy
31{
32
33class EnergySource;
34
35/**
36 * \ingroup energy
37 * \brief Base class for device energy models.
38 *
39 * A device energy model should represent the energy consumption behavior of a
40 * specific device. It will update remaining energy stored in the EnergySource
41 * object installed on node. When energy is depleted, each DeviceEnergyModel
42 * object installed on the same node will be informed by the EnergySource.
43 *
44 */
46{
47 public:
48 /**
49 * Callback type for ChangeState function. Devices uses this state to notify
50 * DeviceEnergyModel of a state change.
51 */
53
54 public:
55 /**
56 * \brief Get the type ID.
57 * \return The object TypeId.
58 */
59 static TypeId GetTypeId();
61 ~DeviceEnergyModel() override;
62
63 /**
64 * \param source Pointer to energy source installed on node.
65 *
66 * This function sets the pointer to energy source installed on node. Should
67 * be called only by DeviceEnergyModel helper classes.
68 */
69 virtual void SetEnergySource(Ptr<EnergySource> source) = 0;
70
71 /**
72 * \returns Total energy consumption of the device.
73 *
74 * DeviceEnergyModel records its own energy consumption during simulation.
75 */
76 virtual double GetTotalEnergyConsumption() const = 0;
77
78 /**
79 * \param newState New state the device is in.
80 *
81 * DeviceEnergyModel is a state based model. This function is implemented by
82 * all child of DeviceEnergyModel to change the model's state. States are to
83 * be defined by each child using an enum (int).
84 */
85 virtual void ChangeState(int newState) = 0;
86
87 /**
88 * \returns Current draw of the device, in Ampere.
89 *
90 * This function returns the current draw at the device in its current state.
91 * This function is called from the EnergySource to obtain the total current
92 * draw at any given time during simulation.
93 */
94 double GetCurrentA() const;
95
96 /**
97 * This function is called by the EnergySource object when energy stored in
98 * the energy source is depleted. Should be implemented by child classes.
99 */
100 virtual void HandleEnergyDepletion() = 0;
101
102 /**
103 * This function is called by the EnergySource object when energy stored in
104 * the energy source is recharged. Should be implemented by child classes.
105 */
106 virtual void HandleEnergyRecharged() = 0;
107
108 /**
109 * This function is called by the EnergySource object when energy stored in
110 * the energy source is changed. Should be implemented by child classes.
111 */
112 virtual void HandleEnergyChanged() = 0;
113
114 private:
115 /**
116 * \returns 0.0 as the current value, in Ampere.
117 *
118 * Child class does not have to implement this method if current draw for its
119 * states are not know. This default method will always return 0.0A. For the
120 * devices who does know the current draw of its states, this method must be
121 * overwritten.
122 */
123 virtual double DoGetCurrentA() const;
124};
125
126} // namespace energy
127} // namespace ns3
128
129#endif /* DEVICE_ENERGY_MODEL_H */
Callback template class.
Definition: callback.h:438
Introspection did not find any typical Config paths.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Base class for device energy models.
virtual void HandleEnergyRecharged()=0
This function is called by the EnergySource object when energy stored in the energy source is recharg...
virtual void ChangeState(int newState)=0
static TypeId GetTypeId()
Get the type ID.
virtual void HandleEnergyChanged()=0
This function is called by the EnergySource object when energy stored in the energy source is changed...
virtual void HandleEnergyDepletion()=0
This function is called by the EnergySource object when energy stored in the energy source is deplete...
virtual void SetEnergySource(Ptr< EnergySource > source)=0
Callback< void, int > ChangeStateCallback
Callback type for ChangeState function.
virtual double GetTotalEnergyConsumption() const =0
virtual double DoGetCurrentA() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.