From f53d27ed763239cb1a47673fb8d677088661db41 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Mon, 14 Jun 2010 17:13:43 +0200 Subject: [PATCH] fixed spectrum code for python bindings as per Gustavo's suggestion --- src/common/spectrum-converter.cc | 3 +++ src/common/spectrum-converter.h | 2 ++ src/common/spectrum-value.cc | 3 +++ src/common/spectrum-value.h | 12 ++++++++++++ src/devices/spectrum/aloha-noack-net-device.cc | 7 +++++++ src/devices/spectrum/non-communicating-net-device.cc | 6 ++++++ src/devices/spectrum/waveform-generator.h | 10 ---------- src/helper/adhoc-aloha-noack-ideal-phy-helper.cc | 1 + src/helper/spectrum-analyzer-helper.cc | 2 ++ src/helper/waveform-generator-helper.cc | 3 ++- 10 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/common/spectrum-converter.cc b/src/common/spectrum-converter.cc index 71c32d660..0a48e5e30 100644 --- a/src/common/spectrum-converter.cc +++ b/src/common/spectrum-converter.cc @@ -29,6 +29,9 @@ NS_LOG_COMPONENT_DEFINE ("SpectrumConverter"); namespace ns3 { +SpectrumConverter::SpectrumConverter () +{ +} SpectrumConverter::SpectrumConverter (Ptr fromSpectrumModel, Ptr toSpectrumModel) { diff --git a/src/common/spectrum-converter.h b/src/common/spectrum-converter.h index e1bfad2cf..82da3fb93 100644 --- a/src/common/spectrum-converter.h +++ b/src/common/spectrum-converter.h @@ -50,6 +50,8 @@ public: */ SpectrumConverter (Ptr fromSpectrumModel, Ptr toSpectrumModel); + SpectrumConverter (); + /** diff --git a/src/common/spectrum-value.cc b/src/common/spectrum-value.cc index 4582c7f0b..8ba0dae69 100644 --- a/src/common/spectrum-value.cc +++ b/src/common/spectrum-value.cc @@ -31,6 +31,9 @@ NS_LOG_COMPONENT_DEFINE ("SpectrumValue"); namespace ns3 { +SpectrumValue::SpectrumValue () +{ +} SpectrumValue::SpectrumValue (Ptr sof) : m_spectrumModel (sof), diff --git a/src/common/spectrum-value.h b/src/common/spectrum-value.h index 24ea0999c..d70603366 100644 --- a/src/common/spectrum-value.h +++ b/src/common/spectrum-value.h @@ -74,6 +74,10 @@ public: */ SpectrumValue (Ptr sm); + + SpectrumValue (); + + /** * Access value at given frequency index * @@ -517,6 +521,14 @@ private: std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf); +double Norm (const SpectrumValue& x); +double Sum (const SpectrumValue& x); +double Prod (const SpectrumValue& x); +SpectrumValue Pow (const SpectrumValue& base, double exp); +SpectrumValue Pow (double base, const SpectrumValue& exp); +SpectrumValue Log10 (const SpectrumValue& arg); +SpectrumValue Log2 (const SpectrumValue& arg); +SpectrumValue Log (const SpectrumValue& arg); } // namespace ns3 diff --git a/src/devices/spectrum/aloha-noack-net-device.cc b/src/devices/spectrum/aloha-noack-net-device.cc index 854c3755b..033d44823 100644 --- a/src/devices/spectrum/aloha-noack-net-device.cc +++ b/src/devices/spectrum/aloha-noack-net-device.cc @@ -263,6 +263,13 @@ AlohaNoackNetDevice::GetPhy () const } +void +AlohaNoackNetDevice::SetChannel (Ptr c) +{ + NS_LOG_FUNCTION (this << c); + m_channel = c; +} + Ptr AlohaNoackNetDevice::GetChannel (void) const diff --git a/src/devices/spectrum/non-communicating-net-device.cc b/src/devices/spectrum/non-communicating-net-device.cc index b9511fe0f..f256f41c5 100644 --- a/src/devices/spectrum/non-communicating-net-device.cc +++ b/src/devices/spectrum/non-communicating-net-device.cc @@ -196,6 +196,12 @@ NonCommunicatingNetDevice::GetPhy () const } +void +NonCommunicatingNetDevice::SetChannel (Ptr c) +{ + NS_LOG_FUNCTION (this << c); + m_channel = c; +} Ptr NonCommunicatingNetDevice::GetChannel (void) const diff --git a/src/devices/spectrum/waveform-generator.h b/src/devices/spectrum/waveform-generator.h index 4e0476838..6f3f7eceb 100644 --- a/src/devices/spectrum/waveform-generator.h +++ b/src/devices/spectrum/waveform-generator.h @@ -111,16 +111,6 @@ public: - /** - * Set the time resolution of the generated waveforms. - * - * @param resolution time resolution of the generated - * waveforms. This determines both the duration of waveforms, and - * the time between subsequent waveforms (i.e., they are generated - * back to back during the active portion of the generator cycle). - */ - void SetResolution (Time resolution); - /** * Start the waveform generator * diff --git a/src/helper/adhoc-aloha-noack-ideal-phy-helper.cc b/src/helper/adhoc-aloha-noack-ideal-phy-helper.cc index 394ecbdbc..922bddd82 100644 --- a/src/helper/adhoc-aloha-noack-ideal-phy-helper.cc +++ b/src/helper/adhoc-aloha-noack-ideal-phy-helper.cc @@ -126,6 +126,7 @@ AdhocAlohaNoackIdealPhyHelper::Install (NodeContainer c) const NS_ASSERT_MSG (m_channel, "you forgot to call AdhocAlohaNoackIdealPhyHelper::SetChannel ()"); phy->SetChannel (m_channel); + dev->SetChannel (m_channel); m_channel->AddRx (phy); phy->SetPhyMacTxEndCallback (MakeCallback (&AlohaNoackNetDevice::NotifyTransmissionEnd, dev)); diff --git a/src/helper/spectrum-analyzer-helper.cc b/src/helper/spectrum-analyzer-helper.cc index dafc19089..8b3371921 100644 --- a/src/helper/spectrum-analyzer-helper.cc +++ b/src/helper/spectrum-analyzer-helper.cc @@ -153,6 +153,8 @@ SpectrumAnalyzerHelper::Install (NodeContainer c) const NS_ASSERT_MSG (m_channel, "you forgot to call SpectrumAnalyzerHelper::SetChannel ()"); m_channel->AddRx (phy); + dev->SetChannel (m_channel); + uint32_t devId = node->AddDevice (dev); devices.Add (dev); diff --git a/src/helper/waveform-generator-helper.cc b/src/helper/waveform-generator-helper.cc index 9cf89abc9..1b6b51b96 100644 --- a/src/helper/waveform-generator-helper.cc +++ b/src/helper/waveform-generator-helper.cc @@ -108,7 +108,8 @@ WaveformGeneratorHelper::Install (NodeContainer c) const NS_ASSERT_MSG (m_channel, "you forgot to call WaveformGeneratorHelper::SetChannel ()"); phy->SetChannel (m_channel); - //m_channel->AddRx (phy); + dev->SetChannel (m_channel); + node->AddDevice (dev); devices.Add (dev);