From e83db03597f84dcf70f679048ba84488acc4e8e6 Mon Sep 17 00:00:00 2001 From: Budiarto Herman Date: Sun, 18 Aug 2013 17:15:58 +0300 Subject: [PATCH] Additional conversion functions for Hysteresis and A3 Offset --- src/lte/model/lte-common.cc | 72 ++++++++++++++++++++++++++++--------- src/lte/model/lte-common.h | 44 ++++++++++++++++++----- 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/lte/model/lte-common.cc b/src/lte/model/lte-common.cc index 43c868efb..eb52bcb3d 100644 --- a/src/lte/model/lte-common.cc +++ b/src/lte/model/lte-common.cc @@ -243,47 +243,87 @@ EutranMeasurementMapping::QuantizeRsrq (double v) } double -EutranMeasurementMapping::IeValue2ActualHysteresis (uint8_t hysteresis) +EutranMeasurementMapping::IeValue2ActualHysteresis (uint8_t hysteresisIeValue) { - if (hysteresis > 30) + if (hysteresisIeValue > 30) { - NS_FATAL_ERROR ("The value " << hysteresis << " is out of the allowed range (0..30) for Hysteresis"); + NS_FATAL_ERROR ("The value " << (uint16_t) hysteresisIeValue + << " is out of the allowed range (0..30)" + << " for Hysteresis IE value"); } - return (static_cast (hysteresis) * 0.5); + return (static_cast (hysteresisIeValue) * 0.5); +} + +uint8_t +EutranMeasurementMapping::ActualHysteresis2IeValue (double hysteresisDb) +{ + if ((hysteresisDb < 0.0) || (hysteresisDb > 15.0)) + { + NS_FATAL_ERROR ("The value " << hysteresisDb + << " is out of the allowed range (0..15) dB" + << " for hysteresis"); + } + + uint8_t ieValue = lround (hysteresisDb * 2.0); + NS_ASSERT (ieValue >= 0); + NS_ASSERT (ieValue <= 15); + return ieValue; } double -EutranMeasurementMapping::IeValue2ActualA3Offset (int8_t a3Offset) +EutranMeasurementMapping::IeValue2ActualA3Offset (int8_t a3OffsetIeValue) { - if ((a3Offset < -30) || (a3Offset > 30)) + if ((a3OffsetIeValue < -30) || (a3OffsetIeValue > 30)) { - NS_FATAL_ERROR ("The value " << a3Offset << " is out of the allowed range (-30..30) for a3-Offset"); + NS_FATAL_ERROR ("The value " << (int16_t) a3OffsetIeValue + << " is out of the allowed range (-30..30)" + << " for a3-Offset IE value"); } - return (static_cast (a3Offset) * 0.5); + return (static_cast (a3OffsetIeValue) * 0.5); +} + +int8_t +EutranMeasurementMapping::ActualA3Offset2IeValue (double a3OffsetDb) +{ + if ((a3OffsetDb < -15.0) || (a3OffsetDb > 15.0)) + { + NS_FATAL_ERROR ("The value " << a3OffsetDb + << " is out of the allowed range (-15..15) dB" + << " for A3 Offset"); + } + + uint8_t ieValue = lround (a3OffsetDb * 2.0); + NS_ASSERT (ieValue >= -15); + NS_ASSERT (ieValue <= 15); + return ieValue; } double -EutranMeasurementMapping::IeValue2ActualQRxLevMin (int8_t qRxLevMin) +EutranMeasurementMapping::IeValue2ActualQRxLevMin (int8_t qRxLevMinIeValue) { - if ((qRxLevMin < -70) || (qRxLevMin > -22)) + if ((qRxLevMinIeValue < -70) || (qRxLevMinIeValue > -22)) { - NS_FATAL_ERROR ("The value " << qRxLevMin << " is out of the allowed range (-70..-22) for Q-RxLevMin"); + NS_FATAL_ERROR ("The value " << (int16_t) qRxLevMinIeValue + << " is out of the allowed range (-70..-22)" + << " for Q-RxLevMin IE value"); } - return (static_cast (qRxLevMin) * 2); + return (static_cast (qRxLevMinIeValue) * 2); } double -EutranMeasurementMapping::IeValue2ActualQQualMin (int8_t qQualMin) +EutranMeasurementMapping::IeValue2ActualQQualMin (int8_t qQualMinIeValue) { - if ((qQualMin < -34) || (qQualMin > -3)) + if ((qQualMinIeValue < -34) || (qQualMinIeValue > -3)) { - NS_FATAL_ERROR ("The value " << qQualMin << " is out of the allowed range (-34..-3) for Q-QualMin"); + NS_FATAL_ERROR ("The value " << (int16_t) qQualMinIeValue + << " is out of the allowed range (-34..-3)" + << " for Q-QualMin IE value"); } - return (static_cast (qQualMin)); + return (static_cast (qQualMinIeValue)); } }; // namespace ns3 diff --git a/src/lte/model/lte-common.h b/src/lte/model/lte-common.h index 001f762aa..e9510729a 100644 --- a/src/lte/model/lte-common.h +++ b/src/lte/model/lte-common.h @@ -214,47 +214,75 @@ public: /** * \brief Returns the actual value of a hysteresis parameter. - * \param hysteresis IE value of hysteresis + * \param hysteresisIeValue IE value of hysteresis * \return actual value in dB, which is IE value * 0.5 dB * * As per section 6.3.5 of 3GPP TS 36.331. * + * The allowed values for hysteresis IE value are between 0 and 30. + * * \sa LteRrcSap::ReportConfigEutra */ - static double IeValue2ActualHysteresis (uint8_t hysteresis); + static double IeValue2ActualHysteresis (uint8_t hysteresisIeValue); + + /** + * \brief Returns the IE value of hysteresis. + * \param hysteresisDb actual hysteresis value in dB + * \return IE value of hysteresis in dB, which is actual value * 2, rounded + * to the nearest integer + * + * The allowed values for hysteresis are between 0 and 15 dB. + * + * \sa LteRrcSap::ReportConfigEutra + */ + static uint8_t ActualHysteresis2IeValue (double hysteresisDb); /** * \brief Returns the actual value of an a3-Offset parameter. - * \param a3-Offset IE value of a3-offset + * \param a3OffsetIeValue IE value of a3-Offset * \return actual value in dB, which is IE value * 0.5 dB * * As per section 6.3.5 of 3GPP TS 36.331. * + * The allowed values for a3-Offset IE value are between -30 and 30. + * * \sa LteRrcSap::ReportConfigEutra */ - static double IeValue2ActualA3Offset (int8_t a3Offset); + static double IeValue2ActualA3Offset (int8_t a3OffsetIeValue); + + /** + * \brief Returns the IE value of a3-Offset. + * \param a3OffsetDb actual A3 Offset value in dB + * \return IE value of a3-Offset in dB, which is actual value * 2, rounded + * to the nearest integer + * + * The allowed values for A3 Offset are between -15 and 15 dB. + * + * \sa LteRrcSap::ReportConfigEutra + */ + static int8_t ActualA3Offset2IeValue (double a3OffsetDb); /** * \brief Returns the actual value of an Q-RxLevMin parameter. - * \param IE value of Q-RxLevMin + * \param qRxLevMinIeValue IE value of Q-RxLevMin * \return Q-RxLevMin actual value in dBm, which is IE value * 2 dBm * * As per section 6.3.4 of 3GPP TS 36.331. * * \sa LteRrcSap::CellSelectionInfo */ - static double IeValue2ActualQRxLevMin (int8_t qRxLevMin); + static double IeValue2ActualQRxLevMin (int8_t qRxLevMinIeValue); /** * \brief Returns the actual value of an Q-QualMin parameter. - * \param IE value of Q-QualMin + * \param qQualMinIeValue IE value of Q-QualMin * \return Q-QualMin actual value in dB, which is IE value dB * * As per section 6.3.4 of 3GPP TS 36.331. * * \sa LteRrcSap::CellSelectionInfo */ - static double IeValue2ActualQQualMin (int8_t qQualMin); + static double IeValue2ActualQQualMin (int8_t qQualMinIeValue); }; // end of class EutranMeasurementMapping