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

#include <IsotropicDimensionalBackgroundNoise.h>

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

Public Member Functions

 IsotropicDimensionalBackgroundNoise ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) 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::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Protected Member Functions

virtual void initialize (int stage) override
 

Protected Attributes

DimensionSet dimensions
 
Mapping::InterpolationMethod interpolationMode
 
W power
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 

Constructor & Destructor Documentation

inet::physicallayer::IsotropicDimensionalBackgroundNoise::IsotropicDimensionalBackgroundNoise ( )
28  :
30  power(W(NaN))
31 {
32 }
InterpolationMethod
Types of interpolation methods for mappings.
Definition: MappingBase.h:1249
compose< J, pow< s,-1 > > W
Definition: Units.h:770
W power
Definition: IsotropicDimensionalBackgroundNoise.h:33
#define NaN
Definition: INETMath.h:103
Mapping::InterpolationMethod interpolationMode
Definition: IsotropicDimensionalBackgroundNoise.h:32

Member Function Documentation

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

Implements inet::physicallayer::IBackgroundNoise.

73 {
74  const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
75  const simtime_t startTime = listening->getStartTime();
76  const simtime_t endTime = listening->getEndTime();
77  Hz carrierFrequency = bandListening->getCarrierFrequency();
78  Hz bandwidth = bandListening->getBandwidth();
80  Argument position(dimensions);
81  bool hasTimeDimension = dimensions.hasDimension(Dimension::time);
82  bool hasFrequencyDimension = dimensions.hasDimension(Dimension::frequency);
83  if (hasTimeDimension && hasFrequencyDimension) {
84  // before the start
85  position.setTime(0);
86  position.setArgValue(Dimension::frequency, 0);
87  powerMapping->setValue(position, 0);
88  position.setTime(startTime);
89  powerMapping->setValue(position, 0);
90  position.setTime(endTime);
91  powerMapping->setValue(position, 0);
92  // start frequency
93  position.setTime(0);
94  position.setArgValue(Dimension::frequency, (carrierFrequency - bandwidth / 2).get());
95  powerMapping->setValue(position, 0);
96  position.setTime(startTime);
97  powerMapping->setValue(position, power.get());
98  position.setTime(endTime);
99  powerMapping->setValue(position, 0);
100  // end frequency
101  position.setTime(0);
102  position.setArgValue(Dimension::frequency, (carrierFrequency + bandwidth / 2).get());
103  powerMapping->setValue(position, 0);
104  position.setTime(startTime);
105  powerMapping->setValue(position, 0);
106  position.setTime(endTime);
107  powerMapping->setValue(position, 0);
108  }
109  else if (hasTimeDimension) {
110  position.setTime(0);
111  powerMapping->setValue(position, 0);
112  position.setTime(startTime);
113  powerMapping->setValue(position, power.get());
114  position.setTime(endTime);
115  powerMapping->setValue(position, 0);
116  }
117  else if (hasFrequencyDimension) {
118  position.setArgValue(Dimension::frequency, 0);
119  powerMapping->setValue(position, 0);
120  position.setArgValue(Dimension::frequency, (carrierFrequency - bandwidth / 2).get());
121  powerMapping->setValue(position, power.get());
122  position.setArgValue(Dimension::frequency, (carrierFrequency + bandwidth / 2).get());
123  powerMapping->setValue(position, 0);
124  }
125  else
126  throw cRuntimeError("Unknown dimensions");
127  return new DimensionalNoise(startTime, endTime, carrierFrequency, bandwidth, powerMapping);
128 }
static const mapped_type MappedZero
Zero value of a Argument value.
Definition: MappingBase.h:427
pow< s,-1 > Hz
Definition: Units.h:766
bool hasDimension(const DimensionSet::value_type &d) const
Returns true if the passed Dimension is inside this DimensionSet.
Definition: MappingBase.h:282
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
const value_type & get() const
Definition: Units.h:89
static Mapping * createMapping(const DimensionSet &domain=DimensionSet(Dimension::time), Mapping::InterpolationMethod intpl=Mapping::LINEAR)
Returns an appropriate changeable Mapping with the specified domain and the specified interpolation m...
Definition: MappingUtils.cc:103
DimensionSet dimensions
Definition: IsotropicDimensionalBackgroundNoise.h:31
W power
Definition: IsotropicDimensionalBackgroundNoise.h:33
static const Dimension frequency
Shortcut to the frequency Dimension, same as &#39;Dimension("frequency")&#39;, but spares the parsing of a st...
Definition: MappingBase.h:68
Mapping::InterpolationMethod interpolationMode
Definition: IsotropicDimensionalBackgroundNoise.h:32
void inet::physicallayer::IsotropicDimensionalBackgroundNoise::initialize ( int  stage)
overrideprotectedvirtual
35 {
36  cModule::initialize(stage);
37  if (stage == INITSTAGE_LOCAL) {
38  // TODO: factor parsing?
39  const char *dimensionsString = par("dimensions");
40  cStringTokenizer tokenizer(dimensionsString);
41  while (tokenizer.hasMoreTokens()) {
42  const char *dimensionString = tokenizer.nextToken();
43  if (!strcmp("time", dimensionString))
45  else if (!strcmp("frequency", dimensionString))
47  else
48  throw cRuntimeError("Unknown dimension");
49  }
50  const char *interpolationModeString = par("interpolationMode");
51  if (!strcmp("linear", interpolationModeString))
53  else if (!strcmp("sample-hold", interpolationModeString))
55  else
56  throw cRuntimeError("Unknown interpolation mode: '%s'", interpolationModeString);
57  power = mW(math::dBm2mW(par("power")));
58  }
59 }
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
double dBm2mW(double dBm)
Converts a dBm value into milliwatts.
Definition: INETMath.h:176
DimensionSet dimensions
Definition: IsotropicDimensionalBackgroundNoise.h:31
W power
Definition: IsotropicDimensionalBackgroundNoise.h:33
interpolates with next lower entry
Definition: MappingBase.h:1251
Local initializations.
Definition: InitStages.h:35
interpolates linear with next lower and next upper entry constant before the first and after the last...
Definition: MappingBase.h:1256
void addDimension(const DimensionSet::value_type &d)
Adds the passed dimension to the DimensionSet.
Definition: MappingBase.h:274
static const Dimension frequency
Shortcut to the frequency Dimension, same as &#39;Dimension("frequency")&#39;, but spares the parsing of a st...
Definition: MappingBase.h:68
milli< W >::type mW
Definition: Units.h:903
Mapping::InterpolationMethod interpolationMode
Definition: IsotropicDimensionalBackgroundNoise.h:32
std::ostream & inet::physicallayer::IsotropicDimensionalBackgroundNoise::printToStream ( std::ostream &  stream,
int  level 
) const
overridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

62 {
63  stream << "IsotropicDimensionalBackgroundNoise";
64  if (level <= PRINT_LEVEL_DETAIL)
65  stream << ", power = " << power;
66  if (level <= PRINT_LEVEL_TRACE)
67  stream << ", interpolationMode = " << interpolationMode
68  << ", dimensions = " << dimensions ;
69  return stream;
70 }
DimensionSet dimensions
Definition: IsotropicDimensionalBackgroundNoise.h:31
W power
Definition: IsotropicDimensionalBackgroundNoise.h:33
Mapping::InterpolationMethod interpolationMode
Definition: IsotropicDimensionalBackgroundNoise.h:32

Member Data Documentation

DimensionSet inet::physicallayer::IsotropicDimensionalBackgroundNoise::dimensions
protected
Mapping::InterpolationMethod inet::physicallayer::IsotropicDimensionalBackgroundNoise::interpolationMode
protected
W inet::physicallayer::IsotropicDimensionalBackgroundNoise::power
protected

The documentation for this class was generated from the following files: