src/spectrum/model/multi-model-spectrum-channel.cc
author Nicola Baldo <nbaldo@cttc.es>
Fri, 26 Oct 2012 14:10:40 +0200
changeset 9113 63eba52498e1
parent 9063 32755d0516f4
child 9653 382d27da8905
permissions -rw-r--r--
make MultiModelSpectrumChannel support SpectrumModel changes at run time
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7343
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     2
/*
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     3
 * Copyright (c) 2009 CTTC
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     4
 *
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     8
 *
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    13
 *
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    17
 *
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    18
 * Author: Nicola Baldo <nbaldo@cttc.es>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    19
 */
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    20
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    21
#include <ns3/object.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    22
#include <ns3/simulator.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    23
#include <ns3/log.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    24
#include <ns3/packet.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    25
#include <ns3/packet-burst.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    26
#include <ns3/net-device.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    27
#include <ns3/node.h>
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    28
#include <ns3/double.h>
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    29
#include <ns3/mobility-model.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    30
#include <ns3/spectrum-phy.h>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    31
#include <ns3/spectrum-converter.h>
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    32
#include <ns3/spectrum-propagation-loss-model.h>
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    33
#include <ns3/propagation-loss-model.h>
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    34
#include <ns3/propagation-delay-model.h>
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
    35
#include <ns3/antenna-model.h>
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
    36
#include <ns3/angles.h>
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    37
#include <iostream>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    38
#include <utility>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    39
#include "multi-model-spectrum-channel.h"
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    40
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    41
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    42
NS_LOG_COMPONENT_DEFINE ("MultiModelSpectrumChannel");
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    43
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    44
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    45
namespace ns3 {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    46
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    47
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    48
NS_OBJECT_ENSURE_REGISTERED (MultiModelSpectrumChannel);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    49
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    50
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    51
std::ostream& operator<< (std::ostream& lhs, TxSpectrumModelInfoMap_t& rhs)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    52
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    53
  for (TxSpectrumModelInfoMap_t::iterator it = rhs.begin ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    54
       it != rhs.end ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    55
       ++it)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    56
    {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    57
      SpectrumConverterMap_t::iterator jt;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    58
      for (jt = it->second.m_spectrumConverterMap.begin ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    59
           jt != it->second.m_spectrumConverterMap.end ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    60
           ++jt)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    61
        {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    62
          lhs << "(" << it->first << "," << jt->first << ") ";
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    63
        }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    64
    }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    65
  return lhs;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    66
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    67
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    68
TxSpectrumModelInfo::TxSpectrumModelInfo (Ptr<const SpectrumModel> txSpectrumModel)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    69
  : m_txSpectrumModel (txSpectrumModel)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    70
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    71
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    72
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    73
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    74
RxSpectrumModelInfo::RxSpectrumModelInfo (Ptr<const SpectrumModel> rxSpectrumModel)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    75
  : m_rxSpectrumModel (rxSpectrumModel)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    76
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    77
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    78
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    79
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    80
MultiModelSpectrumChannel::MultiModelSpectrumChannel ()
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    81
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    82
  NS_LOG_FUNCTION (this);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    83
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    84
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    85
void
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    86
MultiModelSpectrumChannel::DoDispose ()
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    87
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    88
  NS_LOG_FUNCTION (this);
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    89
  m_propagationDelay = 0;
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    90
  m_propagationLoss = 0;
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
    91
  m_spectrumPropagationLoss = 0;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    92
  m_txSpectrumModelInfoMap.clear ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    93
  m_rxSpectrumModelInfoMap.clear ();
6986
f2534c707213 fixed disposal of MultiModelSpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 6801
diff changeset
    94
  SpectrumChannel::DoDispose ();
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    95
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    96
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    97
TypeId
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    98
MultiModelSpectrumChannel::GetTypeId (void)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
    99
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   100
  static TypeId tid = TypeId ("ns3::MultiModelSpectrumChannel")
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   101
    .SetParent<SpectrumChannel> ()
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   102
    .AddConstructor<MultiModelSpectrumChannel> ()
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   103
    .AddAttribute ("MaxLossDb",
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   104
                   "If a single-frequency PropagationLossModel is used, this value "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   105
                   "represents the maximum loss in dB for which transmissions will be "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   106
                   "passed to the receiving PHY. Signals for which the PropagationLossModel "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   107
                   "returns a loss bigger than this value will not be propagated to the receiver. "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   108
                   "This parameter is to be used to reduce "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   109
                   "the computational load by not propagating signals that are far beyond "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   110
                   "the interference range. Note that the default value corresponds to "
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   111
                   "considering all signals for reception. Tune this value with care. ",
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   112
                   DoubleValue (1.0e9),
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   113
                   MakeDoubleAccessor (&MultiModelSpectrumChannel::m_maxLossDb),
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   114
                   MakeDoubleChecker<double> ())
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   115
    .AddTraceSource ("PathLoss",
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   116
                     "This trace is fired "
7554
e536a09d83ee added PropagationLoss trace to SpectrumChannel implementations
Nicola Baldo <nbaldo@cttc.es>
parents: 7553
diff changeset
   117
                     "whenever a new path loss value is calculated. The first and second parameters "
e536a09d83ee added PropagationLoss trace to SpectrumChannel implementations
Nicola Baldo <nbaldo@cttc.es>
parents: 7553
diff changeset
   118
                     "to the trace are pointers respectively to the TX and RX SpectrumPhy instances, "
e536a09d83ee added PropagationLoss trace to SpectrumChannel implementations
Nicola Baldo <nbaldo@cttc.es>
parents: 7553
diff changeset
   119
                     "whereas the third parameters is the loss value in dB. Note that the loss value "
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   120
                     "reported by this trace is the single-frequency loss value obtained by evaluating "
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   121
                     "only the TX and RX AntennaModels and the PropagationLossModel. In particular, note that "
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   122
                     "SpectrumPropagationLossModel (even if present) is never used to evaluate the loss value "
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   123
                     "reported in this trace. ",
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   124
                     MakeTraceSourceAccessor (&MultiModelSpectrumChannel::m_pathLossTrace))
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   125
  ;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   126
  return tid;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   127
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   128
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   129
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   130
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   131
void
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   132
MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   133
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   134
  NS_LOG_FUNCTION (this << phy);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   135
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   136
  Ptr<const SpectrumModel> rxSpectrumModel = phy->GetRxSpectrumModel ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   137
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   138
  NS_ASSERT_MSG ((0 != rxSpectrumModel), "phy->GetRxSpectrumModel () returned 0. Please check that the RxSpectrumModel is already set for the phy before calling MultiModelSpectrumChannel::AddRx (phy)");
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   139
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   140
  SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   141
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   142
  std::vector<Ptr<SpectrumPhy> >::const_iterator it;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   143
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   144
  // remove a previous entry of this phy if it exists
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   145
  // we need to scan for all rxSpectrumModel values since we don't
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   146
  // know which spectrum model the phy had when it was previously added
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   147
  // (it's probably different than the current one)
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   148
  for (RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   149
       rxInfoIterator !=  m_rxSpectrumModelInfoMap.end ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   150
       ++rxInfoIterator)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   151
    {
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   152
      std::set<Ptr<SpectrumPhy> >::iterator phyIt = rxInfoIterator->second.m_rxPhySet.find (phy);
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   153
      if (phyIt !=  rxInfoIterator->second.m_rxPhySet.end ())
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   154
        {
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   155
          rxInfoIterator->second.m_rxPhySet.erase (phyIt);
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   156
          --m_numDevices;
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   157
          break; // there should be at most one entry
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   158
        }       
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   159
    }
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   160
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   161
  ++m_numDevices;
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   162
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   163
  RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.find (rxSpectrumModelUid);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   164
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   165
  if (rxInfoIterator == m_rxSpectrumModelInfoMap.end ())
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   166
    {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   167
      // spectrum model unknown, add it to the list of RxSpectrumModels
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   168
      std::pair<RxSpectrumModelInfoMap_t::iterator, bool> ret;
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   169
      ret = m_rxSpectrumModelInfoMap.insert (std::make_pair (rxSpectrumModelUid, RxSpectrumModelInfo (rxSpectrumModel)));
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   170
      NS_ASSERT (ret.second);
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   171
      // also add the phy to the newly created set of SpectrumPhy for this RxSpectrumModel
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   172
      std::pair<std::set<Ptr<SpectrumPhy> >::iterator, bool> ret2 = ret.first->second.m_rxPhySet.insert (phy);
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   173
      NS_ASSERT (ret2.second);
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   174
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   175
      // and create the necessary converters for all the TX spectrum models that we know of
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   176
      for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   177
           txInfoIterator != m_txSpectrumModelInfoMap.end ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   178
           ++txInfoIterator)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   179
        {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   180
          Ptr<const SpectrumModel> txSpectrumModel = txInfoIterator->second.m_txSpectrumModel;
6350
2a88eb4e8dac Fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 6349
diff changeset
   181
          NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid );
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   182
          SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   183
          std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   184
          ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   185
          NS_ASSERT (ret2.second);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   186
        }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   187
    }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   188
  else
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   189
    {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   190
      // spectrum model is already known, just add the device to the corresponding list
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   191
      std::pair<std::set<Ptr<SpectrumPhy> >::iterator, bool> ret2 = rxInfoIterator->second.m_rxPhySet.insert (phy);
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   192
      NS_ASSERT (ret2.second);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   193
    }
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   194
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   195
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   196
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   197
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   198
TxSpectrumModelInfoMap_t::const_iterator
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   199
MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel (Ptr<const SpectrumModel> txSpectrumModel)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   200
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   201
  NS_LOG_FUNCTION (this << txSpectrumModel);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   202
  SpectrumModelUid_t txSpectrumModelUid = txSpectrumModel->GetUid ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   203
  TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.find (txSpectrumModelUid);
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   204
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   205
  if (txInfoIterator == m_txSpectrumModelInfoMap.end ())
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   206
    {
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   207
      // first time we see this TX SpectrumModel
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   208
      // we add it to the list
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   209
      std::pair<TxSpectrumModelInfoMap_t::iterator, bool> ret;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   210
      ret = m_txSpectrumModelInfoMap.insert (std::make_pair (txSpectrumModelUid, TxSpectrumModelInfo (txSpectrumModel)));
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   211
      NS_ASSERT (ret.second);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   212
      txInfoIterator = ret.first;
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   213
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   214
      // and we create the converters for all the RX SpectrumModels that we know of
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   215
      for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   216
           rxInfoIterator != m_rxSpectrumModelInfoMap.end ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   217
           ++rxInfoIterator)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   218
        {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   219
          Ptr<const SpectrumModel> rxSpectrumModel = rxInfoIterator->second.m_rxSpectrumModel;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   220
          SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   221
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   222
          if (rxSpectrumModelUid != txSpectrumModelUid)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   223
            {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   224
              NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModelUid << " and " << rxSpectrumModelUid );
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   225
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   226
              SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   227
              std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   228
              ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   229
              NS_ASSERT (ret2.second);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   230
            }
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   231
        }
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   232
    }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   233
  else
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   234
    {
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   235
      NS_LOG_LOGIC ("SpectrumModelUid " << txSpectrumModelUid << " already present");
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   236
    }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   237
  return txInfoIterator;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   238
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   239
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   240
    
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   241
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   242
void
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   243
MultiModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   244
{
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   245
  NS_LOG_FUNCTION (this << txParams);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   246
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   247
  NS_ASSERT (txParams->txPhy);
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   248
  NS_ASSERT (txParams->psd);
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   249
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   250
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   251
  Ptr<MobilityModel> txMobility = txParams->txPhy->GetMobility ();
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   252
  SpectrumModelUid_t txSpectrumModelUid = txParams->psd->GetSpectrumModelUid ();
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   253
  NS_LOG_LOGIC (" txSpectrumModelUid " << txSpectrumModelUid);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   254
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   255
  //
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   256
  TxSpectrumModelInfoMap_t::const_iterator txInfoIteratorerator = FindAndEventuallyAddTxSpectrumModel (txParams->psd->GetSpectrumModel ());
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   257
  NS_ASSERT (txInfoIteratorerator != m_txSpectrumModelInfoMap.end ());
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   258
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   259
  NS_LOG_LOGIC ("converter map for TX SpectrumModel with Uid " << txInfoIteratorerator->first);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   260
  NS_LOG_LOGIC ("converter map size: " << txInfoIteratorerator->second.m_spectrumConverterMap.size ());
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   261
  NS_LOG_LOGIC ("converter map first element: " << txInfoIteratorerator->second.m_spectrumConverterMap.begin ()->first);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   262
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   263
  for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   264
       rxInfoIterator != m_rxSpectrumModelInfoMap.end ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   265
       ++rxInfoIterator)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   266
    {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   267
      SpectrumModelUid_t rxSpectrumModelUid = rxInfoIterator->second.m_rxSpectrumModel->GetUid ();
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   268
      NS_LOG_LOGIC (" rxSpectrumModelUids " << rxSpectrumModelUid);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   269
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   270
      Ptr <SpectrumValue> convertedTxPowerSpectrum;
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   271
      if (txSpectrumModelUid == rxSpectrumModelUid)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   272
        {
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   273
          NS_LOG_LOGIC ("no spectrum conversion needed");
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   274
          convertedTxPowerSpectrum = txParams->psd;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   275
        }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   276
      else
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   277
        {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   278
          NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   279
          SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   280
          NS_ASSERT (rxConverterIterator != txInfoIteratorerator->second.m_spectrumConverterMap.end ());
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   281
          convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   282
        }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   283
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   284
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   285
      for (std::set<Ptr<SpectrumPhy> >::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhySet.begin ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   286
           rxPhyIterator != rxInfoIterator->second.m_rxPhySet.end ();
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   287
           ++rxPhyIterator)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   288
        {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   289
          NS_ASSERT_MSG ((*rxPhyIterator)->GetRxSpectrumModel ()->GetUid () == rxSpectrumModelUid,
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   290
                         "SpectrumModel change was not notified to MultiModelSpectrumChannel (i.e., AddRx should be called again after model is changed)");
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   291
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   292
          if ((*rxPhyIterator) != txParams->txPhy)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   293
            {
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   294
              NS_LOG_LOGIC (" copying signal parameters " << txParams);
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   295
              Ptr<SpectrumSignalParameters> rxParams = txParams->Copy ();
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   296
              rxParams->psd = Copy<SpectrumValue> (convertedTxPowerSpectrum);
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   297
              Time delay = MicroSeconds (0);
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   298
7553
2b93d333dea6 Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents: 7385
diff changeset
   299
              Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ();
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   300
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   301
              if (txMobility && receiverMobility)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   302
                {
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   303
                  double pathLossDb = 0;
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   304
                  if (rxParams->txAntenna != 0)
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   305
                    {
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   306
                      Angles txAngles (receiverMobility->GetPosition (), txMobility->GetPosition ());
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   307
                      double txAntennaGain = rxParams->txAntenna->GetGainDb (txAngles);
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   308
                      NS_LOG_LOGIC ("txAntennaGain = " << txAntennaGain << " dB");
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   309
                      pathLossDb -= txAntennaGain;
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   310
                    }
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   311
                  Ptr<AntennaModel> rxAntenna = (*rxPhyIterator)->GetRxAntenna ();
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   312
                  if (rxAntenna != 0)
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   313
                    {
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   314
                      Angles rxAngles (txMobility->GetPosition (), receiverMobility->GetPosition ());
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   315
                      double rxAntennaGain = rxAntenna->GetGainDb (rxAngles);
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   316
                      NS_LOG_LOGIC ("rxAntennaGain = " << rxAntennaGain << " dB");
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   317
                      pathLossDb -= rxAntennaGain;
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   318
                    }
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   319
                  if (m_propagationLoss)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   320
                    {
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   321
                      double propagationGainDb = m_propagationLoss->CalcRxPower (0, txMobility, receiverMobility);
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   322
                      NS_LOG_LOGIC ("propagationGainDb = " << propagationGainDb << " dB");
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   323
                      pathLossDb -= propagationGainDb;
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   324
                    }                    
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   325
                  NS_LOG_LOGIC ("total pathLoss = " << pathLossDb << " dB");    
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   326
                  m_pathLossTrace (txParams->txPhy, *rxPhyIterator, pathLossDb);
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   327
                  if ( pathLossDb > m_maxLossDb)
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   328
                    {
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   329
                      // beyond range
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   330
                      continue;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   331
                    }
9063
32755d0516f4 Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents: 8591
diff changeset
   332
                  double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
7836
9cf68ee51869 integrated AntennaModel with spectrum
Nicola Baldo <nbaldo@cttc.es>
parents: 7581
diff changeset
   333
                  *(rxParams->psd) *= pathGainLinear;              
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   334
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   335
                  if (m_spectrumPropagationLoss)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   336
                    {
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   337
                      rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, txMobility, receiverMobility);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   338
                    }
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   339
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   340
                  if (m_propagationDelay)
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   341
                    {
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   342
                      delay = m_propagationDelay->GetDelay (txMobility, receiverMobility);
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   343
                    }
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   344
                }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   345
7553
2b93d333dea6 Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents: 7385
diff changeset
   346
              Ptr<NetDevice> netDev = (*rxPhyIterator)->GetDevice ();
2b93d333dea6 Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents: 7385
diff changeset
   347
              if (netDev)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   348
                {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   349
                  // the receiver has a NetDevice, so we expect that it is attached to a Node
7553
2b93d333dea6 Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents: 7385
diff changeset
   350
                  uint32_t dstNode =  netDev->GetNode ()->GetId ();
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   351
                  Simulator::ScheduleWithContext (dstNode, delay, &MultiModelSpectrumChannel::StartRx, this,
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   352
                                                  rxParams, *rxPhyIterator);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   353
                }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   354
              else
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   355
                {
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   356
                  // the receiver is not attached to a NetDevice, so we cannot assume that it is attached to a node
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   357
                  Simulator::Schedule (delay, &MultiModelSpectrumChannel::StartRx, this,
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   358
                                       rxParams, *rxPhyIterator);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   359
                }
7142
89a701fec3a1 run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents: 6986
diff changeset
   360
            }
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   361
        }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   362
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   363
    }
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   364
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   365
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   366
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   367
void
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   368
MultiModelSpectrumChannel::StartRx (Ptr<SpectrumSignalParameters> params, Ptr<SpectrumPhy> receiver)
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   369
{
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   370
  NS_LOG_FUNCTION (this);
7581
6ac3fa410583 spectrum API change
Nicola Baldo <nicola@baldo.biz>
parents: 7565
diff changeset
   371
  receiver->StartRx (params);
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   372
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   373
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   374
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   375
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   376
uint32_t
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   377
MultiModelSpectrumChannel::GetNDevices (void) const
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   378
{
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   379
  return m_numDevices;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   380
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   381
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   382
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   383
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   384
Ptr<NetDevice>
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   385
MultiModelSpectrumChannel::GetDevice (uint32_t i) const
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   386
{
9113
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   387
  NS_ASSERT (i < m_numDevices);
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   388
  // this method implementation is computationally intensive. This
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   389
  // method would be faster if we actually used a std::vector for
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   390
  // storing devices, which we don't due to the need to have fast 
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   391
  // SpectrumModel conversions and to allow PHY devices to changea
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   392
  // SpectrumModel at run time. Note that having this method slow is
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   393
  // acceptable as it is not used much at run time (often not at all).
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   394
  // On the other hand, having slow SpectrumModel conversion would be
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   395
  // less acceptable. 
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   396
  uint32_t j = 0;
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   397
  for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   398
       rxInfoIterator !=  m_rxSpectrumModelInfoMap.end ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   399
       ++rxInfoIterator)
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   400
    {
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   401
      for (std::set<Ptr<SpectrumPhy> >::const_iterator phyIt = rxInfoIterator->second.m_rxPhySet.begin ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   402
           phyIt != rxInfoIterator->second.m_rxPhySet.end ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   403
           ++phyIt)        
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   404
        {
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   405
          if (j == i)
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   406
            {
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   407
              return (*phyIt)->GetDevice ();
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   408
            }
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   409
        }
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   410
    }
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   411
  NS_FATAL_ERROR ("m_numDevice > actual number of devices");
63eba52498e1 make MultiModelSpectrumChannel support SpectrumModel changes at run time
Nicola Baldo <nbaldo@cttc.es>
parents: 9063
diff changeset
   412
  return 0;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   413
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   414
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   415
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   416
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   417
void
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   418
MultiModelSpectrumChannel::AddPropagationLossModel (Ptr<PropagationLossModel> loss)
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   419
{
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   420
  NS_LOG_FUNCTION (this << loss);
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   421
  NS_ASSERT (m_propagationLoss == 0);
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   422
  m_propagationLoss = loss;
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   423
}
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   424
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   425
void
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   426
MultiModelSpectrumChannel::AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel> loss)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   427
{
7565
b62db8c69d56 fixed assertion in {Single,Multi}ModelSpectrumChannel::AddSpectrumPropagationLossModel
Nicola Baldo <nbaldo@cttc.es>
parents: 7554
diff changeset
   428
  NS_ASSERT (m_spectrumPropagationLoss == 0);
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   429
  m_spectrumPropagationLoss = loss;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   430
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   431
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   432
void
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   433
MultiModelSpectrumChannel::SetPropagationDelayModel (Ptr<PropagationDelayModel> delay)
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   434
{
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   435
  NS_ASSERT (m_propagationDelay == 0);
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   436
  m_propagationDelay = delay;
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   437
}
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   438
6704
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   439
Ptr<SpectrumPropagationLossModel>
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   440
MultiModelSpectrumChannel::GetSpectrumPropagationLossModel (void)
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   441
{
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   442
  NS_LOG_FUNCTION (this);
7343
b3e668a5949c added support for single-freq PropagationLossModel to SpectrumChannel
Nicola Baldo <nbaldo@cttc.es>
parents: 7142
diff changeset
   443
  return m_spectrumPropagationLoss;
6704
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   444
}
de8a506b7437 LTE module form GSoC project
Giuseppe Piro <g.piro@poliba.it>
parents: 6350
diff changeset
   445
6349
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   446
4bab6b10a034 merged spectrum framework
Nicola Baldo <nbaldo@cttc.es>
parents:
diff changeset
   447
} // namespace ns3