View | Details | Raw Unified | Return to bug 2467
Collapse All | Expand All

(-)a/src/spectrum/model/multi-model-spectrum-channel.cc (-8 / +17 lines)
 Lines 190-200    Link Here 
190
           ++txInfoIterator)
190
           ++txInfoIterator)
191
        {
191
        {
192
          Ptr<const SpectrumModel> txSpectrumModel = txInfoIterator->second.m_txSpectrumModel;
192
          Ptr<const SpectrumModel> txSpectrumModel = txInfoIterator->second.m_txSpectrumModel;
193
          NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid );
193
          SpectrumModelUid_t txSpectrumModelUid = txSpectrumModel->GetUid ();
194
          SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
194
195
          std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
195
          if (rxSpectrumModelUid != txSpectrumModelUid && !txSpectrumModel->IsOrthogonal (*rxSpectrumModel))
196
          ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
196
            {
197
          NS_ASSERT (ret2.second);
197
              NS_LOG_LOGIC ("Creating converter between SpectrumModelUid " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid);
198
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
199
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
200
              ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
201
              NS_ASSERT (ret2.second);
202
            }
198
        }
203
        }
199
    }
204
    }
200
  else
205
  else
 Lines 231-239    Link Here 
231
          Ptr<const SpectrumModel> rxSpectrumModel = rxInfoIterator->second.m_rxSpectrumModel;
236
          Ptr<const SpectrumModel> rxSpectrumModel = rxInfoIterator->second.m_rxSpectrumModel;
232
          SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
237
          SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
233
238
234
          if (rxSpectrumModelUid != txSpectrumModelUid)
239
          if (rxSpectrumModelUid != txSpectrumModelUid && !txSpectrumModel->IsOrthogonal (*rxSpectrumModel))
235
            {
240
            {
236
              NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModelUid << " and " << rxSpectrumModelUid );
241
              NS_LOG_LOGIC ("Creating converter between SpectrumModelUid " << txSpectrumModelUid << " and " << rxSpectrumModelUid);
237
242
238
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
243
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
239
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
244
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
 Lines 289-295    Link Here 
289
        {
294
        {
290
          NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
295
          NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
291
          SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
296
          SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
292
          NS_ASSERT (rxConverterIterator != txInfoIteratorerator->second.m_spectrumConverterMap.end ());
297
          if (rxConverterIterator == txInfoIteratorerator->second.m_spectrumConverterMap.end ())
298
            {
299
              // No converter means TX SpectrumModel is orthogonal RX SpectrumModel
300
              continue;
301
            }
293
          convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
302
          convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
294
        }
303
        }
295
304
(-)a/src/spectrum/model/spectrum-model.cc (+19 lines)
 Lines 101-106    Link Here 
101
  return m_uid;
101
  return m_uid;
102
}
102
}
103
103
104
bool
105
SpectrumModel::IsOrthogonal (const SpectrumModel &other) const
106
{
107
  for (Bands::const_iterator myIt = Begin ();
108
       myIt != End ();
109
       ++myIt)
110
    {
111
      for (Bands::const_iterator otherIt = other.Begin ();
112
           otherIt != other.End ();
113
           ++otherIt)
114
        {
115
          if (std::max (myIt->fl, otherIt->fl) < std::min (myIt->fh, otherIt->fh))
116
            {
117
              return false;
118
            }
119
        }
120
    }
121
  return true;
122
}
104
123
105
124
106
} // namespace ns3
125
} // namespace ns3
(-)a/src/spectrum/model/spectrum-model.h (+8 lines)
 Lines 120-125    Link Here 
120
   */
120
   */
121
  Bands::const_iterator End () const;
121
  Bands::const_iterator End () const;
122
122
123
  /**
124
   * Check if another SpectrumModels has bands orthogonal to our bands.
125
   *
126
   * \param other another SpectrumModel
127
   * \returns true if bands are orthogonal
128
   */
129
  bool IsOrthogonal (const SpectrumModel &other) const;
130
123
private:
131
private:
124
  Bands m_bands;         //!< Actual definition of frequency bands within this SpectrumModel
132
  Bands m_bands;         //!< Actual definition of frequency bands within this SpectrumModel
125
  SpectrumModelUid_t m_uid;        //!< unique id for a given set of frequencies
133
  SpectrumModelUid_t m_uid;        //!< unique id for a given set of frequencies

Return to bug 2467