Scope
ScannerVectorFrameResonanceBiDi.cpp
1 #include "stdafx.h"
2 #include "ScannerVectorFrameResonanceBiDi.h"
3 
4 namespace scope {
5 
7  : ScannerVectorFrameBasic(ScannerVectorTypeHelper::ResonanceBiDi, _filltype) {
8 }
9 
11  // samples for x,y,z,pockels
12  // shorter vector than in other framescan modes, because the clock is the resonance scanner sync signal here
13  vecptr->resize(4 * svparameters->YTotalLines() / 2);
14  lookup->resize(svparameters->YTotalLines() / 2);
15 
16  FillY();
17  FillP();
18 }
19 
22  const Scaler<int16_t> scaletodevice(-daqparameters->outputs->range(), daqparameters->outputs->range()); // convert full device range to full range of int16_t
23  const double zoom = tmp->zoom();
24  const double range = daqparameters->outputs->maxoutputscanner() - daqparameters->outputs->minoutputscanner();
25  const double rangezoomed = range / zoom;
26 
27  // choose the maximum scanner amplitude for the larger frame side
28  double yrangezoomed;
29  if(tmp->xaspectratio >= tmp->yaspectratio) {
30  yrangezoomed = static_cast<double>(tmp->yaspectratio) / static_cast<double>(tmp->xaspectratio) * rangezoomed;
31  }
32  else {
33  yrangezoomed = zoom * tmp->yaspectratio / (tmp->xaspectratio * static_cast<double>(round2ui32(tmp->yaspectratio / tmp->xaspectratio * zoom))) * rangezoomed;
34  }
35  const double devicecenter = (daqparameters->outputs->minoutputscanner() + daqparameters->outputs->maxoutputscanner()) * 0.5; // center of the device range (e.g. scanner takes +-3V -> center is 0V)
36  double center = devicecenter + tmp->yoffset()*0.5*range; // center of the frame, offset +-1 means maximum offset
37  if ( center - 0.5*yrangezoomed < daqparameters->outputs->minoutputscanner() )
38  center = daqparameters->outputs->minoutputscanner()+0.5*yrangezoomed;
39  if ( center + 0.5*yrangezoomed > daqparameters->outputs->maxoutputscanner() )
40  center = daqparameters->outputs->maxoutputscanner()-0.5*yrangezoomed;
41  const double yminzoomed = center - 0.5*yrangezoomed; // minimum y value after zoom
42  const double ymaxzoomed = center + 0.5*yrangezoomed; // maximum y value after zoom
43  // The slope is related to the number of lines and not to the number of pixels, as in the other framescan modes
44  // (because the sync signal of the resonance scanner indicates a new line and it triggers the y scanner signal)
45  const double yscanslope = yrangezoomed / static_cast<double>(tmp->YScanLines());
46  const double yretraceslope = -yrangezoomed / static_cast<double>(tmp->YRetraceLines());
47  const uint32_t yscanlines = 4*tmp->YScanLines()/2;
48  const uint32_t ytotallines = 4*tmp->YTotalLines()/2;
49 
50  // fill in YScanLines() with increasing values (scanning) in Y
51  uint32_t y = 0;
52  size_t cy = 0;
53  for ( size_t i = cy ; i < yscanlines ; i+= 4, y+= 2 )
54  vecptr->at(i) = scaletodevice(yminzoomed + y * yscanslope);
55  y = 0;
56  // fill in YRetraceLines() with decreasing values (retracing) in Y
57  for ( size_t i = cy + yscanlines ; i < ytotallines ; i+= 4, y+= 2 )
58  vecptr->at(i) = scaletodevice(ymaxzoomed + y * yretraceslope);
59 }
60 
63  const uint32_t cutofflines = tmp->YCutoffLines() / 2;
64  const uint32_t scanlines = tmp->YScanLines() / 2;
65  const uint32_t totallines = tmp->YTotalLines() / 2;
66  // convert full device range to full range of int16_t
67  const Scaler<int16_t> scaletodevice(-daqparameters->outputs->range(), daqparameters->outputs->range());
68  // get the voltage corresponding to current etl position in micron and scale to device
69  const int16_t pockelsdev = scaletodevice(tmp->pockels());
70  // pockels starts at sample 3
71  size_t cp = 1;
72 
73  for ( size_t i = cp ; i < cp + 4*cutofflines ; i += 4 )
74  vecptr->at(i) = scaletodevice(0.0);
75  for ( size_t i = cp + 4*cutofflines ; i < cp + 4*scanlines ; i += 4 )
76  vecptr->at(i) = pockelsdev;
77  for ( size_t i = cp + 4*scanlines ; i < cp + 4*totallines ; i += 4 )
78  vecptr->at(i) = scaletodevice(0.0);
79 }
80 
81 
82 
83 }
virtual uint32_t YTotalLines() const
Definition: Framescan.h:181
std::unique_ptr< Outputs > outputs
the output parameters
Definition: IO.h:767
ScopeNumber< double > pockels
pockels cell value
Definition: Framescan.h:163
void FillY()
Fill the samples for the y scanner axis.
Parameters for a ScannerVectorFrameResonance.
Definition: Framescan.h:439
Parent class for frame scans.
ScopeNumber< double > xaspectratio
aspect ratio in x direction
Definition: Framescan.h:141
Class for scaling to the full range of a datatype.
Definition: helpers.h:113
ScopeNumber< double > yaspectratio
aspect ratio in y direction
Definition: Framescan.h:144
ScannerVectorFrameResonanceBiDi(const ScannerVectorFillType &_filltype)
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
void FillP()
Fill the samples for the Pockels cell (cutoff&retrace blanking for x and y)
void UpdateVector() override
Calculate the scanner vector based on the current parameters.
This is the include file for standard system include files, or project specific include files that ar...
parameters::ScannerVectorFrameBasic * svparameters
current scanner vector parameter set (needs to be pointer for dynamic_cast in derived classes and bec...
std::shared_ptr< std::vector< std::size_t > > lookup
gives the position in the image vector for each position in the acquired data vector (keep in mind th...
parameters::Daq * daqparameters
current daq parameter set
std::shared_ptr< std::vector< int16_t > > vecptr
the actual scanner vector (if fullframevector) with x, y, fast z, Pockels either interleaved (for ful...
Describes the scanner vector type.
ScopeNumber< double > yoffset
y offset
Definition: Framescan.h:157
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
Definition: Framescan.h:151