lasp/cpp_src/device/lasp_deviceinfo.h

159 lines
4.0 KiB
C
Raw Permalink Normal View History

#pragma once
#include "lasp_config.h"
#include "lasp_daqconfig.h"
#include "lasp_types.h"
#include <memory>
/** \addtogroup device
* @{
*/
using DeviceInfoList = std::vector<std::unique_ptr<DeviceInfo>>;
/**
* @brief Structure containing device info parameters
*/
class DeviceInfo {
public:
/**
* @brief Virtual desctructor. Can be derived class.
*/
virtual ~DeviceInfo() {}
DeviceInfo& operator=(const DeviceInfo&) = delete;
/**
* @brief Clone a device info.
*
* @return Cloned device info
*/
virtual std::unique_ptr<DeviceInfo> clone() const {
return std::make_unique<DeviceInfo>(*this);
}
/**
* @brief Backend API corresponding to device
*/
DaqApi api;
/**
* @brief The name of the device
*/
string device_name = "";
/**
* @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");
}
}
2022-07-20 12:58:48 +00:00
/**
* @brief Whether the device has an internal monitor of the output signal. If
* true, the device is able to monitor output signals internally and able to
* present output signals as virtual input signals. This only works together
* Daq's that are able to run in full duplex mode.
2022-07-20 12:58:48 +00:00
*/
bool hasInternalOutputMonitor = false;
/**
* @brief This flag is used to be able to indicate that the device cannot run
* input and output streams independently, without opening the device in
* duplex mode. This is for example true for the UlDaq: only one handle to
* the device can be given at the same time.
*/
bool duplexModeForced = false;
/**
* @brief The physical quantity of the output signal. For 'normal' audio
* devices, this is typically a 'number' between +/- full scale. For some
* devices however, the output quantity corresponds to a physical signal,
* such a Volts.
*/
DaqChannel::Qty physicalOutputQty = DaqChannel::Qty::Number;
/**
* @brief String representation of DeviceInfo
*
* @return string
*/
operator string() const {
using std::endl;
std::stringstream str;
str << api.apiname + " " << endl
<< " number of input channels: " << ninchannels
<< endl
<< " 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 DeviceInfoList getDeviceInfo();
};
/** @} */