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

#include <InterpolatingAntenna.h>

Inheritance diagram for inet::physicallayer::InterpolatingAntenna::AntennaGain:
inet::physicallayer::IAntennaGain inet::IPrintableObject inet::IntrusivePtrCounter< IAntennaGain >

Public Member Functions

 AntennaGain (const char *elevation, const char *heading, const char *bank)
 
virtual double getMinGain () const override
 Returns the minimum possible antenna gain independent of any direction. More...
 
virtual double getMaxGain () const override
 Returns the maximum possible antenna gain independent of any direction. More...
 
virtual double computeGain (const Quaternion &direction) const override
 Returns the antenna gain in the provided direction. More...
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const
 Prints this object to the provided output stream. More...
 
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
 
- Public Member Functions inherited from inet::IntrusivePtrCounter< IAntennaGain >
INET_ALWAYS_INLINE IntrusivePtrCounter () noexcept
 
INET_ALWAYS_INLINE IntrusivePtrCounter (IntrusivePtrCounter const &) noexcept
 
INET_ALWAYS_INLINE unsigned int use_count () const noexcept
 
INET_ALWAYS_INLINE IntrusivePtrCounteroperator= (IntrusivePtrCounter const &) noexcept
 
INET_ALWAYS_INLINE IntrusivePtr< IAntennaGainshared_from_this ()
 

Protected Member Functions

virtual void parseMap (std::map< rad, double > &gainMap, const char *text)
 
virtual double computeGain (const std::map< rad, double > &gainMap, rad angle) const
 
- Protected Member Functions inherited from inet::IntrusivePtrCounter< IAntennaGain >
INET_ALWAYS_INLINE ~IntrusivePtrCounter ()=default
 

Protected Attributes

double minGain
 
double maxGain
 
std::map< rad, double > elevationGainMap
 
std::map< rad, double > headingGainMap
 
std::map< rad, double > bankGainMap
 

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) }
 

Constructor & Destructor Documentation

◆ AntennaGain()

inet::physicallayer::InterpolatingAntenna::AntennaGain::AntennaGain ( const char *  elevation,
const char *  heading,
const char *  bank 
)
37  :
39 {
40  parseMap(elevationGainMap, elevation);
41  parseMap(headingGainMap, heading);
42  parseMap(bankGainMap, bank);
43 }

Member Function Documentation

◆ computeGain() [1/2]

double inet::physicallayer::InterpolatingAntenna::AntennaGain::computeGain ( const Quaternion direction) const
overridevirtual

Returns the antenna gain in the provided direction.

The direction is determined by rotating the X axis using the given quaternion. The direction is to be interpreted in the local coordinate system of the radiation pattern. This way the gain depends only on the antenna radion pattern characteristics, and not on the antenna orientation determined by the antenna's mobility model.

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 specified direction.

Implements inet::physicallayer::IAntennaGain.

97 {
98  auto eulerAngles = direction.toEulerAngles();
99  return computeGain(headingGainMap, eulerAngles.alpha) *
100  computeGain(elevationGainMap, eulerAngles.beta) *
101  computeGain(bankGainMap, eulerAngles.gamma);
102 }

◆ computeGain() [2/2]

double inet::physicallayer::InterpolatingAntenna::AntennaGain::computeGain ( const std::map< rad, double > &  gainMap,
rad  angle 
) const
protectedvirtual
74 {
75  angle = rad(fmod(rad(angle).get(), 2 * M_PI));
76  if (angle < rad(0.0)) angle += rad(2 * M_PI);
77  // NOTE: 0 and 2 * M_PI are always in the map
78  std::map<rad, double>::const_iterator lowerBound = gainMap.lower_bound(angle);
79  std::map<rad, double>::const_iterator upperBound = gainMap.upper_bound(angle);
80  if (lowerBound->first != angle)
81  lowerBound--;
82  if (upperBound == gainMap.end())
83  upperBound--;
84  if (upperBound == lowerBound)
85  return lowerBound->second;
86  else {
87  auto lowerAngle = lowerBound->first;
88  auto upperAngle = upperBound->first;
89  double lowerGain = lowerBound->second;
90  double upperGain = upperBound->second;
91  double alpha = unit((angle - lowerAngle) / (upperAngle - lowerAngle)).get();
92  return (1 - alpha) * lowerGain + alpha * upperGain;
93  }
94 }

◆ getMaxGain()

virtual double inet::physicallayer::InterpolatingAntenna::AntennaGain::getMaxGain ( ) const
inlineoverridevirtual

Returns the maximum possible antenna gain independent of any direction.

Implements inet::physicallayer::IAntennaGain.

39 { return maxGain; }

◆ getMinGain()

virtual double inet::physicallayer::InterpolatingAntenna::AntennaGain::getMinGain ( ) const
inlineoverridevirtual

Returns the minimum possible antenna gain independent of any direction.

Implements inet::physicallayer::IAntennaGain.

38 { return minGain; }

◆ parseMap()

void inet::physicallayer::InterpolatingAntenna::AntennaGain::parseMap ( std::map< rad, double > &  gainMap,
const char *  text 
)
protectedvirtual
46 {
47  cStringTokenizer tokenizer(text);
48  const char *firstAngle = tokenizer.nextToken();
49  if (!firstAngle)
50  throw cRuntimeError("Insufficient number of values");
51  if (strcmp(firstAngle, "0"))
52  throw cRuntimeError("The first angle must be 0");
53  const char *firstGain = tokenizer.nextToken();
54  if (!firstGain)
55  throw cRuntimeError("Insufficient number of values");
56  gainMap.insert(std::pair<rad, double>(rad(0), math::dB2fraction(atof(firstGain))));
57  gainMap.insert(std::pair<rad, double>(rad(2 * M_PI), math::dB2fraction(atof(firstGain))));
58  while (tokenizer.hasMoreTokens()) {
59  const char *angleString = tokenizer.nextToken();
60  const char *gainString = tokenizer.nextToken();
61  if (!angleString || !gainString)
62  throw cRuntimeError("Insufficient number of values");
63  auto angle = deg(atof(angleString));
64  double gain = math::dB2fraction(atof(gainString));
65  if (std::isnan(minGain) || gain < minGain)
66  minGain = gain;
67  if (std::isnan(maxGain) || gain > maxGain)
68  maxGain = gain;
69  gainMap.insert(std::pair<rad, double>(angle, gain));
70  }
71 }

Referenced by AntennaGain().

Member Data Documentation

◆ bankGainMap

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

Referenced by AntennaGain().

◆ elevationGainMap

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

Referenced by AntennaGain().

◆ headingGainMap

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

Referenced by AntennaGain().

◆ maxGain

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

◆ minGain

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

The documentation for this class was generated from the following files:
inet::units::units::deg
fscale< rad, rad2degScale > deg
Definition: Units.h:1158
inet::physicallayer::InterpolatingAntenna::AntennaGain::minGain
double minGain
Definition: InterpolatingAntenna.h:26
inet::physicallayer::InterpolatingAntenna::AntennaGain::computeGain
virtual double computeGain(const std::map< rad, double > &gainMap, rad angle) const
Definition: InterpolatingAntenna.cc:73
inet::physicallayer::InterpolatingAntenna::AntennaGain::elevationGainMap
std::map< rad, double > elevationGainMap
Definition: InterpolatingAntenna.h:28
inet::math::dB2fraction
double dB2fraction(double dB)
Converts a dB value to fraction.
Definition: INETMath.h:153
inet::physicallayer::InterpolatingAntenna::AntennaGain::parseMap
virtual void parseMap(std::map< rad, double > &gainMap, const char *text)
Definition: InterpolatingAntenna.cc:45
NaN
#define NaN
Definition: INETMath.h:91
inet::units::unit
pow< internal::none, 0 > unit
Definition: Units.h:72
inet::physicallayer::InterpolatingAntenna::AntennaGain::maxGain
double maxGain
Definition: InterpolatingAntenna.h:27
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::physicallayer::InterpolatingAntenna::AntennaGain::headingGainMap
std::map< rad, double > headingGainMap
Definition: InterpolatingAntenna.h:29
inet::physicallayer::InterpolatingAntenna::gain
Ptr< AntennaGain > gain
Definition: InterpolatingAntenna.h:43
inet::units::values::rad
value< double, units::rad > rad
Definition: Units.h:1245
M_PI
#define M_PI
Definition: INETMath.h:52
inet::physicallayer::InterpolatingAntenna::AntennaGain::bankGainMap
std::map< rad, double > bankGainMap
Definition: InterpolatingAntenna.h:30