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

#include <AxiallySymmetricAntenna.h>

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

Public Member Functions

 AntennaGain (const char *axis, double baseGain, const char *gains)
 
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 Attributes

double minGain = NaN
 
double maxGain = NaN
 
Coord axisOfSymmetryDirection = Coord::NIL
 
std::map< rad, double > gainMap
 

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) }
 
- Protected Member Functions inherited from inet::IntrusivePtrCounter< IAntennaGain >
INET_ALWAYS_INLINE ~IntrusivePtrCounter ()=default
 

Constructor & Destructor Documentation

◆ AntennaGain()

inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::AntennaGain ( const char *  axis,
double  baseGain,
const char *  gains 
)
38  :
39  minGain(NaN),
40  maxGain(NaN)
41 {
43  cStringTokenizer tokenizer(gains);
44  while (tokenizer.hasMoreTokens()) {
45  const char *angleString = tokenizer.nextToken();
46  const char *gainString = tokenizer.nextToken();
47  if (!angleString || !gainString)
48  throw cRuntimeError("Insufficient number of values");
49  auto angle = deg(atof(angleString));
50  double gain = baseGain * math::dB2fraction(atof(gainString));
51  if (std::isnan(minGain) || gain < minGain)
52  minGain = gain;
53  if (std::isnan(maxGain) || gain > maxGain)
54  maxGain = gain;
55  gainMap.insert(std::pair<rad, double>(angle, gain));
56  }
57  if (!containsKey(gainMap, deg(0)))
58  throw cRuntimeError("The first angle must be 0");
59  if (!containsKey(gainMap, deg(180)))
60  throw cRuntimeError("The last angle must be 180");
61 }

Member Function Documentation

◆ computeGain()

double inet::physicallayer::AxiallySymmetricAntenna::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.

64 {
65  double product = math::minnan(1.0, math::maxnan(-1.0, direction.rotate(Coord::X_AXIS) * Coord::X_AXIS));
66  rad angle = rad(std::acos(product));
67  // NOTE: 0 and M_PI are always in the map
68  std::map<rad, double>::const_iterator lowerBound = gainMap.lower_bound(angle);
69  std::map<rad, double>::const_iterator upperBound = gainMap.upper_bound(angle);
70  if (lowerBound->first != angle)
71  lowerBound--;
72  if (upperBound == gainMap.end())
73  upperBound--;
74  if (upperBound == lowerBound)
75  return lowerBound->second;
76  else {
77  auto lowerAngle = lowerBound->first;
78  auto upperAngle = upperBound->first;
79  double lowerGain = lowerBound->second;
80  double upperGain = upperBound->second;
81  double alpha = unit((angle - lowerAngle) / (upperAngle - lowerAngle)).get();
82  double gain = (1 - alpha) * lowerGain + alpha * upperGain;
83  ASSERT(!std::isnan(gain));
84  return gain;
85  }
86 }

◆ getMaxGain()

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

Returns the maximum possible antenna gain independent of any direction.

Implements inet::physicallayer::IAntennaGain.

31 { return maxGain; }

◆ getMinGain()

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

Returns the minimum possible antenna gain independent of any direction.

Implements inet::physicallayer::IAntennaGain.

30 { return minGain; }

Member Data Documentation

◆ axisOfSymmetryDirection

Coord inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::axisOfSymmetryDirection = Coord::NIL
protected

Referenced by AntennaGain().

◆ gainMap

std::map<rad, double> inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::gainMap
protected

Referenced by AntennaGain().

◆ maxGain

double inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::maxGain = NaN
protected

Referenced by AntennaGain().

◆ minGain

double inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::minGain = NaN
protected

Referenced by AntennaGain().


The documentation for this class was generated from the following files:
inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::minGain
double minGain
Definition: AxiallySymmetricAntenna.h:22
inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::axisOfSymmetryDirection
Coord axisOfSymmetryDirection
Definition: AxiallySymmetricAntenna.h:24
inet::units::units::deg
fscale< rad, rad2degScale > deg
Definition: Units.h:1158
inet::physicallayer::AxiallySymmetricAntenna::gain
Ptr< AntennaGain > gain
Definition: AxiallySymmetricAntenna.h:35
inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::maxGain
double maxGain
Definition: AxiallySymmetricAntenna.h:23
inet::math::maxnan
const T maxnan(const T &a, const T &b)
This function properly and symmetrically handles NaNs in contrast with std::max and std::fmax.
Definition: INETMath.h:234
inet::math::dB2fraction
double dB2fraction(double dB)
Converts a dB value to fraction.
Definition: INETMath.h:153
NaN
#define NaN
Definition: INETMath.h:91
inet::Coord::X_AXIS
static const Coord X_AXIS
Definition: Coord.h:29
inet::units::unit
pow< internal::none, 0 > unit
Definition: Units.h:72
inet::physicallayer::AxiallySymmetricAntenna::AntennaGain::gainMap
std::map< rad, double > gainMap
Definition: AxiallySymmetricAntenna.h:25
inet::Coord::parse
static Coord parse(const char *text)
Definition: Coord.h:328
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::math::minnan
const T minnan(const T &a, const T &b)
This function properly and symmetrically handles NaNs in contrast with std::min and std::fmin.
Definition: INETMath.h:216
inet::units::values::rad
value< double, units::rad > rad
Definition: Units.h:1245
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80