Obs_Calibration_Vector.hpp 2.49 KB
Newer Older
Achim Morschhauser's avatar
Achim Morschhauser committed
1
2
3
4
#ifndef INCLUDE_OBS_CALIBRATION_VECTOR_HPP_
#define INCLUDE_OBS_CALIBRATION_VECTOR_HPP_

#include <vector>
Achim Morschhauser's avatar
Achim Morschhauser committed
5
#include <string>           // String
Achim Morschhauser's avatar
Achim Morschhauser committed
6
7
8
9

#include <data_obs_vector.hpp>
#include <data_obs_scalar.hpp>
#include <Obs_Calibration.hpp>
Achim Morschhauser's avatar
Achim Morschhauser committed
10
#include <unordered_map>
Achim Morschhauser's avatar
Achim Morschhauser committed
11

Achim Morschhauser's avatar
Achim Morschhauser committed
12
class Obs_Calibration_Vector {
Achim Morschhauser's avatar
Achim Morschhauser committed
13
14
15
16
17
18
19

	//
	// Private class variables
	//

private:

Achim Morschhauser's avatar
Achim Morschhauser committed
20
21
22
    /** File for ADC calibration constants */
    std::string file_ADC="";
    
Achim Morschhauser's avatar
Achim Morschhauser committed
23
24
25
26
27
28
29
30
31
	/** The offset */
	double offset[3];
	/** The scale value */
	double scale[3];


	/** Non-zero calibration constants */
	char do_cal;

Achim Morschhauser's avatar
Achim Morschhauser committed
32
33
34
35
36
37
38
39
40
        /** ADC calibration constant */
        struct adc_cal {
            std::string offset;
            std::string scale;
        };
        
        /** Map containing the ADC calibration key-value pairs */
        std::unordered_map<std::string, struct adc_cal> map_ADC;
        
Achim Morschhauser's avatar
Achim Morschhauser committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	/** ADC Offsets */
	std::vector<int> adc_offset;
	/** ADC scale values */
	std::vector<int> adc_scale;
	/** ADC configuration */
	std::vector<int> adc_config;

	//
	// Constructors
	//

public:

	/** Constructor with single values */
	Obs_Calibration_Vector(double offset=0, double scale=1);

	/** Constructor with vector values */
	Obs_Calibration_Vector(double* offset, double* scale);

Achim Morschhauser's avatar
Achim Morschhauser committed
60
        /** Constructor with individual values */
Achim Morschhauser's avatar
Achim Morschhauser committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	Obs_Calibration_Vector(double scale_X, double scale_Y, double scale_Z,
			double offset_X=0, double offset_Y=0, double offset_Z=0);


	//
	// Public Methods
	//

public:

	/** Calibrate the vector data */
	int calibrate(data_obs_vector* vdata);

	/** Calibrate the scalar data */
	int calibrate(data_obs_scalar* sdata);

	/** Get the calibration constants for the ADC */
Achim Morschhauser's avatar
Achim Morschhauser committed
78
79
	int get_adc_calibrate(std::string config, std::string &offset,
                std::string &scale);
Achim Morschhauser's avatar
Achim Morschhauser committed
80
81
82


	/** Add a calibration constant for the ADC */
Achim Morschhauser's avatar
Achim Morschhauser committed
83
84
85
86
87
	int add_adc_calibrate(std::string config, std::string offset,
                std::string scale);
        
        /** Save the calibration constants to file */
        int save_adc_calibrate(std::string filename);
Achim Morschhauser's avatar
Achim Morschhauser committed
88
        int save_adc_calibrate();
Achim Morschhauser's avatar
Achim Morschhauser committed
89
90
91
        
        /** Read the calibration constants from file */
        int read_adc_calibrate(std::string filename);
Achim Morschhauser's avatar
Achim Morschhauser committed
92
        int read_adc_calibrate();
Achim Morschhauser's avatar
Achim Morschhauser committed
93

Achim Morschhauser's avatar
Achim Morschhauser committed
94
95
96
97
98
        /** Parse an ADC calibration line */
        int parse_adc_calibration(std::string line, 
         std::string& config, struct adc_cal& cal);
        int parse_adc_calibration(std::string line, 
         std::string& config, struct adc_cal& cal, std::string& comment);
Achim Morschhauser's avatar
Achim Morschhauser committed
99
100
101
102

};

#endif /* INCLUDE_OBS_CALIBRATION_VECTOR_HPP_ */