Scope
IO.cpp
1 #include "stdafx.h"
2 #include "IO.h"
3 #include "devices/daqmx/DAQmxTask.h"
4 #include "helpers/ScopeException.h"
5 
6 namespace scope {
7 
8 namespace parameters {
9 
10 // Save some typing here...
11 using namespace boost::property_tree;
12 
13 
14 Inputs::Inputs()
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") {
19 }
20 
21 void Inputs::Load(const wptree& _pt) {
24  rangetype.SetFromPropertyTree(_pt);
26 }
27 
28 void Inputs::Save(wptree& _pt) const {
31  rangetype.AddToPropertyTree(_pt);
33 }
34 
36 }
37 
38 std::unique_ptr<Inputs> Inputs::Factory(const InputsType& _type) {
39  switch ( _type.t ) {
40  case InputsTypeHelper::InputsDAQmx:
41  return InputsDAQmx::Create();
42  case InputsTypeHelper::InputsFPGA:
43  return InputsFPGA::Create();
44  case InputsTypeHelper::InputsFPGAIO6587:
45  return InputsFPGAIO6587::Create();
46  case InputsTypeHelper::InputsFPGADigitalDemultiplexer:
48  case InputsTypeHelper::InputsFPGAPhotonCounter:
50  case InputsTypeHelper::InputsFPGAIO5771:
51  return InputsFPGAIO5771::Create();
52  case InputsTypeHelper::InputsFPGAIO5751:
53  return InputsFPGAIO5751::Create();
54  case InputsTypeHelper::InputsFPGAAnalogDemultiplexer:
56  case InputsTypeHelper::InputsFPGAAnalogIntegrator:
58  case InputsTypeHelper::InputsFPGAResonanceScanner:
60  default:
61  return InputsDAQmx::Create();
62  }
63 }
64 
65 InputsDAQmx::InputsDAQmx()
66  : channelsstring(L"PXI-6259_0/ai0:1", L"ChannelsString")
67  , range(0.5, 0.1, 10, L"Range_V")
68  , daq_timing(DaqTimingHelper::ReferenceClock, L"DAQTimingMethod")
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")
73  , sampling(DaqSamplingHelper::NonSimultaneousSampling, L"Sampling") {
74  uInt32 data = 0;
75  std::wostringstream stream;
76  DAQmxGetSysNIDAQMajorVersion(&data);
77  stream << data;
78  DAQmxGetSysNIDAQMinorVersion(&data);
79  stream << L"." << data;
80  DAQmxGetSysNIDAQUpdateVersion(&data);
81  stream << L"." << data;
82  diagnosis.daqmxversion = stream.str();
83 }
84 
86  if ( sampling() == DaqSamplingHelper::SimultaneousSampling )
87  return 1/maxrateaggregate() * 1E6;
88  else
89  return channels()/maxrateaggregate() * 1E6;
90 }
91 
92 double InputsDAQmx::CoercedPixeltime(const double& _pixeltime) const {
93  // If oversampling pixeltime can only be integer multiple of minimum pixel time
94  // If not oversampling, supported pixel time is dependent on DAQmx::CoerceSampleRates (see there)
95  if ( oversampling() )
96  return std::floor(_pixeltime/MinimumPixeltime()) * MinimumPixeltime(); // Always floor here, not to coerce to pixeltime bigger than upper limit (causes circular call in Daq::CoercePixeltime)
97  else
98  return 1/DAQmx::PredictSampleRate(1/_pixeltime, channels(), referenceclockrate(), DAQmx_Val_AI);
99 }
100 
101 void InputsDAQmx::Load(const wptree& _pt) {
102  Inputs::Load(_pt);
105  daq_timing.SetFromPropertyTree(_pt);
110  sampling.SetFromPropertyTree(_pt);
111 }
112 
113 void InputsDAQmx::Save(wptree& _pt) const {
114  Inputs::Save(_pt);
117  daq_timing.AddToPropertyTree(_pt);
122  sampling.AddToPropertyTree(_pt);
123 }
124 
126 }
127 
128 InputsFPGA::InputsFPGA() {
129  // Not oversampling is standard for FPGA, since FPGA generates the pixel clock for the output task
130  oversampling = false;
131 }
132 
134  return 1.0; // in µs
135 }
136 
137 double InputsFPGA::CoercedPixeltime(const double& _pixeltime) const {
138  return _pixeltime;
139 }
140 
141 void InputsFPGA::Load(const wptree& _pt) {
142  Inputs::Load(_pt);
143 }
144 
145 void InputsFPGA::Save(wptree& _pt) const {
146  Inputs::Save(_pt);
147 }
148 
151 }
152 
153 InputsFPGAIO6587::InputsFPGAIO6587()
154  : samplingrate(1E9, 1E8, 1.4E9, L"SamplingRate_Hz") {
155 }
156 
158  return 60.0 / samplingrate() * 1E6; // in µs. Must be multiple of 60 samples, since FPGA acquistion loop works on arrays of 60 samples
159 }
160 
161 double InputsFPGAIO6587::CoercedPixeltime(const double& _pixeltime) const {
162  // must be multiple of 60 samples
163  return std::floor(_pixeltime/MinimumPixeltime()) * MinimumPixeltime(); // Always floor here, not to coerce to pixeltime bigger than upper limit (causes circular call in Daq::CoercePixeltime)
164 }
165 
166 void InputsFPGAIO6587::Load(const wptree& _pt) {
167  InputsFPGA::Load(_pt);
169 }
170 
171 void InputsFPGAIO6587::Save(wptree& _pt) const {
172  InputsFPGA::Save(_pt);
174 }
175 
178 }
179 
180 
181 InputsFPGADigitalDemultiplexer::InputsFPGADigitalDemultiplexer()
182  : countmode(true, false, true, L"CountingMode") {
183 }
184 
185 void InputsFPGADigitalDemultiplexer::Load(const wptree& _pt) {
188 }
189 
190 void InputsFPGADigitalDemultiplexer::Save(wptree& _pt) const {
193 }
194 
197 }
198 
199 InputsFPGAPhotonCounter::InputsFPGAPhotonCounter()
200  : countmode(true, false, true, L"CountingMode") {
201 }
202 
203 void InputsFPGAPhotonCounter::Load(const wptree& _pt) {
206 }
207 
208 void InputsFPGAPhotonCounter::Save(wptree& _pt) const {
211 }
212 
215 }
216 
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"){
222 }
223 
225  return 8.0E6 / 1.5E9 ; // in µs. Samples at 1.5GHz. Must be multiple of 8 samples, since FPGA acquires 8 samples in one loop cycle
226 }
227 
228 double InputsFPGAIO5771::CoercedPixeltime(const double& _pixeltime) const {
229  // must be multiple of 8 samples
230  return std::floor(_pixeltime/MinimumPixeltime()) * MinimumPixeltime(); // Always floor here, not to coerce to pixeltime bigger than upper limit (causes circular call in Daq::CoercePixeltime)
231 }
232 
233 void InputsFPGAIO5771::Load(const wptree& _pt) {
234  InputsFPGA::Load(_pt);
239 }
240 
241 void InputsFPGAIO5771::Save(wptree& _pt) const {
242  InputsFPGA::Save(_pt);
247 }
248 
251 }
252 
253 
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") {
258 }
259 
261  return 1/AcquisitionClockRate()*1E6; // in microseconds.
262 }
263 
265  return 10;
266 }
267 
268 double InputsFPGAIO5751::CoercedPixeltime(const double& _pixeltime) const {
269  // 2, because the fastest possible acqusition would lead to performance problems in Scope
270  return std::max(2*MinimumPixeltime(), std::floor(_pixeltime*AcquisitionClockRate()/1E6) * 1E6/AcquisitionClockRate()); // Always floor here, not to coerce to pixeltime bigger than upper limit (causes circular call in Daq::CoercePixeltime)
271 }
272 
273 void InputsFPGAIO5751::Load(const wptree& _pt) {
274  InputsFPGA::Load(_pt);
278 }
279 
280 void InputsFPGAIO5751::Save(wptree& _pt) const {
281  InputsFPGA::Save(_pt);
285 }
286 
289 }
290 
291 
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") {
297 }
298 
299 void InputsFPGAAnalogDemultiplexer::Load(const wptree& pt) {
305 }
306 
307 void InputsFPGAAnalogDemultiplexer::Save(wptree& pt) const {
313 }
314 
317 }
318 
319 
320 InputsFPGAAnalogIntegrator::InputsFPGAAnalogIntegrator()
321  : BitshiftCh1(3, 0, 16, L"BitshiftCh1")
322  , BitshiftCh2(3, 1, 16, L"BitshiftCh2") {
323 }
324 
325 void InputsFPGAAnalogIntegrator::Load(const wptree& pt) {
329 }
330 
331 void InputsFPGAAnalogIntegrator::Save(wptree& pt) const {
335 }
336 
339 }
340 
341 
342 InputsFPGAResonanceScanner::InputsFPGAResonanceScanner()
343  : BitshiftCh1(0, 0, 16, L"BitshiftCh1")
344  , BitshiftCh2(0, 0, 16, L"BitshiftCh2") {
345 }
346 
347 void InputsFPGAResonanceScanner::Load(const wptree& pt) {
351 }
352 
353 void InputsFPGAResonanceScanner::Save(wptree& pt) const {
357 }
358 
361 }
362 
363 
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"){
370 
371 }
372 
373 void Outputs::Load(const wptree& _pt) {
379 }
380 
381 void Outputs::Save(wptree& _pt) const {
387 }
388 
390  // too lazy to do it...
391 }
392 
393 std::unique_ptr<Outputs> Outputs::Factory(const OutputsType& _type) {
394  switch ( _type.t ) {
395  case OutputsTypeHelper::OutputsDAQmx:
396  return OutputsDAQmx::Create();
397  case OutputsTypeHelper::OutputsDAQmxLineClock:
399  case OutputsTypeHelper::OutputsDAQmxSlave:
400  return OutputsDAQmxSlave::Create();
401  case OutputsTypeHelper::OutputsDAQmxResonance:
403  default:
404  return OutputsDAQmx::Create();
405  }
406 }
407 
408 OutputsDAQmx::OutputsDAQmx()
409  : channelsstring(L"PXI-6259_0/ao0:3", L"ChannelsString")
410  , daq_timing(DaqTimingHelper::ReferenceClock, L"DAQTimingMethod")
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") {
416 }
417 
418 double OutputsDAQmx::CoercedPixeltime(const double& _pixeltime) const {
419  return std::max(MinimumPixeltime(), 1/DAQmx::PredictSampleRate(1/_pixeltime, 4, referenceclockrate(), DAQmx_Val_AO));
420 }
421 
423  return minimumpixeltime();
424 }
425 
426 void OutputsDAQmx::Load(const wptree& _pt) {
427  Outputs::Load(_pt);
429  daq_timing.SetFromPropertyTree(_pt);
435 }
436 
437 void OutputsDAQmx::Save(wptree& _pt) const {
438  Outputs::Save(_pt);
440  daq_timing.AddToPropertyTree(_pt);
446 }
447 
450 }
451 
452 OutputsDAQmxLineClock::OutputsDAQmxLineClock()
453  : xpout(L"PXI-6259_0/ao0:1", L"XPOutString")
454  , yzout(L"PXI-6259_1/ao0:1", L"YZOutString")
455  , pixel_timing(DaqTimingHelper::ReferenceClock, L"PixelTimingMethod")
456  , line_timing(DaqTimingHelper::ReferenceClock, L"LineTimingMethod")
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") {
464 }
465 
466 double OutputsDAQmxLineClock::CoercedPixeltime(const double& _pixeltime) const {
467  return std::max(MinimumPixeltime(), 1/DAQmx::PredictSampleRate(1/_pixeltime, 2, pixel_referenceclockrate(), DAQmx_Val_AO));
468 }
469 
471  return minimumpixeltime();
472 }
473 
474 void OutputsDAQmxLineClock::Load(const wptree& _pt) {
475  Outputs::Load(_pt);
478  pixel_timing.SetFromPropertyTree(_pt);
479  line_timing.SetFromPropertyTree(_pt);
487 }
488 
489 void OutputsDAQmxLineClock::Save(wptree& _pt) const {
490  Outputs::Save(_pt);
493  pixel_timing.AddToPropertyTree(_pt);
494  line_timing.AddToPropertyTree(_pt);
502 }
503 
504 OutputsDAQmxSlave::OutputsDAQmxSlave()
505  : zpout(L"PXI-6259_1/ao0:1", L"ZPOutString")
506  , timing(DaqTimingHelper::ReferenceClock, L"DAQTimingMethod")
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") {
511 
512 }
513 
516 }
517 
518 double OutputsDAQmxSlave::CoercedPixeltime(const double& _pixeltime) const {
519  return std::max(MinimumPixeltime(), 1/DAQmx::PredictSampleRate(1/_pixeltime, 2, referenceclockrate(), DAQmx_Val_AO));
520 }
521 
523  return minimumpixeltime();
524 }
525 
526 void OutputsDAQmxSlave::Load(const wptree& _pt) {
527  Outputs::Load(_pt);
529  timing.SetFromPropertyTree(_pt);
534 }
535 
536 void OutputsDAQmxSlave::Save(wptree& _pt) const {
537  Outputs::Save(_pt);
539  timing.AddToPropertyTree(_pt);
544 }
545 
548 }
549 
550 
551 OutputsDAQmxResonance::OutputsDAQmxResonance()
552  : channelsstring(L"PXI-6259_0/ao0:1", L"ChannelsString")
553  , zoomchannelstring(L"PXI-6259_0/port0/line1:2", L"ZoomChannelsString")
554  , daq_timing(DaqTimingHelper::ReferenceClock, DaqTimingHelper::OnboardClock, DaqTimingHelper::External, L"DAQTimingMethod")
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") {
560 }
561 
562 double OutputsDAQmxResonance::CoercedPixeltime(const double& _pixeltime) const {
563  return std::max(MinimumPixeltime(), 1/DAQmx::PredictSampleRate(1/_pixeltime, 4, referenceclockrate(), DAQmx_Val_AO));
564 }
565 
567  return minimumpixeltime();
568 }
569 
570 void OutputsDAQmxResonance::Load(const wptree& _pt) {
571  Outputs::Load(_pt);
574  daq_timing.SetFromPropertyTree(_pt);
580 }
581 
582 void OutputsDAQmxResonance::Save(wptree& _pt) const {
583  Outputs::Save(_pt);
586  daq_timing.AddToPropertyTree(_pt);
592 }
593 
596 }
597 
598 
599 Daq::Daq(const bool& _isslave)
600  : isslave(_isslave)
601  , inputs(Inputs::Factory(InputsTypeHelper::SCOPE_INPUTS_PARAMETERS_T))
602  , outputs((_isslave)?Outputs::Factory(OutputsTypeHelper::SCOPE_SLAVEOUTPUTS_T):Outputs::Factory(OutputsTypeHelper::SCOPE_OUTPUTS_T))
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") {
610 
611  // Pixeltime lower limit is maximum of minimum pixel times of inputs and outputs (important for FPGA/DAQmx combinations)
612  pixeltime.SetLimits(std::max(inputs->MinimumPixeltime(), outputs->MinimumPixeltime()), pixeltime.ul());
613  pixeltime.ConnectOther(std::bind(&Daq::CoercePixeltime, this));
614 }
615 
616 Daq::Daq(const Daq& _daq)
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) {
627 
628  // Pixeltime lower limit is maximum of minimum pixel times of inputs and outputs (important for FPGA/DAQmx combinations)
629  pixeltime.SetLimits(std::max(inputs->MinimumPixeltime(), outputs->MinimumPixeltime()), pixeltime.ul());
630  pixeltime.ConnectOther(std::bind(&Daq::CoercePixeltime, this));
631 }
632 
633 Daq& Daq::operator=(const Daq& _daq) {
634  if (isslave != _daq.isslave )
635  throw ScopeException(__FUNCTION__);
636 
637  inputs = _daq.inputs->Clone();
638  outputs = _daq.outputs->Clone();
639 
640  shutterline = _daq.shutterline;
642  pixeltime = _daq.pixeltime;
643  scannerdelay = _daq.scannerdelay;
644  averages = _daq.averages;
647 
648  // Pixeltime lower limit is maximum of minimum pixel times of inputs and outputs (important for FPGA/DAQmx combinations)
649  pixeltime.SetLimits(std::max(inputs->MinimumPixeltime(), outputs->MinimumPixeltime()), pixeltime.ul());
650  pixeltime.ConnectOther(std::bind(&Daq::CoercePixeltime, this));
651 
652  return *this;
653 }
654 
655 int32_t Daq::ScannerDelaySamples(const bool& _respectoversampling) const {
656  if ( inputs->oversampling() && _respectoversampling )
657  return round2i32(scannerdelay() / inputs->MinimumPixeltime());
658  else
659  return round2i32(scannerdelay() / pixeltime());
660 }
661 
662 void Daq::Load(const wptree& _pt) {
663  inputs->Load(_pt.get_child(L"inputs"));
664  outputs->Load(_pt.get_child(L"outputs"));
672  // easier than to connect from samplingtype, maxrateaggregate, and channels
673  pixeltime.SetLimits(std::max(inputs->MinimumPixeltime(), outputs->MinimumPixeltime()), pixeltime.ul());
674 }
675 
676 void Daq::Save(wptree& _pt) const {
677  wptree ptinputs;
678  wptree ptoutputs;
679  inputs->Save(ptinputs);
680  _pt.add_child(L"inputs", ptinputs);
681  outputs->Save(ptoutputs);
682  _pt.add_child(L"outputs", ptoutputs);
690 }
691 
692 void Daq::SetReadOnlyWhileScanning(const RunState& _runstate) {
693  inputs->SetReadOnlyWhileScanning(_runstate);
694  outputs->SetReadOnlyWhileScanning(_runstate);
695  switch ( static_cast<RunStateHelper::Mode>(_runstate) ) {
696  case RunStateHelper::Mode::Stopped:
697  pixeltime.SetRWState(true);
698  averages.SetRWState(true);
699  scannerdelay.SetRWState(true);
700  break;
701  // RESONANCE CODE
702  case RunStateHelper::Mode::RunningSingle:
703  //if( SCOPE_USE_RESONANCESCANNER )
704  // scannerdelay.SetRWState(false);
705  case RunStateHelper::Mode::RunningStack:
706  //if( SCOPE_USE_RESONANCESCANNER )
707  // scannerdelay.SetRWState(false);
708  case RunStateHelper::Mode::RunningTimeseries:
709  scannerdelay.SetRWState(false);
710  case RunStateHelper::Mode::RunningContinuous:
711  //if( SCOPE_USE_RESONANCESCANNER )
712  // scannerdelay.SetRWState(false);
713  default:
714  pixeltime.SetRWState(false);
715  averages.SetRWState(false);
716  }
717 }
718 
720  // If oversampling, input samples at maximum rate and pixel time can only be integer multiple of that sampling time
721  // Otherwise, rate is given by DAQmx or by FPGA
722  const double inputtime = inputs->CoercedPixeltime(pixeltime());
723  const double outputtime = outputs->CoercedPixeltime(pixeltime());
724  DBOUT(L"Daq::CoercePixeltime " << pixeltime() << L" " << inputtime << L" " << outputtime);
725  // Only set if not good time already (otherwise we get circular calls...)
726  DBOUT(L"Daq::CoercePixeltime inputtime " << inputtime);
727  DBOUT(L"Daq::CoercePixeltime outputtime " << outputtime);
728  // Do it like this to avoid trouble because of limited precision/rounding errors etc
729  if ( !(std::fabs(pixeltime()-inputtime) < std::numeric_limits<double>::epsilon()) )
730  pixeltime.Set(inputtime);
731 }
732 
733 
734 }
735 
736 }
ScopeNumber< uint32_t > preframelines
number of lines to acquire before each frame, e.g.
Definition: IO.h:40
ScopeNumber< double > range
Input range of the ADC.
Definition: IO.h:73
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:213
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
Definition: IO.h:727
static std::unique_ptr< Inputs > Create()
Create method for factory.
Definition: IO.h:65
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:203
ScopeNumber< uint8_t > BitshiftCh2
Number of bits to shift U32 right before casting to U16 (channel 2)
Definition: IO.h:425
static std::unique_ptr< Outputs > Create()
Create function for factory.
Definition: IO.h:561
ScopeString referenceclocksource
source terminal of the reference clock
Definition: IO.h:79
ScopeValue< DaqSampling > sampling
simultaneous sampling or not
Definition: IO.h:92
ScopeNumber< bool > countmode
Type of photon counting.
Definition: IO.h:257
std::unique_ptr< Outputs > outputs
the output parameters
Definition: IO.h:767
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:518
ScopeString pixel_referenceclocksource
source terminal of the reference clock for pixel sampling clock
Definition: IO.h:625
ScopeNumber< double > samplingrate
Sampling rate of the IO modules clock (which is double the clock rate of the FPGA acquisition loop) i...
Definition: IO.h:184
ScopeNumber< uint32_t > requested_frames
number of frames to acquire
Definition: IO.h:788
ScopeString zoomchannelstring
the digital channel to use for the resonance scanner zoom factor
Definition: IO.h:714
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:426
double MinimumPixeltime() const override
Definition: IO.cpp:566
double MinimumPixeltime() const override
Definition: IO.cpp:470
ScopeNumber< uint32_t > BaselineCh1
Baseline U16 value to set zero in channel 1.
Definition: IO.h:336
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.
Definition: ScopeValue.h:67
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:361
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
Definition: IO.h:779
ScopeNumber< bool > oversampling
if yes acquisition with maximum rate allowed by device (1/MinimumPixelTime(), calculated from maxrate...
Definition: IO.h:34
Simple exception class for Scope.
Definition: ScopeException.h:9
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:21
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:359
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
Definition: IO.h:577
ScopeNumber< double > maxrateaggregate
maximum aggregate sampling rate (divide this by number of channels to get per channel rate for non-si...
Definition: IO.h:89
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:418
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:373
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:526
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:474
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:202
ScopeNumber< double > minimumpixeltime
Minimum sample time for 2 channel output.
Definition: IO.h:622
ScopeNumber< double > minoutputpockels
minimum output voltage for scaling of the pockels signal
Definition: IO.h:535
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
Definition: ScopeValue.h:103
static std::unique_ptr< Outputs > Create()
Create function for factory.
Definition: IO.h:605
ScopeString externalclocksource
source terminal of an external clock for sampling clock (could be e.g.
Definition: IO.h:684
ScopeValue< DaqTiming > line_timing
where to get the line sampling clock from? Onboard, from external reference clock, or from external source
Definition: IO.h:617
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock.
Definition: IO.h:83
ScopeNumber< uint8_t > BitshiftA1Ch2
Number of bits to shift U32 right before casting to U16 (area 1 channel 2)
Definition: IO.h:369
ScopeNumber< uint32_t > resonance_frequency
frequency of the resonance scanner used, which is especially the frequency of the synchronization sig...
Definition: IO.h:791
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:141
ScopeNumber< uint8_t > BitshiftCh2
Number of bits to shift U32 right before casting to U16 (channel 2)
Definition: IO.h:475
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:489
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:161
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:35
ScopeNumber< double > minimumpixeltime
Minimum sample time for 4 channel output.
Definition: IO.h:720
All parameters for scanner data generation and pixel acquisition If you add/remove parameters or deri...
Definition: IO.h:747
double MinimumPixeltime() const override
Definition: IO.cpp:422
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...
Definition: ScopeNumber.h:174
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:536
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:233
ScopeNumber< uint32_t > BaselineCh2
Baseline U16 value to set zero in channel 2.
Definition: IO.h:339
ScopeNumber< double > referenceclockrate
rate in Hertz of the reference clock for sampling clock.
Definition: IO.h:681
ScopeString shutterline
digital output line of the shutter
Definition: IO.h:770
ScopeString referenceclocksource
source terminal of the reference clock
Definition: IO.h:573
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:228
double MinimumPixeltime() const override
Definition: IO.cpp:85
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:179
ScopeString channelsstring
How many input channels (if sampling non-simulataneous this influences the available sampling rates) ...
Definition: IO.h:70
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:331
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:273
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:208
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:662
Parameters for pixel acquisition, base class.
Definition: IO.h:18
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:325
ScopeNumber< uint8_t > BitshiftCh1
Number of bits to shift U32 right before casting to U16 (channel 1)
Definition: IO.h:422
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:176
ScopeNumber< uint8_t > BitshiftA2Ch1
Number of bits to shift U32 right before casting to U16 (area 2 channel 1)
Definition: IO.h:372
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:185
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:331
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:466
ScopeString exportpixelclockterminal
terminal to which the pixel/sampleclock is exported
Definition: IO.h:733
ScopeNumber< uint8_t > BaselineCh2
Baseline U8 value to set zero in channel 2 (NI5771 reads ~ -1..+1V as unsigned 8 bit number...
Definition: IO.h:307
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:113
ScopeValue< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
Definition: IO.h:567
Parameters for scanner data generation, base class.
Definition: IO.h:511
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:562
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:546
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:692
ScopeString externalclocksource
source terminal of an external clock
Definition: IO.h:580
ScopeString externalclocksource
source terminal of an external clock
Definition: IO.h:730
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.
Definition: IO.h:674
ScopeValue< Uint16Range > rangetype
which part of the uint16_t range is used for valid input signals
Definition: IO.h:37
ScopeString referenceclocksource
source terminal of the reference clock
Definition: IO.h:723
ScopeNumber< uint8_t > CutoffCh2
Cutoff U8 value to set zero in channel 2 (NI5771 reads ~ -1..+1V as unsigned 8 bit number...
Definition: IO.h:313
static std::unique_ptr< Outputs > Create()
Create function for factory.
Definition: IO.h:665
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:149
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:299
ScopeNumber< uint32_t > channels
number of channels to acquire
Definition: IO.h:31
ScopeNumber< uint8_t > BitshiftA2Ch2
Number of bits to shift U32 right before casting to U16 (area 2 channel 2)
Definition: IO.h:375
Describes the type of signals output to scanners/fast z/Pockels.
int32_t ScannerDelaySamples(const bool &_respectoversampling) const
Definition: IO.cpp:655
ScopeNumber< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
Definition: IO.h:717
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:347
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:570
double MinimumPixeltime() const override
Definition: IO.cpp:224
ScopeValue< DaqTiming > pixel_timing
where to get the pixel sampling clock from? Onboard, from external reference clock, or from external source
Definition: IO.h:614
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:417
ScopeValue< DaqTiming > daq_timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
Definition: IO.h:76
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:467
static std::unique_ptr< Inputs > Factory(const InputsType &_type)
Factory method to generate parameter sets for different scan types and put them into a ScannerVectorF...
Definition: IO.cpp:38
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:252
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:166
ScopeString channelsstring
the four analog output channels to use for x, y, z, Pockels
Definition: IO.h:708
ScopeNumber< double > pixel_referenceclockrate
rate in Hertz of the reference clock for pixel clock.
Definition: IO.h:632
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:514
Daq & operator=(const Daq &_daq)
Supply assignment operator because of the unique_ptrs to base class.
Definition: IO.cpp:633
static std::unique_ptr< Outputs > Create()
Create function for factory.
Definition: IO.h:705
#define DBOUT(s)
A debug output to the debug console.
Definition: helpers.h:153
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:92
ScopeString channelsstring
the four analog output channels to use for x, y, z, Pockels
Definition: IO.h:564
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:381
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:299
ScopeString line_referenceclocksource
source terminal of the reference clock for line sampling clock
Definition: IO.h:628
const bool isslave
true if belongs to a slave area
Definition: IO.h:761
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:389
ScopeString exportpixelclockterminal
terminal to which the pixel/sampleclock is exported
Definition: IO.h:583
double MinimumPixeltime() const override
Definition: IO.cpp:133
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:241
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:582
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:353
double MinimumPixeltime() const override
Definition: IO.cpp:260
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:280
ScopeString externalclocksource
source terminal of an external clock
Definition: IO.h:86
std::unique_ptr< Inputs > inputs
the input parameters
Definition: IO.h:764
double MinimumPixeltime() const override
Definition: IO.cpp:157
ScopeNumber< uint32_t > averages
number of images to average
Definition: IO.h:785
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:287
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:676
ScopeNumber< bool > countmode
Type of photon counting.
Definition: IO.h:207
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:268
ScopeNumber< double > line_referenceclockrate
rate in Hertz of the reference clock for line clock.
Definition: IO.h:636
void SetRWState(const bool &_state)
Sets readonly/read-write state.
ScopeNumber< double > range
Output range of the DAC to use for all outputs.
Definition: IO.h:526
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:337
ScopeString yzout
Analog output channel for y-scanner and fast z device (clocked by line clock)
Definition: IO.h:611
ScopeValue< DaqTiming > timing
where to get the sampling clock from? Onboard, from external reference clock, or from external source...
Definition: IO.h:671
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:190
ScopeNumber< double > minimumpixeltime
Minimum sample time for 4 channel output.
Definition: IO.h:570
Daq(const bool &_isslave)
Constructor.
Definition: IO.cpp:599
ScopeString pixel_externalclocksource
source terminal of an external clock for x and p pixel clock
Definition: IO.h:639
Describes the type of signal input from PMTs.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:28
double CoercedPixeltime(const double &_pixeltime) const override
Definition: IO.cpp:137
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.
Definition: IO.cpp:594
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:145
double MaximumPixeltime() const override
Definition: IO.cpp:264
ScopeNumber< uint8_t > BitshiftCh1
Number of bits to shift U32 right before casting to U16 (channel 1)
Definition: IO.h:472
double PredictSampleRate(const double &_desiredrate, const uint32_t &_nochannels, const double &_refclockrate, const int32 &_mode)
Predicts the actual sampling rate.
Definition: DAQmxTask.cpp:23
ScopeString switchresonanceline
digital output line turning the resonance scanner on and off
Definition: IO.h:773
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:315
Class for the DAQmx timing, either by onboard clock, through a reference clock or by an external cloc...
ScopeNumber< uint8_t > BaselineCh1
Baseline U8 value to set zero in channel 1 (NI5771 reads ~ -1..+1V as unsigned 8 bit number...
Definition: IO.h:304
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:125
double MinimumPixeltime() const override
Definition: IO.cpp:522
ScopeNumber< double > AcquisitionClockRate
Frequency in Hz of the clock used in the FPGA VI for the acquisition.
Definition: IO.h:342
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:448
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
Definition: IO.cpp:437
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
Definition: ScopeValue.h:108
ScopeNumber< double > maxoutputpockels
maximum output voltage for scaling of the pockels signal
Definition: IO.h:538
ScopeNumber< uint8_t > CutoffCh1
Cutoff U8 value to set zero in channel 1 (NI5771 reads ~ -1..+1V as unsigned 8 bit number...
Definition: IO.h:310
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...
Definition: IO.cpp:393
ScopeString line_externalclocksource
source terminal of an external clock for y and z line clock
Definition: IO.h:642
ScopeString zpout
Analog output channel for fast z and Pockels cell (clocked by a pixel clock)
Definition: IO.h:668
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:249
ScopeString referenceclocksource
source terminal of the reference clock for the sampling clock
Definition: IO.h:677
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:307
ScopeNumber< uint8_t > BitshiftA1Ch1
Number of bits to shift U32 right before casting to U16 (area 1 channel 1)
Definition: IO.h:366
ScopeNumber< double > scannerdelay
compensate, by waiting, the time that scanners lag behind the command voltage, in microseconds ...
Definition: IO.h:782
ScopeString xpout
Analog output channel for x-scanner and Pockels cell (clocked by pixel clock)
Definition: IO.h:608
ScopeNumber< double > minoutputscanner
minimum output voltage for scaling of the scanner signal
Definition: IO.h:529
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:101
ScopeNumber< double > maxoutputscanner
maximum output voltage for scaling of the scanner signal
Definition: IO.h:532
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:171
static std::unique_ptr< Inputs > Create()
Create function for factory.
Definition: IO.h:123
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:195
void CoercePixeltime()
Coerces pixeltime to a value that both inputs and outputs support.
Definition: IO.cpp:719