nidas  v1.2-1520
DSMAnalogSensor.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_DSMANALOGSENSOR_H
27 #define NIDAS_DYNLD_RAF_DSMANALOGSENSOR_H
28 
29 #include <nidas/dynld/A2DSensor.h>
30 #include <nidas/linux/ncar_a2d.h>
31 #include <nidas/linux/irigclock.h>
32 
33 namespace nidas { namespace dynld { namespace raf {
34 
35 using namespace nidas::core;
36 
40 class DSMAnalogSensor : public A2DSensor {
41 
42 public:
43  enum OutputMode { Counts, Volts, Engineering };
44 
46  ~DSMAnalogSensor();
47 
48  IODevice* buildIODevice() throw(nidas::util::IOException);
49 
50  SampleScanner* buildSampleScanner()
51  throw(nidas::util::InvalidParameterException);
52 
56  void open(int flags) throw(nidas::util::IOException,
57  nidas::util::InvalidParameterException);
58 
62  void close() throw(nidas::util::IOException);
63 
67  void init() throw(nidas::util::InvalidParameterException);
68 
69  void printStatus(std::ostream& ostr) throw();
70 
71  int getMaxNumChannels() const { return NUM_NCAR_A2D_CHANNELS; }
72 
73  void setA2DParameters(int ichan,int gain,int bipolar)
75 
76  void getBasicConversion(int ichan,float& intercept, float& slope) const;
77 
78  void setConversionCorrection(int ichan, float corIntercept, float corSlope)
80 
81 
82  void setOutputMode(OutputMode mode) { _outputMode = mode; }
83 
84  OutputMode getOutputMode() const { return _outputMode; }
85 
91  bool process(const Sample*,std::list<const Sample*>& result)
92  throw();
93 
94  void validate() throw(nidas::util::InvalidParameterException);
95 
99  float getTemp() throw(nidas::util::IOException);
100 
105  void readCalFile(dsm_time_t tt) throw();
106 
107  int getInt32TimeTagUsecs() const
108  {
109  return USECS_PER_MSEC;
110  }
111 
112  void executeXmlRpc(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
113  throw();
114 
115  void getA2DSetup(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
116  throw();
117 
118  void testVoltage(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
119  throw();
120 
121 protected:
122 
123  bool processTemperature(const Sample*, std::list<const Sample*>& result) throw();
124 
134  int readFilterFile(const std::string& name,unsigned short* coefs,
135  int nexpect);
136 
141 
147 
152  enum irigClockRates _temperatureRate;
153 
159 
166 
170  static const float DEGC_PER_CNT;
175  float _basIntercept[NUM_NCAR_A2D_CHANNELS], _basSlope[NUM_NCAR_A2D_CHANNELS];
176 
178 
185  float voltageActual(float voltageMeasured);
186 
187  inline float SecondPoly(float x, const float c[]) const
188  { return(c[0] + x * (c[1] + x * c[2])); }
189 
195 
200  static const int N_COEFF = 3;
201 
206  static const int N_G4_VDC = 9;
207 
212  static const float TemperatureChamberVoltagesGain4[N_G4_VDC];
213 
217  static const float TemperatureTableGain4[N_G4_VDC][N_COEFF];
219 
220 private:
221 
224 
226  DSMAnalogSensor& operator=(const DSMAnalogSensor&);
227 
228 };
229 
230 }}} // namespace nidas namespace dynld namespace raf
231 
232 #endif
const SampleTag * _temperatureTag
Pointer to temperature SampleTag if user has asked for it, otherwise NULL.
Definition: DSMAnalogSensor.h:146
A class for reading ASCII files containing a time series of calibration data.
Definition: CalFile.h:164
CalFile * _calFile
CalFile for this DSMAnalogSensor.
Definition: DSMAnalogSensor.h:158
float SecondPoly(float x, const float c[]) const
Definition: DSMAnalogSensor.h:187
OutputMode
Definition: DSMAnalogSensor.h:43
Definition: DSMAnalogSensor.h:43
A sensor connected to the DSM A2D.
Definition: DSMAnalogSensor.h:40
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
OutputMode getOutputMode() const
Definition: DSMAnalogSensor.h:84
float _currentTemperature
Capture the current A/D board temperature, so we can do a temperature drift compensation to all the r...
Definition: DSMAnalogSensor.h:194
#define NUM_NCAR_A2D_CHANNELS
Definition: ncar_a2d.h:55
void setOutputMode(OutputMode mode)
Definition: DSMAnalogSensor.h:82
An interface to an IO device.
Definition: IODevice.h:41
Interface to a data sample.
Definition: Sample.h:189
static const float DEGC_PER_CNT
Conversion factor from 16 bit raw temperature to degC.
Definition: DSMAnalogSensor.h:170
Definition: IOException.h:37
#define USECS_PER_MSEC
Definition: types.h:115
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
OutputMode _outputMode
Whethere to output samples as counts, volts or engineering units.
Definition: DSMAnalogSensor.h:165
int _deltatUsec
The output delta t, 1/rate, in microseconds.
Definition: DSMAnalogSensor.h:140
One or more sensors connected to an A2D.
Definition: A2DSensor.h:45
irigClockRates
Enumeration of the callback rates supported by this module.
Definition: irigclock.h:52
Definition: InvalidParameterException.h:35