2022-10-05 17:23:00 +00:00
|
|
|
/* #define DEBUGTRACE_ENABLED */
|
2022-10-05 09:27:46 +00:00
|
|
|
#include "debugtrace.hpp"
|
|
|
|
#include "lasp_config.h"
|
2023-06-07 19:49:07 +00:00
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
#if LASP_HAS_ULDAQ == 1
|
2023-01-04 13:21:39 +00:00
|
|
|
#include "lasp_uldaq.h"
|
|
|
|
#include "lasp_uldaq_impl.h"
|
2023-01-04 14:15:03 +00:00
|
|
|
#include <uldaq.h>
|
2022-05-23 15:26:29 +00:00
|
|
|
|
2023-06-09 08:43:04 +00:00
|
|
|
/**
|
|
|
|
* @brief The maximum number of devices that can be enumerated when calling
|
|
|
|
* ulGetDaqDeviceInventory()
|
|
|
|
*/
|
|
|
|
const us MAX_ULDAQ_DEV_COUNT_PER_API = 100;
|
|
|
|
|
2023-01-20 14:50:51 +00:00
|
|
|
void fillUlDaqDeviceInfo(DeviceInfoList &devinfolist) {
|
2022-05-23 15:26:29 +00:00
|
|
|
|
|
|
|
DEBUGTRACE_ENTER;
|
|
|
|
|
2022-06-13 17:35:41 +00:00
|
|
|
UlError err;
|
2023-01-04 13:21:39 +00:00
|
|
|
unsigned int numdevs = MAX_ULDAQ_DEV_COUNT_PER_API;
|
2022-05-23 15:26:29 +00:00
|
|
|
|
2023-01-04 13:21:39 +00:00
|
|
|
DaqDeviceDescriptor devdescriptors[MAX_ULDAQ_DEV_COUNT_PER_API];
|
2022-05-23 15:26:29 +00:00
|
|
|
DaqDeviceDescriptor descriptor;
|
|
|
|
DaqDeviceInterface interfaceType = ANY_IFC;
|
|
|
|
|
2023-06-07 19:49:07 +00:00
|
|
|
err = ulGetDaqDeviceInventory(interfaceType, devdescriptors, &numdevs);
|
2022-05-23 15:26:29 +00:00
|
|
|
|
|
|
|
if (err != ERR_NO_ERROR) {
|
2022-10-05 09:27:46 +00:00
|
|
|
throw rte("UlDaq device inventarization failed");
|
2022-05-23 15:26:29 +00:00
|
|
|
}
|
|
|
|
|
2023-06-07 19:49:07 +00:00
|
|
|
DEBUGTRACE_PRINT(string("Number of devices: ") + std::to_string(numdevs));
|
2022-05-23 15:26:29 +00:00
|
|
|
for (unsigned i = 0; i < numdevs; i++) {
|
|
|
|
|
|
|
|
descriptor = devdescriptors[i];
|
|
|
|
|
2023-01-20 14:50:51 +00:00
|
|
|
UlDaqDeviceInfo devinfo;
|
|
|
|
devinfo._uldaqDescriptor = descriptor;
|
2023-01-04 13:21:39 +00:00
|
|
|
|
2022-05-23 15:26:29 +00:00
|
|
|
devinfo.api = uldaqapi;
|
2023-06-06 13:57:20 +00:00
|
|
|
{
|
2023-06-07 19:49:07 +00:00
|
|
|
string name;
|
2023-06-06 13:57:20 +00:00
|
|
|
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 = ";
|
|
|
|
}
|
|
|
|
|
2023-06-07 19:49:07 +00:00
|
|
|
name += productname + " " + string(descriptor.uniqueId);
|
|
|
|
devinfo.device_name = name;
|
2022-05-23 15:26:29 +00:00
|
|
|
}
|
|
|
|
|
2022-10-21 20:30:06 +00:00
|
|
|
devinfo.physicalOutputQty = DaqChannel::Qty::Voltage;
|
|
|
|
|
2022-05-23 15:26:29 +00:00
|
|
|
devinfo.availableDataTypes.push_back(
|
|
|
|
DataTypeDescriptor::DataType::dtype_fl64);
|
|
|
|
devinfo.prefDataTypeIndex = 0;
|
|
|
|
|
2023-04-18 09:09:01 +00:00
|
|
|
devinfo.availableSampleRates = ULDAQ_SAMPLERATES;
|
2022-05-23 15:26:29 +00:00
|
|
|
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;
|
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
devinfo.hasInternalOutputMonitor = true;
|
|
|
|
|
2023-01-20 14:50:51 +00:00
|
|
|
devinfo.duplexModeForced = true;
|
|
|
|
|
2022-05-23 15:26:29 +00:00
|
|
|
// Finally, this devinfo is pushed back in list
|
2023-01-20 14:50:51 +00:00
|
|
|
devinfolist.push_back(std::make_unique<UlDaqDeviceInfo>(devinfo));
|
2022-05-23 15:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-04 13:21:39 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Daq> createUlDaqDevice(const DeviceInfo &devinfo,
|
|
|
|
const DaqConfiguration &config) {
|
2023-06-07 19:49:07 +00:00
|
|
|
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);
|
2023-01-04 13:21:39 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
#endif // LASP_HAS_ULDAQ
|