CARMA C++
TelemetryClient.h
Go to the documentation of this file.
1 
2 
13 #ifndef CARMA_BIMA_TELEMETRYCLIENT_H
14 #define CARMA_BIMA_TELEMETRYCLIENT_H
15 
16 #include <iosfwd>
17 #include <string>
18 #include <map>
19 #include <vector>
20 
21 #include <sys/poll.h>
22 
23 #include <xercesc/parsers/SAXParser.hpp>
24 #include <xercesc/validators/DTD/DTDValidator.hpp>
25 
30 
31 #include "carma/util/ScopedPthreadMutexLock.h"
32 #include "carma/util/IPQwriter.h"
34 #include "carma/util/Logger.h"
35 #include "carma/util/Trace.h"
36 
37 // Constants defined to compute conversion factors
38 // for units...
39 // These come directly from hatcreek/subs/misc/atod.c
40 #define VOLTS15 4.516129/32768.*3.608
41 #define VOLTS10 4.516129/32768.*2.697
42 #define VOLTS10P 4.516129/32768.*2.758
43 #define VOLTS5 4.516129/32768.*1.347
44 #define VOLTS4 4.516129/32768.
45 #define VOLTS1P2 4.516129/32768.*.280
46 #define VOLTS1 4.516129/32768.*.250
47 #define VOLTSP4 4.516129/32768.*.100
48 // Milivolts mv
49 #define MVOLTS 4.516129/32768.*5.
50 // microAmps uA 402 ohm sense resistor
51 #define UAMPS 4.516129/32768.*124.38
52 // Temp sensors volts
53 #define TVOLTS 4.516129/32768./2.5
54 #define THERMI 4.516129/32768.
55 
56 #define BIMASTATUSINFO(T,S) \
57 { \
58  std::ostringstream bsioss; \
59  bsioss << S ; \
60  T.setStatusInfo( bsioss.str() ); \
61 }
62 
63 namespace carma
64 {
65  namespace antenna
66  {
67  namespace bima
68  {
69  class TelemetryClient : public SharedMemory
70  {
71  public:
72  TelemetryClient( Configuration& config, bool checkTelemHost = true );
73  TelemetryClient();
74  ~TelemetryClient();
75 
76  bool status();
77 
78  void tpoke( const char *ccname, unsigned char value = 1);
79  void tpoke( const char *ccname, unsigned short value = 1 );
80  void tpoke( const char *ccname, unsigned long value = 1 );
81 
82  void tpeekWriteSpace( const char *ccname, unsigned short *value );
83  void tpeek( const char *ccname, unsigned short *value );
84  void tpeek( const char *ccname, unsigned long *value );
85 
86  int atodin ( const char *ccname );
87  int atodin ( int value )
88  {
89  if ( value & 0x8000 )
90  value |= 0xffff0000;
91 
92  return -value;
93  };
94  double thermistor( double volts );
95  double psi( int value );
96  void limit( double& value, double min, double max );
97 
98  bool atodSaturated();
99 
100  void setbits( const char *bitsin, unsigned char value, unsigned char mask );
101 
102  void cpoke( unsigned short msgId, std::vector<carma::canbus::byteType> data );
103 
104  void enableToggleBit( const char *name, int mask, int update );
105  void disableToggleBit( void );
106  void enableMonitorPackets( void );
107  void disableMonitorPackets( void );
108  void serialEnable( void );
109  void serialDisable( void );
110 
111  Configuration& getConfig() { return _config; }
112 
113  unsigned char getStatusByteA();
114  unsigned char getStatusByteB();
115  unsigned char getStatusByteC();
116 
117  // Status Control Box bit info
118  bool isElLim();
119  bool isElULim();
120  bool isAzLim();
121  bool isAzULim();
122  bool isKey();
123  bool isWtrPrssrNotNorm();
124  bool isCollisionDectOff();
125  bool isCollision();
126  bool isAzDrvTempNorm();
127  bool isElDrvTempNorm();
128  bool isRxTempNorm();
129  bool isCabTempNorm();
130  bool isSpareTempNorm();
131  bool isCameraSafe();
132  bool isComputerCtl();
133  bool isCamFlapOpen();
134  bool isCamFlapBypass();
135  bool isCabPwrOff();
136 
137  int getNumByteAErrs();
138  int getNumByteBErrs();
139  int getNumByteCErrs();
140 
141  // Status string info for some useful info to be
142  // passed back to RTD windows mostly...
143  void setStatusInfo( std::string msg );
144  std::string getStatusInfo();
145 
146  std::string getFirmwareVersion();
147  std::string getTelemetryVersion();
148  void setTelemetryVersion( std::string ver );
149 
150  protected:
151  Configuration &_config;
152 
153  private:
154  static TelemetryConfigHandler *_tmConfig;
155  static SemaphoreOperator *_semOp;
156  static ::carma::util::PthreadMutex mConfigGuard;
157  static std::map<std::string, unsigned short> _nameMap;
159 
160  };
161  }
162  }
163 }
164 
165 
166 
167 #endif // CARMA_BIMA_TELEMETRYCLIENT_H
Class definition for TelemetryCommand on the BIMA antennas.
Exception class for errors.
SAX Handler for parsing BIMA Telemetry configuration file.
Interface file for the carma::util::Trace class and related macros.
Class definition for SharedMemory on the BIMA antennas.