LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp_uldaq.cpp
Go to the documentation of this file.
1/* #define DEBUGTRACE_ENABLED */
2#include "debugtrace.hpp"
3#include "lasp_config.h"
4
5#if LASP_HAS_ULDAQ == 1
6#include "lasp_uldaq.h"
7#include "lasp_uldaq_impl.h"
8#include <uldaq.h>
9
14const us MAX_ULDAQ_DEV_COUNT_PER_API = 100;
15
16void fillUlDaqDeviceInfo(DeviceInfoList &devinfolist) {
17
18 DEBUGTRACE_ENTER;
19
20 UlError err;
21 unsigned int numdevs = MAX_ULDAQ_DEV_COUNT_PER_API;
22
23 DaqDeviceDescriptor devdescriptors[MAX_ULDAQ_DEV_COUNT_PER_API];
24 DaqDeviceDescriptor descriptor;
25 DaqDeviceInterface interfaceType = ANY_IFC;
26
27 err = ulGetDaqDeviceInventory(interfaceType, devdescriptors, &numdevs);
28
29 if (err != ERR_NO_ERROR) {
30 throw rte("UlDaq device inventarization failed");
31 }
32
33 DEBUGTRACE_PRINT(string("Number of devices: ") + std::to_string(numdevs));
34 for (unsigned i = 0; i < numdevs; i++) {
35
36 descriptor = devdescriptors[i];
37
38 UlDaqDeviceInfo devinfo;
39 devinfo._uldaqDescriptor = descriptor;
40
41 devinfo.api = uldaqapi;
42 {
43 string name;
44 string productname = descriptor.productName;
45 if (productname != "DT9837A") {
46 throw rte("Unknown UlDAQ type: " + productname);
47 }
48
49 switch (descriptor.devInterface) {
50 case USB_IFC:
51 name = "USB - ";
52 break;
53 case BLUETOOTH_IFC:
54 /* devinfo. */
55 name = "Bluetooth - ";
56 break;
57
58 case ETHERNET_IFC:
59 /* devinfo. */
60 name = "Ethernet - ";
61 break;
62 default:
63 name = "Uknown interface = ";
64 }
65
66 name += productname + " " + string(descriptor.uniqueId);
67 devinfo.device_name = name;
68 }
69
71
72 devinfo.availableDataTypes.push_back(
74 devinfo.prefDataTypeIndex = 0;
75
77 devinfo.prefSampleRateIndex = 11;
78
79 devinfo.availableFramesPerBlock = {512, 1024, 2048, 4096, 8192};
80
81 devinfo.availableInputRanges = {1.0, 10.0};
82 devinfo.prefInputRangeIndex = 0;
83
84 devinfo.ninchannels = 4;
85 devinfo.noutchannels = 1;
86
87 devinfo.hasInputIEPE = true;
88 devinfo.hasInputACCouplingSwitch = true;
89 devinfo.hasInputTrigger = true;
90
91 devinfo.hasInternalOutputMonitor = true;
92
93 devinfo.duplexModeForced = true;
94
95 // Finally, this devinfo is pushed back in list
96 devinfolist.push_back(std::make_unique<UlDaqDeviceInfo>(devinfo));
97 }
98}
99
100std::unique_ptr<Daq> createUlDaqDevice(const DeviceInfo &devinfo,
101 const DaqConfiguration &config) {
102 const UlDaqDeviceInfo *_info =
103 dynamic_cast<const UlDaqDeviceInfo *>(&devinfo);
104 if (_info == nullptr) {
105 throw rte("BUG: Could not cast DeviceInfo to UlDaqDeviceInfo");
106 }
107 return std::make_unique<DT9837A>(*_info, config);
108}
109
110#endif // LASP_HAS_ULDAQ
Configuration of a DAQ device.
Structure containing device info parameters.
unsigned ninchannels
The number of input channels available for the device.
bool duplexModeForced
This flag is used to be able to indicate that the device cannot run input and output streams independ...
unsigned noutchannels
The number of output channels available for the device.
dvec availableSampleRates
Available sample rates the device can run on.
string device_name
The name of the device.
std::vector< DataTypeDescriptor::DataType > availableDataTypes
The available data types the device can output.
DaqChannel::Qty physicalOutputQty
The physical quantity of the output signal. For 'normal' audio devices, this is typically a 'number' ...
int prefDataTypeIndex
The device's prefferd data type.
bool hasInputACCouplingSwitch
Whether the device is capable of enabling a hardware AC-coupling.
usvec availableFramesPerBlock
Available latency-setting (number of frames passed in each callback).
int prefInputRangeIndex
Its preffered range.
DaqApi api
Backend API corresponding to device.
bool hasInternalOutputMonitor
Whether the device has an internal monitor of the output signal. If true, the device is able to monit...
bool hasInputTrigger
Whether the device is able to trigger on input.
dvec availableInputRanges
Available ranges for the input, i.e. +/- 1V and/or +/- 10 V etc.
int prefSampleRateIndex
Preferred setting for the sample rate.
bool hasInputIEPE
Whether the device is capable to provide IEPE constant current power supply.
UlDaq-specific device information. Adds a copy of the underlying DaqDeDaqDeviceDescriptor.
DaqDeviceDescriptor _uldaqDescriptor
std::runtime_error rte
Definition lasp_daq.cpp:16
std::vector< std::unique_ptr< DeviceInfo > > DeviceInfoList
const std::vector< d > ULDAQ_SAMPLERATES
List of available sampling frequencies for DT9837A.
std::unique_ptr< Daq > createUlDaqDevice(const DeviceInfo &devinfo, const DaqConfiguration &config)
void fillUlDaqDeviceInfo(DeviceInfoList &devinfolist)
Append device info list with UlDaq specific devices, if any.
size_t us
We often use boolean values.
Definition lasp_types.h:29