|
|
| 34 |
#include <ns3/propagation-delay-model.h> |
34 |
#include <ns3/propagation-delay-model.h> |
| 35 |
#include <ns3/antenna-model.h> |
35 |
#include <ns3/antenna-model.h> |
| 36 |
#include <ns3/angles.h> |
36 |
#include <ns3/angles.h> |
|
|
37 |
#include <algorithm> |
| 37 |
#include <iostream> |
38 |
#include <iostream> |
| 38 |
#include <utility> |
39 |
#include <utility> |
| 39 |
#include "multi-model-spectrum-channel.h" |
40 |
#include "multi-model-spectrum-channel.h" |
|
|
| 159 |
rxInfoIterator != m_rxSpectrumModelInfoMap.end (); |
160 |
rxInfoIterator != m_rxSpectrumModelInfoMap.end (); |
| 160 |
++rxInfoIterator) |
161 |
++rxInfoIterator) |
| 161 |
{ |
162 |
{ |
| 162 |
std::set<Ptr<SpectrumPhy> >::iterator phyIt = rxInfoIterator->second.m_rxPhySet.find (phy); |
163 |
std::vector<Ptr<SpectrumPhy>> &rxPhys = rxInfoIterator->second.m_rxPhys; |
| 163 |
if (phyIt != rxInfoIterator->second.m_rxPhySet.end ()) |
164 |
std::vector<Ptr<SpectrumPhy>>::iterator phyIt = std::find (begin (rxPhys), end (rxPhys), phy); |
|
|
165 |
if (phyIt != rxInfoIterator->second.m_rxPhys.end ()) |
| 164 |
{ |
166 |
{ |
| 165 |
rxInfoIterator->second.m_rxPhySet.erase (phyIt); |
167 |
rxPhys.erase (phyIt); |
| 166 |
--m_numDevices; |
168 |
--m_numDevices; |
| 167 |
break; // there should be at most one entry |
169 |
break; // there should be at most one entry |
| 168 |
} |
170 |
} |
| 169 |
} |
171 |
} |
| 170 |
|
172 |
|
| 171 |
++m_numDevices; |
173 |
++m_numDevices; |
|
|
| 179 |
ret = m_rxSpectrumModelInfoMap.insert (std::make_pair (rxSpectrumModelUid, RxSpectrumModelInfo (rxSpectrumModel))); |
181 |
ret = m_rxSpectrumModelInfoMap.insert (std::make_pair (rxSpectrumModelUid, RxSpectrumModelInfo (rxSpectrumModel))); |
| 180 |
NS_ASSERT (ret.second); |
182 |
NS_ASSERT (ret.second); |
| 181 |
// also add the phy to the newly created set of SpectrumPhy for this RxSpectrumModel |
183 |
// also add the phy to the newly created set of SpectrumPhy for this RxSpectrumModel |
| 182 |
std::pair<std::set<Ptr<SpectrumPhy> >::iterator, bool> ret2 = ret.first->second.m_rxPhySet.insert (phy); |
184 |
ret.first->second.m_rxPhys.push_back (phy); |
| 183 |
NS_ASSERT (ret2.second); |
|
|
| 184 |
|
185 |
|
| 185 |
// and create the necessary converters for all the TX spectrum models that we know of |
186 |
// and create the necessary converters for all the TX spectrum models that we know of |
| 186 |
for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin (); |
187 |
for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin (); |
|
|
| 203 |
else |
204 |
else |
| 204 |
{ |
205 |
{ |
| 205 |
// spectrum model is already known, just add the device to the corresponding list |
206 |
// spectrum model is already known, just add the device to the corresponding list |
| 206 |
std::pair<std::set<Ptr<SpectrumPhy> >::iterator, bool> ret2 = rxInfoIterator->second.m_rxPhySet.insert (phy); |
207 |
rxInfoIterator->second.m_rxPhys.push_back (phy); |
| 207 |
NS_ASSERT (ret2.second); |
|
|
| 208 |
} |
208 |
} |
| 209 |
|
209 |
|
| 210 |
} |
210 |
} |
|
|
| 301 |
} |
301 |
} |
| 302 |
|
302 |
|
| 303 |
|
303 |
|
| 304 |
for (std::set<Ptr<SpectrumPhy> >::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhySet.begin (); |
304 |
for (std::vector<Ptr<SpectrumPhy>>::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhys.begin (); |
| 305 |
rxPhyIterator != rxInfoIterator->second.m_rxPhySet.end (); |
305 |
rxPhyIterator != rxInfoIterator->second.m_rxPhys.end (); |
| 306 |
++rxPhyIterator) |
306 |
++rxPhyIterator) |
| 307 |
{ |
307 |
{ |
| 308 |
NS_ASSERT_MSG ((*rxPhyIterator)->GetRxSpectrumModel ()->GetUid () == rxSpectrumModelUid, |
308 |
NS_ASSERT_MSG ((*rxPhyIterator)->GetRxSpectrumModel ()->GetUid () == rxSpectrumModelUid, |
|
|
| 412 |
// acceptable as it is not used much at run time (often not at all). |
412 |
// acceptable as it is not used much at run time (often not at all). |
| 413 |
// On the other hand, having slow SpectrumModel conversion would be |
413 |
// On the other hand, having slow SpectrumModel conversion would be |
| 414 |
// less acceptable. |
414 |
// less acceptable. |
| 415 |
uint32_t j = 0; |
|
|
| 416 |
for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin (); |
415 |
for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin (); |
| 417 |
rxInfoIterator != m_rxSpectrumModelInfoMap.end (); |
416 |
rxInfoIterator != m_rxSpectrumModelInfoMap.end (); |
| 418 |
++rxInfoIterator) |
417 |
++rxInfoIterator) |
| 419 |
{ |
418 |
{ |
| 420 |
for (std::set<Ptr<SpectrumPhy> >::const_iterator phyIt = rxInfoIterator->second.m_rxPhySet.begin (); |
419 |
const std::vector<Ptr<SpectrumPhy>> &rxPhys = rxInfoIterator->second.m_rxPhys; |
| 421 |
phyIt != rxInfoIterator->second.m_rxPhySet.end (); |
420 |
if (i < rxPhys.size ()) |
| 422 |
++phyIt) |
|
|
| 423 |
{ |
421 |
{ |
| 424 |
if (j == i) |
422 |
return rxPhys[i]->GetDevice (); |
| 425 |
{ |
|
|
| 426 |
return (*phyIt)->GetDevice (); |
| 427 |
} |
| 428 |
j++; |
| 429 |
} |
423 |
} |
|
|
424 |
i -= rxPhys.size (); |
| 430 |
} |
425 |
} |
| 431 |
NS_FATAL_ERROR ("m_numDevice > actual number of devices"); |
426 |
NS_FATAL_ERROR ("m_numDevice > actual number of devices"); |
| 432 |
return 0; |
427 |
return 0; |