111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
/* #define DEBUGTRACE_ENABLED */
|
|
#include "debugtrace.hpp"
|
|
#include "lasp_config.h"
|
|
|
|
#if LASP_HAS_ULDAQ == 1
|
|
#include "lasp_uldaq.h"
|
|
#include "lasp_uldaq_impl.h"
|
|
#include <uldaq.h>
|
|
|
|
/**
|
|
* @brief The maximum number of devices that can be enumerated when calling
|
|
* ulGetDaqDeviceInventory()
|
|
*/
|
|
const us MAX_ULDAQ_DEV_COUNT_PER_API = 100;
|
|
|
|
void fillUlDaqDeviceInfo(DeviceInfoList &devinfolist) {
|
|
|
|
DEBUGTRACE_ENTER;
|
|
|
|
UlError err;
|
|
unsigned int numdevs = MAX_ULDAQ_DEV_COUNT_PER_API;
|
|
|
|
DaqDeviceDescriptor devdescriptors[MAX_ULDAQ_DEV_COUNT_PER_API];
|
|
DaqDeviceDescriptor descriptor;
|
|
DaqDeviceInterface interfaceType = ANY_IFC;
|
|
|
|
err = ulGetDaqDeviceInventory(interfaceType, devdescriptors, &numdevs);
|
|
|
|
if (err != ERR_NO_ERROR) {
|
|
throw rte("UlDaq device inventarization failed");
|
|
}
|
|
|
|
DEBUGTRACE_PRINT(string("Number of devices: ") + std::to_string(numdevs));
|
|
for (unsigned i = 0; i < numdevs; i++) {
|
|
|
|
descriptor = devdescriptors[i];
|
|
|
|
UlDaqDeviceInfo devinfo;
|
|
devinfo._uldaqDescriptor = descriptor;
|
|
|
|
devinfo.api = uldaqapi;
|
|
{
|
|
string name;
|
|
string productname = descriptor.productName;
|
|
if (productname != "DT9837A") {
|
|
throw rte("Unknown UlDAQ type: " + productname);
|
|
}
|
|
|
|
switch (descriptor.devInterface) {
|
|
case USB_IFC:
|
|
name = "USB - ";
|
|
break;
|
|
case BLUETOOTH_IFC:
|
|
/* devinfo. */
|
|
name = "Bluetooth - ";
|
|
break;
|
|
|
|
case ETHERNET_IFC:
|
|
/* devinfo. */
|
|
name = "Ethernet - ";
|
|
break;
|
|
default:
|
|
name = "Uknown interface = ";
|
|
}
|
|
|
|
name += productname + " " + string(descriptor.uniqueId);
|
|
devinfo.device_name = name;
|
|
}
|
|
|
|
devinfo.physicalOutputQty = DaqChannel::Qty::Voltage;
|
|
|
|
devinfo.availableDataTypes.push_back(
|
|
DataTypeDescriptor::DataType::dtype_fl64);
|
|
devinfo.prefDataTypeIndex = 0;
|
|
|
|
devinfo.availableSampleRates = ULDAQ_SAMPLERATES;
|
|
devinfo.prefSampleRateIndex = 11;
|
|
|
|
devinfo.availableFramesPerBlock = {512, 1024, 2048, 4096, 8192};
|
|
|
|
devinfo.availableInputRanges = {1.0, 10.0};
|
|
devinfo.prefInputRangeIndex = 0;
|
|
|
|
devinfo.ninchannels = 4;
|
|
devinfo.noutchannels = 1;
|
|
|
|
devinfo.hasInputIEPE = true;
|
|
devinfo.hasInputACCouplingSwitch = true;
|
|
devinfo.hasInputTrigger = true;
|
|
|
|
devinfo.hasInternalOutputMonitor = true;
|
|
|
|
devinfo.duplexModeForced = true;
|
|
|
|
// Finally, this devinfo is pushed back in list
|
|
devinfolist.push_back(std::make_unique<UlDaqDeviceInfo>(devinfo));
|
|
}
|
|
}
|
|
|
|
std::unique_ptr<Daq> createUlDaqDevice(const DeviceInfo &devinfo,
|
|
const DaqConfiguration &config) {
|
|
const UlDaqDeviceInfo *_info =
|
|
dynamic_cast<const UlDaqDeviceInfo *>(&devinfo);
|
|
if (_info == nullptr) {
|
|
throw rte("BUG: Could not cast DeviceInfo to UlDaqDeviceInfo");
|
|
}
|
|
return std::make_unique<DT9837A>(*_info, config);
|
|
}
|
|
|
|
#endif // LASP_HAS_ULDAQ
|