nidas  v1.2-1520
DerivedDataReader.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2007, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #ifndef _nidas_core_DerivedDataReader_h_
28 #define _nidas_core_DerivedDataReader_h_
29 
32 #include <nidas/util/Thread.h>
33 
34 #include <vector>
35 
36 namespace nidas { namespace core {
37 
38 class DerivedDataClient;
39 
45 {
46 public:
47 
48  float getTrueAirspeed() const { return _tas; }
49  float getAmbientTemperature() const { return _at; }
50  float getStaticPressure() const { return _ps; }
51  float getLatitude() const { return _lat; }
52  float getLongitude() const { return _lon; }
53  float getAltitude() const { return _alt; }
54  float getRadarAltitude() const { return _radarAlt; }
55  float getTrueHeading() const { return _thdg; }
56  float getGroundSpeed() const { return _grndSpd; }
57 
58  int run() throw(nidas::util::Exception);
59 
64  void addClient(DerivedDataClient * ddc);
65 
66  void removeClient(DerivedDataClient * ddc);
67 
71  static DerivedDataReader * createInstance(const nidas::util::SocketAddress&);
72 
77  static void deleteInstance();
78 
82  static DerivedDataReader * getInstance();
83 
84  void interrupt();
85 
86 private:
87 
95  DerivedDataReader(const nidas::util::SocketAddress&);
96 
98 
99  void notifyClients();
100 
102 
103  static nidas::util::Mutex _instanceMutex;
104 
105  nidas::util::Mutex _clientMutex;
106 
108 
109  nidas::util::SocketAddress* _saddr;
110 
117  int parseIWGADTS(const char *);
118 
119  float _tas; // True Airspeed. Meters per second
120  float _at; // Ambient Temperature. deg_C
121  float _ps; // Static Pressure. hPa
122  float _lat; // Latitude, deg north
123  float _lon; // Longitude, deg east
124  float _alt; // Altitude (probably GPS). Meters
125  float _radarAlt; // Distance above surface/ground. Meters
126  float _thdg; // True Heading. degrees_true
127  float _grndSpd; // Ground Speed. meters per second.
128 
131 
132  struct IWG1_Field {
133  IWG1_Field(int n,float* p): nf(n),fp(p) {}
134  int nf; // which field in the IWG1 string, after the "IWG1,timetag,"
135  float *fp; // pointer to the data
136  };
137 
138  std::vector<IWG1_Field> _fields;
139 
142 
145 
146 };
147 
148 }} // namespace nidas namespace core
149 
150 #endif
151 
float * fp
Definition: DerivedDataReader.h:135
int _parseErrors
Definition: DerivedDataReader.h:129
static void deleteInstance()
Delete the singleton instance of DerivedDataReader, shutting down the thread if is is running...
Definition: DerivedDataReader.cc:243
Definition: DerivedDataReader.h:132
int _errorLogs
Definition: DerivedDataReader.h:130
void removeClient(DerivedDataClient *ddc)
Definition: DerivedDataReader.cc:277
static DerivedDataReader * _instance
Definition: DerivedDataReader.h:101
int run()
The method which will run in its own thread.
Definition: DerivedDataReader.cc:96
nidas::util::SocketAddress * _saddr
Definition: DerivedDataReader.h:109
float getRadarAltitude() const
Definition: DerivedDataReader.h:54
float getTrueHeading() const
Definition: DerivedDataReader.h:55
float _lon
Definition: DerivedDataReader.h:123
float getTrueAirspeed() const
Definition: DerivedDataReader.h:48
IWG1_Field(int n, float *p)
Definition: DerivedDataReader.h:133
float _at
Definition: DerivedDataReader.h:120
static DerivedDataReader * createInstance(const nidas::util::SocketAddress &)
Create the instance of DerivedDataReader.
Definition: DerivedDataReader.cc:232
int nf
Definition: DerivedDataReader.h:134
float getAltitude() const
Definition: DerivedDataReader.h:53
static DerivedDataReader * getInstance()
Fetch the pointer to the instance of DerivedDataReader.
Definition: DerivedDataReader.cc:263
float getLatitude() const
Definition: DerivedDataReader.h:51
float _radarAlt
Definition: DerivedDataReader.h:125
Definition: Thread.h:80
float _tas
Definition: DerivedDataReader.h:119
float _lat
Definition: DerivedDataReader.h:122
float _thdg
Definition: DerivedDataReader.h:126
notifyClients
Whether to notify callback clients if clockAction is RESET_COUNTERS.
Definition: pc104sg.c:239
float getAmbientTemperature() const
Definition: DerivedDataReader.h:49
std::list< DerivedDataClient * > _clients
Definition: DerivedDataReader.h:107
float _ps
Definition: DerivedDataReader.h:121
static nidas::util::Mutex _instanceMutex
Definition: DerivedDataReader.h:103
std::vector< IWG1_Field > _fields
Definition: DerivedDataReader.h:138
int parseIWGADTS(const char *)
Parse the IWGADTS trivial broadcast.
Definition: DerivedDataReader.cc:191
This class will read, parse and make available the parameters in the onboard real-time broadcast of d...
Definition: DerivedDataReader.h:44
void addClient(DerivedDataClient *ddc)
Add a client to DerivedDataReader.
Definition: DerivedDataReader.cc:268
nidas::util::Mutex _clientMutex
Definition: DerivedDataReader.h:105
float _grndSpd
Definition: DerivedDataReader.h:127
DerivedDataReader & operator=(const DerivedDataReader &)
No assignment.
float getGroundSpeed() const
Definition: DerivedDataReader.h:56
float _alt
Definition: DerivedDataReader.h:124
static int char **FILE * fp
Definition: sing.cc:928
float getLongitude() const
Definition: DerivedDataReader.h:52
void interrupt()
Interrupt this thread.
Definition: DerivedDataReader.cc:86
float getStaticPressure() const
Definition: DerivedDataReader.h:50
Interface of a DerivedDataClient of the DerivedDataReader.
Definition: DerivedDataClient.h:37
DerivedDataReader(const nidas::util::SocketAddress &)
Constructor.
Definition: DerivedDataReader.cc:57