CARMA C++
PhaseMonitorSamples.h
1 #ifndef CARMA_PHASEMONITORSAMPLES_H
2 #define CARMA_PHASEMONITORSAMPLES_H
3 /*
4  * $Id: PhaseMonitorSamples.h,v 1.4 2013/02/06 20:07:29 abeard Exp $
5  */
6 
7 
8 #include <math.h>
9 #include <fcntl.h>
10 #include <ctype.h>
11 #include <stdio.h> // for sprintf
12 #include <unistd.h>
13 #include <errno.h>
14 #include <termios.h>
15 #include <sys/time.h>
16 
17 #include <iostream>
18 #include <string>
19 #include <iosfwd>
20 #include <fstream>
21 
22 #include "carma/util/Trace.h"
23 #include "carma/util/Time.h"
24 
25 #include "carma/phasemonitor/Maths.h"
26 
27 namespace carma
28 {
29  namespace phasemonitor
30  {
31  class PhaseMonitorSamples
32  {
33  public:
34  PhaseMonitorSamples( std::string fileName );
35 
36  void process( int n, double startMJD,
37  time_t *sampleTimes,
38  float &skyRMS, float &groundRMS,
39  float *skyPhase, float *groundPhase,
40  float *ampSW, float *ampNE,
41  int errors, float boxTempC );
42  float getTimeTrend( int i );
43  float getSkyPathTrend( int i );
44  float getGroundPathTrend( int i );
45  float getCurrentSkyPath() { return getSkyPathTrend( _mostRecentSample ); };
46  float getCurrentGroundPath() { return getGroundPathTrend( _mostRecentSample ); };
47 
48  int trendsCount() { return _ntrend; };
49 
50  static const float _lambda = 24200.0; // Wavelen@12.4GHz in microns
51 
52  private:
53  std::string _fileName;
54  std::ofstream _file;
55  int _sampleCount;
56  int _mostRecentSample;
57  static const int _ntrend = 3;
58  static const float _avgMultiplier = 0.9; // Smoothing time
59  static const double _oneMJDsec = .00001157407;
60 
61  float _timeTrend[_ntrend];
62  float _skyPathTrend[_ntrend], _groundPathTrend[_ntrend];
63  float _runningSum, _runningWght, _runningAvg;
64 
65  };
66  } // phasemonitor
67 } // carma
68 
69 ::std::ostream& operator<<( ::std::ostream& os,
70  ::carma::phasemonitor::PhaseMonitorSamples &samples );
71 
72 #endif // CARMA_PHASEMONITORSAMPLES_H
std::ostream & operator<<(::std::ostream &os, const carma::dbms::Table &table)
Common time functions.
Interface file for the carma::util::Trace class and related macros.