satellite-fading-oscillator.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Frans Laakso <frans.laakso@magister.fi>
19  */
20 
22 
23 #include <ns3/log.h>
24 
25 namespace ns3
26 {
27 
28 NS_OBJECT_ENSURE_REGISTERED(SatFadingOscillator);
29 NS_LOG_COMPONENT_DEFINE("SatFadingOscillator");
30 
31 TypeId
33 {
34  static TypeId tid = TypeId("ns3::SatFadingOscillator")
35  .SetParent<Object>()
36  .AddConstructor<SatFadingOscillator>();
37  return tid;
38 }
39 
41  : m_complexAmplitude(0, 0),
42  m_amplitude(0),
43  m_phase(0),
44  m_omega(0)
45 {
46  NS_LOG_FUNCTION(this);
47 
48  NS_FATAL_ERROR("SatFadingOscillator::SatFadingOscillator - Constructor not in use");
49 }
50 
51 SatFadingOscillator::SatFadingOscillator(std::complex<double> amplitude,
52  double initialPhase,
53  double omega)
54  : m_complexAmplitude(amplitude),
55  m_amplitude(0),
56  m_phase(initialPhase),
57  m_omega(omega)
58 {
59  NS_LOG_FUNCTION(this << amplitude << " " << initialPhase << " " << omega);
60 }
61 
62 SatFadingOscillator::SatFadingOscillator(double amplitude, double initialPhase, double omega)
63  : m_complexAmplitude(0, 0),
64  m_amplitude(amplitude),
65  m_phase(initialPhase),
66  m_omega(omega)
67 {
68  NS_LOG_FUNCTION(this << amplitude << " " << initialPhase << " " << omega);
69 }
70 
71 std::complex<double>
72 SatFadingOscillator::GetComplexValueAt(double timeInSeconds) const
73 {
74  NS_LOG_FUNCTION(this << timeInSeconds);
75 
76  return (m_complexAmplitude * std::cos(timeInSeconds * m_omega + m_phase));
77 }
78 
79 std::complex<double>
80 SatFadingOscillator::GetCosineWaveValueAt(double timeInSeconds) const
81 {
82  NS_LOG_FUNCTION(this << timeInSeconds);
83 
84  std::complex<double> complexPhase(std::cos(timeInSeconds * m_omega + m_phase),
85  std::sin(timeInSeconds * m_omega + m_phase));
86  return (m_amplitude * std::exp(complexPhase));
87 }
88 
90 {
91  NS_LOG_FUNCTION(this);
92 }
93 
94 void
96 {
97  NS_LOG_FUNCTION(this);
98 
99  Object::DoDispose();
100 }
101 
102 } // namespace ns3
std::complex< double > m_complexAmplitude
Complex amplitude.
void DoDispose()
Do needed dispose actions.
std::complex< double > GetCosineWaveValueAt(double timeInSeconds) const
Returns cosine wave complex value at time t.
static TypeId GetTypeId(void)
NS-3 function for type id.
std::complex< double > GetComplexValueAt(double timeInSeconds) const
Returns complex value at time t.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.