CARMA C++
WS.h
1 #ifndef CARMA_ENVIRONMENT_WS_H
2 #define CARMA_ENVIRONMENT_WS_H
3 
4 #include <vector>
5 
6 #include <boost/shared_ptr.hpp>
7 #include <boost/circular_buffer.hpp>
8 
9 #include <carma/util/types.h>
10 #include <carma/util/Time.h>
11 #include <carma/util/PthreadMutex.h>
12 #include <carma/util/AutoPthreadQuitAndJoinGroup.h>
14 
24 namespace carma {
25 namespace environment {
26 
27 class WSSerialAccessor;
28 
29 /*----------------------------------------------------------------------------*/
30 /* Weather Station Data */
31 /*----------------------------------------------------------------------------*/
32 
33 struct WSData
34 {
35  WSData();
36 
37  carma::util::frameType timestamp;
38  float ambientTemperature;
39  float dewpointTemperature;
40  float pressure;
41  float humidity;
42  float windSpeed;
43  float peakWindSpeed;
44  float averageWindSpeed;
45  float averageWindDirection;
46  float windDirection;
47  float battery;
48  float waterVaporDensity;
49  float waterColumn;
50  std::string weatherStationTime;
51 };
52 
53 /*----------------------------------------------------------------------------*/
54 /* Weather Station Reader */
55 /*----------------------------------------------------------------------------*/
56 
57 class WS
58 {
59 public:
60  WS(const std::string &device, bool reopen = false, bool emulate = false);
61 
62  void getLatestData(struct WSData &data);
63  void startThreads();
64 
65  static void readerThreadEP(WS &This);
66  static void writerThreadEP(WS &This);
67 
68 private:
69  void addRegisterData(const int regnum, const float regval);
70  bool parseData(const char *buf, ssize_t bytes);
71  void readerNormalMode();
72  void readerEmulateMode();
73  void writerNormalMode();
74 
75  const std::string device_;
76  const bool reopen_;
77  const bool emulate_;
78  carma::util::AutoPthreadQuitAndJoinGroup group_;
80  boost::shared_ptr<WSSerialAccessor> serial_;
81 
82  boost::circular_buffer<float> windSpeeds_;
83  boost::circular_buffer<float> windDirections_;
84 
86  WSData data_;
87 };
88 
89 } // namespace environment
90 } // namespace carma
91 
92 /* vim: set ts=4 sts=4 sw=4 et: */
93 #endif // CARMA_ENVIRONMENT_WS_H
Common time functions.
This class is used to calculate a variety of quantities related to the earth&#39;s atmosphere, such as refractivity, saturated pressure, and pathlength (refractivity integrated through the atmosphere).
Definition: Atmosphere.h:46
unsigned int frameType
Half second frames since Jan 1, 2000.
Definition: types.h:29
Constants and methods having to do with the earth&#39;s atmosphere (e.g.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
Various type definitions for util classes.