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

#include <DimensionalAnalogModelBase.h>

Inheritance diagram for inet::physicallayer::DimensionalAnalogModelBase:
inet::physicallayer::AnalogModelBase inet::physicallayer::IAnalogModel inet::physicallayer::IPrintableObject inet::physicallayer::DimensionalAnalogModel inet::physicallayer::LayeredDimensionalAnalogModel

Public Member Functions

virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual const ConstMappingcomputeReceptionPower (const IRadio *radio, const ITransmission *transmission, const IArrival *arrival) const
 
virtual const INoisecomputeNoise (const IListening *listening, const IInterference *interference) const override
 Returns the total noise summing up all the interfering receptions and noises. More...
 
virtual const ISNIRcomputeSNIR (const IReception *reception, const INoise *noise) const override
 Returns the signal to noise and interference ratio. More...
 
- Public Member Functions inherited from inet::physicallayer::IAnalogModel
virtual const IReceptioncomputeReception (const IRadio *receiver, const ITransmission *transmission, const IArrival *arrival) const =0
 Returns the reception for the provided transmission at the receiver. 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
 
- Protected Member Functions inherited from inet::physicallayer::AnalogModelBase
virtual EulerAngles computeTransmissionDirection (const ITransmission *transmission, const IArrival *arrival) const
 

Protected Attributes

bool attenuateWithCarrierFrequency
 
Mapping::InterpolationMethod interpolationMode
 

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
}
 

Member Function Documentation

const INoise * inet::physicallayer::DimensionalAnalogModelBase::computeNoise ( const IListening listening,
const IInterference interference 
) const
overridevirtual

Returns the total noise summing up all the interfering receptions and noises.

This function never returns nullptr.

Implements inet::physicallayer::IAnalogModel.

115 {
116  const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
117  Hz carrierFrequency = bandListening->getCarrierFrequency();
118  Hz bandwidth = bandListening->getBandwidth();
119  std::vector<ConstMapping *> receptionPowers;
120  const DimensionalNoise *dimensionalBackgroundNoise = dynamic_cast<const DimensionalNoise *>(interference->getBackgroundNoise());
121  if (dimensionalBackgroundNoise) {
122  const ConstMapping *backgroundNoisePower = dimensionalBackgroundNoise->getPower();
123  if (backgroundNoisePower->getDimensionSet().hasDimension(Dimension::frequency) || (carrierFrequency == dimensionalBackgroundNoise->getCarrierFrequency() && bandwidth == dimensionalBackgroundNoise->getBandwidth()))
124  receptionPowers.push_back(const_cast<ConstMapping *>(backgroundNoisePower));
125  }
126  const std::vector<const IReception *> *interferingReceptions = interference->getInterferingReceptions();
127  for (const auto & interferingReception : *interferingReceptions) {
128  const DimensionalReception *dimensionalReception = check_and_cast<const DimensionalReception *>(interferingReception);
129  const ConstMapping *receptionPower = dimensionalReception->getPower();
130  if (receptionPower->getDimensionSet().hasDimension(Dimension::frequency) || (carrierFrequency == dimensionalReception->getCarrierFrequency() && bandwidth == dimensionalReception->getBandwidth())) {
131  receptionPowers.push_back(const_cast<ConstMapping *>(receptionPower));
132  EV_DEBUG << "Interference power begin " << endl;
133  dimensionalReception->getPower()->print(EVSTREAM);
134  EV_DEBUG << "Interference power end" << endl;
135  }
136  }
137  DimensionSet dimensions = receptionPowers[0]->getDimensionSet();
138  if (!dimensions.hasDimension(Dimension::time))
139  dimensions.addDimension(Dimension::time);
140  ConstMapping *listeningMapping = MappingUtils::createMapping(Argument::MappedZero, dimensions, Mapping::STEPS);
141  ConcatConstMapping<std::plus<double> > *noisePower = new ConcatConstMapping<std::plus<double> >(listeningMapping, receptionPowers.begin(), receptionPowers.end(), false, Argument::MappedZero);
142  EV_TRACE << "Noise power begin " << endl;
143  noisePower->print(EVSTREAM);
144  EV_TRACE << "Noise power end" << endl;
145  return new DimensionalNoise(listening->getStartTime(), listening->getEndTime(), carrierFrequency, bandwidth, noisePower);
146 }
static const mapped_type MappedZero
Zero value of a Argument value.
Definition: MappingBase.h:427
pow< s,-1 > Hz
Definition: Units.h:766
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
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
interpolates with next lower entry
Definition: MappingBase.h:1251
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
#define EVSTREAM
Definition: Compat.h:36
const ConstMapping * inet::physicallayer::DimensionalAnalogModelBase::computeReceptionPower ( const IRadio radio,
const ITransmission transmission,
const IArrival arrival 
) const
virtual

Referenced by inet::physicallayer::DimensionalAnalogModel::computeReception(), and inet::physicallayer::LayeredDimensionalAnalogModel::computeReception().

53 {
54  const IRadioMedium *radioMedium = receiverRadio->getMedium();
55  const IRadio *transmitterRadio = transmission->getTransmitter();
56  const IAntenna *receiverAntenna = receiverRadio->getAntenna();
57  const IAntenna *transmitterAntenna = transmitterRadio->getAntenna();
58  const INarrowbandSignal *narrowbandSignalAnalogModel = check_and_cast<const INarrowbandSignal *>(transmission->getAnalogModel());
59  const IDimensionalSignal *dimensionalSignalAnalogModel = check_and_cast<const IDimensionalSignal *>(transmission->getAnalogModel());
60  const simtime_t transmissionStartTime = transmission->getStartTime();
61  const simtime_t transmissionEndTime = transmission->getEndTime();
62  const simtime_t receptionStartTime = arrival->getStartTime();
63  const simtime_t receptionEndTime = arrival->getEndTime();
64  const Coord receptionStartPosition = arrival->getStartPosition();
65  const Coord receptionEndPosition = arrival->getEndPosition();
66  const EulerAngles transmissionDirection = computeTransmissionDirection(transmission, arrival);
67  const EulerAngles transmissionAntennaDirection = transmission->getStartOrientation() - transmissionDirection;
68  const EulerAngles receptionAntennaDirection = transmissionDirection - arrival->getStartOrientation();
69  double transmitterAntennaGain = transmitterAntenna->computeGain(transmissionAntennaDirection);
70  double receiverAntennaGain = receiverAntenna->computeGain(receptionAntennaDirection);
71  m distance = m(receptionStartPosition.distance(transmission->getStartPosition()));
72  mps propagationSpeed = radioMedium->getPropagation()->getPropagationSpeed();
73  const ConstMapping *transmissionPower = dimensionalSignalAnalogModel->getPower();
74  EV_DEBUG << "Transmission power begin " << endl;
75  transmissionPower->print(EVSTREAM);
76  EV_DEBUG << "Transmission power end" << endl;
77  const DimensionSet& dimensions = transmissionPower->getDimensionSet();
78  bool hasTimeDimension = dimensions.hasDimension(Dimension::time);
79  bool hasFrequencyDimension = dimensions.hasDimension(Dimension::frequency);
80  ConstMappingIterator *it = transmissionPower->createConstIterator();
81  Mapping *receptionPower = MappingUtils::createMapping(Argument::MappedZero, dimensions, interpolationMode);
82  while (true) {
83  const Argument& elementTransmissionPosition = it->getPosition();
84  Hz carrierFrequency = attenuateWithCarrierFrequency || !hasFrequencyDimension ? narrowbandSignalAnalogModel->getCarrierFrequency() : Hz(elementTransmissionPosition.getArgValue(Dimension::frequency));
85  double pathLoss = radioMedium->getPathLoss()->computePathLoss(propagationSpeed, carrierFrequency, distance);
86  double obstacleLoss = radioMedium->getObstacleLoss() ? radioMedium->getObstacleLoss()->computeObstacleLoss(carrierFrequency, transmission->getStartPosition(), receptionStartPosition) : 1;
87  W elementTransmissionPower = W(it->getValue());
88  W elementReceptionPower = elementTransmissionPower * std::min(1.0, transmitterAntennaGain * receiverAntennaGain * pathLoss * obstacleLoss);
89  Argument elementReceptionPosition = elementTransmissionPosition;
90  if (hasTimeDimension) {
91  if (elementTransmissionPosition.getTime() == transmissionStartTime)
92  elementReceptionPosition.setTime(receptionStartTime);
93  else if (elementTransmissionPosition.getTime() == transmissionEndTime)
94  elementReceptionPosition.setTime(receptionEndTime);
95  else {
96  double alpha = (elementTransmissionPosition.getTime() - transmissionStartTime).dbl() / (transmissionEndTime - transmissionStartTime).dbl();
97  simtime_t elementReceptionTime = (1 - alpha) * receptionStartTime.dbl() + alpha * receptionEndTime.dbl();
98  elementReceptionPosition.setTime(elementReceptionTime);
99  }
100  }
101  receptionPower->setValue(elementReceptionPosition, elementReceptionPower.get());
102  if (it->hasNext())
103  it->next();
104  else
105  break;
106  }
107  delete it;
108  EV_DEBUG << "Reception power begin " << endl;
109  receptionPower->print(EVSTREAM);
110  EV_DEBUG << "Reception power end" << endl;
111  return receptionPower;
112 }
static const mapped_type MappedZero
Zero value of a Argument value.
Definition: MappingBase.h:427
pow< s,-1 > Hz
Definition: Units.h:766
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 min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
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
compose< J, pow< s,-1 > > W
Definition: Units.h:770
virtual EulerAngles computeTransmissionDirection(const ITransmission *transmission, const IArrival *arrival) const
Definition: AnalogModelBase.cc:24
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: DimensionalAnalogModelBase.h:32
#define EVSTREAM
Definition: Compat.h:36
bool attenuateWithCarrierFrequency
Definition: DimensionalAnalogModelBase.h:31
compose< m, pow< s,-1 > > mps
Definition: Units.h:968
const value< double, units::unit > alpha(7.2973525376e-3)
value< double, units::m > m
Definition: Units.h:1047
const ISNIR * inet::physicallayer::DimensionalAnalogModelBase::computeSNIR ( const IReception reception,
const INoise noise 
) const
overridevirtual

Returns the signal to noise and interference ratio.

This function never returns nullptr.

Implements inet::physicallayer::IAnalogModel.

149 {
150  const DimensionalReception *dimensionalReception = check_and_cast<const DimensionalReception *>(reception);
151  const DimensionalNoise *dimensionalNoise = check_and_cast<const DimensionalNoise *>(noise);
152  return new DimensionalSNIR(dimensionalReception, dimensionalNoise);
153 }
void inet::physicallayer::DimensionalAnalogModelBase::initialize ( int  stage)
overrideprotectedvirtual
30 {
31  AnalogModelBase::initialize(stage);
32  if (stage == INITSTAGE_LOCAL) {
33  attenuateWithCarrierFrequency = par("attenuateWithCarrierFrequency");
34  const char *interpolationModeString = par("interpolationMode");
35  if (!strcmp("linear", interpolationModeString))
37  else if (!strcmp("sample-hold", interpolationModeString))
39  else
40  throw cRuntimeError("Unknown interpolation mode: '%s'", interpolationModeString);
41  }
42 }
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
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalAnalogModelBase.h:32
bool attenuateWithCarrierFrequency
Definition: DimensionalAnalogModelBase.h:31
std::ostream & inet::physicallayer::DimensionalAnalogModelBase::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.

Reimplemented in inet::physicallayer::LayeredDimensionalAnalogModel, and inet::physicallayer::DimensionalAnalogModel.

Referenced by inet::physicallayer::DimensionalAnalogModel::printToStream(), and inet::physicallayer::LayeredDimensionalAnalogModel::printToStream().

45 {
46  if (level <= PRINT_LEVEL_TRACE)
47  stream << ", attenuateWithCarrierFrequency = " << attenuateWithCarrierFrequency
48  << ", interpolationMode = " << interpolationMode;
49  return stream;
50 }
Mapping::InterpolationMethod interpolationMode
Definition: DimensionalAnalogModelBase.h:32
bool attenuateWithCarrierFrequency
Definition: DimensionalAnalogModelBase.h:31

Member Data Documentation

bool inet::physicallayer::DimensionalAnalogModelBase::attenuateWithCarrierFrequency
protected
Mapping::InterpolationMethod inet::physicallayer::DimensionalAnalogModelBase::interpolationMode
protected

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