From 8c491f18fdc76505082df44f55c97794f59fe1a7 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 31 Jul 2019 13:00:12 +0200 Subject: [PATCH] quad enabled with gap pixels without the extra vertical pixel line --- slsDetectorGui/src/qDrawPlot.cpp | 4 +- slsReceiverSoftware/include/DataProcessor.h | 6 ++- slsReceiverSoftware/include/GeneralData.h | 10 ++++- .../include/UDPBaseImplementation.h | 3 +- slsReceiverSoftware/include/UDPInterface.h | 3 +- .../include/UDPStandardImplementation.h | 3 +- slsReceiverSoftware/src/DataProcessor.cpp | 40 ++++++++++++------- slsReceiverSoftware/src/DataStreamer.cpp | 1 - .../src/UDPBaseImplementation.cpp | 3 +- .../src/UDPStandardImplementation.cpp | 18 +++++++-- .../src/slsReceiverTCPIPInterface.cpp | 6 ++- 11 files changed, 68 insertions(+), 29 deletions(-) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index c21b2f586..a7344ae8f 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -129,7 +129,7 @@ void qDrawPlot::SetupWidgetWindow(){ break; case slsDetectorDefs::EIGER: if (myDet->setQuad()) { - nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; + nPixelsX = (myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2) - 1; nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; } break; @@ -603,7 +603,7 @@ void qDrawPlot::SetScanArgument(int scanArg){ break; case slsDetectorDefs::EIGER: if (myDet->setQuad()) { - nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; + nPixelsX = (myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2) - 1; nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; } break; diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 6b7692430..0e43a6f33 100644 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -38,6 +38,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { * @param act pointer to activated * @param depaden pointer to deactivated padding enable * @param sm pointer to silent mode + * @param qe pointer to quad Enable * @param dataReadycb pointer to data ready call back function * @param dataModifyReadycb pointer to data ready call back function with modified * @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). @@ -45,7 +46,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, uint32_t* freq, uint32_t* timer, - bool* fp, bool* act, bool* depaden, bool* sm, + bool* fp, bool* act, bool* depaden, bool* sm, bool* qe, void (*dataReadycb)(char*, char*, uint32_t, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void *pDataReadycb); @@ -341,6 +342,9 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { /** Silent Mode */ bool* silentMode; + /** quad enable */ + bool* quadEnable; + /** frame padding */ bool* framePadding; diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index c9276a778..0737c47ac 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -190,8 +190,10 @@ public: /** * Enable Gap Pixels changes member variables * @param enable true if gap pixels enable, else false + * @param dr dynamic range + * @param q quad enable */ - virtual void SetGapPixelsEnable(bool b, int dr) { + virtual void SetGapPixelsEnable(bool b, int dr, bool q) { cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); }; @@ -646,13 +648,17 @@ class EigerData : public GeneralData { * Enable Gap Pixels changes member variables * @param enable true if gap pixels enable, else false * @param dr dynamic range + * @param q quad enable */ - void SetGapPixelsEnable(bool b, int dr) { + void SetGapPixelsEnable(bool b, int dr, bool q) { if (dr == 4) b = 0; switch((int)b) { case 1: nPixelsX = (256 * 2) + 3; + if (q) { + --nPixelsX; // if quad, remove last line + } nPixelsY = 256 + 1; imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit ((dr > 8) ? 2 : // 16 bit diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 3a64fba75..93a3f2b58 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -362,8 +362,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter /** * Set Quad type Enable (eiger and hardware specific) * @param true if quad enabled, else false + * @return OK or FAIL */ - void setQuad(const bool b); + int setQuad(const bool b); //***file parameters*** diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 40c37ac70..f009095d3 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -453,8 +453,9 @@ class UDPInterface { /** * Set Quad type Enable (eiger and hardware specific) * @param true if quad enabled, else false + * @return OK or FAIL */ - virtual void setQuad(const bool b) = 0; + virtual int setQuad(const bool b) = 0; //***file parameters*** diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 4215c5e2e..51e3c4c8e 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -75,8 +75,9 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase /** * Set Quad type Enable (eiger and hardware specific) * @param true if quad enabled, else false + * @return OK or FAIL */ - void setQuad(const bool b); + int setQuad(const bool b); /** * Set File Format diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 3a71e52cd..a6bec004d 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -26,7 +26,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, uint32_t* freq, uint32_t* timer, - bool* fp, bool* act, bool* depaden, bool* sm, + bool* fp, bool* act, bool* depaden, bool* sm, bool* qe, void (*dataReadycb)(char*, char*, uint32_t, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void *pDataReadycb) : @@ -49,6 +49,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f, activated(act), deactivatedPaddingEnable(depaden), silentMode(sm), + quadEnable(qe), framePadding(fp), acquisitionStartedFlag(false), measurementStartedFlag(false), @@ -511,31 +512,34 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) { memset(tempBuffer, 0xFF, generalData->imageSize); + int rightChip = ((*quadEnable) ? 0 : index); // quad enable, then faking both to be left chips const uint32_t nx = generalData->nPixelsX; const uint32_t ny = generalData->nPixelsY; const uint32_t npx = nx * ny; - + bool group3 = (*quadEnable) ? false : true; // if quad enabled, no last line for left chips char* srcptr = 0; char* dstptr = 0; const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode const uint32_t b2px = 2 * b1px; - const uint32_t b1pxofst = (index ? b1px : 0); // left fpga (index 0) has no extra 1px offset, but right fpga has + const uint32_t b1pxofst = (rightChip ? b1px : 0); // left fpga (chipIndex 0) has no extra 1px offset, but right fpga has const uint32_t b1chip = 256 * b1px; const uint32_t b1line = (nx * b1px); + const uint32_t bgroup3chip = b1chip + (group3 ? b1px : 0); // copying line by line srcptr = buf; - dstptr = tempBuffer + b1line + b1pxofst; // left fpga (index 0) has no extra 1px offset, but right fpga has + dstptr = tempBuffer + b1line + b1pxofst; // left fpga (chipIndex 0) has no extra 1px offset, but right fpga has for (uint32_t i = 0; i < (ny-1); ++i) { memcpy(dstptr, srcptr, b1chip); srcptr += b1chip; dstptr += (b1chip + b2px); memcpy(dstptr, srcptr, b1chip); srcptr += b1chip; - dstptr += (b1chip + b1px); + dstptr += bgroup3chip; } + // vertical filling of values { char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0; @@ -550,28 +554,36 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) { dstgp1 = srcgp1 + b1px; srcgp2 = srcgp1 + b3px; dstgp2 = dstgp1 + b1px; - if (!index) { - srcgp3 = srcptr + b1line - b2px; - dstgp3 = srcgp3 + b1px; - } else { - srcgp3 = srcptr + b1px; - dstgp3 = srcptr; + if (group3) { + if (!rightChip) { + srcgp3 = srcptr + b1line - b2px; + dstgp3 = srcgp3 + b1px; + } else { + srcgp3 = srcptr + b1px; + dstgp3 = srcptr; + } } switch (dr) { case 8: (*((uint8_t*)srcgp1)) = (*((uint8_t*)srcgp1))/2; (*((uint8_t*)dstgp1)) = (*((uint8_t*)srcgp1)); (*((uint8_t*)srcgp2)) = (*((uint8_t*)srcgp2))/2; (*((uint8_t*)dstgp2)) = (*((uint8_t*)srcgp2)); - (*((uint8_t*)srcgp3)) = (*((uint8_t*)srcgp3))/2; (*((uint8_t*)dstgp3)) = (*((uint8_t*)srcgp3)); + if (group3) { + (*((uint8_t*)srcgp3)) = (*((uint8_t*)srcgp3))/2; (*((uint8_t*)dstgp3)) = (*((uint8_t*)srcgp3)); + } break; case 16: (*((uint16_t*)srcgp1)) = (*((uint16_t*)srcgp1))/2; (*((uint16_t*)dstgp1)) = (*((uint16_t*)srcgp1)); (*((uint16_t*)srcgp2)) = (*((uint16_t*)srcgp2))/2; (*((uint16_t*)dstgp2)) = (*((uint16_t*)srcgp2)); - (*((uint16_t*)srcgp3)) = (*((uint16_t*)srcgp3))/2; (*((uint16_t*)dstgp3)) = (*((uint16_t*)srcgp3)); + if (group3) { + (*((uint16_t*)srcgp3)) = (*((uint16_t*)srcgp3))/2; (*((uint16_t*)dstgp3)) = (*((uint16_t*)srcgp3)); + } break; default: (*((uint32_t*)srcgp1)) = (*((uint32_t*)srcgp1))/2; (*((uint32_t*)dstgp1)) = (*((uint32_t*)srcgp1)); (*((uint32_t*)srcgp2)) = (*((uint32_t*)srcgp2))/2; (*((uint32_t*)dstgp2)) = (*((uint32_t*)srcgp2)); - (*((uint32_t*)srcgp3)) = (*((uint32_t*)srcgp3))/2; (*((uint32_t*)dstgp3)) = (*((uint32_t*)srcgp3)); + if (group3) { + (*((uint32_t*)srcgp3)) = (*((uint32_t*)srcgp3))/2; (*((uint32_t*)dstgp3)) = (*((uint32_t*)srcgp3)); + } break; } srcptr += b1line; diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index deecbe2f1..0c2c2f258 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -248,7 +248,6 @@ void DataStreamer::ProcessAnImage(char* buf) { //normal else { - if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index e971d1347..2d75f15c6 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -426,12 +426,13 @@ int UDPBaseImplementation::setGapPixelsEnable(const bool b) { return OK; } -void UDPBaseImplementation::setQuad(const bool b) { +int UDPBaseImplementation::setQuad(const bool b) { FILE_LOG(logDEBUG) << __AT__ << " starting"; quadEnable = b; FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; // overridden + return OK; } /***file parameters***/ diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index e54aad2be..5d280c8f6 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -164,7 +164,7 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) { gapPixelsEnable = b; // side effects - generalData->SetGapPixelsEnable(b, dynamicRange); + generalData->SetGapPixelsEnable(b, dynamicRange, quadEnable); // to update npixelsx, npixelsy in file writer for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) (*it)->SetPixelDimension(); @@ -177,10 +177,18 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) { return OK; } -void UDPStandardImplementation::setQuad(const bool b) { +int UDPStandardImplementation::setQuad(const bool b) { if (quadEnable != b) { quadEnable = b; + generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, b); + // to update npixelsx, npixelsy in file writer + for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) + (*it)->SetPixelDimension(); + numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure + if (SetupFifoStructure() == FAIL) + return FAIL; + if (!quadEnable) { for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ (*it)->SetNumberofDetectors(numDet); @@ -198,6 +206,7 @@ void UDPStandardImplementation::setQuad(const bool b) { } } FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; + return OK; } @@ -372,7 +381,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) { //side effects generalData->SetDynamicRange(i,tengigaEnable); - generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange); + generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable); // to update npixelsx, npixelsy in file writer for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) (*it)->SetPixelDimension(); @@ -391,6 +400,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b) { tengigaEnable = b; //side effects generalData->SetTenGigaEnable(b,dynamicRange); + generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable); numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure if (SetupFifoStructure() == FAIL) @@ -473,7 +483,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) { DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, - &framePadding, &activated, &deactivatedPaddingEnable, &silentMode, + &framePadding, &activated, &deactivatedPaddingEnable, &silentMode, &quadEnable, rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); dataProcessor.push_back(p); } diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 87b8851b0..8f1626643 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -3008,7 +3008,11 @@ int slsReceiverTCPIPInterface::set_quad_type() { else if (receiverBase->getStatus() != IDLE) receiverNotIdle(); else { - receiverBase->setQuad(value); // no check required + ret = receiverBase->setQuad(value); + if (ret == FAIL) { + strcpy(mess, "Could not set Quad due to fifo structure.\n"); + FILE_LOG(logERROR) << mess; + } } } //get