From 62370632d572ee3035f1810de1bc34cde011e331 Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Tue, 17 Apr 2012 11:40:06 +0200 Subject: [PATCH] Update tbId_t struct to TbId_t (coding style) and group SetTxModeGain methods --- src/lte/model/lte-spectrum-phy.cc | 195 +++--------------------------- src/lte/model/lte-spectrum-phy.h | 21 ++-- 2 files changed, 27 insertions(+), 189 deletions(-) diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 894e4f021..817e5f579 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -43,24 +43,24 @@ NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy"); namespace ns3 { -tbId_t::tbId_t () +TbId_t::TbId_t () { } -tbId_t::tbId_t (const uint16_t a, const uint8_t b) +TbId_t::TbId_t (const uint16_t a, const uint8_t b) : m_rnti (a), m_layer (b) { } bool -operator == (const tbId_t &a, const tbId_t &b) +operator == (const TbId_t &a, const TbId_t &b) { return ( (a.m_rnti == b.m_rnti) && (a.m_layer == b.m_layer) ); } bool -operator < (const tbId_t& a, const tbId_t& b) +operator < (const TbId_t& a, const TbId_t& b) { return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_layer < b.m_layer) ) ); } @@ -459,7 +459,7 @@ void LteSpectrumPhy::AddExpectedTb (uint16_t rnti, uint16_t size, uint8_t mcs, std::vector map, uint8_t layer) { NS_LOG_LOGIC (this << " rnti: " << rnti << " size " << size << " mcs " << (uint16_t)mcs << " layer " << (uint8_t)layer); - tbId_t tbId; + TbId_t tbId; tbId.m_rnti = rnti; tbId.m_layer = layer; expectedTbs_t::iterator it; @@ -471,7 +471,7 @@ LteSpectrumPhy::AddExpectedTb (uint16_t rnti, uint16_t size, uint8_t mcs, std:: } // insert new entry tbInfo_t tbInfo = {size, mcs, map, false}; - m_expectedTbs.insert (std::pair (tbId,tbInfo )); + m_expectedTbs.insert (std::pair (tbId,tbInfo )); } @@ -519,7 +519,7 @@ LteSpectrumPhy::EndRx () // retrieve TB info of this packet LteRadioBearerTag tag; (*j)->PeekPacketTag (tag); - tbId_t tbId; + TbId_t tbId; tbId.m_rnti = tag.GetRnti (); tbId.m_layer = tag.GetLayer (); itTb = m_expectedTbs.find (tbId); @@ -568,188 +568,31 @@ LteSpectrumPhy::SetTransmissionMode (uint8_t txMode) m_transmissionMode = txMode; } + void -LteSpectrumPhy::SetTxMode1Gain (double gain) +LteSpectrumPhy::SetTxModeGain (uint8_t txMode, double gain) { NS_LOG_FUNCTION (this << gain); // convert to linear gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 1) - { - m_txModeGain.resize (1); - } - + if (m_txModeGain.size () < txMode) + { + m_txModeGain.resize (txMode); + } std::vector temp; temp = m_txModeGain; m_txModeGain.clear (); for (uint8_t i = 0; i < temp.size (); i++) + { + if (i==txMode-1) { - if (i==0) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } + m_txModeGain.push_back (gain); } - -} - -void -LteSpectrumPhy::SetTxMode2Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 2) + else { - m_txModeGain.resize (2); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==1) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } - } -} - -void -LteSpectrumPhy::SetTxMode3Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 3) - { - m_txModeGain.resize (3); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==2) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } - } -} - -void -LteSpectrumPhy::SetTxMode4Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 4) - { - m_txModeGain.resize (4); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==3) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } - } -} - -void -LteSpectrumPhy::SetTxMode5Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 5) - { - m_txModeGain.resize (5); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==4) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } - } -} - -void -LteSpectrumPhy::SetTxMode6Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 6) - { - m_txModeGain.resize (6); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==5) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } - } -} - -void -LteSpectrumPhy::SetTxMode7Gain (double gain) -{ - NS_LOG_FUNCTION (this << gain); - // convert to linear - gain = pow (10.0, (gain / 10.0)); - if (m_txModeGain.size () < 7) - { - m_txModeGain.resize (7); - } - std::vector temp; - temp = m_txModeGain; - m_txModeGain.clear (); - for (uint8_t i = 0; i < temp.size (); i++) - { - if (i==6) - { - m_txModeGain.push_back (gain); - } - else - { - m_txModeGain.push_back (temp.at (i)); - } + m_txModeGain.push_back (temp.at (i)); } + } } diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h index e678e94ef..88776e25e 100644 --- a/src/lte/model/lte-spectrum-phy.h +++ b/src/lte/model/lte-spectrum-phy.h @@ -41,17 +41,17 @@ namespace ns3 { -struct tbId_t +struct TbId_t { uint16_t m_rnti; uint8_t m_layer; public: - tbId_t (); - tbId_t (const uint16_t a, const uint8_t b); + TbId_t (); + TbId_t (const uint16_t a, const uint8_t b); - friend bool operator == (const tbId_t &a, const tbId_t &b); - friend bool operator < (const tbId_t &a, const tbId_t &b); + friend bool operator == (const TbId_t &a, const TbId_t &b); + friend bool operator < (const TbId_t &a, const TbId_t &b); }; @@ -63,7 +63,7 @@ struct tbInfo_t bool corrupt; }; -typedef std::map expectedTbs_t; +typedef std::map expectedTbs_t; class LteNetDevice; @@ -215,13 +215,8 @@ private: void EndTx (); void EndRx (); - void SetTxMode1Gain (double gain); - void SetTxMode2Gain (double gain); - void SetTxMode3Gain (double gain); - void SetTxMode4Gain (double gain); - void SetTxMode5Gain (double gain); - void SetTxMode6Gain (double gain); - void SetTxMode7Gain (double gain); + void SetTxModeGain (uint8_t txMode, double gain); + Ptr m_mobility; Ptr m_antenna;