2 #include "OutputsDAQmx.h"
3 #include "parameters/IO.h"
4 #include "parameters/Scope.h"
6 #include "helpers/ScopeException.h"
13 int32_t samplingtype = (_params.
requested_mode()==DaqModeHelper::continuous)?DAQmx_Val_ContSamps:DAQmx_Val_FiniteSamps;
20 , -_outputparams.
range()
21 , _outputparams.
range());
24 double pixelrate = 1/(_params.
areas[
area]->daq.pixeltime()*1E-6);
25 int32_t pixelsperchan = _params.
areas[
area]->Currentframe().TotalPixels();
30 pixelsperchan = _params.
areas[
area]->Currentframe().TotalPixels() * _params.
areas[
area]->daq.requested_frames() * _params.
areas[ThisAreaOrMasterArea(
area)]->daq.averages();
37 if ( DaqTimingHelper::Mode::ReferenceClock ==_outputparams.
daq_timing() )
79 int32_t sizeperchannel =
static_cast<int32_t
>(_xyzp.size() / 4);
80 int32_t blocksize = sizeperchannel/_blocks;
81 int32_t lastblocksize = blocksize + (sizeperchannel - blocksize*_blocks);
82 DBOUT(L
"OutputsDAQmx::Write blocksize " << blocksize << L
" last block " << lastblocksize);
83 DBOUT(L
"OutputsDAQmx::Write blocks " << _blocks << L
" sizeperchannel " << sizeperchannel << L
" totblocksize " << (_blocks-1)*blocksize+lastblocksize);
85 for ( uint32_t b = 0 ; b < _blocks ; b++ ) {
87 DBOUT(L
"OutputsDAQmx::Write writeabort");
90 DBOUT(L
"OutputsDAQmx::Write block " << b);
93 , ((b==_blocks-1)?lastblocksize:blocksize),
false, 2, DAQmx_Val_GroupByScanNumber);
108 task.
WriteAnalogI16(std::make_shared<std::vector<int16_t>>(4,0)->data(), 1,
true);
Parameters for x/y-scanner/fast z/Pockels signal generation with NI-DAQmx where all output channels (...
ScopeString commontrigger
The trigger channel which is the internal common master trigger for all devices.
void SetRegeneration(const bool &_regenerate)
Sets the mode of sample regeneration.
The master parameters class.
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
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::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
void Start() override
Start task, last the first output task (all other are waiting for it as their start trigger)...
std::wstring ClockString(const scope::DaqTimingHelper::Mode &_timing, const std::wstring &_externalclocksource)
Generates a string for the sample clock from daq_timing.
std::atomic< bool > writeabort
Signal for aborting a write operation (since write is performed in several blocks, abort can happen in between)
ScopeString triggerchannel
channel name for trigger input
uInt32 ConfigureBuffer(const uInt32 &_sampsperchannel)
Configure the daqmx output buffer on the PC.
ZeroOutputsDAQmx(const parameters::OutputsDAQmx &_params)
Create a simple tasks for writing a scalar zero to all channels.
ScopeString referenceclocksource
source terminal of the reference clock
void ExportSignal(int32 _signal, const std::wstring &_terminal)
Exports a signal to an output terminal.
OutputsDAQmx(const uint32_t &_area, const parameters::OutputsDAQmx &_outputparams, const parameters::Scope &_params)
Creates the task for scanner, pockels, and fast-z output with NI DAQmx.
Timeseries timeseries
the TimeseriesParameters
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.
ScopeValue< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
int32_t Write(const std::vector< int16_t > &_xyzp, const uint32_t &_blocks=1) override
Writes values for one frame of X-Y-fastZ and pockels data to the device buffer.
ScopeString externalclocksource
source terminal of an external clock
This is the include file for standard system include files, or project specific include files that ar...
ScopeValue< DaqMode > requested_mode
requested acquisition mode (see DaqModeHelper)
void Start(void)
Starts the task.
ScopeNumber< bool > triggered
the current/first repeat is triggered on triggerchannel
In here all declarations for all kinds of datatypes Scope needs.
#define DBOUT(s)
A debug output to the debug console.
ScopeString channelsstring
the four analog output channels to use for x, y, z, Pockels
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
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.
ScopeString exportpixelclockterminal
terminal to which the pixel/sampleclock is exported
void CreateTask(const std::wstring &_name=L"")
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.
const uint32_t area
which area this one is for
ScopeNumber< double > range
Output range of the DAC to use for all outputs.
~OutputsDAQmx()
Stop and clear output task.
DAQmx::CDAQmxAnalogOutTask task
The DAQmx task for x/y-scanners/fast z/Pockels clocked by a pixel clock.
void Stop() override
Stop task.
void ConfigureDigStartTrigger(const std::wstring &_src, const int32 &_trigedge=DAQmx_Val_Rising)
Configures the start trigger.
void Stop(void)
Stops the task.
Wraps hardware connection for signal output to scanners, fast z control, and pockels cell...