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

#include <InterpolatingAntenna.h>

Inheritance diagram for inet::physicallayer::InterpolatingAntenna:
inet::physicallayer::AntennaBase inet::physicallayer::IAntenna inet::physicallayer::IPrintableObject

Public Member Functions

 InterpolatingAntenna ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual double getMinGain () const
 
virtual double getMaxGain () const override
 Returns the maximum possible antenna gain independent of any direction. More...
 
virtual double computeGain (const EulerAngles direction) const override
 Returns the antenna gain in the provided direction. More...
 
- Public Member Functions inherited from inet::physicallayer::AntennaBase
 AntennaBase ()
 
virtual IMobilitygetMobility () const override
 Returns the mobility of this antenna that describes its position and orientation over time. More...
 
virtual int getNumAntennas () const override
 Returns the number of antennas in the array. More...
 
- 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
 
virtual void parseMap (std::map< double, double > &gainMap, const char *text)
 
virtual double computeGain (const std::map< double, double > &gainMap, double angle) const
 

Protected Attributes

double minGain
 
double maxGain
 
std::map< double, double > elevationGainMap
 
std::map< double, double > headingGainMap
 
std::map< double, double > bankGainMap
 
- Protected Attributes inherited from inet::physicallayer::AntennaBase
IMobilitymobility
 
int numAntennas
 

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::InterpolatingAntenna::InterpolatingAntenna ( )
26  :
27  AntennaBase(),
28  minGain(NaN),
29  maxGain(NaN)
30 {
31 }
AntennaBase()
Definition: AntennaBase.cc:25
double maxGain
Definition: InterpolatingAntenna.h:31
double minGain
Definition: InterpolatingAntenna.h:30
#define NaN
Definition: INETMath.h:103

Member Function Documentation

double inet::physicallayer::InterpolatingAntenna::computeGain ( const std::map< double, double > &  gainMap,
double  angle 
) const
protectedvirtual

Referenced by computeGain().

80 {
81  angle = fmod(angle, 2 * M_PI);
82  if (angle < 0.0) angle += 2 * M_PI;
83  // NOTE: 0 and 2 * M_PI are always in the map
84  std::map<double, double>::const_iterator lowerBound = gainMap.lower_bound(angle);
85  std::map<double, double>::const_iterator upperBound = gainMap.upper_bound(angle);
86  if (lowerBound->first != angle)
87  lowerBound--;
88  if (upperBound == gainMap.end())
89  upperBound--;
90  if (upperBound == lowerBound)
91  return lowerBound->second;
92  else {
93  double lowerAngle = lowerBound->first;
94  double upperAngle = upperBound->first;
95  double lowerGain = lowerBound->second;
96  double upperGain = upperBound->second;
97  double alpha = (angle - lowerAngle) / (upperAngle - lowerAngle);
98  return (1 - alpha) * lowerGain + alpha * upperGain;
99  }
100 }
#define M_PI
Definition: PlotFigure.cc:27
const value< double, units::unit > alpha(7.2973525376e-3)
double inet::physicallayer::InterpolatingAntenna::computeGain ( const EulerAngles  direction) const
overridevirtual

Returns the antenna gain in the provided direction.

The direction is relative to the antenna geometry, so the result depends only on the antenna characteristics. For transmissions, it determines how well the antenna converts input power into radio waves headed in the specified direction. For receptions, it determines how well the antenna converts radio waves arriving from the the specified direction.

Implements inet::physicallayer::IAntenna.

103 {
104  return computeGain(headingGainMap, direction.alpha) *
105  computeGain(elevationGainMap, direction.beta) *
106  computeGain(bankGainMap, direction.gamma);
107 }
std::map< double, double > bankGainMap
Definition: InterpolatingAntenna.h:34
std::map< double, double > elevationGainMap
Definition: InterpolatingAntenna.h:32
virtual double computeGain(const std::map< double, double > &gainMap, double angle) const
Definition: InterpolatingAntenna.cc:79
std::map< double, double > headingGainMap
Definition: InterpolatingAntenna.h:33
virtual double inet::physicallayer::InterpolatingAntenna::getMaxGain ( ) const
inlineoverridevirtual

Returns the maximum possible antenna gain independent of any direction.

Implements inet::physicallayer::IAntenna.

46 { return maxGain; }
double maxGain
Definition: InterpolatingAntenna.h:31
virtual double inet::physicallayer::InterpolatingAntenna::getMinGain ( ) const
inlinevirtual
45 { return minGain; }
double minGain
Definition: InterpolatingAntenna.h:30
void inet::physicallayer::InterpolatingAntenna::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::physicallayer::AntennaBase.

34 {
36  if (stage == INITSTAGE_LOCAL) {
37  parseMap(elevationGainMap, par("elevationGains"));
38  parseMap(headingGainMap, par("headingGains"));
39  parseMap(bankGainMap, par("bankGains"));
40  }
41 }
std::map< double, double > bankGainMap
Definition: InterpolatingAntenna.h:34
std::map< double, double > elevationGainMap
Definition: InterpolatingAntenna.h:32
std::map< double, double > headingGainMap
Definition: InterpolatingAntenna.h:33
Local initializations.
Definition: InitStages.h:35
virtual void parseMap(std::map< double, double > &gainMap, const char *text)
Definition: InterpolatingAntenna.cc:51
virtual void initialize(int stage) override
Definition: AntennaBase.cc:31
void inet::physicallayer::InterpolatingAntenna::parseMap ( std::map< double, double > &  gainMap,
const char *  text 
)
protectedvirtual

Referenced by initialize().

52 {
53  cStringTokenizer tokenizer(text);
54  const char *firstAngle = tokenizer.nextToken();
55  if (!firstAngle)
56  throw cRuntimeError("Insufficient number of values");
57  if (strcmp(firstAngle, "0"))
58  throw cRuntimeError("The first angle must be 0");
59  const char *firstGain = tokenizer.nextToken();
60  if (!firstGain)
61  throw cRuntimeError("Insufficient number of values");
62  gainMap.insert(std::pair<double, double>(0, math::dB2fraction(atof(firstGain))));
63  gainMap.insert(std::pair<double, double>(2 * M_PI, math::dB2fraction(atof(firstGain))));
64  while (tokenizer.hasMoreTokens()) {
65  const char *angleString = tokenizer.nextToken();
66  const char *gainString = tokenizer.nextToken();
67  if (!angleString || !gainString)
68  throw cRuntimeError("Insufficient number of values");
69  double angle = atof(angleString) * M_PI / 180;
70  double gain = math::dB2fraction(atof(gainString));
71  if (std::isnan(minGain) || gain < minGain)
72  minGain = gain;
73  if (std::isnan(maxGain) || gain > maxGain)
74  maxGain = gain;
75  gainMap.insert(std::pair<double, double>(angle, gain));
76  }
77 }
double maxGain
Definition: InterpolatingAntenna.h:31
double dB2fraction(double dB)
Converts a dB value to fraction.
Definition: INETMath.h:166
double minGain
Definition: InterpolatingAntenna.h:30
#define M_PI
Definition: PlotFigure.cc:27
std::ostream & inet::physicallayer::InterpolatingAntenna::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::AntennaBase.

44 {
45  stream << "InterpolatingAntenna";
46  if (level <= PRINT_LEVEL_DETAIL)
47  stream << ", maxGain = " << maxGain;
48  return AntennaBase::printToStream(stream, level);
49 }
double maxGain
Definition: InterpolatingAntenna.h:31
virtual std::ostream & printToStream(std::ostream &stream, int level) const override
Prints this object to the provided output stream.
Definition: AntennaBase.cc:39

Member Data Documentation

std::map<double, double> inet::physicallayer::InterpolatingAntenna::bankGainMap
protected

Referenced by computeGain(), and initialize().

std::map<double, double> inet::physicallayer::InterpolatingAntenna::elevationGainMap
protected

Referenced by computeGain(), and initialize().

std::map<double, double> inet::physicallayer::InterpolatingAntenna::headingGainMap
protected

Referenced by computeGain(), and initialize().

double inet::physicallayer::InterpolatingAntenna::maxGain
protected

Referenced by parseMap(), and printToStream().

double inet::physicallayer::InterpolatingAntenna::minGain
protected

Referenced by parseMap().


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