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 (
"RvBatteryModelOpenCircuitVoltage",
48 "RV battery model open circuit voltage.",
52 MakeDoubleChecker<double> ())
53 .AddAttribute (
"RvBatteryModelCutoffVoltage",
54 "RV battery model cutoff voltage.",
58 MakeDoubleChecker<double> ())
59 .AddAttribute (
"RvBatteryModelAlphaValue",
60 "RV battery model alpha value.",
64 MakeDoubleChecker<double> ())
65 .AddAttribute (
"RvBatteryModelBetaValue",
66 "RV battery model beta value.",
70 MakeDoubleChecker<double> ())
71 .AddAttribute (
"RvBatteryModelNumOfTerms",
72 "The number of terms of the infinite sum for estimating battery level.",
76 MakeIntegerChecker<int> ())
77 .AddTraceSource (
"RvBatteryModelBatteryLevel",
78 "RV battery model battery level.",
80 .AddTraceSource (
"RvBatteryModelBatteryLifetime",
81 "RV battery model battery lifetime.",
149 NS_LOG_DEBUG (
"RvBatteryModel:Updating remaining energy!");
156 NS_LOG_DEBUG (
"RvBatteryModel:Calculated alpha = " << calculatedAlpha <<
167 if (calculatedAlpha >=
m_alpha)
293 NS_LOG_DEBUG (
"RvBatteryModel:Starting battery level update!");
322 if (t != Seconds (0.0))
341 double calculatedAlpha = 0.0;
359 return calculatedAlpha;
375 double square = beta * beta * m * m;
376 sum += (std::exp (-square * (firstDelta)) - std::exp (-square * (secondDelta))) / square;
378 return delta + 2 * sum;
double Discharge(double load, Time t)
Discharges the battery.
keep track of time values and allow control of global simulation resolution
void SetOpenCircuitVoltage(double voltage)
Sets open circuit voltage of battery.
#define NS_LOG_FUNCTION(parameters)
Time GetSamplingInterval(void) const
virtual double GetSupplyVoltage(void) const
Energy source base class.
double GetBeta(void) const
#define NS_ASSERT(condition)
Hold a signed integer type.
#define NS_LOG_COMPONENT_DEFINE(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)
void HandleEnergyDrainedEvent(void)
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.
double GetAlpha(void) const
virtual void DoInitialize(void)
Defined in ns3::Object.
void BreakDeviceEnergyModelRefCycle(void)
double GetSeconds(void) const
Time GetLifetime(void) const
hold objects of type ns3::Time
void SetSamplingInterval(Time interval)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
TracedValue< Time > m_lifetime
static TypeId GetTypeId(void)
void NotifyEnergyDrained(void)
EventId m_currentSampleEvent
TracedValue< double > m_batteryLevel
#define NS_LOG_DEBUG(msg)
virtual double GetRemainingEnergy(void)
virtual void UpdateEnergySource(void)
double GetOpenCircuitVoltage(void) const
static bool IsFinished(void)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
int GetNumOfTerms(void) const
std::vector< double > m_load
Hold an floating point type.
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)