spectrum: Convert model instances to function calls

This commit is contained in:
Ivey
2024-11-19 12:31:13 -05:00
committed by Gabriel Ferreira
parent 4d83351070
commit c8c1e5d3b3
5 changed files with 31 additions and 58 deletions

View File

@@ -255,7 +255,7 @@ main(int argc, char** argv)
SpectrumAnalyzerHelper spectrumAnalyzerHelper;
spectrumAnalyzerHelper.SetChannel(channel);
spectrumAnalyzerHelper.SetRxSpectrumModel(SpectrumModelIsm2400MhzRes1Mhz);
spectrumAnalyzerHelper.SetRxSpectrumModel(SpectrumModelIsm2400MhzRes1Mhz());
spectrumAnalyzerHelper.SetPhyAttribute("Resolution", TimeValue(MilliSeconds(2)));
spectrumAnalyzerHelper.SetPhyAttribute("NoisePowerSpectralDensity",
DoubleValue(1e-15)); // -120 dBm/Hz

View File

@@ -13,35 +13,18 @@ namespace ns3
/**
* @ingroup spectrum
* Spectrum model logger for frequencies between 300 Khz 300 Ghz
* Spectrum model logger for frequencies between 300 KHz 300 GHz
*/
Ptr<SpectrumModel> SpectrumModel300Khz300GhzLog;
/**
* @ingroup spectrum
*
* Static initializer class for Spectrum model logger
* for frequencies between 300 Khz 300 Ghz
*/
class static_SpectrumModel300Khz300GhzLog_initializer
{
public:
static_SpectrumModel300Khz300GhzLog_initializer()
Ptr<SpectrumModel>
SpectrumModel300Khz300GhzLog()
{
std::vector<double> freqs;
for (double f = 3e5; f < 3e11; f = f * 2)
{
freqs.push_back(f);
}
SpectrumModel300Khz300GhzLog = Create<SpectrumModel>(freqs);
static Ptr<SpectrumModel> model = Create<SpectrumModel>(freqs);
return model;
}
};
/**
* @ingroup spectrum
* Static variable for analyzer initialization
*/
static_SpectrumModel300Khz300GhzLog_initializer
g_static_SpectrumModel300Khz300GhzLog_initializer_instance;
} // namespace ns3

View File

@@ -14,8 +14,12 @@
namespace ns3
{
extern Ptr<SpectrumModel> SpectrumModel300Khz300GhzLog;
/**
* @brief Spectrum model logger for frequencies between 300 KHz 300 GHz
* @return Spectrum model with a range of 300 KHz to 300 GHz for center frequencies
*/
Ptr<SpectrumModel> SpectrumModel300Khz300GhzLog();
}
} // namespace ns3
#endif /* FREQS_300KHZ_300GHZ_LOG_H */

View File

@@ -16,35 +16,16 @@ namespace ns3
* Spectrum model logger for frequencies in the 2.4 GHz ISM band
* with 1 MHz resolution.
*/
Ptr<SpectrumModel> SpectrumModelIsm2400MhzRes1Mhz;
/**
* @ingroup spectrum
*
* Static initializer class for Spectrum model logger for
* frequencies in the 2.4 GHz ISM band with 1 MHz resolution.
*/
class static_SpectrumModelIsm2400MhzRes1Mhz_initializer
Ptr<SpectrumModel>
SpectrumModelIsm2400MhzRes1Mhz()
{
public:
static_SpectrumModelIsm2400MhzRes1Mhz_initializer()
{
std::vector<double> freqs;
freqs.reserve(100);
std::vector<double> freqs(100);
for (int i = 0; i < 100; ++i)
{
freqs.push_back((i + 2400) * 1e6);
freqs[i] = ((i + 2400) * 1e6);
}
SpectrumModelIsm2400MhzRes1Mhz = Create<SpectrumModel>(freqs);
static Ptr<SpectrumModel> model = Create<SpectrumModel>(freqs);
return model;
}
};
/**
* @ingroup spectrum
* Static variable for analyzer initialization
*/
static_SpectrumModelIsm2400MhzRes1Mhz_initializer
g_static_SpectrumModelIsm2400MhzRes1Mhz_initializer_instance;
} // namespace ns3

View File

@@ -14,8 +14,13 @@
namespace ns3
{
extern Ptr<SpectrumModel> SpectrumModelIsm2400MhzRes1Mhz;
/**
* @brief Spectrum model logger for frequencies in the 2.4 GHz ISM band
* with 1 MHz resolution.
* @return Spectrum model for 2.4 GHz ISM band
*/
Ptr<SpectrumModel> SpectrumModelIsm2400MhzRes1Mhz();
}
} // namespace ns3
#endif /* FREQS_ISM2400MHZ_RES1MHZ_H */