nidas  v1.2-1520
DSMArincSensor.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  ** 2004, 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 #ifndef NIDAS_DYNLD_RAF_DSMARINCSENSOR_H
27 #define NIDAS_DYNLD_RAF_DSMARINCSENSOR_H
28 
30 #include <nidas/core/DSMSensor.h>
34 
35 // Significant bits masks
36 //
37 // 32|31 30|29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11|10 9| 8 7 6 5 4 3 2 1
38 // --+-----+--------------------------------------------------------+-----+-----------------------
39 // P | SSM | | SDI | 8-bit label
40 
41 // bitmask for the Sign Status Matrix
42 #define SSM 0x60000000
43 #define NCD 0x20000000
44 #define TST 0x40000000
45 
46 #define NLABELS 256
47 
48 namespace nidas { namespace dynld { namespace raf {
49 
50 using namespace nidas::core;
51 
52 // inHg to mBar
53 const float INHG_MBAR = 33.8639;
54 
55 // NM to meter.
56 const float NM_MTR = 1.0 / 1852.0;
57 
58 // ft to meter.
59 const float FT_MTR = 0.3048;
60 
61 // G to m/s2 (ACINS).
62 const float G_MPS2 = 9.7959;
63 
64 // knot to m/s
65 const float KTS_MS = 0.514791;
66 
67 // ft/min to m/s (VSPD)
68 const float FPM_MPS = 0.00508;
69 
70 // radian to degree.
71 const float RAD_DEG = 180.0 / 3.14159265358979;
72 
73 
79 public:
80  bool operator() (const SampleTag* x, const SampleTag* y) const {
81  if ( x->getRate() > y->getRate() ) return true;
82  if ( x->getRate() < y->getRate() ) return false;
83  if ( x->getId() < y->getId() ) return true;
84  return false;
85  }
86 };
87 
91 class DSMArincSensor : public DSMSensor
92 {
93 
94 public:
95 
100  DSMArincSensor();
101  ~DSMArincSensor();
102 
103  IODevice* buildIODevice() throw(nidas::util::IOException);
104 
105  SampleScanner* buildSampleScanner()
107 
109  void open(int flags) throw(nidas::util::IOException,
111 
113  void close() throw(nidas::util::IOException);
114 
118  void init() throw(nidas::util::InvalidParameterException);
119 
122  bool process(const Sample*, std::list<const Sample*>& result)
123  throw();
124 
125  virtual bool processAlta(const dsm_time_t, unsigned char *, int, std::list<const Sample*> &result)
126  throw();
127 
129  void printStatus(std::ostream& ostr) throw();
130 
132  virtual double processLabel(const int data,sampleType* stype) = 0;
133 
135  void fromDOMElement(const xercesc::DOMElement*)
141 
143  {
144  return USECS_PER_MSEC;
145  }
146 
147  unsigned int Speed() { return _speed; }
148 
149 
150 protected:
154  void registerWithUDPArincSensor();
155 
157  int _processed[NLABELS];
158  int _observedLabelCnt[NLABELS];
159 
161 
162 private:
163 
165  unsigned int _speed;
166  unsigned int _parity;
167 
168  std::map<dsm_sample_id_t,VariableConverter*> _converters;
169 
170  std::map<dsm_sample_id_t, TimetagAdjuster*> _ttadjusters;
171 
172 };
173 
174 // typedef SampleT<unsigned int> ArincSample;
175 
176 }}} // namespace nidas namespace dynld namespace raf
177 
178 #endif
A sensor connected to an ARINC port.
Definition: DSMArincSensor.h:91
sampleType
Definition: sample_type_traits.h:30
std::map< dsm_sample_id_t, TimetagAdjuster * > _ttadjusters
Definition: DSMArincSensor.h:170
int getInt32TimeTagUsecs() const
Definition: DSMArincSensor.h:142
unsigned int _parity
Definition: DSMArincSensor.h:166
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC...
Definition: Sample.h:61
bool _altaEnetDevice
Definition: DSMArincSensor.h:160
#define NLABELS
Definition: DSMArincSensor.h:46
unsigned int Speed()
Definition: DSMArincSensor.h:147
const float NM_MTR
Definition: DSMArincSensor.h:56
const float INHG_MBAR
Definition: DSMArincSensor.h:53
const float KTS_MS
Definition: DSMArincSensor.h:65
An interface to an IO device.
Definition: IODevice.h:41
const float FPM_MPS
Definition: DSMArincSensor.h:68
std::map< dsm_sample_id_t, VariableConverter * > _converters
Definition: DSMArincSensor.h:168
const float FT_MTR
Definition: DSMArincSensor.h:59
Interface to a data sample.
Definition: Sample.h:189
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition: DSMSensor.h:87
unsigned int _speed
channel configuration
Definition: DSMArincSensor.h:165
Definition: IOException.h:37
#define USECS_PER_MSEC
Definition: types.h:115
This is sorts a list of Sample tags by rate (highest first) then by label.
Definition: DSMArincSensor.h:78
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
A scanner of sample data.
Definition: SampleScanner.h:73
const float RAD_DEG
Definition: DSMArincSensor.h:71
virtual double getRate() const
Get sampling rate in samples/sec.
Definition: SampleTag.h:210
const float G_MPS2
Definition: DSMArincSensor.h:62
Definition: InvalidParameterException.h:35
dsm_sample_id_t getId() const
Get the 26 bit id, containing the DSM id and the sensor+sample id.
Definition: SampleTag.h:150