nidas v1.2.3
A2DConverter.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 ** 2006, 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_CORE_A2DCONVERTER_H
27#define NIDAS_CORE_A2DCONVERTER_H
28
29#include "Sample.h"
30
31namespace nidas { namespace core {
32
33class CalFile;
34
62
63public:
64
65 A2DConverter(int nchan, int ncoefs);
66
67 virtual ~A2DConverter();
68
72 int getMaxNumChannels() const { return _maxNumChannels; }
73
79
85 int getGain(int ichan) const;
86
87 void setGain(int ichan, int val);
88
89 int getBipolar(int ichan) const;
90
91 void setBipolar(int ichan, int val);
92
96 virtual float convert(int ichan, float counts) const = 0;
97
101 virtual void set(int ichan, const float* d, int nd) = 0;
102
103 virtual void get(int ichan, float* d, int nd) const = 0;
104
105 virtual void setNAN(int ichan) = 0;
106
107 virtual void setNAN() = 0;
108
130 void readCalFile(CalFile* cf, dsm_time_t tt);
131
132protected:
133
138
145
150
154 int *_gain;
155
161
162private:
167
170};
171
176
177public:
178 LinearA2DConverter(int nchan);
179
181
182 float convert(int ichan, float counts) const;
183
187 void set(int ichan, const float* d, int nd);
188
189 void get(int ichan, float* d, int nd) const;
190
191 void setNAN(int ichan);
192
193 void setNAN();
194
195private:
196
200 float *_b;
201
205 float *_mx;
206
211
214};
215
220
221public:
222 PolyA2DConverter(int nchan, int ncoefs);
223
225
226 float convert(int ichan, float counts) const;
227
231 void set(int ichan, const float* d, int nd);
232
233 void get(int ichan, float* d, int nd) const;
234
235 void setNAN(int ichan);
236
237 void setNAN();
238private:
239
240 float** _d;
241
246
249};
250}} // namespace nidas namespace core
251
252#endif
Virtual class with methods for performing conversions from integer A2D counts to floating point volta...
Definition A2DConverter.h:61
int _ncoefs
Number of coefficients in the conversion.
Definition A2DConverter.h:149
void readCalFile(CalFile *cf, dsm_time_t tt)
Read records from a CalFile for calibration coefficients with time tags less than or equal to tt,...
Definition A2DConverter.cc:285
int * _bipolar
Polarity setting, 1=bi-polar.
Definition A2DConverter.h:160
void setGain(int ichan, int val)
Definition A2DConverter.cc:90
A2DConverter(const A2DConverter &x)
No copy.
int getBipolar(int ichan) const
Definition A2DConverter.cc:97
virtual float convert(int ichan, float counts) const =0
Convert a count to a floating point value.
int _maxNumChannels
How many channels on the A2D.
Definition A2DConverter.h:137
void setBipolar(int ichan, int val)
Definition A2DConverter.cc:103
A2DConverter & operator=(const A2DConverter &x)
No assign.
virtual void setNAN()=0
virtual void get(int ichan, float *d, int nd) const =0
virtual void setNAN(int ichan)=0
int getGain(int ichan) const
Gain of each channel.
Definition A2DConverter.cc:84
virtual ~A2DConverter()
Definition A2DConverter.cc:51
virtual void set(int ichan, const float *d, int nd)=0
Set the initial conversion for a channel.
int * _gain
Gain setting of each channel.
Definition A2DConverter.h:154
int getMaxNumChannels() const
Maximum possible number of channels.
Definition A2DConverter.h:72
A2DConverter(int nchan, int ncoefs)
Definition A2DConverter.cc:39
int getNumConfigChannels() const
One plus the index of the last active channel.
Definition A2DConverter.h:78
int _numConfigChannels
A configured channel has a gain > 0.
Definition A2DConverter.h:144
A class for reading ASCII files containing a time series of calibration data.
Definition CalFile.h:166
A2DConverter for applying a linear conversion to A2D counts values.
Definition A2DConverter.h:175
void setNAN()
Definition A2DConverter.cc:183
float convert(int ichan, float counts) const
Convert a count to a floating point value.
Definition A2DConverter.cc:154
float * _mx
Conversion slopes for each channel.
Definition A2DConverter.h:205
~LinearA2DConverter()
Definition A2DConverter.cc:119
LinearA2DConverter & operator=(const LinearA2DConverter &x)
No assign.
LinearA2DConverter(int nchan)
Definition A2DConverter.cc:108
LinearA2DConverter(const LinearA2DConverter &x)
No copy.
float * _b
Conversion intercepts for each channel.
Definition A2DConverter.h:200
void get(int ichan, float *d, int nd) const
Definition A2DConverter.cc:168
void set(int ichan, const float *d, int nd)
Set the initial linear conversion for a channel.
Definition A2DConverter.cc:160
A2DConverter for applying a polynomial conversion to A2D counts values.
Definition A2DConverter.h:219
void get(int ichan, float *d, int nd) const
Definition A2DConverter.cc:250
PolyA2DConverter(const PolyA2DConverter &x)
No copy.
PolyA2DConverter(int nchan, int ncoefs)
Definition A2DConverter.cc:190
void set(int ichan, const float *d, int nd)
Set the initial polynomial conversion for a channel.
Definition A2DConverter.cc:239
~PolyA2DConverter()
Definition A2DConverter.cc:201
void setNAN()
Definition A2DConverter.cc:265
PolyA2DConverter & operator=(const PolyA2DConverter &x)
No assign.
float ** _d
Definition A2DConverter.h:240
float convert(int ichan, float counts) const
Convert a count to a floating point value.
Definition A2DConverter.cc:271
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