23 #include "ns3/assert.h" 
   24 #include "ns3/double.h" 
   25 #include "ns3/trace-source-accessor.h" 
   26 #include "ns3/simulator.h" 
   41     .AddConstructor<RvBatteryModel> ()
 
   42     .AddAttribute (
"RvBatteryModelPeriodicEnergyUpdateInterval",
 
   43                    "RV battery model sampling interval.",
 
   48     .AddAttribute (
"RvBatteryModelOpenCircuitVoltage",
 
   49                    "RV battery model open circuit voltage.",
 
   53                    MakeDoubleChecker<double> ())
 
   54     .AddAttribute (
"RvBatteryModelCutoffVoltage",
 
   55                    "RV battery model cutoff voltage.",
 
   59                    MakeDoubleChecker<double> ())
 
   60     .AddAttribute (
"RvBatteryModelAlphaValue",
 
   61                    "RV battery model alpha value.",
 
   65                    MakeDoubleChecker<double> ())
 
   66     .AddAttribute (
"RvBatteryModelBetaValue",
 
   67                    "RV battery model beta value.",
 
   71                    MakeDoubleChecker<double> ())
 
   72     .AddAttribute (
"RvBatteryModelNumOfTerms",
 
   73                    "The number of terms of the infinite sum for estimating battery level.",
 
   77                    MakeIntegerChecker<int> ())
 
   78     .AddTraceSource (
"RvBatteryModelBatteryLevel",
 
   79                      "RV battery model battery level.",
 
   81     .AddTraceSource (
"RvBatteryModelBatteryLifetime",
 
   82                      "RV battery model battery lifetime.",
 
  150   NS_LOG_DEBUG (
"RvBatteryModel:Updating remaining energy!");
 
  157   NS_LOG_DEBUG (
"RvBatteryModel:Calculated alpha = " << calculatedAlpha <<
 
  168   if (calculatedAlpha >= 
m_alpha)
 
  294   NS_LOG_DEBUG (
"RvBatteryModel:Starting battery level update!");
 
  323       if (t != Seconds (0.0))
 
  342   double calculatedAlpha = 0.0;
 
  360   return calculatedAlpha;
 
  376       double square = beta * beta * m * m;
 
  377       sum += (std::exp (-square * (firstDelta)) - std::exp (-square * (secondDelta))) / square;
 
  379   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 m_samplingInterval
(1 / sampling interval) = sampling frequency 
 
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. 
 
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
 
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. 
 
double GetAlpha(void) const 
 
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 
 
Time GetLifetime(void) const 
 
hold objects of type ns3::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. 
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
 
static Time Now(void)
Return the "current simulation time". 
 
TracedValue< Time > m_lifetime
 
static TypeId GetTypeId(void)
 
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)
 
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)
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
 
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. 
 
int GetNumOfTerms(void) const 
 
std::vector< double > m_load
 
Hold a 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. 
 
NS_LOG_COMPONENT_DEFINE("RvBatteryModel")
 
virtual double GetEnergyFraction(void)
 
double GetBatteryLevel(void)