lasp/src/lasp/device/lasp_daqdata.cpp

32 lines
879 B
C++

#include "lasp_daqdata.h"
#include "debugtrace.hpp"
#include <cassert>
DEBUGTRACE_VARIABLES;
DaqData::DaqData(const us nchannels, const us nframes,
const DataTypeDescriptor::DataType dtype)
: nchannels(nchannels), nframes(nframes), dtype(dtype),
dtype_descr(dtype_map.at(dtype)),
sw(dtype_descr.sw) {
static_assert(sizeof(char) == 1, "Invalid char size");
const DataTypeDescriptor &desc = dtype_map.at(dtype);
_data.resize(nframes * nchannels * desc.sw);
}
void DaqData::copyInFromRaw(const std::vector<uint8_t *> &ptrs) {
us ch = 0;
assert(ptrs.size() == nchannels);
for (auto ptr : ptrs) {
std::copy(ptr, ptr + sw * nframes, &_data[sw * ch * nframes]);
ch++;
}
}
void DaqData::copyToRaw(const us channel,uint8_t *ptr) {
std::copy(&_data[sw * nframes * channel],
&_data[sw * nframes * (channel + 1)], ptr);
}