satellite-cno-estimator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
21 #ifndef SAT_CNO_ESTIMATOR
22 #define SAT_CNO_ESTIMATOR
23 
25 
26 #include <ns3/nstime.h>
27 #include <ns3/simple-ref-count.h>
28 
29 #include <map>
30 
31 namespace ns3
32 {
33 
39 class SatCnoEstimator : public SimpleRefCount<SatCnoEstimator>
40 {
41  public:
45  typedef enum
46  {
47  LAST,
49  AVERAGE
51 
56 
62  virtual ~SatCnoEstimator();
63 
70  void AddSample(double cno);
71 
79  double GetCnoEstimation();
80 
81  private:
88  virtual void DoAddSample(double cno) = 0;
89 
97  virtual double DoGetCnoEstimation() = 0;
98 };
99 
114 {
115  public:
123  static inline double AddToSum(double currentSum, const std::pair<Time, double>& sample)
124  {
125  double newSum = currentSum;
126 
127  if (!std::isnan(sample.second))
128  {
129  newSum += sample.second;
130  }
131 
132  return newSum;
133  }
134 
139 
144 
151 
152  private:
153  typedef std::map<Time, double> SampleMap_t;
154 
156  Time m_window;
158 
164  virtual void DoAddSample(double cno);
165 
172  virtual double DoGetCnoEstimation();
173 
177  void ClearOutdatedSamples();
178 };
179 
180 } // namespace ns3
181 
182 #endif /* SAT_CNO_ESTIMATOR */
class for module SatCnoEstimator.
void ClearOutdatedSamples()
Clear outdated samples from storage.
static double AddToSum(double currentSum, const std::pair< Time, double > &sample)
Method to add a sample value to current sum.
virtual void DoAddSample(double cno)
Add a C/N0 sample to estimator.
SatBasicCnoEstimator()
Default construct a SatCnoEstimator.
std::map< Time, double > SampleMap_t
~SatBasicCnoEstimator()
Destroy a SatCnoEstimator.
virtual double DoGetCnoEstimation()
Estimate C/N0 value of the samples in window.
SatCnoEstimator class defines interface for C/N0 estimators.
double GetCnoEstimation()
Estimate C/N0 value of the samples.
virtual void DoAddSample(double cno)=0
Add a C/N0 sample to estimator.
virtual double DoGetCnoEstimation()=0
Estimate C/N0 value of the samples.
EstimationMode_t
Definition of modes for estimator.
@ MINIMUM
Minimum value in the given window returned.
@ LAST
Last value in the given window returned.
@ AVERAGE
Average value in the given window returned.
virtual ~SatCnoEstimator()
Destroy a SatCnoEstimator.
void AddSample(double cno)
Add a C/N0 sample to estimator.
SatCnoEstimator()
Default construct a SatCnoEstimator.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.