lasp/src/lasp/device/lasp_deviceinfo.h

126 lines
2.9 KiB
C++

#pragma once
#include "lasp_config.h"
#include "lasp_types.h"
#include "lasp_daqconfig.h"
/**
* @brief Structure containing device info parameters
*/
class DeviceInfo {
public:
/**
* @brief Backend API corresponding to device
*/
DaqApi api;
/**
* @brief The name of the device
*/
string device_name = "";
/**
* @brief Specific for the device (Sub-API). Important for the RtAudio
* backend, as RtAudio is able to handle different API's.
*/
int api_specific_devindex = -1;
/**
* @brief The available data types the device can output
*/
std::vector<DataTypeDescriptor::DataType> availableDataTypes;
/**
* @brief The device's prefferd data type.
*/
int prefDataTypeIndex = 0;
/**
* @brief Available sample rates the device can run on
*/
dvec availableSampleRates;
/**
* @brief Preferred setting for the sample rate.
*/
int prefSampleRateIndex = -1;
/**
* @brief Available latency-setting (number of frames passed in each
* callback).
*/
usvec availableFramesPerBlock;
/**
* @brief Preffered number of frames per callback.
*/
us prefFramesPerBlockIndex = 0;
/**
* @brief Available ranges for the input, i.e. +/- 1V and/or +/- 10 V etc.
*/
dvec availableInputRanges;
/**
* @brief Its preffered range
*/
int prefInputRangeIndex = 0;
/**
* @brief The number of input channels available for the device
*/
unsigned ninchannels = 0;
/**
* @brief The number of output channels available for the device
*/
unsigned noutchannels = 0;
/**
* @brief Whether the device is capable to provide IEPE constant current
* power supply.
*/
bool hasInputIEPE = false;
/**
* @brief Whether the device is capable of enabling a hardware AC-coupling
*/
bool hasInputACCouplingSwitch = false;
/**
* @brief Whether the device is able to trigger on input
*/
bool hasInputTrigger = false;
double prefSampleRate() const {
if (((us)prefSampleRateIndex < availableSampleRates.size()) &&
(prefSampleRateIndex >= 0)) {
return availableSampleRates.at(prefSampleRateIndex);
} else {
throw std::runtime_error("No prefered sample rate available");
}
}
/**
* @brief Whether the device has an internal monitor of the output signal.
*/
bool hasInternalOutputMonitor = false;
/**
* @brief String representation of DeviceInfo
*
* @return string
*/
operator string() const {
using std::endl;
std::stringstream str;
str << api.apiname + " " << api_specific_devindex << endl
<< " number of input channels: " << ninchannels << endl
/**
* @brief
*/
<< " number of output channels: " << noutchannels << endl;
return str.str();
}
/**
* @brief Create a list of DeviceInfo's that are at call time avalable
*
* @return The device info's for each found device.
*/
static std::vector<DeviceInfo> getDeviceInfo();
};