3 #include "devices/daqmx/DAQmxTask.h"
4 #include "helpers/ScopeException.h"
15 : channels(2, 1, SCOPE_MAXCHANNELS, L
"Channels")
16 , oversampling(true, false, true, L
"Oversampling")
17 , rangetype(Uint16RangeHelper::full, L
"Uint16Range")
18 , preframelines(0, 0, 20, L
"PreframeLines") {
40 case InputsTypeHelper::InputsDAQmx:
42 case InputsTypeHelper::InputsFPGA:
44 case InputsTypeHelper::InputsFPGAIO6587:
46 case InputsTypeHelper::InputsFPGADigitalDemultiplexer:
48 case InputsTypeHelper::InputsFPGAPhotonCounter:
50 case InputsTypeHelper::InputsFPGAIO5771:
52 case InputsTypeHelper::InputsFPGAIO5751:
54 case InputsTypeHelper::InputsFPGAAnalogDemultiplexer:
56 case InputsTypeHelper::InputsFPGAAnalogIntegrator:
58 case InputsTypeHelper::InputsFPGAResonanceScanner:
65 InputsDAQmx::InputsDAQmx()
66 : channelsstring(L
"PXI-6259_0/ai0:1", L
"ChannelsString")
67 , range(0.5, 0.1, 10, L
"Range_V")
69 , referenceclocksource(L
"PXI_Clk10", L
"ReferenceClockSource")
70 , referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
71 , externalclocksource(L
"/PXI-6259_0/PXI_Trig1", L
"ExternalClockSource")
72 , maxrateaggregate(1000000, 100000, 20000000, L
"MaxRateAggregate_Hz")
75 std::wostringstream stream;
76 DAQmxGetSysNIDAQMajorVersion(&data);
78 DAQmxGetSysNIDAQMinorVersion(&data);
79 stream << L
"." << data;
80 DAQmxGetSysNIDAQUpdateVersion(&data);
81 stream << L
"." << data;
82 diagnosis.daqmxversion = stream.str();
86 if (
sampling() == DaqSamplingHelper::SimultaneousSampling )
128 InputsFPGA::InputsFPGA() {
153 InputsFPGAIO6587::InputsFPGAIO6587()
154 : samplingrate(1E9, 1E8, 1.4E9, L
"SamplingRate_Hz") {
181 InputsFPGADigitalDemultiplexer::InputsFPGADigitalDemultiplexer()
182 : countmode(true, false, true, L
"CountingMode") {
199 InputsFPGAPhotonCounter::InputsFPGAPhotonCounter()
200 : countmode(true, false, true, L
"CountingMode") {
217 InputsFPGAIO5771::InputsFPGAIO5771()
218 : BaselineCh1(127, 0, 255, L
"BaselineCh1")
219 , BaselineCh2(127, 0, 255, L
"BaselineCh2")
220 , CutoffCh1(127, 0, 255, L
"CutoffCh1")
221 , CutoffCh2(127, 0, 255, L
"CutoffCh2"){
225 return 8.0E6 / 1.5E9 ;
254 InputsFPGAIO5751::InputsFPGAIO5751()
255 : BaselineCh1(0, 0, 65535, L
"BaselineCh1")
256 , BaselineCh2(0, 0, 65535, L
"BaselineCh2")
257 , AcquisitionClockRate(40E6, 10E6, 50E6, L
"AcquisitionClockRate_Hz") {
292 InputsFPGAAnalogDemultiplexer::InputsFPGAAnalogDemultiplexer()
293 : BitshiftA1Ch1(3, 0, 16, L
"BitshiftA1Ch1")
294 , BitshiftA1Ch2(3, 0, 16, L
"BitshiftA1Ch2")
295 , BitshiftA2Ch1(3, 0, 16, L
"BitshiftA2Ch1")
296 , BitshiftA2Ch2(3, 0, 16, L
"BitshiftA2Ch2") {
320 InputsFPGAAnalogIntegrator::InputsFPGAAnalogIntegrator()
321 : BitshiftCh1(3, 0, 16, L
"BitshiftCh1")
322 , BitshiftCh2(3, 1, 16, L
"BitshiftCh2") {
342 InputsFPGAResonanceScanner::InputsFPGAResonanceScanner()
343 : BitshiftCh1(0, 0, 16, L
"BitshiftCh1")
344 , BitshiftCh2(0, 0, 16, L
"BitshiftCh2") {
364 Outputs::Outputs(
void)
365 : range(5, 0, 10, L
"OutputRange_V")
366 , minoutputscanner(-1, -10, 10, L
"MinOutputScanner_V")
367 , maxoutputscanner(1, -10, 10, L
"MaxOutputScanner_V")
368 , minoutputpockels(0.0, 0.0, 2.0, L
"MinOutputPockels_V")
369 , maxoutputpockels(2.0, 0.0, 2.0, L
"MaxOutputPockels_V"){
395 case OutputsTypeHelper::OutputsDAQmx:
397 case OutputsTypeHelper::OutputsDAQmxLineClock:
399 case OutputsTypeHelper::OutputsDAQmxSlave:
401 case OutputsTypeHelper::OutputsDAQmxResonance:
408 OutputsDAQmx::OutputsDAQmx()
409 : channelsstring(L
"PXI-6259_0/ao0:3", L
"ChannelsString")
411 , minimumpixeltime(0.8, 0.01, 10.0, L
"MinimumPixelTime_us")
412 , referenceclocksource(L
"PXI_Clk10", L
"ReferenceClockSource")
413 , referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
414 , externalclocksource(L
"/PXI-6259_0/PXI_Trig1", L
"ExternalClockSource")
415 , exportpixelclockterminal(L
"/PXI-6259_0/PFI12", L
"ExportPixelClockTerminal") {
452 OutputsDAQmxLineClock::OutputsDAQmxLineClock()
453 : xpout(L
"PXI-6259_0/ao0:1", L
"XPOutString")
454 , yzout(L
"PXI-6259_1/ao0:1", L
"YZOutString")
457 , minimumpixeltime(0.8, 0.01, 10.0, L
"MinimumPixelTime_us")
458 , pixel_referenceclocksource(L
"PXI_Clk10", L
"PixelReferenceClockSource")
459 , line_referenceclocksource(L
"PXI_Clk10", L
"LineReferenceClockSource")
460 , pixel_referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
461 , line_referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
462 , pixel_externalclocksource(L
"/PXI-6259_0/PXI_Trig1", L
"ExternalPixelClockString")
463 , line_externalclocksource(L
"/PXI-6259_1/PXI_Trig2", L
"ExternalLineClockString") {
504 OutputsDAQmxSlave::OutputsDAQmxSlave()
505 : zpout(L
"PXI-6259_1/ao0:1", L
"ZPOutString")
507 , minimumpixeltime(0.8, 0.01, 10.0, L
"MinimumPixelTime_us")
508 , referenceclocksource(L
"PXI_Clk10", L
"ReferenceClockSource")
509 , referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
510 , externalclocksource(L
"/PXI-6259_0/PXI_Trig1", L
"ExternalClockSource") {
529 timing.SetFromPropertyTree(_pt);
539 timing.AddToPropertyTree(_pt);
551 OutputsDAQmxResonance::OutputsDAQmxResonance()
552 : channelsstring(L
"PXI-6259_0/ao0:1", L
"ChannelsString")
553 , zoomchannelstring(L
"PXI-6259_0/port0/line1:2", L
"ZoomChannelsString")
555 , minimumpixeltime(0.02, 0.02, 10.0, L
"MinimumPixelTime_us")
556 , referenceclocksource(L
"PXI_Clk10", L
"ReferenceClockSource")
557 , referenceclockrate(10000000, 1000000, 100000000, L
"ReferenceClockRate_Hz")
558 , externalclocksource(L
"/PXI-6259_0/PFI1", L
"ExternalClockSource")
559 , exportpixelclockterminal(L
"/PXI-6259_0/PFI12", L
"ExportPixelClockTerminal") {
603 , shutterline(L
"PXI-6259_0/port0/line0", L
"ShutterLine")
604 , switchresonanceline(L
"PXI-6259_0/port0/line3", L
"SwitchResonanceLine")
605 , pixeltime(10, 0.02, 15, L
"Pixeltime_us")
606 , scannerdelay(0, -500, 500, L
"Scannerdelay_us")
607 , averages(1, 1, 32, L
"Averages")
608 , requested_frames(1, 1, 10000, L
"RequestedFrames")
609 , resonance_frequency(7910, 3000, 10000, L
"ResonanceFrequency_Hz") {
617 : isslave(_daq.isslave)
618 , inputs(_daq.inputs->Clone())
619 , outputs(_daq.outputs->Clone())
620 , shutterline(_daq.shutterline)
621 , switchresonanceline(_daq.switchresonanceline)
622 , pixeltime(_daq.pixeltime)
623 , scannerdelay(_daq.scannerdelay)
624 , averages(_daq.averages)
625 , requested_frames(_daq.requested_frames)
626 , resonance_frequency(_daq.resonance_frequency) {
656 if (
inputs->oversampling() && _respectoversampling )
663 inputs->Load(_pt.get_child(L
"inputs"));
664 outputs->Load(_pt.get_child(L
"outputs"));
680 _pt.add_child(L
"inputs", ptinputs);
682 _pt.add_child(L
"outputs", ptoutputs);
693 inputs->SetReadOnlyWhileScanning(_runstate);
694 outputs->SetReadOnlyWhileScanning(_runstate);
695 switch ( static_cast<RunStateHelper::Mode>(_runstate) ) {
696 case RunStateHelper::Mode::Stopped:
702 case RunStateHelper::Mode::RunningSingle:
705 case RunStateHelper::Mode::RunningStack:
708 case RunStateHelper::Mode::RunningTimeseries:
710 case RunStateHelper::Mode::RunningContinuous:
724 DBOUT(L
"Daq::CoercePixeltime " <<
pixeltime() << L
" " << inputtime << L
" " << outputtime);
726 DBOUT(L
"Daq::CoercePixeltime inputtime " << inputtime);
727 DBOUT(L
"Daq::CoercePixeltime outputtime " << outputtime);
729 if ( !(std::fabs(
pixeltime()-inputtime) < std::numeric_limits<double>::epsilon()) )
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
static std::unique_ptr< Outputs > Create()
Create function for factory.
std::unique_ptr< Outputs > outputs
the output parameters
double CoercedPixeltime(const double &_pixeltime) const override
ScopeString pixel_referenceclocksource
source terminal of the reference clock for pixel sampling clock
ScopeNumber< uint32_t > requested_frames
number of frames to acquire
ScopeString zoomchannelstring
the digital channel to use for the resonance scanner zoom factor
void Load(const wptree &pt) override
load parameters from a boost::property_tree
double MinimumPixeltime() const override
double MinimumPixeltime() const override
virtual T Set(const T &_v, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the value and calls both change signals if the value actually changed.
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
Simple exception class for Scope.
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
double CoercedPixeltime(const double &_pixeltime) const override
void Load(const wptree &pt) override
load parameters from a boost::property_tree
void Load(const wptree &pt) override
load parameters from a boost::property_tree
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeNumber< double > minimumpixeltime
Minimum sample time for 2 channel output.
ScopeNumber< double > minoutputpockels
minimum output voltage for scaling of the pockels signal
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
static std::unique_ptr< Outputs > Create()
Create function for factory.
ScopeString externalclocksource
source terminal of an external clock for sampling clock (could be e.g.
ScopeValue< DaqTiming > line_timing
where to get the line sampling clock from? Onboard, from external reference clock, or from external source
ScopeNumber< uint32_t > resonance_frequency
frequency of the resonance scanner used, which is especially the frequency of the synchronization sig...
void Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeNumber< double > minimumpixeltime
Minimum sample time for 4 channel output.
All parameters for scanner data generation and pixel acquisition If you add/remove parameters or deri...
double MinimumPixeltime() const override
T SetLimits(const T &_ll, const T &_ul, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the limits and coerces the value accordingly change signal is called if value has to be coerced...
void Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock for sampling clock.
ScopeString shutterline
digital output line of the shutter
ScopeString referenceclocksource
source terminal of the reference clock
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
double CoercedPixeltime(const double &_pixeltime) const override
ScopeString exportpixelclockterminal
terminal to which the pixel/sampleclock is exported
ScopeValue< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
Parameters for scanner data generation, base class.
double CoercedPixeltime(const double &_pixeltime) const override
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
ScopeString externalclocksource
source terminal of an external clock
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...
T::Mode t
the enum from the template class
ScopeNumber< double > minimumpixeltime
Minimum sample time for 2 channel output.
ScopeString referenceclocksource
source terminal of the reference clock
static std::unique_ptr< Outputs > Create()
Create function for factory.
Describes the type of signals output to scanners/fast z/Pockels.
int32_t ScannerDelaySamples(const bool &_respectoversampling) const
ScopeNumber< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeValue< DaqTiming > pixel_timing
where to get the pixel sampling clock from? Onboard, from external reference clock, or from external source
ScopeString channelsstring
the four analog output channels to use for x, y, z, Pockels
ScopeNumber< double > pixel_referenceclockrate
rate in Hertz of the reference clock for pixel clock.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Daq & operator=(const Daq &_daq)
Supply assignment operator because of the unique_ptrs to base class.
static std::unique_ptr< Outputs > Create()
Create function for factory.
#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 Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeString line_referenceclocksource
source terminal of the reference clock for line sampling clock
const bool isslave
true if belongs to a slave area
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
ScopeString exportpixelclockterminal
terminal to which the pixel/sampleclock is exported
void Save(wptree &pt) const override
save parameters into a boost:property_tree
std::unique_ptr< Inputs > inputs
the input parameters
ScopeNumber< uint32_t > averages
number of images to average
void Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeNumber< double > line_referenceclockrate
rate in Hertz of the reference clock for line clock.
void SetRWState(const bool &_state)
Sets readonly/read-write state.
ScopeNumber< double > range
Output range of the DAC to use for all outputs.
ScopeString yzout
Analog output channel for y-scanner and fast z device (clocked by line clock)
ScopeValue< DaqTiming > timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
ScopeNumber< double > minimumpixeltime
Minimum sample time for 4 channel output.
Daq(const bool &_isslave)
Constructor.
ScopeString pixel_externalclocksource
source terminal of an external clock for x and p pixel clock
Sampling method (depending on card etc), either simultaneous (clock independent of channel number) or...
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
double PredictSampleRate(const double &_desiredrate, const uint32_t &_nochannels, const double &_refclockrate, const int32 &_mode)
Predicts the actual sampling rate.
ScopeString switchresonanceline
digital output line turning the resonance scanner on and off
Class for the DAQmx timing, either by onboard clock, through a reference clock or by an external cloc...
double MinimumPixeltime() const override
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
boost::signals2::connection ConnectOther(signalchange_t::slot_type slot)
Connect signal to slot to other stuff.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
ScopeNumber< double > maxoutputpockels
maximum output voltage for scaling of the pockels signal
static std::unique_ptr< Outputs > Factory(const OutputsType &_type)
Factory method to generate parameter sets for different scan types and put them into a ScannerVectorF...
ScopeString line_externalclocksource
source terminal of an external clock for y and z line clock
ScopeString zpout
Analog output channel for fast z and Pockels cell (clocked by a pixel clock)
ScopeString referenceclocksource
source terminal of the reference clock for the sampling clock
ScopeNumber< double > scannerdelay
compensate, by waiting, the time that scanners lag behind the command voltage, in microseconds ...
ScopeString xpout
Analog output channel for x-scanner and Pockels cell (clocked by pixel clock)
ScopeNumber< double > minoutputscanner
minimum output voltage for scaling of the scanner signal
ScopeNumber< double > maxoutputscanner
maximum output voltage for scaling of the scanner signal
void CoercePixeltime()
Coerces pixeltime to a value that both inputs and outputs support.