LevelMonitor.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2008 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/General/dsp/LevelMonitor.h
10 
11 #ifndef __LevelMonitor_h
12 #define __LevelMonitor_h
13 
14 #include "Reference.h"
15 #include "environ.h"
16 
17 #include <vector>
18 
19 namespace dsp {
20 
21  class WeightedTimeSeries;
22  class LevelHistory;
23  class IOManager;
24  class HistUnpacker;
25 
27  class LevelMonitor : public Reference::Able
28  {
29 
30  public:
31 
33  static bool verbose;
34 
36  static bool connect;
37 
39  LevelMonitor ();
40 
42  virtual ~LevelMonitor ();
43 
45  void set_integration (uint64_t npts);
46 
48  virtual void monitor ();
49 
51  virtual void monitor_abort ();
52 
54  virtual int change_gain (unsigned ichan, unsigned ipol, unsigned idim, double scale);
55 
57  virtual int change_levels (unsigned ichan, unsigned ipol, unsigned idim, double offset);
58 
60  virtual int accumulate_stats (std::vector<double>& mean,
61  std::vector<double>& variance);
62 
64  virtual int set_thresholds (std::vector<double>& mean,
65  std::vector<double>& variance);
66 
68  void set_max_iterations (unsigned);
69 
71  void set_between_iterations (double seconds);
72 
74  void set_history (LevelHistory* history);
75 
77  void set_input (IOManager* input);
78 
80  void set_swap_polarizations (bool swap);
81 
83  void set_consecutive (bool swap);
84 
85  protected:
86 
87  void init();
88 
90  uint64_t n_integrate;
91 
93  uint64_t block_size;
94 
96  unsigned max_iterations;
97 
99  double between_iterations;
100 
102  bool abort;
103 
105  bool stop_after_good;
108 
112  double optimal_dBm;
113 
116 
118  double var_tolerance;
119 
121  bool far_from_good;
122 
124  bool swap_polarizations;
125 
127  bool consecutive;
128 
129  private:
130 
133 
136 
139 
142 
143  void connect_bits ();
144 
145  unsigned nchan, npol, ndim, ndig;
146 
147  };
148 
149 }
150 
152 double variance2dBm (double);
153 
154 #endif
double optimal_dBm
the optimal dBm
Definition: LevelMonitor.h:117
Produces TimeSeries data by integrating an Input with an Unpacker.
Definition: IOManager.h:26
bool swap_polarizations
Swap polarizations.
Definition: LevelMonitor.h:129
Bit unpacker that keeps a histogram and optimal statistics.
Definition: HistUnpacker.h:25
virtual int accumulate_stats(std::vector< double > &mean, std::vector< double > &variance)
Accumulate statistics about incoming data stream.
Definition: LevelMonitor.C:232
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
virtual void set_unpacker(HistUnpacker *)=0
Set the HistUnpacker from which histogram will be recorded.
unsigned get_ndim() const
Return the dimension of each datum.
Definition: Observation.h:80
void set_max_iterations(unsigned)
Set the maximum number of iterations before giving up.
Definition: LevelMonitor.C:155
static bool verbose
Verbosity flag.
Definition: LevelMonitor.h:38
virtual int change_gain(unsigned ichan, unsigned ipol, unsigned idim, double scale)
Change the gain in the given channel.
Definition: LevelMonitor.C:123
double optimal_variance
the optimal variance
Definition: LevelMonitor.h:115
virtual void monitor()
Using input and converter, calculate sampling thresholds.
Definition: LevelMonitor.C:174
void set_input(IOManager *input)
Set the device to be used to plot/log the digitizer statistics.
Definition: LevelMonitor.C:63
LevelMonitor()
Constructor.
Definition: LevelMonitor.C:25
unsigned get_npol() const
Return the number of polarizations.
Definition: Observation.h:90
Container of weighted time-major order floating point data.
Definition: WeightedTimeSeries.h:26
Stores information about digital, band-limited, time-varying signals.
Definition: Observation.h:33
bool far_from_good
flag says we need to get on it
Definition: LevelMonitor.h:126
uint64_t n_integrate
the number of points to integrate
Definition: LevelMonitor.h:95
bool stop_after_good
stop setting the thresholds after they are good
Definition: LevelMonitor.h:110
void set_swap_polarizations(bool swap)
Swap the polarizations.
Definition: LevelMonitor.C:160
void set_consecutive(bool swap)
Read data consecutively (do not seek to end on each iteration)
Definition: LevelMonitor.C:165
unsigned max_iterations
Number of iterations, 0 for infinite.
Definition: LevelMonitor.h:101
uint64_t block_size
the number of points to load in one iteration
Definition: LevelMonitor.h:98
virtual int change_levels(unsigned ichan, unsigned ipol, unsigned idim, double offset)
Change the level in the given channel.
Definition: LevelMonitor.C:141
double mean_tolerance
the amount by which the mean may be off zero
Definition: LevelMonitor.h:120
Logs the history of digitized data statistics.
Definition: LevelHistory.h:24
bool consecutive
Read data consecutively.
Definition: LevelMonitor.h:132
bool abort
abort current integration
Definition: LevelMonitor.h:107
void set_history(LevelHistory *history)
Set the device to be used to plot/log the digitizer statistics.
Definition: LevelMonitor.C:54
double between_iterations
the amount of time to sleep between iterations
Definition: LevelMonitor.h:104
void set_between_iterations(double seconds)
Set the number of seconds to sleep between iterations.
Definition: LevelMonitor.C:108
bool setting_thresholds
call set_thresholds on each loop
Definition: LevelMonitor.h:112
double var_tolerance
the amount by which the variance may be off optimal
Definition: LevelMonitor.h:123
void set_integration(uint64_t npts)
Set the number of points included in each calculation of thresholds.
Definition: LevelMonitor.C:103
virtual ~LevelMonitor()
Destructor.
Definition: LevelMonitor.C:49
static bool connect
Actually connect.
Definition: LevelMonitor.h:41
virtual int set_thresholds(std::vector< double > &mean, std::vector< double > &variance)
Set the sampling thresholds based on mean and variance in each channel.
Definition: LevelMonitor.C:345
virtual void monitor_abort()
Abort monitoring.
Definition: LevelMonitor.C:114
unsigned get_nchan() const
Return the number of channels into which the band is divided.
Definition: Observation.h:85

Generated using doxygen 1.8.17