mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 05:47:14 +02:00
gap pixels for 8, 16, 32 in receiver at udp level
This commit is contained in:
@ -14,11 +14,11 @@ using namespace std;
|
||||
|
||||
FILE* BinaryFile::masterfd = 0;
|
||||
|
||||
BinaryFile::BinaryFile(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
BinaryFile::BinaryFile(int ind, uint32_t maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode):
|
||||
File(ind, maxf, ppf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode),
|
||||
File(ind, maxf, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, portno, smode),
|
||||
filefd(0),
|
||||
numFramesInFile(0),
|
||||
numActualPacketsInFile(0)
|
||||
|
@ -33,7 +33,7 @@ pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
bool DataProcessor::SilentMode(false);
|
||||
|
||||
|
||||
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),
|
||||
@ -46,8 +46,11 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
|
||||
dataStreamEnable(dsEnable),
|
||||
fileFormatType(ftype),
|
||||
fileWriteEnable(fwenable),
|
||||
gapPixelsEnable(gpEnable),
|
||||
dynamicRange(dr),
|
||||
streamingFrequency(freq),
|
||||
streamingTimerInMs(timer),
|
||||
tempBuffer(0),
|
||||
currentFreqCount(0),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
@ -74,6 +77,7 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
|
||||
|
||||
DataProcessor::~DataProcessor() {
|
||||
if (file) delete file;
|
||||
if (tempBuffer) delete [] tempBuffer;
|
||||
ThreadObject::DestroyThread();
|
||||
NumberofDataProcessors--;
|
||||
}
|
||||
@ -165,6 +169,15 @@ void DataProcessor::ResetParametersforNewMeasurement(){
|
||||
numFramesCaught = 0;
|
||||
firstMeasurementIndex = 0;
|
||||
measurementStartedFlag = false;
|
||||
|
||||
if (tempBuffer) {
|
||||
delete [] tempBuffer;
|
||||
tempBuffer = 0;
|
||||
}
|
||||
if (*gapPixelsEnable >= 0) {
|
||||
tempBuffer = new char[generalData->imageSize];
|
||||
memset(tempBuffer, 0, generalData->imageSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +207,6 @@ void DataProcessor::SetGeneralData(GeneralData* g) {
|
||||
generalData->Print();
|
||||
#endif
|
||||
if (file) {
|
||||
file->SetPacketsPerFrame(&generalData->packetsPerFrame);
|
||||
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
||||
if (file->GetFileType() == HDF5) {
|
||||
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
|
||||
@ -240,14 +252,14 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
|
||||
switch(*fileFormatType){
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
file = new HDF5File(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
|
||||
file = new HDF5File(index, generalData->maxFramesPerFile,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno,
|
||||
generalData->nPixelsX, generalData->nPixelsY, &SilentMode);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
file = new BinaryFile(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
|
||||
file = new BinaryFile(index, generalData->maxFramesPerFile,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno, &SilentMode);
|
||||
break;
|
||||
@ -358,6 +370,8 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
}
|
||||
}
|
||||
|
||||
if (*gapPixelsEnable && (*dynamicRange!=4))
|
||||
InsertGapPixels(buf + sizeof(sls_detector_header), *dynamicRange);
|
||||
|
||||
if (*fileWriteEnable)
|
||||
file->WriteToFile(buf, generalData->imageSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex, nump);
|
||||
@ -424,3 +438,103 @@ bool DataProcessor::CheckCount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DataProcessor::SetPixelDimension() {
|
||||
if (file) {
|
||||
if (file->GetFileType() == HDF5) {
|
||||
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** eiger specific */
|
||||
void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
||||
|
||||
memset(tempBuffer, 0xFF, generalData->imageSize);
|
||||
|
||||
const uint32_t nx = generalData->nPixelsX;
|
||||
const uint32_t ny = generalData->nPixelsY;
|
||||
const uint32_t npx = nx * ny;
|
||||
|
||||
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 b1chip = 256 * b1px;
|
||||
const uint32_t b1line = (nx * b1px);
|
||||
|
||||
// copying line by line
|
||||
srcptr = buf;
|
||||
dstptr = tempBuffer + b1line + b1pxofst; // left fpga (index 0) has no extra 1px offset, but right fpga has
|
||||
for (int i = 0; i < (ny-1); ++i) {
|
||||
memcpy(dstptr, srcptr, b1chip);
|
||||
srcptr += b1chip;
|
||||
dstptr += (b1chip + b2px);
|
||||
memcpy(dstptr, srcptr, b1chip);
|
||||
srcptr += b1chip;
|
||||
dstptr += (b1chip + b1px);
|
||||
}
|
||||
|
||||
// vertical filling of values
|
||||
{
|
||||
char* srcgp1 = 0; char* srcgp2 = 0; char* srcgp3 = 0;
|
||||
char* dstgp1 = 0; char* dstgp2 = 0; char* dstgp3 = 0;
|
||||
const uint32_t b3px = 3 * b1px;
|
||||
|
||||
srcptr = tempBuffer + b1line;
|
||||
dstptr = tempBuffer + b1line;
|
||||
|
||||
for (int i = 0; i < (ny-1); ++i) {
|
||||
srcgp1 = srcptr + b1pxofst + b1chip - b1px;
|
||||
dstgp1 = srcgp1 + b1px;
|
||||
srcgp2 = srcgp1 + b3px;
|
||||
dstgp2 = dstgp1 + b1px;
|
||||
if (!index) {
|
||||
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));
|
||||
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));
|
||||
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));
|
||||
break;
|
||||
}
|
||||
srcptr += b1line;
|
||||
dstptr += b1line;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// horizontal filling of values
|
||||
srcptr = tempBuffer + b1line;
|
||||
dstptr = tempBuffer;
|
||||
for (int i = 0; i < nx; ++i) {
|
||||
switch (dr) {
|
||||
case 8: (*((uint8_t*)srcptr)) = (*((uint8_t*)srcptr))/2; (*((uint8_t*)dstptr)) = (*((uint8_t*)srcptr)); break;
|
||||
case 16:(*((uint16_t*)srcptr)) = (*((uint16_t*)srcptr))/2; (*((uint16_t*)dstptr)) = (*((uint16_t*)srcptr)); break;
|
||||
default:(*((uint32_t*)srcptr)) = (*((uint32_t*)srcptr))/2; (*((uint32_t*)dstptr)) = (*((uint32_t*)srcptr)); break;
|
||||
}
|
||||
srcptr += b1px;
|
||||
dstptr += b1px;
|
||||
}
|
||||
|
||||
memcpy(buf, tempBuffer, generalData->imageSize);
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, int* sEnable) :
|
||||
|
||||
DataStreamer::~DataStreamer() {
|
||||
CloseZmqSocket();
|
||||
if (completeBuffer) delete completeBuffer;
|
||||
if (completeBuffer) delete [] completeBuffer;
|
||||
ThreadObject::DestroyThread();
|
||||
NumberofDataStreamers--;
|
||||
}
|
||||
@ -117,7 +117,7 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||
measurementStartedFlag = false;
|
||||
strcpy(fileNametoStream, fname);
|
||||
if (completeBuffer) {
|
||||
delete completeBuffer;
|
||||
delete [] completeBuffer;
|
||||
completeBuffer = 0;
|
||||
}
|
||||
if (*shortFrameEnable >= 0) {
|
||||
@ -253,6 +253,8 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
bprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
}
|
||||
|
||||
|
||||
//normal
|
||||
else {
|
||||
|
||||
|
@ -10,13 +10,12 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
File::File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
File::File(int ind, uint32_t maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode):
|
||||
index(ind),
|
||||
maxFramesPerFile(maxf),
|
||||
packetsPerFrame(ppf),
|
||||
numDetX(nd[0]),
|
||||
numDetY(nd[1]),
|
||||
fileNamePrefix(fname),
|
||||
@ -44,7 +43,6 @@ void File::PrintMembers() {
|
||||
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl
|
||||
<< "Index: " << index << endl
|
||||
<< "Max Frames Per File: " << maxFramesPerFile << endl
|
||||
<< "Packets per Frame: " << *packetsPerFrame << endl
|
||||
<< "Number of Detectors in x dir: " << numDetX << endl
|
||||
<< "Number of Detectors in y dir: " << numDetY << endl
|
||||
<< "File Name Prefix: " << fileNamePrefix << endl
|
||||
@ -83,7 +81,3 @@ void File::SetMaxFramesPerFile(uint32_t maxf) {
|
||||
maxFramesPerFile = maxf;
|
||||
}
|
||||
|
||||
|
||||
void File::SetPacketsPerFrame(const uint32_t* ppf) {
|
||||
packetsPerFrame = ppf;
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ hid_t HDF5File::virtualfd = 0;
|
||||
|
||||
|
||||
|
||||
HDF5File::HDF5File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
HDF5File::HDF5File(int ind, uint32_t maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
uint32_t nx, uint32_t ny,
|
||||
bool* smode):
|
||||
|
||||
File(ind, maxf, ppf, nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, portno, smode),
|
||||
File(ind, maxf, nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, portno, smode),
|
||||
filefd(0),
|
||||
dataspace(0),
|
||||
dataset(0),
|
||||
|
@ -117,6 +117,10 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
|
||||
gapPixelsEnable = b;
|
||||
|
||||
// side effects
|
||||
generalData->SetGapPixelsEnable(b, dynamicRange);
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (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)
|
||||
@ -254,6 +258,10 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
||||
|
||||
//side effects
|
||||
generalData->SetDynamicRange(i,tengigaEnable);
|
||||
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (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)
|
||||
@ -350,7 +358,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
for ( int i=0; i < numThreads; ++i ) {
|
||||
listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange));
|
||||
dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType,
|
||||
&fileWriteEnable, &dataStreamEnable, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||
&fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||
rawDataReadyCallBack,pRawDataReady));
|
||||
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
|
||||
FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")";
|
||||
|
Reference in New Issue
Block a user