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

(-)a/src/common/propagation-loss-model-test-suite.cc (+49 lines)
 Lines 462-467    Link Here 
462
  return GetErrorStatus ();
462
  return GetErrorStatus ();
463
}
463
}
464
464
465
class TwoLossTestCase : public TestCase
466
{
467
public:
468
  TwoLossTestCase ();
469
  virtual ~TwoLossTestCase ();
470
471
private:
472
  virtual bool DoRun (void);
473
};
474
475
TwoLossTestCase::TwoLossTestCase ()
476
  : TestCase ("Test TwoLoss")
477
{
478
}
479
480
TwoLossTestCase::~TwoLossTestCase ()
481
{
482
}
483
484
bool
485
TwoLossTestCase::DoRun (void)
486
{
487
  ObjectFactory a;
488
  ObjectFactory b;
489
  ObjectFactory ma;
490
  ObjectFactory mb;
491
  double txPower = 0.0;
492
 
493
  a.SetTypeId ("ns3::FixedRssLossModel");
494
  a.Set ("Rss",DoubleValue(10.0));
495
  b.SetTypeId ("ns3::FixedRssLossModel");
496
  b.Set ("Rss",DoubleValue(20.0));
497
  Ptr<PropagationLossModel> oneLoss = a.Create<PropagationLossModel> ();
498
  Ptr<PropagationLossModel> twoLoss = b.Create<PropagationLossModel> ();
499
500
  ma.SetTypeId ("ns3::ConstantPositionMobilityModel");
501
  mb.SetTypeId ("ns3::ConstantPositionMobilityModel");
502
  Ptr<MobilityModel> mobilitya = ma.Create<MobilityModel> ();
503
  Ptr<MobilityModel> mobilityb = mb.Create<MobilityModel> ();
504
505
  oneLoss->SetNext (twoLoss);
506
  double tolerance = 1e-6;
507
  double resultdBm = oneLoss->CalcRxPower(txPower,mobilitya,mobilityb);
508
  NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, 30.0, tolerance, "Added one and two; got unexpected rcv power");
509
510
  return GetErrorStatus ();
511
}
512
465
class PropagationLossModelsTestSuite : public TestSuite
513
class PropagationLossModelsTestSuite : public TestSuite
466
{
514
{
467
public:
515
public:
 Lines 476-481    Link Here 
476
  AddTestCase (new LogDistancePropagationLossModelTestCase);
524
  AddTestCase (new LogDistancePropagationLossModelTestCase);
477
  AddTestCase (new MatrixPropagationLossModelTestCase);
525
  AddTestCase (new MatrixPropagationLossModelTestCase);
478
  AddTestCase (new RangePropagationLossModelTestCase);
526
  AddTestCase (new RangePropagationLossModelTestCase);
527
  AddTestCase (new TwoLossTestCase);
479
}
528
}
480
529
481
PropagationLossModelsTestSuite WifiPropagationLossModelsTestSuite;
530
PropagationLossModelsTestSuite WifiPropagationLossModelsTestSuite;
(-)a/src/common/propagation-loss-model.cc (-4 / +12 lines)
 Lines 58-74    Link Here 
58
  m_next = next;
58
  m_next = next;
59
}
59
}
60
60
61
Ptr<PropagationLossModel>
62
PropagationLossModel::GetNext (void) const
63
{
64
  return m_next;
65
}
66
61
double 
67
double 
62
PropagationLossModel::CalcRxPower (double txPowerDbm,
68
PropagationLossModel::CalcRxPower (double txPowerDbm,
63
                                   Ptr<MobilityModel> a,
69
                                   Ptr<MobilityModel> a,
64
                                   Ptr<MobilityModel> b) const
70
                                   Ptr<MobilityModel> b) const
65
{
71
{
66
  double self = DoCalcRxPower (txPowerDbm, a, b);
72
  double rxPower = DoCalcRxPower (txPowerDbm, a, b);
67
  if (m_next != 0)
73
  Ptr<PropagationLossModel> next = m_next;
74
  while (next != 0)
68
    {
75
    {
69
      self = m_next->CalcRxPower (self, a, b);
76
      rxPower += m_next->CalcRxPower (rxPower, a, b);
77
      next = next->GetNext ();
70
    }
78
    }
71
  return self;
79
  return rxPower;
72
}
80
}
73
81
74
// ------------------------------------------------------------------------- //
82
// ------------------------------------------------------------------------- //
(-)a/src/common/propagation-loss-model.h (+1 lines)
 Lines 49-54    Link Here 
49
  virtual ~PropagationLossModel ();
49
  virtual ~PropagationLossModel ();
50
50
51
  void SetNext (Ptr<PropagationLossModel> next);
51
  void SetNext (Ptr<PropagationLossModel> next);
52
  Ptr<PropagationLossModel> GetNext (void) const;
52
53
53
  /**
54
  /**
54
   * \param txPowerDbm current transmission power (in dBm)
55
   * \param txPowerDbm current transmission power (in dBm)

Return to bug 1008