2022-07-20 12:58:48 +00:00
|
|
|
#include "lasp_daqconfig.h"
|
|
|
|
#include "lasp_deviceinfo.h"
|
2022-09-22 08:18:38 +00:00
|
|
|
#include <algorithm>
|
2022-07-20 12:58:48 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <pybind11/numpy.h>
|
|
|
|
#include <pybind11/stl.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
using std::cerr;
|
|
|
|
namespace py = pybind11;
|
|
|
|
|
|
|
|
void init_daqconfiguration(py::module &m) {
|
|
|
|
|
|
|
|
/// DataType
|
|
|
|
py::class_<DataTypeDescriptor> dtype_desc(m, "DataTypeDescriptor");
|
2022-09-22 08:18:38 +00:00
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
dtype_desc.def_readonly("name", &DataTypeDescriptor::name);
|
|
|
|
dtype_desc.def_readonly("sw", &DataTypeDescriptor::sw);
|
|
|
|
dtype_desc.def_readonly("is_floating", &DataTypeDescriptor::is_floating);
|
2022-09-22 08:18:38 +00:00
|
|
|
dtype_desc.def_readonly("dtype", &DataTypeDescriptor::dtype);
|
2022-07-20 12:58:48 +00:00
|
|
|
|
|
|
|
py::enum_<DataTypeDescriptor::DataType>(dtype_desc, "DataType")
|
|
|
|
.value("dtype_fl32", DataTypeDescriptor::DataType::dtype_fl32)
|
|
|
|
.value("dtype_fl64", DataTypeDescriptor::DataType::dtype_fl64)
|
|
|
|
.value("dtype_int8", DataTypeDescriptor::DataType::dtype_int8)
|
|
|
|
.value("dtype_int16", DataTypeDescriptor::DataType::dtype_int16)
|
2022-09-22 08:18:38 +00:00
|
|
|
.value("dtype_int32", DataTypeDescriptor::DataType::dtype_int32);
|
|
|
|
|
|
|
|
dtype_desc.def_static("toStr", [](const DataTypeDescriptor::DataType d) {
|
|
|
|
return dtype_map.at(d).name;
|
|
|
|
});
|
|
|
|
dtype_desc.def_static("fromStr", [](const std::string &dtype_str) {
|
|
|
|
decltype(dtype_map.cbegin()) d = std::find_if(
|
|
|
|
dtype_map.cbegin(), dtype_map.cend(),
|
|
|
|
[&dtype_str](const auto &d) { return d.second.name == dtype_str; });
|
|
|
|
if (d != dtype_map.cend()) {
|
|
|
|
return d->first;
|
|
|
|
}
|
|
|
|
throw std::runtime_error(dtype_str + " not found in list of data types");
|
|
|
|
});
|
2022-07-20 12:58:48 +00:00
|
|
|
|
|
|
|
dtype_desc.def_readonly("dtype", &DataTypeDescriptor::dtype);
|
|
|
|
|
|
|
|
/// DaqApi
|
|
|
|
py::class_<DaqApi> daqapi(m, "DaqApi");
|
|
|
|
daqapi.def_readonly("apiname", &DaqApi::apiname);
|
|
|
|
daqapi.def_readonly("apicode", &DaqApi::apicode);
|
|
|
|
daqapi.def_readonly("api_specific_subcode", &DaqApi::api_specific_subcode);
|
|
|
|
daqapi.def("__str__", [](const DaqApi &d) { return std::string(d); });
|
|
|
|
|
|
|
|
/// DaqChannel, DaqConfiguration
|
|
|
|
py::class_<DaqConfiguration> daqconfig(m, "DaqConfiguration");
|
|
|
|
|
|
|
|
py::class_<DaqChannel> daqchannel(m, "DaqChannel");
|
2022-09-22 08:18:38 +00:00
|
|
|
daqchannel.def(py::init<>());
|
2022-07-20 12:58:48 +00:00
|
|
|
daqchannel.def_readwrite("enabled", &DaqChannel::enabled);
|
|
|
|
daqchannel.def_readwrite("name", &DaqChannel::name);
|
|
|
|
daqchannel.def_readwrite("sensitivity", &DaqChannel::sensitivity);
|
|
|
|
daqchannel.def_readwrite("ACCouplingMode", &DaqChannel::ACCouplingMode);
|
|
|
|
daqchannel.def_readwrite("IEPEEnabled", &DaqChannel::IEPEEnabled);
|
|
|
|
daqchannel.def_readwrite("digitalHighpassCutOn",
|
|
|
|
&DaqChannel::digitalHighPassCutOn);
|
|
|
|
daqchannel.def_readwrite("rangeIndex", &DaqChannel::rangeIndex);
|
2022-09-22 08:18:38 +00:00
|
|
|
|
|
|
|
py::enum_<DaqChannel::Qty>(daqchannel, "Qty")
|
|
|
|
.value("Number", DaqChannel::Qty::Number)
|
|
|
|
.value("AcousticPressure", DaqChannel::Qty::AcousticPressure)
|
|
|
|
.value("Voltage", DaqChannel::Qty::Voltage)
|
|
|
|
.value("UserDefined", DaqChannel::Qty::UserDefined);
|
2022-07-20 12:58:48 +00:00
|
|
|
daqchannel.def_readwrite("qty", &DaqChannel::qty);
|
|
|
|
|
2022-10-17 17:37:31 +00:00
|
|
|
daqchannel.def("__eq__", [](const DaqChannel &a, const DaqChannel &b) {
|
|
|
|
return a == b;
|
|
|
|
});
|
2022-10-01 17:59:35 +00:00
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
/// DaqConfiguration
|
|
|
|
daqconfig.def(py::init<>());
|
|
|
|
daqconfig.def(py::init<const DeviceInfo &>());
|
2022-09-22 08:18:38 +00:00
|
|
|
daqconfig.def_readwrite("api", &DaqConfiguration::api);
|
|
|
|
daqconfig.def_readwrite("device_name", &DaqConfiguration::device_name);
|
2022-07-29 07:32:26 +00:00
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
daqconfig.def_readwrite("sampleRateIndex",
|
|
|
|
&DaqConfiguration::sampleRateIndex);
|
|
|
|
daqconfig.def_readwrite("dataTypeIndex", &DaqConfiguration::dataTypeIndex);
|
|
|
|
|
|
|
|
daqconfig.def_readwrite("framesPerBlockIndex",
|
|
|
|
&DaqConfiguration::framesPerBlockIndex);
|
|
|
|
daqconfig.def_readwrite("monitorOutput", &DaqConfiguration::monitorOutput);
|
|
|
|
|
|
|
|
daqconfig.def("match", &DaqConfiguration::match);
|
|
|
|
|
2022-08-01 15:26:22 +00:00
|
|
|
daqconfig.def_static("fromTOML", &DaqConfiguration::fromTOML);
|
2022-07-20 12:58:48 +00:00
|
|
|
daqconfig.def("toTOML", &DaqConfiguration::toTOML);
|
|
|
|
daqconfig.def_readwrite("inchannel_config",
|
|
|
|
&DaqConfiguration::inchannel_config);
|
|
|
|
daqconfig.def_readwrite("outchannel_config",
|
|
|
|
&DaqConfiguration::outchannel_config);
|
2022-09-27 15:20:45 +00:00
|
|
|
daqconfig.def("setAllInputEnabled", &DaqConfiguration::setAllInputEnabled);
|
|
|
|
daqconfig.def("setAllOutputEnabled", &DaqConfiguration::setAllOutputEnabled);
|
2022-10-17 17:37:31 +00:00
|
|
|
daqconfig.def("enabledInChannels", &DaqConfiguration::enabledInChannels,
|
|
|
|
py::arg("include_monitor") = true);
|
2022-07-20 12:58:48 +00:00
|
|
|
}
|