nidas v1.2.3
A2D_Serial.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 ** 2008, 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_dynld_raf_a2d_serial_h_
28#define _nidas_dynld_raf_a2d_serial_h_
29
32
34
35// change this later to a const or something
36#define NUM_GPDAQ_A2D_CHANNELS 4
37
38
39namespace nidas { namespace dynld { namespace raf {
40
41using namespace nidas::core;
42
51{
52
53public:
55
56 A2D_Serial();
58
62 void open(int flags);
63
67 void init();
68
69 virtual Sample* nextSample()
70 {
71 Sample *samp = SerialSensor::nextSample();
72
73 if (samp) {
74 const char *input = (const char *)samp->getConstVoidDataPtr();
75 if (input[0] == 'H') // header packet
76 extractStatus(input, samp->getDataByteLength());
77 }
78 return samp;
79 }
80
81 void extractStatus(const char *msg, int len);
82
83 void printStatus(std::ostream& ostr) throw();
84
85 bool process(const Sample* samp,std::list<const Sample*>& results);
86
87 void validate();
88
90
94 int getGain(int ichan) const;
95
100 int getBipolar(int ichan) const;
101
102 void getDefaultConversion(int ichan, float& intercept, float& slope) const;
103
104 void setOutputMode(OutputMode mode) { _outputMode = mode; }
105
107
108protected:
109
114
119
123 void readConfig();
124
128 void parseConfigLine(const char *data);
129
130 void dumpConfig() const;
131
132
137 bool checkCkSum(const Sample *samp, const char *data);
138
142 bool samplingChannel(int channel) const;
143
148 void readCalFile(dsm_time_t tt) throw();
149
154 float applyCalibration(float value, const std::vector<float> &cals) const;
155
156
161
163
167 size_t _deltaT; // in usecs
168
174 size_t _staticLag; // in usecs.
175
176 int _boardID; // serial number
177 bool _haveCkSum; // Will packets have checksum
178
184
191
198 size_t _havePPS;
199
204
209
210 // We will need these to map to cal files.
211 // int _gains[NUM_GPDAQ_A2D_CHANNELS]; // map _ifsr to this; 0->1, 1->2
212
219
220 // int _bipolar[NUM_GPDAQ_A2D_CHANNELS]; // true
221
222 int _calset; // Diagnostic (auto_cal) channels, toggle bit per channel.
223 int _voltage; // Diagnostic (auto_cal) voltage, -99 = normal operation.
224
232 std::map<std::string, int> configStatus;
233
237
239
240 void executeXmlRpc(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
241 throw();
242
243 void getA2DSetup(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
244 throw();
245
246 void testVoltage(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
247 throw();
248
249private:
250
253
256
257};
258
259}}} // namespace nidas namespace dynld namespace raf
260
261#endif
#define NUM_GPDAQ_A2D_CHANNELS
Definition A2D_Serial.h:36
Virtual class with methods for performing conversions from integer A2D counts to floating point volta...
Definition A2DConverter.h:61
A class for reading ASCII files containing a time series of calibration data.
Definition CalFile.h:166
Interface to a data sample.
Definition Sample.h:190
Support for a sensor that is sending packets on a TCP socket, a UDP socket, a Bluetooth RF Comm socke...
Definition SerialSensor.h:65
A2D Serial Sensor supporting the GP-DACQ, developed at NCAR EOL .
Definition A2D_Serial.h:51
void init()
Setup whatever is necessary for process method to work.
Definition A2D_Serial.cc:285
size_t _badCkSumCnt
Definition A2D_Serial.h:235
int _nVars
Number of variables to decode.
Definition A2D_Serial.h:160
int getBipolar(int ichan) const
Get the current bipolar parameter for a channel.
Definition A2D_Serial.cc:609
int getMaxNumChannels() const
Definition A2D_Serial.h:89
float applyCalibration(float value, const std::vector< float > &cals) const
Apply A2D calibrations.
Definition A2D_Serial.cc:620
int getGain(int ichan) const
Get the current gain for a channel.
Definition A2D_Serial.cc:603
A2D_Serial & operator=(const A2D_Serial &)
No assignment.
void getA2DSetup(XmlRpc::XmlRpcValue &params, XmlRpc::XmlRpcValue &result)
Definition A2D_Serial.cc:655
OutputMode
Definition A2D_Serial.h:54
@ Volts
Definition A2D_Serial.h:54
@ Engineering
Definition A2D_Serial.h:54
@ Counts
Definition A2D_Serial.h:54
int _ifsr[NUM_GPDAQ_A2D_CHANNELS]
Full scale range, 0=+-10, 1=+-5.
Definition A2D_Serial.h:208
int _ivarByChan[NUM_GPDAQ_A2D_CHANNELS]
Mapping from channel index to variable index.
Definition A2D_Serial.h:203
size_t _largeTimeStampOffset
Definition A2D_Serial.h:236
OutputMode getOutputMode() const
Definition A2D_Serial.h:106
int _voltage
Definition A2D_Serial.h:223
void printStatus(std::ostream &ostr)
Definition A2D_Serial.cc:306
A2DConverter * _finalConverter
Final A2DConverter.
Definition A2D_Serial.h:118
OutputMode _outputMode
Whethere to output samples as counts, volts or engineering units.
Definition A2D_Serial.h:190
int headerLines
Definition A2D_Serial.h:238
std::map< std::string, int > configStatus
This contains the status of config verification between what we read off the device and what is in th...
Definition A2D_Serial.h:232
A2DConverter * _initialConverter
Initial A2DConverter.
Definition A2D_Serial.h:113
int _calset
Definition A2D_Serial.h:222
void readCalFile(dsm_time_t tt)
Read calibration file for this A2D.
void open(int flags)
open the sensor and perform any intialization to the driver.
Definition A2D_Serial.cc:80
bool process(const Sample *samp, std::list< const Sample * > &results)
Process a raw sample, which in this case means do a sscanf on the character string contents,...
Definition A2D_Serial.cc:373
virtual Sample * nextSample()
Extract the next sample from the buffer.
Definition A2D_Serial.h:69
int _boardID
Definition A2D_Serial.h:176
void extractStatus(const char *msg, int len)
Definition A2D_Serial.cc:590
size_t _sampleRate
Definition A2D_Serial.h:162
size_t _deltaT
Number of usecs between two samples (i.e.
Definition A2D_Serial.h:167
void parseConfigLine(const char *data)
Parse a configuration line from from either open() or process().
Definition A2D_Serial.cc:524
A2D_Serial(const A2D_Serial &)
No copying.
size_t _shortPacketCnt
Definition A2D_Serial.h:234
size_t _havePPS
Is device receiving PPS.
Definition A2D_Serial.h:198
bool checkCkSum(const Sample *samp, const char *data)
Check the checksum for data lines.
Definition A2D_Serial.cc:344
void executeXmlRpc(XmlRpc::XmlRpcValue &params, XmlRpc::XmlRpcValue &result)
Method invoked when the DSMEngineIntf XmlRpcServer receives a "SensorAction" request,...
Definition A2D_Serial.cc:634
void testVoltage(XmlRpc::XmlRpcValue &params, XmlRpc::XmlRpcValue &result)
Definition A2D_Serial.cc:669
bool _haveCkSum
Definition A2D_Serial.h:177
CalFile * _calFile
CalFile for this A2D_Serial sensor.
Definition A2D_Serial.h:183
void validate()
validate() is called once on a DSMSensor after it has been configured, but before open() or init() ar...
Definition A2D_Serial.cc:162
void setOutputMode(OutputMode mode)
Definition A2D_Serial.h:104
int _ipol[NUM_GPDAQ_A2D_CHANNELS]
This device will only support/use 2 voltage ranges.
Definition A2D_Serial.h:218
void getDefaultConversion(int ichan, float &intercept, float &slope) const
Definition A2D_Serial.cc:153
void readConfig()
Read configuration from sensor, this is on the DSM called from open().
Definition A2D_Serial.cc:90
bool samplingChannel(int channel) const
Check _ivarByChan[] to see if we are sampling the target channel.
Definition A2D_Serial.cc:615
size_t _staticLag
Offset caused by DIR filtering onboard the A2D device.
Definition A2D_Serial.h:174
void dumpConfig() const
Definition A2D_Serial.cc:126
~A2D_Serial()
Definition A2D_Serial.cc:72
A2D_Serial()
Definition A2D_Serial.cc:47
The essential core classes of nidas.
Definition A2DConverter.h:31
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
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:62
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948