5 #pragma comment(lib, "NIDAQmx.lib")
33 double PredictSampleRate(
const double& _desiredrate,
const uint32_t& _nochannels,
const double& _refclockrate,
const int32& _mode);
45 double CoerceSampleRates(
const double& _desiredrate,
const uint32_t& _nochannelsin,
const uint32_t& _nochannelsout,
const double& _refclockrate);
67 void CreateTask(
const std::wstring& _name = L
"");
83 void ConfigureSampleTiming(
const std::wstring& _src,
const float64& _rate,
const int32& _samplesperchan,
const int32& _samplingtype = DAQmx_Val_ContSamps,
const int32& _actedge = DAQmx_Val_Rising);
127 void ExportSignal(int32 _signal,
const std::wstring& _terminal);
150 const std::wstring& _channelname = L
"",
151 float64 _minval = -10.0,
152 float64 _maxval = 10.0,
153 int32 _units = DAQmx_Val_Volts,
154 const std::wstring& _customscalename = L
"");
204 int32
WriteAnalog(
const float64* _data, int32 _sampsperchan,
bool _autostart =
false, int32 _timeout = 2, bool32 _layout = DAQmx_Val_GroupByChannel);
210 void WriteAnalogScalar(
const float64& _value,
bool _autostart =
false, int32 _timeout = 1000);
220 int32
WriteAnalogI16(
const int16* _data, int32 _sampsperchan,
bool _autostart =
false, int32 _timeout = 2, bool32 _layout = DAQmx_Val_GroupByChannel);
231 void CreateDOChannel(
const std::wstring& _devicelines,
const std::wstring& _channelname = L
"");
241 int32
WriteDigitalU8(
const uInt8* _data, int32 _sampsperchan,
bool _autostart =
false, float64 _timeout = 2, bool32 _layout = DAQmx_Val_GroupByChannel);
251 int32_t
WriteDigitalLines(
const uInt8* _data, int32 _sampsperchan,
bool _autostart =
false, float64 _timeout = 2, bool32 _layout = DAQmx_Val_GroupByChannel);
263 std::mersenne_twister<uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 7, 0x9d2c5680, 15, 0xefc60000, 18>
mtgen;
281 const std::wstring& _name = L
"",
282 int32 _terminalconfig = DAQmx_Val_Cfg_Default ,
283 float64 _minval = -10.0,
284 float64 _maxval = 10.0,
285 int32 _units = DAQmx_Val_Volts,
286 const std::wstring& _customscalename = L
"");
301 int32
ReadU16(std::vector<uint16_t>& _data,
const int32& _sampsperchan,
const uint32_t& _channels,
bool& _timedout,
const float64& _timeout = 2);
311 int32
ReadU16Dummy(std::vector<uint16_t>& _data,
const int32& _sampsperchan,
const uint32_t& _channels,
bool& _timedout,
const float64& _timeout = 2);
323 int32
ReadI16(std::vector<int16_t>& _data,
const int32& _sampsperchan,
const uint32_t& _channels,
bool& _timedout,
const float64& _timeout = 2);
341 ,
const std::wstring& _name = L
""
342 , int32 _idlestate = 0
343 , float64 _initdelay = 0
344 , float64 _lowtime = 0.1
345 , float64 _hightime = 0.1);
int32_t WriteDigitalLines(const uInt8 *_data, int32 _sampsperchan, bool _autostart=false, float64 _timeout=2, bool32 _layout=DAQmx_Val_GroupByChannel)
Writes to up to 8 digital lines (in one port, I suppose), depending on which lines are configured int...
uInt32 ConfigureOnboardBuffer(const uInt32 &_sampsperchannel)
Configure the output buffer on the device hardware.
int32 WriteAnalog(const float64 *_data, int32 _sampsperchan, bool _autostart=false, int32 _timeout=2, bool32 _layout=DAQmx_Val_GroupByChannel)
Writes several samples to the buffer of an analog output task.
void SetRegeneration(const bool &_regenerate)
Sets the mode of sample regeneration.
void WriteAnalogScalar(const float64 &_value, bool _autostart=false, int32 _timeout=1000)
Writes a single sample to the buffer of an analog output task.
void ConfigureReferenceClock(const std::wstring &_src, const float64 &_rate)
Configures the reference clock for the task.
int32_t WaitUntilDone(const float64 &_waittime)
Waits until the task is done.
std::wstring ClockString(const scope::DaqTimingHelper::Mode &_timing, const std::wstring &_externalclocksource)
Generates a string for the sample clock from daq_timing.
uInt32 ConfigureBuffer(const uInt32 &_sampsperchannel)
Configure the daqmx output buffer on the PC.
void CreateDOChannel(const std::wstring &_devicelines, const std::wstring &_channelname=L"")
Creates a digital output channel.
void SetIdleOutputBehaviour(const std::wstring &_channel, const int32_t &_behav)
Configures the output behaviour when the task is not running.
void ExportSignal(int32 _signal, const std::wstring &_terminal)
Exports a signal to an output terminal.
Wraps a DAQmx Counter Output task.
int32 WriteAnalogI16(const int16 *_data, int32 _sampsperchan, bool _autostart=false, int32 _timeout=2, bool32 _layout=DAQmx_Val_GroupByChannel)
Writes several samples to the buffer of an analog output task.
void SetWriteOffset(int32 posreltofirst)
Sets the write offset relative to the first buffer position.
void SetDataTransferCondition(const std::wstring &_channel, const int32_t &_cond)
Configures the condition for data transfer to the device.
void Start(void)
Starts the task.
Base class for DAQmx tasks.
void UseOnlyOnboardMemory(const std::wstring &_channel)
Configures the task to use only the devices' onboard memory.
std::mersenne_twister< uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 7, 0x9d2c5680, 15, 0xefc60000, 18 > mtgen
For the ReadDummy function which returns random numbers.
In here all declarations for all kinds of datatypes Scope needs.
bool CheckError(const int32 &error)
Checks return value of NI DAQmx function for error, prints out error information and throws an except...
TaskHandle task_handle
the DAQmx task handle
Wraps a DAQmx Digital Output task.
~CDAQmxTask(void)
Clear the task.
This is basically a C++ wrapper around NI's DAQmx C library.
void CreateAOVoltageChannel(const std::wstring &_devices, const std::wstring &_channelname=L"", float64 _minval=-10.0, float64 _maxval=10.0, int32 _units=DAQmx_Val_Volts, const std::wstring &_customscalename=L"")
Creates an analog output channel Allowed values for terminal configuration (from NiDAQmx.h): Values for DAQmx_PhysicalChan_AI_TermCfgs and DAQmx_PhysicalChan_AO_TermCfgs Value set TerminalConfigurationBits .
Wraps a DAQmx Analog Output task.
void Clear(void)
Clear the task.
void CreateTask(const std::wstring &_name=L"")
void ConfigureBuffer(const uInt32 &_sampsperchannel)
Configures input buffer (there is one buffer per channel)
void ConfigureSampleTiming(const std::wstring &_src, const float64 &_rate, const int32 &_samplesperchan, const int32 &_samplingtype=DAQmx_Val_ContSamps, const int32 &_actedge=DAQmx_Val_Rising)
Configures a sample timing for the task.
int32 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.
int32 WriteDigitalU8(const uInt8 *_data, int32 _sampsperchan, bool _autostart=false, float64 _timeout=2, bool32 _layout=DAQmx_Val_GroupByChannel)
Writes to an 8 bit digital output port, lowest bit is line0, highest bit is line7.
double PredictSampleRate(const double &_desiredrate, const uint32_t &_nochannels, const double &_refclockrate, const int32 &_mode)
Predicts the actual sampling rate.
void ConfigureImplicitTiming(const int32 &_mode, const int32 &_samplesperchan)
Configures implicit timing for the task.
void SetDataTransferMode(const std::wstring &_channel, const int32_t &_mode)
Configures the mode of data transfer between the daqmx buffer on the PC and the onboard buffer of the...
void CreateCOChannel(const std::wstring &_counter, const std::wstring &_name=L"", int32 _idlestate=0, float64 _initdelay=0, float64 _lowtime=0.1, float64 _hightime=0.1)
Creates a counter output task.
double CoerceSampleRates(const double &_desiredrate, const uint32_t &_nochannelsin, const uint32_t &_nochannelsout, const double &_refclockrate)
Calculates a sampling rate which both analog in and out can comply to.
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 ConfigureDigStartTrigger(const std::wstring &_src, const int32 &_trigedge=DAQmx_Val_Rising)
Configures the start trigger.
void Stop(void)
Stops the task.
int32 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.
Wraps a DAQmx Analog Input Task.
int32 ReadU16(std::vector< uint16_t > &_data, const int32 &_sampsperchan, const uint32_t &_channels, bool &_timedout, const float64 &_timeout=2)