INET Framework for OMNeT++/OMNEST
inet::physicallayer::IsotropicDimensionalBackgroundNoise Class Reference

#include <IsotropicDimensionalBackgroundNoise.h>

Inheritance diagram for inet::physicallayer::IsotropicDimensionalBackgroundNoise:
inet::physicallayer::IBackgroundNoise inet::IPrintableObject

Public Member Functions

virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const override
 Prints this object to the provided output stream. More...
 
virtual const INoisecomputeNoise (const IListening *listening) const override
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string printToString () const
 
virtual std::string printToString (int level, int evFlags=0) const
 
virtual std::string getInfoStringRepresentation (int evFlags=0) const
 
virtual std::string getDetailStringRepresentation (int evFlags=0) const
 
virtual std::string getDebugStringRepresentation (int evFlags=0) const
 
virtual std::string getTraceStringRepresentation (int evFlags=0) const
 
virtual std::string getCompleteStringRepresentation (int evFlags=0) const
 

Protected Member Functions

virtual void initialize (int stage) override
 

Protected Attributes

WpHz powerSpectralDensity = WpHz(NaN)
 
W power = W(NaN)
 
Hz bandwidth = Hz(NaN)
 

Additional Inherited Members

- Public Types inherited from inet::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 

Member Function Documentation

◆ computeNoise()

const INoise * inet::physicallayer::IsotropicDimensionalBackgroundNoise::computeNoise ( const IListening listening) const
overridevirtual

Implements inet::physicallayer::IBackgroundNoise.

48 {
49  const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
50  Hz centerFrequency = bandListening->getCenterFrequency();
51  Hz listeningBandwidth = bandListening->getBandwidth();
52  WpHz noisePowerSpectralDensity;
53  if (!std::isnan(powerSpectralDensity.get()))
54  noisePowerSpectralDensity = powerSpectralDensity;
55  else {
56  if (std::isnan(bandwidth.get()))
57  bandwidth = listeningBandwidth;
58  else if (bandwidth != listeningBandwidth)
59  throw cRuntimeError("The powerSpectralDensity parameter is not specified and the power parameter cannot be used, because background noise bandwidth doesn't match listening bandwidth");
60  // NOTE: dividing by the bandwidth here makes sure the total background noise power in the listening band is the given power
61  noisePowerSpectralDensity = power / bandwidth;
62  }
63  const Ptr<const IFunction<WpHz, Domain<simsec, Hz>>>& powerFunction = makeShared<ConstantFunction<WpHz, Domain<simsec, Hz>>>(noisePowerSpectralDensity);
64  const simtime_t startTime = listening->getStartTime();
65  const simtime_t endTime = listening->getEndTime();
66  return new DimensionalNoise(startTime, endTime, centerFrequency, bandwidth, makeFirstQuadrantLimitedFunction(powerFunction));
67 }

◆ initialize()

void inet::physicallayer::IsotropicDimensionalBackgroundNoise::initialize ( int  stage)
overrideprotectedvirtual
20 {
21  cModule::initialize(stage);
22  if (stage == INITSTAGE_LOCAL) {
23  powerSpectralDensity = WpHz(dBmWpMHz2WpHz(par("powerSpectralDensity")));
24  power = mW(dBmW2mW(par("power")));
25  bandwidth = Hz(par("bandwidth"));
26  if (std::isnan(powerSpectralDensity.get()) && std::isnan(power.get()))
27  throw cRuntimeError("One of powerSpectralDensity or power parameters must be specified");
28  if (!std::isnan(powerSpectralDensity.get()) && !std::isnan(power.get()))
29  throw cRuntimeError("Both of powerSpectralDensity and power parameters cannot be specified");
30  }
31 }

◆ printToStream()

std::ostream & inet::physicallayer::IsotropicDimensionalBackgroundNoise::printToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
overridevirtual

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

34 {
35  stream << "IsotropicDimensionalBackgroundNoise";
36  if (level <= PRINT_LEVEL_DETAIL) {
37  if (!std::isnan(powerSpectralDensity.get()))
38  stream << EV_FIELD(powerSpectralDensity);
39  else {
40  stream << EV_FIELD(power);
41  stream << EV_FIELD(bandwidth);
42  }
43  }
44  return stream;
45 }

Member Data Documentation

◆ bandwidth

Hz inet::physicallayer::IsotropicDimensionalBackgroundNoise::bandwidth = Hz(NaN)
mutableprotected

◆ power

W inet::physicallayer::IsotropicDimensionalBackgroundNoise::power = W(NaN)
protected

◆ powerSpectralDensity

WpHz inet::physicallayer::IsotropicDimensionalBackgroundNoise::powerSpectralDensity = WpHz(NaN)
protected

The documentation for this class was generated from the following files:
inet::physicallayer::IsotropicDimensionalBackgroundNoise::bandwidth
Hz bandwidth
Definition: IsotropicDimensionalBackgroundNoise.h:22
inet::units::units::Hz
pow< s, -1 > Hz
Definition: Units.h:935
inet::IPrintableObject::PRINT_LEVEL_DETAIL
@ PRINT_LEVEL_DETAIL
Definition: IPrintableObject.h:24
inet::math::dBmW2mW
double dBmW2mW(double dBm)
Converts a dBmW value to mW.
Definition: INETMath.h:163
inet::physicallayer::IsotropicDimensionalBackgroundNoise::power
W power
Definition: IsotropicDimensionalBackgroundNoise.h:21
inet::units::units::mW
milli< W >::type mW
Definition: Units.h:1080
inet::physicallayer::IsotropicDimensionalBackgroundNoise::powerSpectralDensity
WpHz powerSpectralDensity
Definition: IsotropicDimensionalBackgroundNoise.h:20
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::units::units::WpHz
compose< W, pow< Hz, -1 > > WpHz
Definition: Units.h:940
inet::math::makeFirstQuadrantLimitedFunction
Ptr< const DomainLimitedFunction< R, D > > makeFirstQuadrantLimitedFunction(const Ptr< const IFunction< R, D >> &f)
Definition: CompoundFunctions.h:71
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::math::dBmWpMHz2WpHz
double dBmWpMHz2WpHz(double dBmWpMHz)
Converts a dBmW/MHz value into W/Hz.
Definition: INETMath.h:173
inet::units::value::get
const value_type & get() const
Definition: Units.h:108