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

#include <ScalarAnalogModelBase.h>

Inheritance diagram for inet::physicallayer::ScalarAnalogModelBase:
inet::physicallayer::AnalogModelBase inet::physicallayer::IAnalogModel inet::physicallayer::IPrintableObject inet::physicallayer::LayeredScalarAnalogModel inet::physicallayer::ScalarAnalogModel

Public Member Functions

virtual W computeReceptionPower (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::ostream & printToStream (std::ostream &stream, int level) const
 Prints this object to the provided output stream. More...
 
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 bool areOverlappingBands (Hz carrierFrequency1, Hz bandwidth1, Hz carrierFrequency2, Hz bandwidth2) const
 
- Protected Member Functions inherited from inet::physicallayer::AnalogModelBase
virtual EulerAngles computeTransmissionDirection (const ITransmission *transmission, const IArrival *arrival) const
 

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

bool inet::physicallayer::ScalarAnalogModelBase::areOverlappingBands ( Hz  carrierFrequency1,
Hz  bandwidth1,
Hz  carrierFrequency2,
Hz  bandwidth2 
) const
protectedvirtual

Referenced by computeNoise().

30 {
31  return carrierFrequency1 + bandwidth1 / 2 >= carrierFrequency2 - bandwidth2 / 2 &&
32  carrierFrequency1 - bandwidth1 / 2 <= carrierFrequency2 + bandwidth2 / 2;
33 }
const INoise * inet::physicallayer::ScalarAnalogModelBase::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.

57 {
58  const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
59  Hz commonCarrierFrequency = bandListening->getCarrierFrequency();
60  Hz commonBandwidth = bandListening->getBandwidth();
61  simtime_t noiseStartTime = SimTime::getMaxTime();
62  simtime_t noiseEndTime = 0;
63  std::map<simtime_t, W> *powerChanges = new std::map<simtime_t, W>();
64  const std::vector<const IReception *> *interferingReceptions = interference->getInterferingReceptions();
65  for (auto reception : *interferingReceptions) {
66  const ISignalAnalogModel *signalAnalogModel = reception->getAnalogModel();
67  const INarrowbandSignal *narrowbandSignalAnalogModel = check_and_cast<const INarrowbandSignal *>(signalAnalogModel);
68  Hz signalCarrierFrequency = narrowbandSignalAnalogModel->getCarrierFrequency();
69  Hz signalBandwidth = narrowbandSignalAnalogModel->getBandwidth();
70  if (commonCarrierFrequency == signalCarrierFrequency && commonBandwidth == signalBandwidth)
71  {
72  const IScalarSignal *scalarSignalAnalogModel = check_and_cast<const IScalarSignal *>(signalAnalogModel);
73  W power = scalarSignalAnalogModel->getPower();
74  simtime_t startTime = reception->getStartTime();
75  simtime_t endTime = reception->getEndTime();
76  if (startTime < noiseStartTime)
77  noiseStartTime = startTime;
78  if (endTime > noiseEndTime)
79  noiseEndTime = endTime;
80  std::map<simtime_t, W>::iterator itStartTime = powerChanges->find(startTime);
81  if (itStartTime != powerChanges->end())
82  itStartTime->second += power;
83  else
84  powerChanges->insert(std::pair<simtime_t, W>(startTime, power));
85  std::map<simtime_t, W>::iterator itEndTime = powerChanges->find(endTime);
86  if (itEndTime != powerChanges->end())
87  itEndTime->second -= power;
88  else
89  powerChanges->insert(std::pair<simtime_t, W>(endTime, -power));
90  }
91  else if (areOverlappingBands(commonCarrierFrequency, commonBandwidth, narrowbandSignalAnalogModel->getCarrierFrequency(), narrowbandSignalAnalogModel->getBandwidth()))
92  throw cRuntimeError("Overlapping bands are not supported");
93  }
94  const ScalarNoise *scalarBackgroundNoise = dynamic_cast<const ScalarNoise *>(interference->getBackgroundNoise());
95  if (scalarBackgroundNoise) {
96  if (commonCarrierFrequency == scalarBackgroundNoise->getCarrierFrequency() && commonBandwidth == scalarBackgroundNoise->getBandwidth()) {
97  const std::map<simtime_t, W> *backgroundNoisePowerChanges = scalarBackgroundNoise->getPowerChanges();
98  for (const auto & backgroundNoisePowerChange : *backgroundNoisePowerChanges) {
99  std::map<simtime_t, W>::iterator jt = powerChanges->find(backgroundNoisePowerChange.first);
100  if (jt != powerChanges->end())
101  jt->second += backgroundNoisePowerChange.second;
102  else
103  powerChanges->insert(std::pair<simtime_t, W>(backgroundNoisePowerChange.first, backgroundNoisePowerChange.second));
104  }
105  }
106  else if (areOverlappingBands(commonCarrierFrequency, commonBandwidth, scalarBackgroundNoise->getCarrierFrequency(), scalarBackgroundNoise->getBandwidth()))
107  throw cRuntimeError("Overlapping bands are not supported");
108  }
109  EV_TRACE << "Noise power begin " << endl;
110  W noise = W(0);
111  for (std::map<simtime_t, W>::const_iterator it = powerChanges->begin(); it != powerChanges->end(); it++) {
112  noise += it->second;
113  EV_TRACE << "Noise at " << it->first << " = " << noise << endl;
114  }
115  EV_TRACE << "Noise power end" << endl;
116  return new ScalarNoise(noiseStartTime, noiseEndTime, commonCarrierFrequency, commonBandwidth, powerChanges);
117 }
pow< s,-1 > Hz
Definition: Units.h:766
compose< J, pow< s,-1 > > W
Definition: Units.h:770
virtual bool areOverlappingBands(Hz carrierFrequency1, Hz bandwidth1, Hz carrierFrequency2, Hz bandwidth2) const
Definition: ScalarAnalogModelBase.cc:29
W inet::physicallayer::ScalarAnalogModelBase::computeReceptionPower ( const IRadio radio,
const ITransmission transmission,
const IArrival arrival 
) const
virtual

Referenced by inet::physicallayer::ScalarAnalogModel::computeReception(), and inet::physicallayer::LayeredScalarAnalogModel::computeReception().

36 {
37  const IRadioMedium *radioMedium = receiverRadio->getMedium();
38  const IRadio *transmitterRadio = transmission->getTransmitter();
39  const IAntenna *receiverAntenna = receiverRadio->getAntenna();
40  const IAntenna *transmitterAntenna = transmitterRadio->getAntenna();
41  const INarrowbandSignal *narrowbandSignalAnalogModel = check_and_cast<const INarrowbandSignal *>(transmission->getAnalogModel());
42  const IScalarSignal *scalarSignalAnalogModel = check_and_cast<const IScalarSignal *>(transmission->getAnalogModel());
43  const Coord receptionStartPosition = arrival->getStartPosition();
44  const Coord receptionEndPosition = arrival->getEndPosition();
45  const EulerAngles transmissionDirection = computeTransmissionDirection(transmission, arrival);
46  const EulerAngles transmissionAntennaDirection = transmission->getStartOrientation() - transmissionDirection;
47  const EulerAngles receptionAntennaDirection = transmissionDirection - arrival->getStartOrientation();
48  double transmitterAntennaGain = transmitterAntenna->computeGain(transmissionAntennaDirection);
49  double receiverAntennaGain = receiverAntenna->computeGain(receptionAntennaDirection);
50  double pathLoss = radioMedium->getPathLoss()->computePathLoss(transmission, arrival);
51  double obstacleLoss = radioMedium->getObstacleLoss() ? radioMedium->getObstacleLoss()->computeObstacleLoss(narrowbandSignalAnalogModel->getCarrierFrequency(), transmission->getStartPosition(), receptionStartPosition) : 1;
52  W transmissionPower = scalarSignalAnalogModel->getPower();
53  return transmissionPower * std::min(1.0, transmitterAntennaGain * receiverAntennaGain * pathLoss * obstacleLoss);
54 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
compose< J, pow< s,-1 > > W
Definition: Units.h:770
virtual EulerAngles computeTransmissionDirection(const ITransmission *transmission, const IArrival *arrival) const
Definition: AnalogModelBase.cc:24
const ISNIR * inet::physicallayer::ScalarAnalogModelBase::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.

120 {
121  return new ScalarSNIR(reception, noise);
122 }

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