quad enabled with gap pixels without the extra vertical pixel line

This commit is contained in:
2019-07-31 13:00:12 +02:00
parent e07e2f2da0
commit 8c491f18fd
11 changed files with 68 additions and 29 deletions

View File

@ -129,7 +129,7 @@ void qDrawPlot::SetupWidgetWindow(){
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
if (myDet->setQuad()) { if (myDet->setQuad()) {
nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; nPixelsX = (myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2) - 1;
nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2;
} }
break; break;
@ -603,7 +603,7 @@ void qDrawPlot::SetScanArgument(int scanArg){
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
if (myDet->setQuad()) { if (myDet->setQuad()) {
nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; nPixelsX = (myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2) - 1;
nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2;
} }
break; break;

View File

@ -38,6 +38,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param act pointer to activated * @param act pointer to activated
* @param depaden pointer to deactivated padding enable * @param depaden pointer to deactivated padding enable
* @param sm pointer to silent mode * @param sm pointer to silent mode
* @param qe pointer to quad Enable
* @param dataReadycb pointer to data ready call back function * @param dataReadycb pointer to data ready call back function
* @param dataModifyReadycb pointer to data ready call back function with modified * @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). * @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, DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, 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 (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb); void *pDataReadycb);
@ -341,6 +342,9 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** Silent Mode */ /** Silent Mode */
bool* silentMode; bool* silentMode;
/** quad enable */
bool* quadEnable;
/** frame padding */ /** frame padding */
bool* framePadding; bool* framePadding;

View File

@ -190,8 +190,10 @@ public:
/** /**
* Enable Gap Pixels changes member variables * Enable Gap Pixels changes member variables
* @param enable true if gap pixels enable, else false * @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"); 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 * Enable Gap Pixels changes member variables
* @param enable true if gap pixels enable, else false * @param enable true if gap pixels enable, else false
* @param dr dynamic range * @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) if (dr == 4)
b = 0; b = 0;
switch((int)b) { switch((int)b) {
case 1: case 1:
nPixelsX = (256 * 2) + 3; nPixelsX = (256 * 2) + 3;
if (q) {
--nPixelsX; // if quad, remove last line
}
nPixelsY = 256 + 1; nPixelsY = 256 + 1;
imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit ((dr > 8) ? 2 : // 16 bit

View File

@ -362,8 +362,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
/** /**
* Set Quad type Enable (eiger and hardware specific) * Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false * @param true if quad enabled, else false
* @return OK or FAIL
*/ */
void setQuad(const bool b); int setQuad(const bool b);
//***file parameters*** //***file parameters***

View File

@ -453,8 +453,9 @@ class UDPInterface {
/** /**
* Set Quad type Enable (eiger and hardware specific) * Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false * @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*** //***file parameters***

View File

@ -75,8 +75,9 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
/** /**
* Set Quad type Enable (eiger and hardware specific) * Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false * @param true if quad enabled, else false
* @return OK or FAIL
*/ */
void setQuad(const bool b); int setQuad(const bool b);
/** /**
* Set File Format * Set File Format

View File

@ -26,7 +26,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
fileFormat* ftype, bool fwenable, fileFormat* ftype, bool fwenable,
bool* dsEnable, bool* gpEnable, uint32_t* dr, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, 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 (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb) : void *pDataReadycb) :
@ -49,6 +49,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
activated(act), activated(act),
deactivatedPaddingEnable(depaden), deactivatedPaddingEnable(depaden),
silentMode(sm), silentMode(sm),
quadEnable(qe),
framePadding(fp), framePadding(fp),
acquisitionStartedFlag(false), acquisitionStartedFlag(false),
measurementStartedFlag(false), measurementStartedFlag(false),
@ -511,31 +512,34 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
memset(tempBuffer, 0xFF, generalData->imageSize); 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 nx = generalData->nPixelsX;
const uint32_t ny = generalData->nPixelsY; const uint32_t ny = generalData->nPixelsY;
const uint32_t npx = nx * ny; const uint32_t npx = nx * ny;
bool group3 = (*quadEnable) ? false : true; // if quad enabled, no last line for left chips
char* srcptr = 0; char* srcptr = 0;
char* dstptr = 0; char* dstptr = 0;
const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode 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 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 b1chip = 256 * b1px;
const uint32_t b1line = (nx * b1px); const uint32_t b1line = (nx * b1px);
const uint32_t bgroup3chip = b1chip + (group3 ? b1px : 0);
// copying line by line // copying line by line
srcptr = buf; 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) { for (uint32_t i = 0; i < (ny-1); ++i) {
memcpy(dstptr, srcptr, b1chip); memcpy(dstptr, srcptr, b1chip);
srcptr += b1chip; srcptr += b1chip;
dstptr += (b1chip + b2px); dstptr += (b1chip + b2px);
memcpy(dstptr, srcptr, b1chip); memcpy(dstptr, srcptr, b1chip);
srcptr += b1chip; srcptr += b1chip;
dstptr += (b1chip + b1px); dstptr += bgroup3chip;
} }
// vertical filling of values // vertical filling of values
{ {
char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0; char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0;
@ -550,28 +554,36 @@ void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
dstgp1 = srcgp1 + b1px; dstgp1 = srcgp1 + b1px;
srcgp2 = srcgp1 + b3px; srcgp2 = srcgp1 + b3px;
dstgp2 = dstgp1 + b1px; dstgp2 = dstgp1 + b1px;
if (!index) { if (group3) {
srcgp3 = srcptr + b1line - b2px; if (!rightChip) {
dstgp3 = srcgp3 + b1px; srcgp3 = srcptr + b1line - b2px;
} else { dstgp3 = srcgp3 + b1px;
srcgp3 = srcptr + b1px; } else {
dstgp3 = srcptr; srcgp3 = srcptr + b1px;
dstgp3 = srcptr;
}
} }
switch (dr) { switch (dr) {
case 8: case 8:
(*((uint8_t*)srcgp1)) = (*((uint8_t*)srcgp1))/2; (*((uint8_t*)dstgp1)) = (*((uint8_t*)srcgp1)); (*((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*)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; break;
case 16: case 16:
(*((uint16_t*)srcgp1)) = (*((uint16_t*)srcgp1))/2; (*((uint16_t*)dstgp1)) = (*((uint16_t*)srcgp1)); (*((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*)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; break;
default: default:
(*((uint32_t*)srcgp1)) = (*((uint32_t*)srcgp1))/2; (*((uint32_t*)dstgp1)) = (*((uint32_t*)srcgp1)); (*((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*)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; break;
} }
srcptr += b1line; srcptr += b1line;

View File

@ -248,7 +248,6 @@ void DataStreamer::ProcessAnImage(char* buf) {
//normal //normal
else { else {
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback 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", cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",

View File

@ -426,12 +426,13 @@ int UDPBaseImplementation::setGapPixelsEnable(const bool b) {
return OK; return OK;
} }
void UDPBaseImplementation::setQuad(const bool b) { int UDPBaseImplementation::setQuad(const bool b) {
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
quadEnable = b; quadEnable = b;
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
// overridden // overridden
return OK;
} }
/***file parameters***/ /***file parameters***/

View File

@ -164,7 +164,7 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
gapPixelsEnable = b; gapPixelsEnable = b;
// side effects // side effects
generalData->SetGapPixelsEnable(b, dynamicRange); generalData->SetGapPixelsEnable(b, dynamicRange, quadEnable);
// to update npixelsx, npixelsy in file writer // to update npixelsx, npixelsy in file writer
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension(); (*it)->SetPixelDimension();
@ -177,10 +177,18 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
return OK; return OK;
} }
void UDPStandardImplementation::setQuad(const bool b) { int UDPStandardImplementation::setQuad(const bool b) {
if (quadEnable != b) { if (quadEnable != b) {
quadEnable = b; quadEnable = b;
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, b);
// to update npixelsx, npixelsy in file writer
for (std::vector<DataProcessor*>::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) { if (!quadEnable) {
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->SetNumberofDetectors(numDet); (*it)->SetNumberofDetectors(numDet);
@ -198,6 +206,7 @@ void UDPStandardImplementation::setQuad(const bool b) {
} }
} }
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
return OK;
} }
@ -372,7 +381,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
//side effects //side effects
generalData->SetDynamicRange(i,tengigaEnable); generalData->SetDynamicRange(i,tengigaEnable);
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange); generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable);
// to update npixelsx, npixelsy in file writer // to update npixelsx, npixelsy in file writer
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension(); (*it)->SetPixelDimension();
@ -391,6 +400,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b) {
tengigaEnable = b; tengigaEnable = b;
//side effects //side effects
generalData->SetTenGigaEnable(b,dynamicRange); generalData->SetTenGigaEnable(b,dynamicRange);
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable);
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
if (SetupFifoStructure() == FAIL) if (SetupFifoStructure() == FAIL)
@ -473,7 +483,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode, &framePadding, &activated, &deactivatedPaddingEnable, &silentMode, &quadEnable,
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
dataProcessor.push_back(p); dataProcessor.push_back(p);
} }

View File

@ -3008,7 +3008,11 @@ int slsReceiverTCPIPInterface::set_quad_type() {
else if (receiverBase->getStatus() != IDLE) else if (receiverBase->getStatus() != IDLE)
receiverNotIdle(); receiverNotIdle();
else { 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 //get