00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "phyPER.h"
00019
00020 Define_Module(phyPER);
00021
00022 void phyPER::initialize(int stage)
00023 {
00024 BaseModule::initialize(stage);
00025 if(stage == 0) {
00026 catPacket = utility->subscribe(this, &packet, -1);
00027 catUWBIRPacket = utility->subscribe(this, &uwbirpacket, -1);
00028 maiPER.setName("maiPER");
00029 maiPERnoRS.setName("maiPERnoRS");
00030 nbSyncAttempts = 0;
00031 nbSyncSuccesses = 0;
00032 nbRx = 0;
00033 nbRxnoRS = 0;
00034 }
00035 }
00036
00037
00038 void phyPER::receiveBBItem(int category, const BBItem * details, int scopeModuleId) {
00039 if(category == catPacket) {
00040 packet = *(static_cast<const Packet*>(details));
00041 nbRx = static_cast<long>(packet.getNbPacketsReceived());
00042 nbRxnoRS = static_cast<long>(packet.getNbPacketsReceivedNoRS());
00043 } else if(category == catUWBIRPacket) {
00044 uwbirpacket = *(static_cast<const UWBIRPacket*>(details));
00045 nbSyncAttempts = static_cast<long>(uwbirpacket.getNbSyncAttempts());
00046 nbSyncSuccesses = uwbirpacket.getNbSyncSuccesses();
00047 }
00048 if(nbSyncAttempts > 0) {
00049 maiPER.record( static_cast<double>(nbRx) / nbSyncAttempts );
00050 maiPERnoRS.record( static_cast<double>(nbRxnoRS) / nbSyncAttempts );
00051 }
00052
00053 }