μHAL
acq.h
1#ifndef ACQ_H
2#define ACQ_H
3
4#include <chrono>
5#include <memory>
6#include <string>
7#include <variant>
8#include <vector>
9
10#include "controllers.h"
11#include "decoders.h"
12
13namespace acq {
14
15/* forward declaration */
16struct acq_core;
17
19class Core: public RegisterDecoder {
20 std::unique_ptr<struct acq_core> regs_storage;
21 struct acq_core &regs;
22
23 void decode() override;
24
25 public:
26 Core(struct pcie_bars &);
27 ~Core() override;
28};
29
30enum class acq_error {
31 success,
32 error,
33 bad_post_samples,
34 too_many_samples,
35 no_samples,
36};
37
38enum class acq_status {
39 idle,
40 success,
41 in_progress,
42 timeout,
43};
44
54 /* read from internal MemoryAllocator */
55 size_t ram_start_addr, ram_end_addr;
56
57 /* information from the current acquisition:
58 * - current channel information
59 * - current channel information that had to be calculated
60 * - amount of samples */
61 unsigned channel_atom_width, channel_num_atoms,
62 sample_size, alignment,
63 acq_pre_samples, acq_post_samples;
64
65 std::unique_ptr<struct acq_core> regs_storage;
66 struct acq_core &regs;
67
68 void get_internal_values();
69 void encode_params() override;
70 bool acquisition_ready();
71
72 void set_devinfo_callback() override;
73
74 /* state variables for async */
75 enum class acq_step {
76 stop,
77 started,
78 done,
79 } m_step = acq_step::stop;
80
81 public:
82 Controller(struct pcie_bars &);
84
85 unsigned channel = 0;
86 unsigned pre_samples = 4;
87 unsigned post_samples = 0;
88 unsigned number_shots = 1;
89 std::string trigger_type = "now";
90 unsigned data_trigger_threshold = 0;
91 bool data_trigger_polarity_neg = true;
92 unsigned data_trigger_sel = 0;
93 unsigned data_trigger_filt = 1;
94 unsigned data_trigger_channel = 0;
95 unsigned trigger_delay = 0;
96
97 acq_error start_acquisition();
98 void stop_acquisition();
99
100 template <class Data>
101 std::vector<Data> get_result();
102
103 template <class Data> [[nodiscard]]
104 std::vector<Data> result(std::optional<std::chrono::milliseconds> wait_time=std::nullopt);
106 [[nodiscard]]
107 acq_status get_acq_status();
108
109 template<typename T>
110 void print_csv(FILE *f, std::vector<T> &res);
111};
112
113} /* namespace acq */
114
115#endif
Definition: controllers.h:7
Definition: decoders.h:97
Definition: acq.h:53
void set_devinfo_callback() override
Definition: acq.cc:214
void encode_params() override
Definition: acq.cc:259
acq_status get_acq_status()
Definition: acq.cc:502
Definition: acq.h:19
void decode() override
Definition: acq.cc:124
Definition: pcie-defs.h:19