Returns the total noise summing up all the interfering receptions and noises.
This function never returns nullptr.
95 const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
96 Hz commonCenterFrequency = bandListening->getCenterFrequency();
97 Hz commonBandwidth = bandListening->getBandwidth();
98 simtime_t noiseStartTime = SimTime::getMaxTime();
99 simtime_t noiseEndTime = 0;
100 std::map<simtime_t, W> *powerChanges =
new std::map<simtime_t, W>();
101 const std::vector<const IReception *> *interferingReceptions = interference->getInterferingReceptions();
102 for (
auto reception : *interferingReceptions) {
103 const ISignalAnalogModel *signalAnalogModel = reception->getAnalogModel();
104 const INarrowbandSignal *narrowbandSignalAnalogModel = check_and_cast<const INarrowbandSignal *>(signalAnalogModel);
105 Hz signalCenterFrequency = narrowbandSignalAnalogModel->getCenterFrequency();
106 Hz signalBandwidth = narrowbandSignalAnalogModel->getBandwidth();
107 if (commonCenterFrequency == signalCenterFrequency && commonBandwidth >= signalBandwidth)
108 addReception(reception, noiseStartTime, noiseEndTime, powerChanges);
110 throw cRuntimeError(
"Partially interfering signals are not supported by ScalarAnalogModel, enable ignorePartialInterference to avoid this error!");
112 const ScalarNoise *scalarBackgroundNoise =
dynamic_cast<const ScalarNoise *
>(interference->getBackgroundNoise());
113 if (scalarBackgroundNoise) {
114 if (commonCenterFrequency == scalarBackgroundNoise->getCenterFrequency() && commonBandwidth >= scalarBackgroundNoise->getBandwidth())
115 addNoise(scalarBackgroundNoise, noiseStartTime, noiseEndTime, powerChanges);
117 throw cRuntimeError(
"Partially interfering background noise is not supported by ScalarAnalogModel, enable ignorePartialInterference to avoid this error!");
119 EV_TRACE <<
"Noise power begin " << endl;
121 for (std::map<simtime_t, W>::const_iterator it = powerChanges->begin(); it != powerChanges->end(); it++) {
123 EV_TRACE <<
"Noise at " << it->first <<
" = " << noise << endl;
125 EV_TRACE <<
"Noise power end" << endl;
126 return new ScalarNoise(noiseStartTime, noiseEndTime, commonCenterFrequency, commonBandwidth, powerChanges);