OBSDAQ_Logger.cpp 1.59 KB
Newer Older
Achim Morschhauser's avatar
Achim Morschhauser committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// C Headers
#include <stdio.h>
#include <iostream>

#include <thread>

// C++ Headers from library (should use dynamic linking in future)

#include <data_obs_vector.hpp>
#include <driver_obs_obsdaq.hpp>
#include <buffer_obs_pipe.hpp>
#include <buffer_obs_queue.hpp>
#include <Obs_Calibration_Vector.hpp>
#include <Parameters_Reader.hpp>


int main() {

    // Read from parameters file
DTU RPi3's avatar
DTU RPi3 committed
20
    Parameters_Reader par = Parameters_Reader("usr/par/parameters.par");
Achim Morschhauser's avatar
Achim Morschhauser committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

    // Set the calibration constants.
    // Will be done in driver_obs_obsdaq constructor in future, and parameter
    // file will be given as argument to constructor
    double R   = par.get_dbl("R");
    double X_s = par.get_dbl("X_s");
    double Y_s = par.get_dbl("Y_s");
    double Z_s = par.get_dbl("Z_s");
    
    // Initialize new buffer for STDOUT
    buffer_obs_pipe pipe = buffer_obs_pipe(5);

    // Initialize the calibration constants for FGE
    Obs_Calibration_Vector cal = Obs_Calibration_Vector(X_s/R,Y_s/R,Z_s/R);
    // Initialize the calibration constants for ObsDAQ
    cal.set_adc_calibrate("usr/par/ADC.par");

    // Initialize new OBSDAQ device
    driver_obs_obsdaq obsdaq = driver_obs_obsdaq(par.get_str("PORT"),
Tobias Bjerg's avatar
Tobias Bjerg committed
40
                    par.get_int("BAUD"), &pipe, &cal, par.get_int("ADDRESS"));
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
60
61
62
63
64

    // Get some data

    /*

    data_obs_vector data=data_obs_vector();

    printf("First try\n");
    obsdaq.get(&data);
    pipe.put(&data);

    printf("Second try\n");
    obsdaq.get(&data);
    pipe.put(&data);

    */

    // Take continuous measurements
    fprintf(stderr,"Run\n");
    obsdaq.freerun(par.get_dbl("Freq"));

}