A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
7
*/
8
9
#ifndef DEVICE_ENERGY_MODEL_H
10
#define DEVICE_ENERGY_MODEL_H
11
12
#include "ns3/node.h"
13
#include "ns3/object.h"
14
#include "ns3/ptr.h"
15
#include "ns3/type-id.h"
16
17
namespace
ns3
18
{
19
namespace
energy
20
{
21
22
class
EnergySource;
23
24
/**
25
* \ingroup energy
26
* \brief Base class for device energy models.
27
*
28
* A device energy model should represent the energy consumption behavior of a
29
* specific device. It will update remaining energy stored in the EnergySource
30
* object installed on node. When energy is depleted, each DeviceEnergyModel
31
* object installed on the same node will be informed by the EnergySource.
32
*
33
*/
34
class
DeviceEnergyModel
:
public
Object
35
{
36
public
:
37
/**
38
* Callback type for ChangeState function. Devices uses this state to notify
39
* DeviceEnergyModel of a state change.
40
*/
41
typedef
Callback<void, int>
ChangeStateCallback
;
42
43
public
:
44
/**
45
* \brief Get the type ID.
46
* \return The object TypeId.
47
*/
48
static
TypeId
GetTypeId
();
49
DeviceEnergyModel
();
50
~DeviceEnergyModel
()
override
;
51
52
/**
53
* \param source Pointer to energy source installed on node.
54
*
55
* This function sets the pointer to energy source installed on node. Should
56
* be called only by DeviceEnergyModel helper classes.
57
*/
58
virtual
void
SetEnergySource
(
Ptr<EnergySource>
source) = 0;
59
60
/**
61
* \returns Total energy consumption of the device.
62
*
63
* DeviceEnergyModel records its own energy consumption during simulation.
64
*/
65
virtual
double
GetTotalEnergyConsumption
()
const
= 0;
66
67
/**
68
* \param newState New state the device is in.
69
*
70
* DeviceEnergyModel is a state based model. This function is implemented by
71
* all child of DeviceEnergyModel to change the model's state. States are to
72
* be defined by each child using an enum (int).
73
*/
74
virtual
void
ChangeState
(
int
newState) = 0;
75
76
/**
77
* \returns Current draw of the device, in Ampere.
78
*
79
* This function returns the current draw at the device in its current state.
80
* This function is called from the EnergySource to obtain the total current
81
* draw at any given time during simulation.
82
*/
83
double
GetCurrentA
()
const
;
84
85
/**
86
* This function is called by the EnergySource object when energy stored in
87
* the energy source is depleted. Should be implemented by child classes.
88
*/
89
virtual
void
HandleEnergyDepletion
() = 0;
90
91
/**
92
* This function is called by the EnergySource object when energy stored in
93
* the energy source is recharged. Should be implemented by child classes.
94
*/
95
virtual
void
HandleEnergyRecharged
() = 0;
96
97
/**
98
* This function is called by the EnergySource object when energy stored in
99
* the energy source is changed. Should be implemented by child classes.
100
*/
101
virtual
void
HandleEnergyChanged
() = 0;
102
103
private
:
104
/**
105
* \returns 0.0 as the current value, in Ampere.
106
*
107
* Child class does not have to implement this method if current draw for its
108
* states are not know. This default method will always return 0.0A. For the
109
* devices who does know the current draw of its states, this method must be
110
* overwritten.
111
*/
112
virtual
double
DoGetCurrentA
()
const
;
113
};
114
115
}
// namespace energy
116
}
// namespace ns3
117
118
#endif
/* DEVICE_ENERGY_MODEL_H */
ns3::Callback
Callback template class.
Definition
callback.h:422
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::energy::DeviceEnergyModel
Base class for device energy models.
Definition
device-energy-model.h:35
ns3::energy::DeviceEnergyModel::HandleEnergyRecharged
virtual void HandleEnergyRecharged()=0
This function is called by the EnergySource object when energy stored in the energy source is recharg...
ns3::energy::DeviceEnergyModel::ChangeState
virtual void ChangeState(int newState)=0
ns3::energy::DeviceEnergyModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
device-energy-model.cc:22
ns3::energy::DeviceEnergyModel::HandleEnergyChanged
virtual void HandleEnergyChanged()=0
This function is called by the EnergySource object when energy stored in the energy source is changed...
ns3::energy::DeviceEnergyModel::GetCurrentA
double GetCurrentA() const
Definition
device-energy-model.cc:42
ns3::energy::DeviceEnergyModel::HandleEnergyDepletion
virtual void HandleEnergyDepletion()=0
This function is called by the EnergySource object when energy stored in the energy source is deplete...
ns3::energy::DeviceEnergyModel::SetEnergySource
virtual void SetEnergySource(Ptr< EnergySource > source)=0
ns3::energy::DeviceEnergyModel::ChangeStateCallback
Callback< void, int > ChangeStateCallback
Callback type for ChangeState function.
Definition
device-energy-model.h:41
ns3::energy::DeviceEnergyModel::DeviceEnergyModel
DeviceEnergyModel()
Definition
device-energy-model.cc:31
ns3::energy::DeviceEnergyModel::GetTotalEnergyConsumption
virtual double GetTotalEnergyConsumption() const =0
ns3::energy::DeviceEnergyModel::DoGetCurrentA
virtual double DoGetCurrentA() const
Definition
device-energy-model.cc:53
ns3::energy::DeviceEnergyModel::~DeviceEnergyModel
~DeviceEnergyModel() override
Definition
device-energy-model.cc:36
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
energy
model
device-energy-model.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0