Public Member Functions | Protected Member Functions | Protected Attributes

WorldUtilityStats Class Reference
[IEEE 802.15.4 Narrow band example - Classes from the ieee802154Narrow example]

Collects global statistics (like channel usage) from the global blackboard. More...

#include <WorldUtilityStats.h>

Inherits BaseWorldUtility, and ImNotifiable.

Collaboration diagram for WorldUtilityStats:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void receiveBBItem (int category, const BBItem *details, int scopeModuleId)
 Called by the Blackboard whenever a change of a category occurs to which this client has subscribed.
virtual void finish ()

Protected Member Functions

virtual void initialize (int stage)

Protected Attributes

int catPacket
 BBItem category for Packets.
double bitsSent
 Stores the number of bits sent.
double bitsReceived
 Stores the number of bits received.
cOutVector sent
cOutVector rcvd
bool recordVectors
double bitrate

Detailed Description

Collects global statistics (like channel usage) from the global blackboard.

Definition at line 28 of file WorldUtilityStats.h.


Member Function Documentation

void WorldUtilityStats::receiveBBItem ( int  category,
const BBItem details,
int  scopeModuleId 
) [virtual]

Called by the Blackboard whenever a change of a category occurs to which this client has subscribed.

If your class is derived from a class that also is notifiable, make sure that you call it first thing you do. E.g.

BaseClass : public ImNotifiable ...

YourClass : public BaseClass ...

YourClass::receiveBBItem(category, details, scopeModuleId) { BaseClass::receiveBBItem(category, details, scopeModuleId); switch(category) { ... } }

This also implies that you should handle unknown categories gracefully -- maybe a subclass subscribed to them.

This function is called from within publishBBItem, please pay attention to race conditions that can appear. If you want to schedule messages when this function of your module is called, you have to use the Enter_Method or the Enter_Method_Silent macro.

Implements ImNotifiable.

Definition at line 42 of file WorldUtilityStats.cc.

References bitsReceived, bitsSent, and catPacket.

{
  Enter_Method_Silent();

  if(category == catPacket)
  {
    const Packet* p = static_cast<const Packet*>(details);
    double nbBitsSent = p->getNbBitsSent();
    double nbBitsRcvd = p->getNbBitsReceived();
    bitsSent += nbBitsSent;
    bitsReceived += nbBitsRcvd;

    if(recordVectors) {
      sent.record(bitsSent);
      rcvd.record(bitsReceived);
    }
  }
}


The documentation for this class was generated from the following files: