8 : num_channels(num_channels), sample_rate(sample_rate) {
18 auto num_channels = json[
"num_channels"];
19 if (!num_channels.isNull() and num_channels.is<
unsigned int>())
20 daq_config.num_channels = num_channels;
21 auto sample_rate = json[
"sample_rate"];
22 if (!sample_rate.isNull() and sample_rate.is<
unsigned int>())
23 daq_config.sample_rate = sample_rate;
24 auto sample_op = json[
"sample_op"];
25 if (!sample_op.isNull() and sample_op.is<
bool>())
26 daq_config.sample_op = sample_op;
27 auto sample_op_end = json[
"sample_op_end"];
28 if (!sample_op_end.isNull() and sample_op_end.is<
bool>())
29 daq_config.sample_op_end = sample_op_end;
43 if (sample_rate * num_channels > 1'000'000 or sample_rate < 32)
46 if ((num_channels > 0) and ((num_channels & (num_channels - 1)) != 0))
52 return static_cast<float>(
index) /
static_cast<float>(sample_rate);
Data acquisition configuration.
bool should_sample_op_end() const
Get whether to sample at the end of OP.
bool should_sample_op() const
Get whether to sample during OP.
static DAQConfig from_json(JsonObjectConst &&json)
Construct a configuration from a JsonObject.
uint8_t get_num_channels() const
Get the configured number of channels.
DAQConfig()=default
Construct a configuration using default values.
float index_to_time(size_t index) const
Convert a sample index to a time in seconds.
bool is_valid() const
Check whether the configuration is valid.
unsigned int get_sample_rate() const
Get the configured sample rate.
FLASHMEM void index(awot::Request &req, awot::Response &res)