Debian Codegraph @

comedi-calibrate/comedi_soft_calibrate/calibration_set.hpp

raw
1 /*
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17 #ifndef _CALIBRATION_SET_HPP
18 #define _CALIBRATION_SET_HPP
19
20 #include "calibrator_misc.hpp"
21 #include <map>
22 #include <utility>
23 #include <string>
24 #include <vector>
25
26
27 class SubdeviceCalibration
28 {
29 public:
30 SubdeviceCalibration(bool toPhys = true): _toPhys(toPhys) {}
31 static const unsigned allChannels = static_cast<unsigned>(-1);
32 static const unsigned allRanges = static_cast<unsigned>(-1);
33 const Polynomial& polynomial(unsigned channel = allChannels, unsigned range = allRanges) const;
34 void insertPolynomial(const Polynomial &polynomial, unsigned channel = allChannels, unsigned range = allRanges);
35 bool toPhys() const {return _toPhys;}
36 const std::map<std::pair<unsigned, unsigned>, Polynomial>& polynomials() const {return _polynomials;}
37 private:
38 /* channelRangeMatch is passed to std::find so we can find
39 * a matching calibration, taking into account the possibility
40 * of allChannels and allRanges */
41 static bool channelRangeMatch(unsigned channel, unsigned range,
42 const std::pair<std::pair<unsigned, unsigned>, Polynomial> &calibration);
43 std::map<std::pair<unsigned, unsigned>, Polynomial> _polynomials;
44 bool _toPhys;
45 };
46
47 /* A complete set of calibration coefficients for a device */
48 typedef std::map<unsigned, SubdeviceCalibration> CalibrationSet;
49
50 #endif // _CALIBRATION_SET_HPP