2 #include "ScannerVectorFrameSaw.h"
3 #include "controllers/ScopeLogger.h"
11 ScannerVectorFrameSaw::~ScannerVectorFrameSaw() {
17 LARGE_INTEGER countspre;
18 LARGE_INTEGER countspost;
19 LARGE_INTEGER countfreq;
20 QueryPerformanceCounter(&countspre);
24 case ScannerVectorFillTypeHelper::FullframeXYZP:
32 case ScannerVectorFillTypeHelper::LineXPColumnYZ:
38 case ScannerVectorFillTypeHelper::LineZP:
51 QueryPerformanceCounter(&countspost);
52 QueryPerformanceFrequency(&countfreq);
53 double time =
static_cast<double>((countspost.QuadPart-countspre.QuadPart))/
static_cast<double>(countfreq.QuadPart) * 1000;
54 DBOUT(L
"Time for updating vector " << time << L
" ms");
67 uint32_t imagepos = 0;
69 for ( uint32_t l = 0 ; l < ytotallines ; l++ ) {
70 for ( uint32_t x = 0 ; x < xtotalpixels ; x++ ) {
71 if ( (l >= cutofflines) && (l < scanlines) && (x >= cutoffpixels) && (x < scanpixels) )
72 lookup->at(datapos) = imagepos++;
92 const double zoom = tmp->
zoom();
94 const double rangezoomed = range / zoom;
99 xrangezoomed = rangezoomed;
105 double center = devicecenter + tmp->
xoffset()*0.5*range;
106 if ( center - 0.5*xrangezoomed < daqparameters->outputs->minoutputscanner() )
110 const double xminzoomed = center - 0.5*xrangezoomed;
111 const double xmaxzoomed = center + 0.5*xrangezoomed;
112 const double xscanslope = xrangezoomed /
static_cast<double>(tmp->
XScanPixels());
113 const double xretraceslope = -xrangezoomed /
static_cast<double>(tmp->
XRetracePixels());
114 const uint32_t xscansamples = 4*tmp->
XScanPixels();
123 for (
size_t i = cx ; i < cx+xscansamples ; i += 4, x++ )
124 vecptr->at(i) = scaletodevice(xminzoomed + x * xscanslope);
128 for (
size_t i = cx+xscansamples ; i < cx+xtotalsamples ; i += 4, x++ )
129 vecptr->at(i) = scaletodevice(xmaxzoomed + x * xretraceslope);
132 }
while ( cx < 4*framesamples );
140 const double zoom = tmp->
zoom();
142 const double rangezoomed = range / zoom;
150 yrangezoomed = rangezoomed;
153 double center = devicecenter + tmp->
yoffset()*0.5*range;
154 if ( center - 0.5*yrangezoomed < daqparameters->outputs->minoutputscanner() )
158 const double yminzoomed = center - 0.5*yrangezoomed;
159 const double ymaxzoomed = center + 0.5*yrangezoomed;
160 const double yscanslope = yrangezoomed /
static_cast<double>(tmp->
YScanLines());
162 const uint32_t yscanlinesamples = 4*tmp->
YScanLines()*linesamples;
164 uint32_t yretrace = 0;
169 if ( cy < (1 + yscanlinesamples) ) {
170 for (
size_t i = cy ; i < cy+4*linesamples ; i += 4 )
171 vecptr->at(i) = scaletodevice(yminzoomed + yscan * yscanslope);
176 for (
size_t i = cy ; i < cy+4*linesamples ; i += 4 ) {
177 vecptr->at(i) = scaletodevice(ymaxzoomed + yretrace * yretraceslope);
182 }
while ( cy < (4*framesamples + 1) );
191 size_t cz, cz_init, step_size;
193 if (
filltype == ScannerVectorFillTypeHelper::FullframeXYZP) {
194 cz = 2; cz_init = 2; step_size = 4;
196 if (
filltype == ScannerVectorFillTypeHelper::LineZP) {
197 cz = 0; cz_init = 0; step_size = 2;
202 for (
size_t i = cz ; i < cz + step_size*linesamples ; i += step_size )
203 vecptr->at(i) = fastzoutdev;
204 cz += step_size*linesamples;
205 }
while ( cz < (step_size*framesamples + cz_init) );
219 size_t cp, cp_init, step_size;
221 if (
filltype == ScannerVectorFillTypeHelper::FullframeXYZP) {
222 cp = 3; cp_init = 3; step_size = 4;
224 if (
filltype == ScannerVectorFillTypeHelper::LineZP) {
225 cp = 1; cp_init = 1; step_size = 2;
230 if ( (cp < (cp_init + step_size*cutofflines*linesamples))
231 || (cp > (cp_init + step_size*scanlines*linesamples)) ) {
232 for (
size_t i = cp ; i < cp + step_size*linesamples ; i += step_size )
233 vecptr->at(i) = scaletodevice(0.0);
237 for (
size_t i = cp ; i < cp+step_size*cutoffpixels ; i += step_size )
238 vecptr->at(i) = scaletodevice(0.0);
239 for (
size_t i = cp+step_size*cutoffpixels ; i < cp+step_size*scanpixels ; i += step_size )
240 vecptr->at(i) = scaletodevice(pockelsoutval);
241 for (
size_t i = cp+step_size*scanpixels ; i < cp+4*linesamples ; i += step_size )
242 vecptr->at(i) = scaletodevice(0.0);
244 cp += step_size*linesamples;
245 }
while ( cp < (step_size*framesamples + cp_init) );
249 if ( pockels_rotation > 0 ) {
250 auto length =
vecptr->size() / step_size;
252 size_t pr = p + pockels_rotation;
253 for ( uint32_t i = 0 ; i < length ; ++i ) {
254 std::swap(
vecptr->at(cp_init+step_size*p),
vecptr->at(cp_init+step_size*pr));
260 if ( pockels_rotation < 0 ) {
261 auto length =
vecptr->size() / step_size;
263 size_t pr = p - pockels_rotation;
264 for ( uint32_t i = 0 ; i < length ; ++i) {
265 std::swap(
vecptr->at(step_size*(length-p)-1),
vecptr->at(step_size*(length-pr)-1));
276 const double zoom = tmp->
zoom();
278 const double rangezoomed = range / zoom;
283 xrangezoomed = rangezoomed;
289 double center = devicecenter + tmp->
xoffset()*0.5*range;
290 if ( center - 0.5*xrangezoomed < daqparameters->outputs->minoutputscanner() )
294 const double xminzoomed = center - 0.5*xrangezoomed;
295 const double xmaxzoomed = center + 0.5*xrangezoomed;
296 const double xscanslope = xrangezoomed /
static_cast<double>(tmp->
XScanPixels());
297 const double xretraceslope = -xrangezoomed /
static_cast<double>(tmp->
XRetracePixels());
310 for (
size_t i = cx ; i < cx+xcutoffsamples ; i += 2, ++x ) {
312 vecptr->at(i) = scaletodevice(xminzoomed + x * xscanslope);
316 for (
size_t i = cx+xcutoffsamples ; i < cx+xcutoffsamples+ximagesamples ; i += 2, ++x ) {
318 vecptr->at(i) = scaletodevice(xminzoomed + x * xscanslope);
320 vecptr->at(i+1) = scaletodevice(pockelsoutval);
324 for (
size_t i = cx+xcutoffsamples+ximagesamples ; i < cx+xtotalsamples ; i += 2, ++x ) {
326 vecptr->at(i) = scaletodevice(xmaxzoomed + x * xretraceslope);
333 if ( pockels_rotation > 0 ) {
334 auto length = xtotalsamples;
336 size_t pr = p + pockels_rotation*2;
337 for ( uint32_t i = 0 ; i < length ; ++i ) {
344 if ( pockels_rotation < 0 ) {
345 auto length = xtotalsamples;
347 size_t pr = p + pockels_rotation*2;
348 for ( uint32_t i = 0 ; i < length ; ++i) {
360 const double zoom = tmp->
zoom();
362 const double rangezoomed = range / zoom;
369 yrangezoomed = rangezoomed;
372 double center = devicecenter + tmp->
yoffset()*0.5*range;
373 if ( center - 0.5*yrangezoomed < daqparameters->outputs->minoutputscanner() )
377 const double yminzoomed = center - 0.5*yrangezoomed;
378 const double ymaxzoomed = center + 0.5*yrangezoomed;
379 const double yscanslope = yrangezoomed /
static_cast<double>(tmp->
YScanLines());
380 const double yretraceslope = -yrangezoomed /
static_cast<double>(tmp->
YRetraceLines());
383 const uint32_t yimagesamples = 2*tmp->
YImageLines();
384 const uint32_t ytotalsamples = 2*tmp->
YTotalLines();
393 for (
size_t i = cy ; i < cy+ycutoffsamples+yimagesamples ; i += 2, ++y ) {
395 vecptr->at(i) = scaletodevice(yminzoomed + y * yscanslope);
397 vecptr->at(i+1) = fastzoutdev;
401 for (
size_t i = cy+ycutoffsamples+yimagesamples ; i < cy+ytotalsamples ; i += 2, ++y ) {
403 vecptr->at(i) = scaletodevice(ymaxzoomed + y * yretraceslope);
405 vecptr->at(i+1) = fastzoutdev;
422 for (
size_t i = 0 ; i < xcutoffsamples ; i+=2 ) {
423 vecptr->operator[](i) = fastzoutdev;
424 vecptr->operator[](i+1) = 0;
426 for (
size_t i = xcutoffsamples ; i < xcutoffsamples+ximagesamples ; i+=2 ) {
427 vecptr->operator[](i) = fastzoutdev;
428 vecptr->operator[](i+1) = pockelsoutval;
430 for (
size_t i = xcutoffsamples+ximagesamples ; i < xtotalsamples ; i+=2 ) {
431 vecptr->operator[](i) = fastzoutdev;
432 vecptr->operator[](i+1) = 0;
438 const size_t length =
vecptr->size();
439 if ( _rotateby > 0 ) {
441 size_t pr = p + _rotateby*_interleavedfactor;
442 for ( uint32_t i = 0 ; i < length ; i += _interleavedfactor ) {
445 p = (p+_interleavedfactor)%length;
446 pr = (pr+_interleavedfactor)%length;
449 if ( _rotateby < 0 ) {
451 size_t pr = p + _rotateby*_interleavedfactor;
452 for ( uint32_t i = 0 ; i <
vecptr->size() ; i += _interleavedfactor ) {
455 p = (p+_interleavedfactor)%length;
456 pr = (pr+_interleavedfactor)%length;
virtual uint32_t YTotalLines() const
virtual uint32_t XTotalPixels() const
std::unique_ptr< Outputs > outputs
the output parameters
uint32_t TotalPixels() const override
ScopeNumber< double > pockels
pockels cell value
void FillZP()
Fill the samples for fast z and Pockels for one line, used for slave areas.
Simple exception class for Scope.
void UpdateVector() override
Calculate the scanner vector based on the current parameters.
virtual uint32_t XImagePixels() const
Parent class for frame scans.
void FillP()
Fill the samples for the Pockels cell (cutoff&retrace blanking for x and y)
ScannerVectorFrameSaw(const ScannerVectorFillType &_filltype)
ScopeNumber< double > xaspectratio
aspect ratio in x direction
Class for scaling to the full range of a datatype.
void FillYZ()
Fill the samples for y and fast z for one column (one sample per line).
ScopeNumber< double > yaspectratio
aspect ratio in y direction
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
void FillLookup()
Fill in the lookup vector.
This is the include file for standard system include files, or project specific include files that ar...
uint32_t XRetracePixels() const
int32_t ScannerDelaySamples(const bool &_respectoversampling) const
parameters::ScannerVectorFrameBasic * svparameters
current scanner vector parameter set (needs to be pointer for dynamic_cast in derived classes and bec...
int32_t lookup_rotation
how much is the current lookup vector rotated to adjust for scannerdelay
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...
ScopeNumber< double > xoffset
x offset
#define DBOUT(s)
A debug output to the debug console.
const ScannerVectorFillTypeHelper::Mode filltype
The fill type.
parameters::Daq * daqparameters
current daq parameter set
uint32_t YTotalLines() const override
Parameters for a ScannerVectorFrameSaw.
std::shared_ptr< std::vector< int16_t > > vecptr
the actual scanner vector (if fullframevector) with x, y, fast z, Pockels either interleaved (for ful...
void RotateP(const size_t &_pstart, const size_t &_interleavedfactor, const int32_t &_rotateby)
Rotate the Pockels samples in the scanner vector.
Describes the scanner vector type.
ScopeNumber< double > yoffset
y offset
uint32_t XCutoffPixels() const
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
ScopeNumber< double > fastz
current fast z position
uint32_t TotalPixels() const override
uint32_t YRetraceLines() const
uint32_t YScanLines() const
uint32_t YCutoffLines() const
void FillY()
Fill the samples for the y scanner axis.
uint32_t XTotalPixels() const override
parameters::SCOPE_FPUZCONTROL_T * zparameters
current fast z parameter set
void FillXP()
Fill the samples for x and Pockels cell for one line.
void FillZ()
Fill the samples for the fast z axis (stays constant here)
void FillX()
Fill the samples for the x scanner axis.
uint32_t XScanPixels() const
virtual uint32_t YImageLines() const