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

(-)a/src/spectrum/model/multi-model-spectrum-channel.cc (-9 / +15 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
          if (rxSpectrumModelUid != txSpectrumModelUid && !txSpectrumModel->IsOrthogonal (*rxSpectrumModel))
194
          SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
194
            {
195
          std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
195
              NS_LOG_LOGIC ("Creating converter between SpectrumModelUid " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid);
196
          ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
196
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
197
          NS_ASSERT (ret2.second);
197
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
198
              ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
199
              NS_ASSERT (ret2.second);
200
            }
198
        }
201
        }
199
    }
202
    }
200
  else
203
  else
 Lines 231-239    Link Here 
231
          Ptr<const SpectrumModel> rxSpectrumModel = rxInfoIterator->second.m_rxSpectrumModel;
234
          Ptr<const SpectrumModel> rxSpectrumModel = rxInfoIterator->second.m_rxSpectrumModel;
232
          SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
235
          SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
233
236
234
          if (rxSpectrumModelUid != txSpectrumModelUid)
237
          if (rxSpectrumModelUid != txSpectrumModelUid && !txSpectrumModel->IsOrthogonal (*rxSpectrumModel))
235
            {
238
            {
236
              NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModelUid << " and " << rxSpectrumModelUid );
239
              NS_LOG_LOGIC ("Creating converter between SpectrumModelUid " << txSpectrumModelUid << " and " << rxSpectrumModelUid);
237
240
238
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
241
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
239
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
242
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
 Lines 289-299    Link Here 
289
        {
292
        {
290
          NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
293
          NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
291
          SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
294
          SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
292
          NS_ASSERT (rxConverterIterator != txInfoIteratorerator->second.m_spectrumConverterMap.end ());
295
          if (rxConverterIterator == txInfoIteratorerator->second.m_spectrumConverterMap.end ())
296
            {
297
              // No converter means TX SpectrumModel is orthogonal RX SpectrumModel
298
              continue;
299
            }
293
          convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
300
          convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
294
        }
301
        }
295
302
296
297
      for (std::set<Ptr<SpectrumPhy> >::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhySet.begin ();
303
      for (std::set<Ptr<SpectrumPhy> >::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhySet.begin ();
298
           rxPhyIterator != rxInfoIterator->second.m_rxPhySet.end ();
304
           rxPhyIterator != rxInfoIterator->second.m_rxPhySet.end ();
299
           ++rxPhyIterator)
305
           ++rxPhyIterator)
(-)a/src/spectrum/model/spectrum-model.cc (+20 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
}
123
104
124
105
125
106
} // namespace ns3
126
} // 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