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