LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
Daq Class Referenceabstract

Base cass for all DAQ (Data Acquisition) interfaces. A DAQ can be a custom device, or for example a sound card. More...

#include <lasp_daq.h>

Inheritance diagram for Daq:
Collaboration diagram for Daq:

Classes

class  StreamException
 Used for internal throwing of exceptions. More...
 
class  StreamStatus
 Information regarding a stream. More...
 

Public Types

using rte = std::runtime_error
 

Public Member Functions

virtual void start (InDaqCallback inCallback, OutDaqCallback outCallback)=0
 Start the Daq.
 
virtual void stop ()=0
 Stop the Daq device. Throws an exception if the device is not running at the time this method is called.
 
virtual ~Daq ()=0
 
us neninchannels (bool include_monitorchannels=true) const
 Returns the number of enabled input channels.
 
us nenoutchannels () const
 Returns the number of enabled output channels.
 
boolvec eninchannels (const bool include_monitor=true) const
 Create a vector of boolean values of the enabled input channels.
 
boolvec enoutchannels () const
 Create an array of booleans for each enabled output channel.
 
double samplerate () const
 Returns current sample rate.
 
dvec inputRangeForEnabledChannels (const bool include_monitor=true) const
 Returns the input range for each channel. Maximum allowed absolute value of the signal that can pass unclipped.
 
DataTypeDescriptor::DataType dataType () const
 Returns datatype (enum) corresponding to the datatype of the samples.
 
const DataTypeDescriptordtypeDescr () const
 More elaborate description of the datatypes.
 
us framesPerBlock () const
 The number of frames that is send in a block of DaqData.
 
virtual StreamStatus getStreamStatus () const =0
 Get stream status corresponding to current DAQ.
 
bool duplexMode () const
 Whether the device runs in duplex mode (both input and output), or false if only input / only output.
 
- Public Member Functions inherited from DaqConfiguration
std::string toTOML () const
 Export the class to TOML markup language.
 
std::vector< DaqChannelenabledInChannels (const bool include_monitor=true) const
 Return list of enabled input channels.
 
 DaqConfiguration (const DeviceInfo &deviceinfo)
 Create a default configuration, with all channels disabled on both input and output, and default channel names.
 
 DaqConfiguration ()
 
bool match (const DeviceInfo &devinfo) const
 Check to see whether the DAQ configuration matches with the device. This means, some basic checks are done on channels, sampling rate, etc, and that the name corresponds with the device name.
 
int getHighestEnabledInChannel () const
 Get the enabled highest channel number from the list of enabled input channels.
 
int getHighestEnabledOutChannel () const
 Get the highest channel number from the list of enabled output channels.
 
int getLowestEnabledInChannel () const
 Get the lowest channel number from the list of enabled input channels.
 
int getLowestEnabledOutChannel () const
 Get the lowest channel number from the list of enabled output channels.
 
void setAllInputEnabled (bool val)
 Set all input channels to enabled / disabled state.
 
void setAllOutputEnabled (bool val)
 Set all output channels to enabled / disabled state.
 
- Public Member Functions inherited from DeviceInfo
virtual ~DeviceInfo ()
 Virtual desctructor. Can be derived class.
 
DeviceInfooperator= (const DeviceInfo &)=delete
 
virtual std::unique_ptr< DeviceInfoclone () const
 Clone a device info.
 
double prefSampleRate () const
 
 operator string () const
 String representation of DeviceInfo.
 

Static Public Member Functions

static std::unique_ptr< DaqcreateDaq (const DeviceInfo &devinfo, const DaqConfiguration &config)
 Create a Daq based on given device info and configuration.
 
- Static Public Member Functions inherited from DaqConfiguration
static DaqConfiguration fromTOML (const std::string &toml)
 Load in a DAQConfiguration from TOML.
 
- Static Public Member Functions inherited from DeviceInfo
static DeviceInfoList getDeviceInfo ()
 Create a list of DeviceInfo's that are at call time avalable.
 

Protected Member Functions

 Daq (const DeviceInfo &devinfo, const DaqConfiguration &config)
 
 Daq (const Daq &)=delete
 

Additional Inherited Members

- Public Attributes inherited from DaqConfiguration
DaqApi api
 
string device_name
 The internal device name this DAQ configuration applies to.
 
std::vector< DaqChannelinchannel_config
 Channel configuration for input channels.
 
std::vector< DaqChanneloutchannel_config
 Channel configuration for output channels.
 
int sampleRateIndex = 0
 Index in list of sample rates that are available for the device.
 
int dataTypeIndex = 0
 Required datatype for output, should be present in the list.
 
int framesPerBlockIndex = 0
 The index in the array of frames per block that can be used for the device.
 
bool monitorOutput = false
 If set to true and if the device has this capability, the output channels are added as input channels as well.
 
- Public Attributes inherited from DeviceInfo
DaqApi api
 Backend API corresponding to device.
 
string device_name = ""
 The name of the device.
 
std::vector< DataTypeDescriptor::DataTypeavailableDataTypes
 The available data types the device can output.
 
int prefDataTypeIndex = 0
 The device's prefferd data type.
 
dvec availableSampleRates
 Available sample rates the device can run on.
 
int prefSampleRateIndex = -1
 Preferred setting for the sample rate.
 
usvec availableFramesPerBlock
 Available latency-setting (number of frames passed in each callback).
 
us prefFramesPerBlockIndex = 0
 Preffered number of frames per callback.
 
dvec availableInputRanges
 Available ranges for the input, i.e. +/- 1V and/or +/- 10 V etc.
 
int prefInputRangeIndex = 0
 Its preffered range.
 
unsigned ninchannels = 0
 The number of input channels available for the device.
 
unsigned noutchannels = 0
 The number of output channels available for the device.
 
bool hasInputIEPE = false
 Whether the device is capable to provide IEPE constant current power supply.
 
bool hasInputACCouplingSwitch = false
 Whether the device is capable of enabling a hardware AC-coupling.
 
bool hasInputTrigger = false
 Whether the device is able to trigger on input.
 
bool hasInternalOutputMonitor = false
 Whether the device has an internal monitor of the output signal. If true, the device is able to monitor output signals internally and able to present output signals as virtual input signals. This only works together Daq's that are able to run in full duplex mode.
 
bool duplexModeForced = false
 This flag is used to be able to indicate that the device cannot run input and output streams independently, without opening the device in duplex mode. This is for example true for the UlDaq: only one handle to the device can be given at the same time.
 
DaqChannel::Qty physicalOutputQty = DaqChannel::Qty::Number
 The physical quantity of the output signal. For 'normal' audio devices, this is typically a 'number' between +/- full scale. For some devices however, the output quantity corresponds to a physical signal, such a Volts.
 

Detailed Description

Base cass for all DAQ (Data Acquisition) interfaces. A DAQ can be a custom device, or for example a sound card.

Definition at line 29 of file lasp_daq.h.

Member Typedef Documentation

◆ rte

using Daq::rte = std::runtime_error

Definition at line 86 of file lasp_daq.h.

Constructor & Destructor Documentation

◆ Daq() [1/2]

Daq::Daq ( const DeviceInfo devinfo,
const DaqConfiguration config 
)
protected

Definition at line 43 of file lasp_daq.cpp.

◆ Daq() [2/2]

Daq::Daq ( const Daq )
protecteddelete

◆ ~Daq()

Daq::~Daq ( )
pure virtual

Definition at line 18 of file lasp_daq.cpp.

Member Function Documentation

◆ createDaq()

std::unique_ptr< Daq > Daq::createDaq ( const DeviceInfo devinfo,
const DaqConfiguration config 
)
static

Create a Daq based on given device info and configuration.

Parameters
devinfoDevice information of device to be used.
configConfiguation to apply to the deviec
Returns
Pointer to Daq device created.

Definition at line 20 of file lasp_daq.cpp.

◆ dataType()

DataTypeDescriptor::DataType Daq::dataType ( ) const

Returns datatype (enum) corresponding to the datatype of the samples.

Returns
That as stated aboce

Definition at line 83 of file lasp_daq.cpp.

◆ dtypeDescr()

const DataTypeDescriptor & Daq::dtypeDescr ( ) const

More elaborate description of the datatypes.

Returns
A DataTypeDescriptor

Definition at line 86 of file lasp_daq.cpp.

◆ duplexMode()

bool Daq::duplexMode ( ) const
inline

Whether the device runs in duplex mode (both input and output), or false if only input / only output.

Returns
true if duplex

Definition at line 224 of file lasp_daq.h.

◆ eninchannels()

boolvec Daq::eninchannels ( const bool  include_monitor = true) const

Create a vector of boolean values of the enabled input channels.

Parameters
include_monitorIf set to true and a monitor channel is available, the first index in the array will correspond to the monitor channel, and whether it is enabled
Returns
Boolean vector

Definition at line 109 of file lasp_daq.cpp.

◆ enoutchannels()

boolvec Daq::enoutchannels ( ) const

Create an array of booleans for each enabled output channel.

Returns
Boolean vector

Definition at line 120 of file lasp_daq.cpp.

◆ framesPerBlock()

us Daq::framesPerBlock ( ) const
inline

The number of frames that is send in a block of DaqData.

Returns
The number of frames per block

Definition at line 207 of file lasp_daq.h.

◆ getStreamStatus()

virtual StreamStatus Daq::getStreamStatus ( ) const
pure virtual

Get stream status corresponding to current DAQ.

Returns
StreamStatus object.

Implemented in DT9837A.

◆ inputRangeForEnabledChannels()

dvec Daq::inputRangeForEnabledChannels ( const bool  include_monitor = true) const

Returns the input range for each channel. Maximum allowed absolute value of the signal that can pass unclipped.

Parameters
include_monitorIf set to true and a monitor channel is available, the first index in the array will correspond to the monitor channel.
Returns
Maximum offset from 0 before clipping.

Definition at line 90 of file lasp_daq.cpp.

◆ neninchannels()

us Daq::neninchannels ( bool  include_monitorchannels = true) const

Returns the number of enabled input channels.

Parameters
include_monitorchannelsif true, all channels that are internally monitored are added to the list.
Returns
number of enabled input channels

Definition at line 99 of file lasp_daq.cpp.

◆ nenoutchannels()

us Daq::nenoutchannels ( ) const

Returns the number of enabled output channels.

Returns
Number of enabled output channels

Definition at line 104 of file lasp_daq.cpp.

◆ samplerate()

double Daq::samplerate ( ) const

Returns current sample rate.

Returns
Sample rate in [Hz]

Definition at line 78 of file lasp_daq.cpp.

◆ start()

virtual void Daq::start ( InDaqCallback  inCallback,
OutDaqCallback  outCallback 
)
pure virtual

Start the Daq.

Parameters
inCallbackFunction that is called with input data as argument, and which expects output data as a return value. If no input data is required, this callback should be unset.
outCallbackFunction that is called when output data is required. If the stream does not require output data, this callback should be unset.

Implemented in DT9837A.

◆ stop()

virtual void Daq::stop ( )
pure virtual

Stop the Daq device. Throws an exception if the device is not running at the time this method is called.

Implemented in DT9837A.


The documentation for this class was generated from the following files: