μ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
25public:
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, sample_size, alignment,
62 acq_pre_samples, acq_post_samples;
63
64 std::unique_ptr<struct acq_core> regs_storage;
65 struct acq_core &regs;
66
67 void get_internal_values();
68 void encode_params() override;
69 bool acquisition_ready();
70
71 void set_devinfo_callback() override;
72
73 /* state variables for async */
74 enum class acq_step {
75 stop,
76 started,
77 done,
78 } m_step = acq_step::stop;
79
80public:
81 Controller(struct pcie_bars &);
83
84 unsigned channel = 0;
85 unsigned pre_samples = 4;
86 unsigned post_samples = 0;
87 unsigned number_shots = 1;
88 std::string trigger_type = "now";
89 unsigned data_trigger_threshold = 0;
90 bool data_trigger_polarity_neg = true;
91 unsigned data_trigger_sel = 0;
92 unsigned data_trigger_filt = 1;
93 unsigned data_trigger_channel = 0;
94 unsigned trigger_delay = 0;
95
96 acq_error start_acquisition();
97 void stop_acquisition();
98
99 template <class Data> std::vector<Data> get_result();
100
101 template <class Data>
102 [[nodiscard]]
103 std::vector<Data> result(
104 std::optional<std::chrono::milliseconds> wait_time = std::nullopt);
106 [[nodiscard]]
107 acq_status get_acq_status();
108
109 template <typename T> void print_csv(FILE *f, std::vector<T> &res);
110};
111
112} /* namespace acq */
113
114#endif
Definition: controllers.h:7
Definition: decoders.h:97
Definition: acq.h:53
void set_devinfo_callback() override
Definition: acq.cc:270
void encode_params() override
Definition: acq.cc:336
acq_status get_acq_status()
Definition: acq.cc:613
Definition: acq.h:19
void decode() override
Definition: acq.cc:162
Definition: pcie-defs.h:19