My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
AzTiltMeter.h
1 #ifndef GCP_UTIL_AZ_TILT_METER_H
2 #define GCP_UTIL_AZ_TILT_METER_H
3 
4 #include "gcp/util/common/MovingAverage.h"
5 #include "gcp/antenna/control/specific/OffsetBase.h"
6 #include "gcp/util/common/Angle.h"
7 #include "gcp/util/common/Exception.h"
8 
9 namespace gcp {
10  namespace antenna {
11  namespace control {
12 
13  using namespace gcp::util;
14 
15  class AzTiltMeter : public OffsetBase {
16 
17  public:
18 
19  AzTiltMeter();
20  ~AzTiltMeter();
21  // Set number of samples in moving average and reset average window to empty
22  void setMovingAvgSampleCount(unsigned int count);
23  // Set number of samples between tilt updates
24  void enable(); // Enable tilt updates
25  void disable(); // Disable tilt updates and reset moving average window to empty.
26  void reset(); // Reset moving average windows to empty
27  // Set angle between Grid North and x tilt meter axis
28  void setTheta(Angle theta);
29  // Set maximum absolute value to which moving average of each tilt meter reading is clipped
30  void setRange(Angle maxAngle) {
31  maxAngle_ = maxAngle.radians();
32  COUT("AzTiltMeter maxAngle = " << maxAngle.degrees());
33  }
34  // Set offset to be added to raw tilt meter values to zero tilt meter
35  void setOffset(Angle x, Angle y) {
36  COUT("AzTiltMeter offset x = " << x.degrees() << " y = " << y.degrees());
37  xOffset_ = x.radians(); yOffset_ = y.radians();
38  };
39 
40  void addSample(Angle x, Angle y); // Called for each valid set of tilt meter readings
41  // Return hour angle and lattitude tilt corrections for specified azimuth
42  void apply(PointingCorrections *f);
43  Angle xAvg() {return Angle(Angle::Radians(), *xAvg_);};
44  Angle yAvg() {return Angle(Angle::Radians(), *yAvg_);};
45  Angle xOffset() {return Angle(Angle::Radians(), xOffset_);};
46  Angle yOffset() {return Angle(Angle::Radians(), yOffset_);};
47  bool enabled() {return meterEnabled_;};
48  Angle maxAngle() {return Angle(Angle::Radians(), maxAngle_);};
49  Angle theta() {return theta_;};
50  unsigned int movingAvgSampleCount() {return avgCount_;};
51  bool lacking(); // True if disabled or moving average window not full
52 
53  private:
54 
55  const static unsigned int defaultAvgCount = 1000; // Default number of samples in moving average
56  unsigned int avgCount_; // number of samples in moving average
57  MovingAverage<double>* xAvg_; // Moving average of x tilt meter value
58  MovingAverage<double>* yAvg_; // Moving average of y tilt meter value
59  bool meterEnabled_; // True if tilt correction based on meter enabled
60  Angle theta_; // Angle between grid North and x tilt meter axis
61  // increases counterclockwise looking down
62  double maxAngle_; // Max allowed absolute value of tilt meter angle in radians
63  double xOffset_;
64  double yOffset_;
65  // cached trig functions
66  double sinTheta_;
67  double cosTheta_;
68  };
69 
70  } // End namespace control
71  } // End namespace antenna
72 } // End namespace gcp
73 
74 #endif // End #ifndef GCP_UTIL_AZ_TILT_METER_H
Definition: Angle.h:23
Definition: AzTiltMeter.h:15
Definition: Angle.h:20
Definition: OffsetBase.h:27
Definition: PointingCorrections.h:22
double radians()
Definition: Angle.h:79