From 83a10c9dd2ffc874f428a02bf1ad7df5a6508467 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Tue, 24 Jan 2012 13:38:59 +0100 Subject: [PATCH] REM helper deactivates PHYs instead of removing, and exit when done by default --- src/lte/examples/lena-rem-sector-antenna.cc | 8 +++--- src/lte/examples/lena-rem.cc | 4 +-- .../helper/radio-environment-map-helper.cc | 17 +++++++++--- src/lte/helper/radio-environment-map-helper.h | 4 ++- src/lte/model/rem-spectrum-phy.cc | 26 +++++++++++++------ src/lte/model/rem-spectrum-phy.h | 13 ++++++++++ 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/lte/examples/lena-rem-sector-antenna.cc b/src/lte/examples/lena-rem-sector-antenna.cc index 87cedff7a..800a1558a 100644 --- a/src/lte/examples/lena-rem-sector-antenna.cc +++ b/src/lte/examples/lena-rem-sector-antenna.cc @@ -215,17 +215,19 @@ main (int argc, char *argv[]) } Simulator::Stop (Seconds (simTime)); - lteHelper->EnableTraces (); + + // better to leave traces disabled + //lteHelper->EnableTraces (); Ptr remHelper = CreateObject (); remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0")); remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); remHelper->SetAttribute ("XMin", DoubleValue (-200.0)); remHelper->SetAttribute ("XMax", DoubleValue (1200.0)); - remHelper->SetAttribute ("XRes", UintegerValue (100)); + remHelper->SetAttribute ("XRes", UintegerValue (400)); remHelper->SetAttribute ("YMin", DoubleValue (-300.0)); remHelper->SetAttribute ("YMax", DoubleValue (+3500.0)); - remHelper->SetAttribute ("YRes", UintegerValue (100)); + remHelper->SetAttribute ("YRes", UintegerValue (300)); remHelper->SetAttribute ("Z", DoubleValue (1.5)); remHelper->Install (); // Recall the buildings helper to place the REM nodes in its position diff --git a/src/lte/examples/lena-rem.cc b/src/lte/examples/lena-rem.cc index 5cb00aa0c..2e0ce5c65 100644 --- a/src/lte/examples/lena-rem.cc +++ b/src/lte/examples/lena-rem.cc @@ -90,10 +90,10 @@ int main (int argc, char *argv[]) remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); remHelper->SetAttribute ("XMin", DoubleValue (-400.0)); remHelper->SetAttribute ("XMax", DoubleValue (400.0)); - remHelper->SetAttribute ("XRes", UintegerValue (100)); + remHelper->SetAttribute ("XRes", UintegerValue (40)); remHelper->SetAttribute ("YMin", DoubleValue (-300.0)); remHelper->SetAttribute ("YMax", DoubleValue (300.0)); - remHelper->SetAttribute ("YRes", UintegerValue (75)); + remHelper->SetAttribute ("YRes", UintegerValue (30)); remHelper->SetAttribute ("Z", DoubleValue (0.0)); remHelper->Install (); diff --git a/src/lte/helper/radio-environment-map-helper.cc b/src/lte/helper/radio-environment-map-helper.cc index 2e3b55162..5592d6223 100644 --- a/src/lte/helper/radio-environment-map-helper.cc +++ b/src/lte/helper/radio-environment-map-helper.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,10 @@ RadioEnvironmentMapHelper::GetTypeId (void) DoubleValue (0.0), MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_z), MakeDoubleChecker ()) + .AddAttribute ("ExitWhenDone", "If true, Simulator::Stop () will be called as soon as the REM has been generated", + BooleanValue (true), + MakeBooleanAccessor (&RadioEnvironmentMapHelper::m_exitWhenDone), + MakeBooleanChecker ()) ; return tid; @@ -147,7 +152,7 @@ RadioEnvironmentMapHelper::Install () } } Simulator::Schedule (Seconds (0.0055), &RadioEnvironmentMapHelper::Connect, this); - Simulator::Schedule (Seconds (0.0065), &RadioEnvironmentMapHelper::PrintAndDisconnect, this); + Simulator::Schedule (Seconds (0.0065), &RadioEnvironmentMapHelper::PrintAndDeactivate, this); } @@ -170,7 +175,7 @@ RadioEnvironmentMapHelper::Connect () } void -RadioEnvironmentMapHelper::PrintAndDisconnect () +RadioEnvironmentMapHelper::PrintAndDeactivate () { NS_LOG_FUNCTION (this); std::ofstream outFile; @@ -195,10 +200,16 @@ RadioEnvironmentMapHelper::PrintAndDisconnect () << pos.z << "\t" << it2->phy->GetSinr () << std::endl; - m_channel->RemoveRx (it2->phy); + it2->phy->Deactivate (); } } outFile.close (); + if (m_exitWhenDone) + { + Simulator::Stop (); + Simulator::Destroy (); + exit (0); + } } diff --git a/src/lte/helper/radio-environment-map-helper.h b/src/lte/helper/radio-environment-map-helper.h index 1f95309f2..27ca17906 100644 --- a/src/lte/helper/radio-environment-map-helper.h +++ b/src/lte/helper/radio-environment-map-helper.h @@ -56,7 +56,7 @@ public: private: void Connect (); - void PrintAndDisconnect (); + void PrintAndDeactivate (); struct RemPoint @@ -81,6 +81,8 @@ private: std::string m_channelPath; std::string m_outputFile; + + bool m_exitWhenDone; Ptr m_channel; }; diff --git a/src/lte/model/rem-spectrum-phy.cc b/src/lte/model/rem-spectrum-phy.cc index 15b00bd74..bff9696ed 100644 --- a/src/lte/model/rem-spectrum-phy.cc +++ b/src/lte/model/rem-spectrum-phy.cc @@ -39,7 +39,8 @@ RemSpectrumPhy::RemSpectrumPhy () m_netDevice (0), m_channel (0), m_referenceSignalPower (0), - m_sumPower (0) + m_sumPower (0), + m_active (true) { NS_LOG_FUNCTION (this); } @@ -139,13 +140,16 @@ void RemSpectrumPhy::StartRx (Ptr params) { NS_LOG_FUNCTION ( this << params); - double power = Integral (*(params->psd)); - NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1, - "RemSpectrumPhy works only for LTE signals with duration of 1 ms"); - m_sumPower += power; - if (power > m_referenceSignalPower) - { - m_referenceSignalPower = power; + if (m_active) + { + double power = Integral (*(params->psd)); + NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1, + "RemSpectrumPhy works only for LTE signals with duration of 1 ms"); + m_sumPower += power; + if (power > m_referenceSignalPower) + { + m_referenceSignalPower = power; + } } } @@ -155,5 +159,11 @@ RemSpectrumPhy::GetSinr () return m_referenceSignalPower / (m_sumPower + m_noisePower); } +void +RemSpectrumPhy::Deactivate () +{ + m_active = false; +} + } // namespace ns3 diff --git a/src/lte/model/rem-spectrum-phy.h b/src/lte/model/rem-spectrum-phy.h index 24c0ba953..0230220a3 100644 --- a/src/lte/model/rem-spectrum-phy.h +++ b/src/lte/model/rem-spectrum-phy.h @@ -67,6 +67,11 @@ public: Ptr GetRxAntenna (); void StartRx (Ptr params); + + /** + * set the SpectrumModel to be used for reception + * + */ void SetRxSpectrumModel (Ptr); /** @@ -76,6 +81,12 @@ public: */ double GetSinr (); + /** + * make StartRx a no-op from now on + * + */ + void Deactivate (); + protected: void DoDispose (); @@ -89,6 +100,8 @@ private: double m_sumPower; double m_noisePower; + bool m_active; + };