collects and formates statistical data from the battery More...
#include <BatteryStats.h>
Inherits BaseModule.

Public Member Functions | |
| virtual void | initialize (int) |
| Basic initialization for all modules. | |
| virtual void | handleMessage (cMessage *) |
| virtual void | receiveBBItem (int category, const BBItem *details, int scopeModuleId) |
| Called by the Blackboard whenever a change of a category occurs to which we have subscribed. Redefined from ImNotifiable. In this base class just handle the host state switching and some debug notifications. | |
| virtual void | finish () |
| virtual void | summary (double, double, simtime_t) |
| invoked by the Battery Module's finish() | |
| virtual void | detail (DeviceEntry *, int) |
| invoked by the Battery Module's at finish() | |
Protected Attributes | |
| int | doDetail |
| int | doTimeSeries |
| Enable tracking of output vectors? | |
| int | batteryCat |
| Blackboard category for the BatteryStats BBItem. | |
| BaseBattery * | battery |
| Pointer to the battery module. | |
Tracked statistic values. | |
| cOutVector | residualVec |
| cOutVector | relativeVec |
| cOutVector | estimateVec |
| cOutVector | estimateRelVec |
collects and formates statistical data from the battery
See BatteryStats.ned for parameters
Generates time series information from BatteryState information published by the battery and by reading its s-o-c information (currently not interesting). Also generates summary statistics when the Battery module passes its DeviceEntry table at finish(). Note: only BatteryStats modules should access BatteryState information, other modules should use Battery's estimateResidual method.
Definition at line 39 of file BatteryStats.h.
| void BatteryStats::detail | ( | DeviceEntry * | devices, | |
| int | numDevices | |||
| ) | [virtual] |
invoked by the Battery Module's at finish()
(should not rely on BatteryStats::finish() to clean up resources
Definition at line 90 of file BatteryStats.cc.
References DeviceEntry::accts, and DeviceEntry::numAccts.
{
Enter_Method_Silent();
if (!doDetail)
return;
recordScalar("num devices", numDevices);
for (int i = 0; i < numDevices; i++){
double total = 0;
for (int j = 0; j < devices[i].numAccts; j++) {
total += devices[i].accts[j];
}
recordScalar(devices[i].name.c_str(), i);
recordScalar("device total (mWs)", total);
for (int j = 0; j < devices[i].numAccts; j++) {
recordScalar("account", j);
recordScalar("energy (mWs)", devices[i].accts[j]);
recordScalar("time (s)", devices[i].times[j]);
}
}
}
| void BatteryStats::initialize | ( | int | stage | ) | [virtual] |
Basic initialization for all modules.
Subscription to Blackboard should be in stage==0, and firing notifications in stage==1 or later.
NOTE: You have to call this in the initialize() function of the inherited class!
Reimplemented from BaseModule.
Definition at line 34 of file BatteryStats.cc.
References battery, batteryCat, doTimeSeries, BaseModule::findHost(), Blackboard::subscribe(), and BaseModule::utility.
{
BaseModule::initialize(stage);
if (stage==0) {
doDetail = 0;
doDetail = par("detail").boolValue();
debugEV << "show details = " << doDetail << endl;
doTimeSeries = 0;
doTimeSeries = par("timeSeries").boolValue();
debugEV << "show timeSeries = " << doTimeSeries << endl;
batteryCat = -1;
if (doTimeSeries) {
int scopeHost = (this->findHost())->getId();
BatteryState bs;
batteryCat = utility->subscribe(this, &bs, scopeHost);
// suggest enabling only residualVec (omnetpp.ini), unless
// others are of interest
residualVec.setName("capacity");
residualVec.setUnit("mW-s");
relativeVec.setName("capacity(relative)");
BaseBattery* batteryModule = FindModule<BaseBattery*>::findSubModule(getParentModule());
if (batteryModule) {
battery = batteryModule;
}
else {
error("no battery module found, please check your Host.ned");
}
estimateVec.setName("estimate");
estimateVec.setUnit("mW-s");
estimateRelVec.setName("estimate(relative)");
}
}
}
| void BatteryStats::summary | ( | double | init, | |
| double | final, | |||
| simtime_t | lifetime | |||
| ) | [virtual] |
invoked by the Battery Module's finish()
(should not rely on BatteryStats::finish() to clean up resources
Definition at line 81 of file BatteryStats.cc.
{
Enter_Method_Silent();
recordScalar("nominal", init, "mW-s");
recordScalar("total", init - final, "mW-s");
recordScalar("lifetime", lifetime, "s");
recordScalar("Mean power consumption", (init - final)/simTime().dbl(), "mW");
}
1.7.1