Loading...
Searching...
No Matches
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#include <cmath>
26#include <complex>
27#include <stdint.h>
28
29namespace ns3
30{
31
32NS_OBJECT_ENSURE_REGISTERED(SatFadingOscillator);
33NS_LOG_COMPONENT_DEFINE("SatFadingOscillator");
34
35TypeId
37{
38 static TypeId tid = TypeId("ns3::SatFadingOscillator")
39 .SetParent<Object>()
40 .AddConstructor<SatFadingOscillator>();
41 return tid;
42}
43
45 : m_complexAmplitude(0, 0),
46 m_amplitude(0),
47 m_phase(0),
48 m_omega(0)
49{
50 NS_LOG_FUNCTION(this);
51
52 NS_FATAL_ERROR("SatFadingOscillator::SatFadingOscillator - Constructor not in use");
53}
54
55SatFadingOscillator::SatFadingOscillator(std::complex<double> amplitude,
56 double initialPhase,
57 double omega)
58 : m_complexAmplitude(amplitude),
59 m_amplitude(0),
60 m_phase(initialPhase),
61 m_omega(omega)
62{
63 NS_LOG_FUNCTION(this << amplitude << " " << initialPhase << " " << omega);
64}
65
66SatFadingOscillator::SatFadingOscillator(double amplitude, double initialPhase, double omega)
67 : m_complexAmplitude(0, 0),
68 m_amplitude(amplitude),
69 m_phase(initialPhase),
70 m_omega(omega)
71{
72 NS_LOG_FUNCTION(this << amplitude << " " << initialPhase << " " << omega);
73}
74
75std::complex<double>
76SatFadingOscillator::GetComplexValueAt(double timeInSeconds) const
77{
78 NS_LOG_FUNCTION(this << timeInSeconds);
79
80 return (m_complexAmplitude * std::cos(timeInSeconds * m_omega + m_phase));
81}
82
83std::complex<double>
85{
86 NS_LOG_FUNCTION(this << timeInSeconds);
87
88 std::complex<double> complexPhase(std::cos(timeInSeconds * m_omega + m_phase),
89 std::sin(timeInSeconds * m_omega + m_phase));
90 return (m_amplitude * std::exp(complexPhase));
91}
92
94{
95 NS_LOG_FUNCTION(this);
96}
97
98void
100{
101 NS_LOG_FUNCTION(this);
102
103 Object::DoDispose();
104}
105
106} // namespace ns3
Oscillator class for faders.
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.