7#include <gsl/gsl-lite.hpp>
142 arma::Col<d>
toFloat(
const us channel_no)
const;
154 d
toFloat(
const us frame_no,
const us channel_no)
const;
174 void fromFloat(
const us channel,
const arma::Col<d> &data);
177 template <
typename T> T &
value(
const us frame,
const us channel) {
181 return *
reinterpret_cast<T *
>(
raw_ptr(frame, channel));
183 template <
typename T>
const T &
value(
const us frame,
const us channel)
const {
187 return *
reinterpret_cast<const T *
>(
raw_ptr(frame, channel));
199 bool correct =
false;
200 static_assert(std::is_arithmetic<T>::value);
202 if constexpr (std::is_floating_point<T>::value) {
203 correct |=
sizeof(T) == 4 &&
dtype == DataType::dtype_fl32;
204 correct |=
sizeof(T) == 8 &&
dtype == DataType::dtype_fl64;
207 correct |=
sizeof(T) == 1 &&
dtype == DataType::dtype_int8;
208 correct |=
sizeof(T) == 2 &&
dtype == DataType::dtype_int16;
209 correct |=
sizeof(T) == 4 &&
dtype == DataType::dtype_int32;
212 throw std::runtime_error(
"Wrong datatype for template argument");
216 template <
typename T> arma::Mat<d>
toFloat()
const;
217 template <
typename T> arma::Col<d>
toFloat(
const us channel_no)
const;
218 template <
typename T> d
toFloat(
const us frame_no,
const us channel_no)
const;
221 template <
typename T>
223 template <
typename T>
224 void fromFloat(
const us frame_no,
const us channel_no,
const d val);
Data coming from / going to DAQ. Non-interleaved format, which means data in buffer is ordered by cha...
void copyInFromRaw(const std::vector< byte_t * > &ptrs)
Copy data from a set of raw pointers of uninterleaved data. Overwrites any existing available data.
arma::Mat< d > toFloat() const
Convert samples to floating point values and return a nframes x nchannels array of floats....
arma::Mat< d > toFloat() const
DataTypeDescriptor::DataType dtype
The data type corresponding to a sample.
arma::Col< d > toFloat(const us channel_no) const
byte_t * raw_ptr(const us frame=0, const us channel=0)
Return pointer to the raw data corresponding to a certain sample (frame, channel combo).
void print() const
For debugging purposes: prints some stats.
const byte_t * raw_ptr(const us frame=0, const us channel=0) const
DataTypeDescriptor dtype_descr
The data type description corresponding to a sample.
void copyToRaw(const us channel, byte_t *ptr)
Copy contents of DaqData for a certain channel to a raw pointer.
void fromFloat(const us frame_no, const us channel_no, const d data)
Convert to channel data of native type from floating point values. Useful for 'changing' raw data in ...
us nchannels
The number of channels.
us size_bytes() const
Return the total number of bytes.
us sw
The number of bytes per sample (sample width, sw)
byte_t * _data
Storage for the actual data.
void fromFloat(const us channel_no, const arma::Col< d > &vals)
DaqData & operator=(const DaqData &)=delete
us nframes
The number of frames in this block of data.
T & value(const us frame, const us channel)
const T & value(const us frame, const us channel) const
Base cass for all DAQ (Data Acquisition) interfaces. A DAQ can be a custom device,...
Descriptor for data types containing more detailed information.
DataType
Basic data types coming from a DAQ that we can deal with. The naming will be self-explainging.
size_t us
We often use boolean values.