Scope
DAQmx::CDAQmxAnalogInTask Class Reference

#include <DAQmxTask.h>

Inherits DAQmx::CDAQmxTask.

Public Member Functions

void CreateAIVoltageChannel (const std::wstring &_devicechannel, const std::wstring &_name=L"", int32 _terminalconfig=DAQmx_Val_Cfg_Default, float64 _minval=-10.0, float64 _maxval=10.0, int32 _units=DAQmx_Val_Volts, const std::wstring &_customscalename=L"")
 
void ConfigureBuffer (const uInt32 &_sampsperchannel)
 
int32 ReadU16 (std::vector< uint16_t > &_data, const int32 &_sampsperchan, const uint32_t &_channels, bool &_timedout, const float64 &_timeout=2)
 
int32 ReadU16Dummy (std::vector< uint16_t > &_data, const int32 &_sampsperchan, const uint32_t &_channels, bool &_timedout, const float64 &_timeout=2)
 
int32 ReadI16 (std::vector< int16_t > &_data, const int32 &_sampsperchan, const uint32_t &_channels, bool &_timedout, const float64 &_timeout=2)
 
- Public Member Functions inherited from DAQmx::CDAQmxTask
 ~CDAQmxTask (void)
 
void CreateTask (const std::wstring &_name=L"")
 
bool Created () const
 
void ConfigureImplicitTiming (const int32 &_mode, const int32 &_samplesperchan)
 
void ConfigureSampleTiming (const std::wstring &_src, const float64 &_rate, const int32 &_samplesperchan, const int32 &_samplingtype=DAQmx_Val_ContSamps, const int32 &_actedge=DAQmx_Val_Rising)
 
void ConfigureReferenceClock (const std::wstring &_src, const float64 &_rate)
 
void ConfigureDigStartTrigger (const std::wstring &_src, const int32 &_trigedge=DAQmx_Val_Rising)
 
void Start (void)
 
void Stop (void)
 
void Clear (void)
 
bool IsTaskDone (void)
 
int32_t WaitUntilDone (const float64 &_waittime)
 
void ExportSignal (int32 _signal, const std::wstring &_terminal)
 
void SetWriteOffset (int32 posreltofirst)
 
void SetRegeneration (const bool &_regenerate)
 

Protected Attributes

std::mersenne_twister< uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 7, 0x9d2c5680, 15, 0xefc60000, 18 > mtgen
 
- Protected Attributes inherited from DAQmx::CDAQmxTask
TaskHandle task_handle
 

Detailed Description

Wraps a DAQmx Analog Input Task.

Usually the device has int16 internally (since the ranges are +-x volts) If one, however, reads that out as a uin16, positive data is from 0-32767 and all negative data is 0

Definition at line 258 of file DAQmxTask.h.

Member Function Documentation

void DAQmx::CDAQmxAnalogInTask::CreateAIVoltageChannel ( const std::wstring &  _devicechannel,
const std::wstring &  _name = L"",
int32  _terminalconfig = DAQmx_Val_Cfg_Default,
float64  _minval = -10.0,
float64  _maxval = 10.0,
int32  _units = DAQmx_Val_Volts,
const std::wstring &  _customscalename = L"" 
)
Parameters
[in]_devicechannelchannel names on the device
[in]_namename this channel should have
[in]_terminalconfigInput terminal configuration. Possible values are (from NiDAQmx.h):
  • DAQmx_Val_Bit_TermCfg_RSE (1<<0) // RSE terminal configuration
    • DAQmx_Val_Bit_TermCfg_NRSE (1<<1) // NRSE terminal configuration
    • DAQmx_Val_Bit_TermCfg_Diff (1<<2) // Differential terminal configuration
    • DAQmx_Val_Bit_TermCfg_PseudoDIFF (1<<3) // Pseudodifferential terminal configuration
[in]_minval,_maxvalminimum and maximum expected input signal (changes the digitizer preamp, so choose wisely)
[in]_unitsUnit type of the input signal. Possible values are (from NiDAQmx.h):
  • DAQmx_Val_Volts 10348 // Volts
  • DAQmx_Val_FromCustomScale 10065 // From Custom Scale
[in]_customscalenamename of a custom defined scale

Definition at line 312 of file DAQmxTask.cpp.

void DAQmx::CDAQmxAnalogInTask::ConfigureBuffer ( const uInt32 &  _sampsperchannel)

Configures input buffer (there is one buffer per channel)

Parameters
[in]_sampsperchannelbuffersize per channel

Definition at line 333 of file DAQmxTask.cpp.

int32 DAQmx::CDAQmxAnalogInTask::ReadU16 ( std::vector< uint16_t > &  _data,
const int32 &  _sampsperchan,
const uint32_t &  _channels,
bool &  _timedout,
const float64 &  _timeout = 2 
)
Parameters
[in,out]_dataint16_t vector to read into
[in]_sampsperchannumber of samples to read per channel
[in]_channelsnumber of channels to read from
[out]_timedouttrue if read timedout (then also returning -1)
[in]_timeoutin seconds, wait that long for enough samples to be in the buffer
Returns
number of samples read, or -1 in case of an error
Warning
size of _data has to be at least _sampsperchan*_channels
time out error does never throw an exception
Exceptions
scope::ScopeExceptionon error during read, except time out error

Definition at line 340 of file DAQmxTask.cpp.

int32 DAQmx::CDAQmxAnalogInTask::ReadU16Dummy ( std::vector< uint16_t > &  _data,
const int32 &  _sampsperchan,
const uint32_t &  _channels,
bool &  _timedout,
const float64 &  _timeout = 2 
)

Generates random numbers or zeros instead of real read from a device.

Parameters
[in,out]_dataint16_t vector to generate into
[in]_sampsperchannumber of samples to generate per channel
[in]_channelsnumber of channels to read from
[out]_timedouttrue if read timedout (then also returning -1)
[in]_timeoutin seconds, wait that long for enough samples to be in the buffer
Returns
number of samples read, or -1 in case of an error
Warning
size of _data has to be at least _sampsperchan*_channels

Definition at line 361 of file DAQmxTask.cpp.

int32 DAQmx::CDAQmxAnalogInTask::ReadI16 ( std::vector< int16_t > &  _data,
const int32 &  _sampsperchan,
const uint32_t &  _channels,
bool &  _timedout,
const float64 &  _timeout = 2 
)

Reads from a device as signed 16bit integers.

Parameters
[in,out]_dataint16_t vector to read into
[in]_sampsperchannumber of samples to read per channel
[in]_channelsnumber of channels to read from
[out]_timedouttrue if read timedout (then also returning -1)
[in]_timeoutwait that long for enough samples to be in the buffer
Returns
number of samples read, or -1 in case of an error
Warning
size of _data has to be at least _sampsperchan*_channels
time out error does never throw an exception
Exceptions
scope::ScopeExceptionon error during read, except time out error

Definition at line 369 of file DAQmxTask.cpp.

Member Data Documentation

std::mersenne_twister<uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 7, 0x9d2c5680, 15, 0xefc60000, 18> DAQmx::CDAQmxAnalogInTask::mtgen
protected

For the ReadDummy function which returns random numbers.

Definition at line 263 of file DAQmxTask.h.


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