CARMA C++
DewarRegulation.h
Go to the documentation of this file.
1 
11 #ifndef CARMA_ANTENNA_BIMA_DEWARREGULATION_H
12 #define CARMA_ANTENNA_BIMA_DEWARREGULATION_H
13 
14 #include <stdio.h>
15 
16 #include <list>
17 #include <string>
18 
19 // System includes
20 #include <sys/time.h>
21 #include <unistd.h>
22 
23 // CARMA includes
24 #include "carma/util/Program.h"
25 #include "carma/util/Logger.h"
26 #include "carma/services/Table.h"
30 
32 #include "carma/util/ExceptionUtils.h"
33 
34 
35 namespace carma
36 {
37  namespace antenna
38  {
39  namespace bima
40  {
41  class TimedValue
42  {
43  public:
44  TimedValue( time_t t, float value )
45  {
46  _t = t;
47  _v = value;
48  }
49 
50  time_t _t; // time in seconds from epoch
51  float _v;
52  };
53 
54  class DewarRegulation : public SharedMemory
55  {
56 
57  public:
58  DewarRegulation(
59  Configuration& config,
60  bool server,
61  bool emulate );
62 
63  ~DewarRegulation();
64 
65  bool alreadyRunning();
66  bool isOk();
67  void updateWatchdog();
68  void setPoint( double temp );
69  double getPoint();
70  double getPointMJD();
71  void setHeater( double temp );
72  void diagnosticLog( double temp, double min, double max );
73  void startDiagLog( bool start );
74 
75  // Calls regulate
76  static void thread( DewarRegulation &This );
77  void regulate();
78 
79  bool isOn();
80  void on();
81  void off();
82  void defrost();
83  void cancelDefrost();
84  bool isDefrosting();
85 
86  void setRunningV( float volts );
87  void setMaxV( float volts );
88  void setMinV( float volts );
89  float getRunningV();
90  float getMaxV();
91  float getMinV();
92  void setAvgTemp( float t );
93  void setMaxAvgTemp( float t );
94  void setMinAvgTemp( float t );
95  void computeAvgTempSetPointRMS( std::list<TimedValue> &aList );
96  float getTempSetPointRMS();
97  float getAvgTemp();
98  float getMaxAvgTemp();
99  float getMinAvgTemp();
100 
101  void cullEntriesOlderThan( std::list<TimedValue> &aList, time_t t );
102  void insertAndCullMaxMin( std::list<TimedValue> &aList, float value );
103  Dewar & getDewar() { return _dewar; }
104  double getStage1Temp() { return _dewar.stage1temp(); };
105  double getStage2Temp() { return _dewar.stage2temp(); };
106  double getStage3Temp() { return _dewar.stage3temp(); };
107  double getStage4Temp() { return _dewar.stage4temp(); };
108  double getStage5Temp() { return _dewar.stage5temp(); };
109 
110  void setStage( int stage );
111  double (DewarRegulation::*getTemp)();
112 
113  private:
114  static const std::string _poaName;
115  Dewar _dewar;
116  Configuration &_config;
117  log4cpp::Category &_log;
118  double _setPoint, _oldPoint;
119  bool _emulate;
120  time_t _defrostStart, _lastRMS;
121 
122  std::list<TimedValue> _maxminT; // avg'd temps
123  std::list<TimedValue> _maxminV; // voltages
124  std::list<TimedValue> _tempList; // running avg of temps for rms
125 
126  }; // class DewarRegulation
127  } // namespace bima
128  } // namespace antenna
129 } // namespace carma
130 
131 #endif // CARMA_ANTENNA_BIMA_DEWARREGULATION_H
Class definition for Stepper Motors for BIMA systems.
Exception class for errors.
Common table functions.
Class definition for TelemetryClient on the BIMA antennas.
Class definition for Stepper Motors for BIMA systems.