User Manual, Developers Guide and API Documentation

PhyMeasurementsProbe.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <LTE/macr/PhyCommand.hpp>
00029 #include <LTE/helper/PhyMeasurementsProbe.hpp>
00030 
00031 #include <DLL/Layer2.hpp>
00032 
00033 #include <WNS/service/phy/phymode/PhyModeMapperInterface.hpp>
00034 #include <WNS/StaticFactory.hpp>
00035 
00036 
00037 #include <boost/bind.hpp>
00038 
00039 
00040 using namespace lte::helper;
00041 STATIC_FACTORY_REGISTER_WITH_CREATOR(PhyMeasurementProbe,
00042                      wns::ldk::FunctionalUnit,
00043                      "lte.helper.PhyMeasurement",
00044                      wns::ldk::FUNConfigCreator);
00045 
00046 
00047 PhyMeasurementProbe::PhyMeasurementProbe(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00048     wns::ldk::CommandTypeSpecifier<>(fun),
00049     wns::ldk::HasReceptor<>(),
00050     wns::ldk::HasConnector<>(),
00051     wns::ldk::HasDeliverer<>(),
00052     wns::Cloneable<PhyMeasurementProbe>(),
00053     wns::ldk::Processor<PhyMeasurementProbe>(),
00054     lte::helper::HasModeName(config),
00055     phyCommandReader(NULL),
00056     phyModeMapper(wns::service::phy::phymode::PhyModeMapperInterface::getPhyModeMapper(config.getView("phyModeMapper"))),
00057     sinrProbe(NULL),
00058     sinrEstProbe(NULL),
00059     sinrEstErrProbe(NULL),
00060     rxPwrProbe(NULL),
00061     interfProbe(NULL),
00062     modulationProbe(NULL),
00063     phyModeProbe(NULL),
00064     pathlossProbe(NULL),
00065     logger(config.get("logger"))
00066 {
00067 
00068     dll::ILayer2* layer2 = fun->getLayer<dll::ILayer2*>();
00069     wns::node::Interface* node = layer2->getNode();
00070     wns::probe::bus::ContextProviderCollection localIDs(&node->getContextProviderCollection());
00071 
00072     // read the localIDs from the config
00073     for (int ii = 0; ii<config.len("localIDs.keys()"); ++ii)
00074     {
00075         std::string key = config.get<std::string>("localIDs.keys()",ii);
00076         uint32_t value  = config.get<uint32_t>("localIDs.values()",ii);
00077         localIDs.addProvider(wns::probe::bus::contextprovider::Constant(key, value));
00078         MESSAGE_SINGLE(VERBOSE, logger, "Using Local IDName '"<<key<<"' with value: "<<value);
00079     }
00080 
00081     sinrProbe        = new wns::probe::bus::ContextCollector(localIDs, "lte.SINR");
00082     carrierProbe        = new wns::probe::bus::ContextCollector(localIDs, "lte.Carrier");
00083     interferenceProbe        = new wns::probe::bus::ContextCollector(localIDs, "lte.Interference");
00084     sinrEstProbe = new wns::probe::bus::ContextCollector(localIDs, "lte.SINRest");
00085     sinrEstErrProbe = new wns::probe::bus::ContextCollector(localIDs, "lte.SINRestError");
00086     rxPwrProbe      = new wns::probe::bus::ContextCollector(localIDs, "lte.RxPower");
00087     txPwrProbe      = new wns::probe::bus::ContextCollector(localIDs, "lte.TxPower");
00088     interfProbe     = new wns::probe::bus::ContextCollector(localIDs, "lte.Interference");
00089     iotProbe        = new wns::probe::bus::ContextCollector(localIDs, "lte.IoT");
00090     modulationProbe = new wns::probe::bus::ContextCollector(localIDs, "lte.Modulation");
00091     phyModeProbe    = new wns::probe::bus::ContextCollector(localIDs, "lte.PhyMode");
00092     pathlossProbe   = new wns::probe::bus::ContextCollector(localIDs, "lte.Pathloss");
00093 }
00094 
00095 
00096 PhyMeasurementProbe::~PhyMeasurementProbe()
00097 {
00098     delete sinrProbe; sinrProbe = NULL;
00099     delete carrierProbe; sinrProbe = NULL;
00100     delete interferenceProbe; sinrProbe = NULL;
00101     delete sinrEstProbe; sinrEstProbe = NULL;
00102     delete sinrEstErrProbe; sinrEstErrProbe = NULL;
00103     delete rxPwrProbe; rxPwrProbe = NULL;
00104     delete interfProbe; interfProbe = NULL;
00105     delete iotProbe; iotProbe = NULL;
00106     delete modulationProbe; modulationProbe = NULL;
00107     delete phyModeProbe; phyModeProbe = NULL;
00108     phyCommandReader = NULL;
00109 }
00110 
00111 void
00112 PhyMeasurementProbe::onFUNCreated()
00113 {
00114     phyCommandReader = getFUN()->getCommandReader(modeBase+separator+"phyUser");
00115     assure(phyModeMapper!=NULL,"cannot get phyModeMapper");
00116 }
00117 
00118 void
00119 PhyMeasurementProbe::processIncoming(const wns::ldk::CompoundPtr& compound)
00120 {
00121     lte::macr::PhyCommand* phyCommand =
00122     phyCommandReader->readCommand<lte::macr::PhyCommand>(compound->getCommandPool());
00123 
00124     if (phyCommand->magic.destination == NULL) { // broadcast
00125     // no probing for broadcast compounds, it would be nicer though to
00126     // realize this through a ConnectionIDProvider ...
00127     return;
00128     }
00129 
00130     // TODO: why should the default be 0dB?
00131     // It may be misinterpreted if written to the probes.
00132     wns::Ratio sinrEstimation = wns::Ratio::from_dB(0.0);
00133     if (phyCommand->magic.estimatedSINR.I.get_mW() != 0.0) {
00134     sinrEstimation = phyCommand->magic.estimatedSINR.C / phyCommand->magic.estimatedSINR.I;
00135     }
00136 
00137     double sinr = phyCommand->local.rxPowerMeasurementPtr->getSINR().get_dB();
00138     double estimationError = sinrEstimation.get_dB() - sinr;
00139     double carrier = phyCommand->local.rxPowerMeasurementPtr->getRxPower().get_dBm();
00140     double interference = phyCommand->local.rxPowerMeasurementPtr->getInterferencePower().get_dBm();
00141 
00142     sinrProbe->put(compound, sinr, boost::make_tuple("Peer.NodeID", phyCommand->magic.source->getNodeID()));
00143     interferenceProbe->put(compound, interference, boost::make_tuple("Peer.NodeID", phyCommand->magic.source->getNodeID()));
00144     carrierProbe->put(compound, carrier, boost::make_tuple("Peer.NodeID", phyCommand->magic.source->getNodeID()));
00145     sinrEstProbe->put(compound, sinrEstimation.get_dB());
00146     sinrEstErrProbe->put(compound, estimationError);
00147     rxPwrProbe->put(compound, phyCommand->local.rxPowerMeasurementPtr->getRxPower().get_dBm());
00148     txPwrProbe->put(compound, phyCommand->magic.txp.get_dBm());
00149     interfProbe->put(compound, phyCommand->local.rxPowerMeasurementPtr->getInterferencePower().get_dBm());
00150     iotProbe->put(compound, phyCommand->local.rxPowerMeasurementPtr->getIoT().get_dB());
00151     pathlossProbe->put(compound, phyCommand->magic.txp.get_dBm() - phyCommand->local.rxPowerMeasurementPtr->getRxPower().get_dBm());
00152     wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr = phyCommand->local.phyModePtr;
00153     int phyModeIndex = phyModeMapper->getIndexForPhyMode(*phyModePtr); // O(n)
00154 
00155     modulationProbe->put(compound, phyModePtr->getModulation());
00156     phyModeProbe->put(compound, phyModeIndex);
00157 }
00158 

Generated on Fri May 25 03:32:05 2012 for openWNS by  doxygen 1.5.5