23 #include "ns3/assert.h"
24 #include "ns3/double.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/simulator.h"
41 .SetGroupName (
"Energy")
43 .AddAttribute (
"LiIonEnergySourceInitialEnergyJ",
44 "Initial energy stored in basic energy source.",
48 MakeDoubleChecker<double> ())
49 .AddAttribute (
"LiIonEnergyLowBatteryThreshold",
50 "Low battery threshold for LiIon energy source.",
53 MakeDoubleChecker<double> ())
54 .AddAttribute (
"InitialCellVoltage",
55 "Initial (maximum) voltage of the cell (fully charged).",
59 MakeDoubleChecker<double> ())
60 .AddAttribute (
"NominalCellVoltage",
61 "Nominal voltage of the cell.",
64 MakeDoubleChecker<double> ())
65 .AddAttribute (
"ExpCellVoltage",
66 "Cell voltage at the end of the exponential zone.",
69 MakeDoubleChecker<double> ())
70 .AddAttribute (
"RatedCapacity",
71 "Rated capacity of the cell.",
74 MakeDoubleChecker<double> ())
75 .AddAttribute (
"NomCapacity",
76 "Cell capacity at the end of the nominal zone.",
79 MakeDoubleChecker<double> ())
80 .AddAttribute (
"ExpCapacity",
81 "Cell Capacity at the end of the exponential zone.",
84 MakeDoubleChecker<double> ())
85 .AddAttribute (
"InternalResistance",
86 "Internal resistance of the cell",
89 MakeDoubleChecker<double> ())
90 .AddAttribute (
"TypCurrent",
91 "Typical discharge current used to fit the curves",
94 MakeDoubleChecker<double> ())
95 .AddAttribute (
"ThresholdVoltage",
96 "Minimum threshold voltage to consider the battery depleted.",
99 MakeDoubleChecker<double> ())
100 .AddAttribute (
"PeriodicEnergyUpdateInterval",
101 "Time between two consecutive periodic energy updates.",
106 .AddTraceSource (
"RemainingEnergy",
107 "Remaining energy at BasicEnergySource.",
109 "ns3::TracedValueCallback::Double")
115 : m_drainedCapacity (0.0),
116 m_lastUpdateTime (
Seconds (0.0))
216 NS_LOG_DEBUG (
"LiIonEnergySource:Updating remaining energy at node #" <<
264 NS_LOG_DEBUG (
"LiIonEnergySource:Energy depleted at node #" <<
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Introspection did not find any typical Config paths.
Ptr< Node > GetNode(void) const
void BreakDeviceEnergyModelRefCycle(void)
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
double CalculateTotalCurrent(void)
void NotifyEnergyDrained(void)
This function notifies all DeviceEnergyModel of energy depletion event.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Model a generic Lithium Ion Battery basing on [1][2].
double m_drainedCapacity
capacity drained from the cell, in Ah
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
void SetInitialEnergy(double initialEnergyJ)
virtual ~LiIonEnergySource()
virtual double GetInitialEnergy(void) const
void DoDispose(void)
All child's implementation must call BreakDeviceEnergyModelRefCycle to ensure reference cycles to Dev...
double m_minVoltTh
minimum threshold voltage to consider the battery depleted
virtual void IncreaseRemainingEnergy(double energyJ)
Time GetEnergyUpdateInterval(void) const
virtual double GetRemainingEnergy(void)
double m_supplyVoltageV
actual voltage of the cell
TracedValue< double > m_remainingEnergyJ
remaining energy, in Joules
double m_initialEnergyJ
initial energy, in Joules
double m_eFull
initial voltage of the cell, in Volts
void SetEnergyUpdateInterval(Time interval)
double m_internalResistance
internal resistance of the cell, in Ohms
void CalculateRemainingEnergy(void)
Calculates remaining energy.
Time m_energyUpdateInterval
energy update interval
virtual double GetSupplyVoltage(void) const
void SetInitialSupplyVoltage(double supplyVoltageV)
double m_eNom
nominal voltage of the cell, in Volts
double m_lowBatteryTh
low battery threshold, as a fraction of the initial energy
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
double m_eExp
cell voltage at the end of the exponential zone, in Volts
virtual double GetEnergyFraction(void)
EventId m_energyUpdateEvent
energy update event
void DoInitialize(void)
Initialize() implementation.
double m_qNom
cell capacity at the end of the nominal zone, in Ah
double m_qExp
capacity value at the end of the exponential zone, in Ah
double GetVoltage(double current) const
double m_qRated
rated capacity of the cell, in Ah
static TypeId GetTypeId(void)
Get the type ID.
virtual void DecreaseRemainingEnergy(double energyJ)
double m_typCurrent
typical discharge current used to fit the curves
Time m_lastUpdateTime
last update time
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static bool IsFinished(void)
Check if the simulation should finish.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
#define E(name, start, end)