TracedValue<double> m_remainingEnergyJ;
.AddTraceSource ("RemainingEnergy",
"Remaining energy at RVEnergySource.",
MakeTraceSourceAccessor (&RvBatteryModel::m_remainingEnergyJ),
"ns3::TracedValue::DoubleCallback")
2.1- Also used a function to pick-up the variable:
double
RvBatteryModel::GetRemainingEnergy (void)
{
NS_LOG_FUNCTION (this);
UpdateEnergySource ();
m_remainingEnergyJ= m_alpha * GetSupplyVoltage () * m_batteryLevel;
return m_remainingEnergyJ;
}
3.- And finally, on my topology file:
void
RemainingEnergy ( double oldValue, double remainingEnergy)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "s Current remaining energy = " << remainingEnergy << "J - ");
}
[...]
Ptr<RvBatteryModel> rvBatteryPtr = DynamicCast<RvBatteryModel> (sources.Get (1));
rvBatteryPtr->TraceConnectWithoutContext("RemainingEnergy", MakeCallback (&RemainingEnergy));
I have double-checked the default TraceSources available on RV and Li-ion battery models and the coding looks pretty similar. In all of them, the desired variable gets updated in other functions. I guess the mistake is on the RV battery cc model file: How should I set the value of the m_remainingEnergyJ there?
Thanks in advance,
David.
9.00087s Total energy consumed by radio = 8.72442J - ID: 1
9.00087s Current battery level = 98.6926% - ID: 1
9.00087s Current remaining energy = 123396J - ID: 1
--
9.00087s -- Received one packet! Socket: 10.1.1.1 port: 49153
--
So according to that (and due to default values of the RV Battery model), the initial energy is 125031 Joules. According to the remaining Energy the quantity left is 123396. So the energy spent is 1634.6 Joules. The energy is calculated as (alpha * supply voltage * battery level).
On the other hand, the total energy consumed by radio is 8.72442 Joules. It is calculated on the WifiRadioEnergyModel as the product of time length (s) * status-current * rv battery supply voltage.
Is the difference between values-1634.6J and 8.72442J- due to the non-linearity effects or it is a coding mistake?
Thanks in advance.
David.
basicRadioModelPtr->TraceConnect ("TotalEnergyConsumption",PrintID(sources.Get(1)->GetNode()), MakeCallback (&TotalEnergy));
(rvBatteryPtr->GetInitialEnergy())-(rvBatteryPtr->GetRemainingEnergy())
Which value is the correct one, the provided by the subtract of the Initial energy minus the remaining energy?
Shall I ignore the total energy consumption? My goal was to get the same information on the three battery designs (ideal, RV and Li-ion) and compare them in the same scenario with the same values (remaining Energy, ConsumedEnergy, etc.). What is your advice? I mean, which values should I compare on the three scenarios?
Thanks in advance,
David.