2#include "debugtrace.hpp"
15#if LASP_HAS_ULDAQ == 1
16 apis.push_back(uldaqapi);
18#if LASP_HAS_RTAUDIO == 1
19 apis.push_back(rtaudioAlsaApi);
20 apis.push_back(rtaudioPulseaudioApi);
21 apis.push_back(rtaudioWasapiApi);
22 apis.push_back(rtaudioDsApi);
23 apis.push_back(rtaudioAsioApi);
37 inch.name =
"Unnamed input channel " + std::to_string(i);
43 outch.name =
"Unnamed output channel " + std::to_string(i);
53 assert(
match(device));
90 vector<DaqChannel> res;
93 ch.
name =
"Internal output monitor (loopback)";
97 res.emplace_back(std::move(ch));
101 if(ch.enabled) { res.push_back(ch);}
106#include "toml++/toml.h"
112 tbl.emplace(
"enabled", ch.
enabled);
113 tbl.emplace(
"name", ch.
name);
118 tbl.emplace(
"qty",
static_cast<int>(ch.
qty));
133 toml::table tbl{{
"daqapi", apitbl}};
141 toml::array inchannel_config_tbl;
145 tbl.emplace(
"inchannel_config", inchannel_config_tbl);
147 toml::array outchannel_config_tbl;
151 tbl.emplace(
"outchannel_config", outchannel_config_tbl);
153 std::stringstream str;
160template <
typename T,
typename R> T
getValue(R &tbl,
const char* key) {
161 using std::runtime_error;
166 std::optional<T> val = tbl[key].template value<T>();
168 throw runtime_error(
string(
"Error while parsing Daq configuration. Table "
169 "does not contain key: ") +
177 toml::table& tbl = *node.as_table();
178 d.enabled = getValue<bool>(tbl,
"enabled");
179 d.name = getValue<string>(tbl,
"name");
180 d.sensitivity = getValue<double>(tbl,
"sensitivity");
181 d.IEPEEnabled = getValue<bool>(tbl,
"IEPEEnabled");
182 d.ACCouplingMode = getValue<bool>(tbl,
"ACCouplingMode");
183 d.rangeIndex = getValue<bool>(tbl,
"rangeIndex");
185 d.digitalHighPassCutOn = getValue<double>(tbl,
"digitalHighpassCutOn");
194 using std::runtime_error;
197 toml::table tbl = toml::parse(tomlstr);
200 auto daqapi = tbl[
"daqapi"];
202 api.
apicode = getValue<int64_t>(daqapi,
"apicode");
204 api.
apiname = getValue<string>(daqapi,
"apiname");
207 config.
device_name = getValue<string>(tbl,
"device_name");
213 if(toml::array* in_arr = tbl[
"inchannel_config"].as_array()) {
214 for(
auto& el: *in_arr) {
219 throw runtime_error(
"inchannel_config is not an array");
222 if(toml::array* out_arr = tbl[
"outchannel_config"].as_array()) {
223 for(
auto& el: *out_arr) {
227 throw runtime_error(
"outchannel_config is not an array");
233 }
catch (
const toml::parse_error &e) {
234 throw std::runtime_error(
string(
"Error parsing TOML DaqConfiguration: ") +
Class that specifies API related information. An API configuration is part of the DAQConfiguration an...
unsigned api_specific_subcode
static std::vector< DaqApi > getAvailableApis()
Stores channel configuration data for each channel. I.e. the physical quantity measured,...
Qty
Possible physical quantities that are recorded.
double sensitivity
The conversion between recorded physical unit and stored / outputed number, i.e. Number/Volt or Numbe...
double digitalHighPassCutOn
Whether to enable a digital high pass on the signal before passing the result in case of input,...
bool IEPEEnabled
For input-only: enable IEPE constant current power supply for this channel. Only for hardware that is...
int rangeIndex
Index in possible ranges for input / output.
bool ACCouplingMode
Whether to enable HW AC-coupling for this channel.
Qty qty
The physical quantity that is inputed / outputed.
bool enabled
Whether the channel is enabled.
Configuration of a DAQ device.
static DaqConfiguration fromTOML(const std::string &toml)
Load in a DAQConfiguration from TOML.
std::vector< DaqChannel > enabledInChannels(const bool include_monitor=true) const
Return list of enabled input channels.
int framesPerBlockIndex
The index in the array of frames per block that can be used for the device.
int dataTypeIndex
Required datatype for output, should be present in the list.
std::vector< DaqChannel > inchannel_config
Channel configuration for input channels.
bool monitorOutput
If set to true and if the device has this capability, the output channels are added as input channels...
int getHighestEnabledOutChannel() const
Get the highest channel number from the list of enabled output channels.
int getHighestEnabledInChannel() const
Get the enabled highest channel number from the list of enabled input channels.
string device_name
The internal device name this DAQ configuration applies to.
std::string toTOML() const
Export the class to TOML markup language.
int sampleRateIndex
Index in list of sample rates that are available for the device.
int getLowestEnabledInChannel() const
Get the lowest channel number from the list of enabled input channels.
std::vector< DaqChannel > outchannel_config
Channel configuration for output channels.
bool match(const DeviceInfo &devinfo) const
Check to see whether the DAQ configuration matches with the device. This means, some basic checks are...
int getLowestEnabledOutChannel() const
Get the lowest channel number from the list of enabled output channels.
Structure containing device info parameters.
unsigned ninchannels
The number of input channels available for the device.
unsigned noutchannels
The number of output channels available for the device.
string device_name
The name of the device.
int prefDataTypeIndex
The device's prefferd data type.
DaqApi api
Backend API corresponding to device.
us prefFramesPerBlockIndex
Preffered number of frames per callback.
int prefSampleRateIndex
Preferred setting for the sample rate.
toml::table daqChannelToTOML(const DaqChannel &ch)
T getValue(R &tbl, const char *key)
DaqChannel TOMLToDaqChannel(T &node)
size_t us
We often use boolean values.