23 #include "ns3/assert.h"
24 #include "ns3/double.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/simulator.h"
40 .AddConstructor<RvBatteryModel> ()
41 .AddAttribute (
"RvBatteryModelPeriodicEnergyUpdateInterval",
42 "RV battery model sampling interval.",
47 .AddAttribute (
"RvBatteryModelLowBatteryThreshold",
48 "Low battery threshold.",
51 MakeDoubleChecker<double> ())
52 .AddAttribute (
"RvBatteryModelOpenCircuitVoltage",
53 "RV battery model open circuit voltage.",
57 MakeDoubleChecker<double> ())
58 .AddAttribute (
"RvBatteryModelCutoffVoltage",
59 "RV battery model cutoff voltage.",
63 MakeDoubleChecker<double> ())
64 .AddAttribute (
"RvBatteryModelAlphaValue",
65 "RV battery model alpha value.",
69 MakeDoubleChecker<double> ())
70 .AddAttribute (
"RvBatteryModelBetaValue",
71 "RV battery model beta value.",
75 MakeDoubleChecker<double> ())
76 .AddAttribute (
"RvBatteryModelNumOfTerms",
77 "The number of terms of the infinite sum for estimating battery level.",
81 MakeIntegerChecker<int> ())
82 .AddTraceSource (
"RvBatteryModelBatteryLevel",
83 "RV battery model battery level.",
85 "ns3::TracedValue::DoubleCallback")
86 .AddTraceSource (
"RvBatteryModelBatteryLifetime",
87 "RV battery model battery lifetime.",
89 "ns3::Time::TracedValueCallback")
156 NS_LOG_DEBUG (
"RvBatteryModel:Updating remaining energy!");
163 NS_LOG_DEBUG (
"RvBatteryModel:Calculated alpha = " << calculatedAlpha <<
300 NS_LOG_DEBUG (
"RvBatteryModel:Starting battery level update!");
348 double calculatedAlpha = 0.0;
366 return calculatedAlpha;
382 double square = beta * beta * m * m;
383 sum += (std::exp (-square * (firstDelta)) - std::exp (-square * (secondDelta))) / square;
385 return delta + 2 * sum;
double Discharge(double load, Time t)
Discharges the battery.
Simulation virtual time values and global simulation resolution.
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
#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 m_samplingInterval
(1 / sampling interval) = sampling frequency
Time GetSamplingInterval(void) const
virtual double GetSupplyVoltage(void) const
Introspection did not find any typical Config paths.
double GetBeta(void) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Hold a signed integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetBeta(double beta)
Sets the beta value for the battery model.
virtual ~RvBatteryModel()
virtual double GetInitialEnergy(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void HandleEnergyDrainedEvent(void)
Handles the remaining energy going to zero event.
void SetNumOfTerms(int num)
Sets the number of terms of the infinite sum for estimating battery level.
double m_openCircuitVoltage
void SetCutoffVoltage(double voltage)
Sets cutoff voltage of battery.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
double GetAlpha(void) const
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void DoInitialize(void)
Defined in ns3::Object.
void BreakDeviceEnergyModelRefCycle(void)
This function is called to break reference cycle between EnergySource and DeviceEnergyModel.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time GetLifetime(void) const
AttributeValue implementation for Time.
void SetSamplingInterval(Time interval)
std::vector< Time > m_timeStamps
virtual void DoDispose(void)
Defined in ns3::Object.
double CalculateTotalCurrent(void)
double RvModelAFunction(Time t, Time sk, Time sk_1, double beta)
RV model A function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
TracedValue< Time > m_lifetime
static TypeId GetTypeId(void)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void NotifyEnergyDrained(void)
This function notifies all DeviceEnergyModel of energy depletion event.
EventId m_currentSampleEvent
TracedValue< double > m_batteryLevel
Battery level is defined as: output of Discharge function / alpha value.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual double GetRemainingEnergy(void)
virtual void UpdateEnergySource(void)
Implements UpdateEnergySource.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
double GetOpenCircuitVoltage(void) const
static bool IsFinished(void)
Check if the simulation should finish.
int GetNumOfTerms(void) const
std::vector< double > m_load
This class can be used to hold variables of floating point type such as 'double' or 'float'...
a unique identifier for an interface.
double GetCutoffVoltage(void) const
TypeId SetParent(TypeId tid)
void SetAlpha(double alpha)
Sets the alpha value for the battery model.
virtual double GetEnergyFraction(void)
double GetBatteryLevel(void)