mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 09:00:41 +02:00
print loss
This commit is contained in:
parent
a276b6b7f5
commit
4aa73c607f
@ -20,21 +20,24 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param ppf packets per frame
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
* @param findex pointer to file index
|
||||
* @param frindexenable pointer to frame index enable
|
||||
* @param owenable pointer to over write enable
|
||||
* @param maxf max frames per file
|
||||
* @param dindex pointer to detector index
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param nf pointer to number of frames
|
||||
* @param dr dynamic range
|
||||
* @param nf pointer to number of images in acquisition
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to udp port number for logging
|
||||
*/
|
||||
BinaryFile(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits,
|
||||
uint64_t* nf, uint32_t* dr);
|
||||
BinaryFile(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -81,9 +84,10 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
* @param buffer buffer to write from
|
||||
* @param buffersize size of buffer
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int WriteToFile(char* buffer, int buffersize, uint64_t fnum);
|
||||
int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump);
|
||||
|
||||
|
||||
|
||||
@ -106,5 +110,8 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
/** Number of frames in file */
|
||||
uint32_t numFramesInFile;
|
||||
|
||||
/** Number of actual packets caught in file */
|
||||
uint64_t numActualPacketsInFile;
|
||||
|
||||
};
|
||||
|
||||
|
@ -156,11 +156,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param dindex pointer to detector index
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param nf pointer to number of images in acquisition
|
||||
* @param dr dynamic range
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to udp port number
|
||||
* @param g address of GeneralData (Detector Data) pointer
|
||||
*/
|
||||
void SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, GeneralData* g = 0);
|
||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, GeneralData* g = 0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -20,20 +20,24 @@ class File : private virtual slsReceiverDefs {
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param ppf packets per frame
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
* @param findex pointer to file index
|
||||
* @param frindexenable pointer to frame index enable
|
||||
* @param owenable pointer to over write enable
|
||||
* @param maxf max frames per file
|
||||
* @param dindex pointer to detector index
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param nf pointer to number of images in acquisition
|
||||
* @param dr dynamic range
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to udp port number for logging
|
||||
*/
|
||||
File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr);
|
||||
File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -68,10 +72,12 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param dindex pointer to detector index
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param nf pointer to number of images in acquisition
|
||||
* @param dr dynamic range
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to dynamic range
|
||||
*/
|
||||
void GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*& findex,
|
||||
bool*& frindexenable, bool*& owenable, int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr);
|
||||
bool*& frindexenable, bool*& owenable,
|
||||
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno);
|
||||
|
||||
/**
|
||||
* Set Max frames per file
|
||||
@ -79,6 +85,12 @@ class File : private virtual slsReceiverDefs {
|
||||
*/
|
||||
void SetMaxFramesPerFile(uint32_t maxf);
|
||||
|
||||
/**
|
||||
* Set Packets per frame (called only for each generalData construction)
|
||||
* @param ppf pointer to packets per frame
|
||||
*/
|
||||
void SetPacketsPerFrame(const uint32_t* ppf);
|
||||
|
||||
/**
|
||||
* Create file
|
||||
* @param fnum current frame index to include in file name
|
||||
@ -107,9 +119,10 @@ class File : private virtual slsReceiverDefs {
|
||||
* Write data to file
|
||||
* @param buffer buffer to write from
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @param OK or FAIL
|
||||
*/
|
||||
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
cprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n");
|
||||
return FAIL;
|
||||
}
|
||||
@ -156,15 +169,25 @@ class File : private virtual slsReceiverDefs {
|
||||
/** Self Index */
|
||||
int index;
|
||||
|
||||
/** Maximum frames per file */
|
||||
uint32_t maxFramesPerFile;
|
||||
|
||||
/** Packets per frame for logging */
|
||||
//pointer because value in generalData could change
|
||||
const uint32_t* packetsPerFrame;
|
||||
|
||||
/** Master File Name */
|
||||
std::string masterFileName;
|
||||
|
||||
/** Current File Name */
|
||||
std::string currentFileName;
|
||||
|
||||
/** Number of Detectors in X dimension */
|
||||
int numDetX;
|
||||
|
||||
/** Number of Detectors in Y dimension */
|
||||
int numDetY;
|
||||
|
||||
/** Master File Name */
|
||||
std::string masterFileName;
|
||||
|
||||
/** File Name Prefix */
|
||||
char* fileNamePrefix;
|
||||
|
||||
@ -177,15 +200,9 @@ class File : private virtual slsReceiverDefs {
|
||||
/** Frame Index */
|
||||
bool* frameIndexEnable;
|
||||
|
||||
/** File Write Enable */
|
||||
bool* fileWriteEnable;
|
||||
|
||||
/** Over write enable */
|
||||
bool* overWriteEnable;
|
||||
|
||||
/** Maximum frames per file */
|
||||
uint32_t maxFramesPerFile;
|
||||
|
||||
/** Detector Index */
|
||||
int* detIndex;
|
||||
|
||||
@ -198,7 +215,8 @@ class File : private virtual slsReceiverDefs {
|
||||
/** Dynamic Range */
|
||||
uint32_t* dynamicRange;
|
||||
|
||||
/** Current File Name */
|
||||
std::string currentFileName;
|
||||
/** UDP Port Number for logging */
|
||||
uint32_t* udpPortNumber;
|
||||
|
||||
};
|
||||
|
||||
|
@ -26,22 +26,26 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param ppf packets per frame
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
* @param findex pointer to file index
|
||||
* @param frindexenable pointer to frame index enable
|
||||
* @param owenable pointer to over write enable
|
||||
* @param maxf max frames per file
|
||||
* @param dindex pointer to detector index
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param nf pointer to number of frames
|
||||
* @param dr dynamic range
|
||||
* @param nf pointer to number of images in acquisition
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to udp port number for logging
|
||||
* @param nx number of pixels in x direction
|
||||
* @param ny number of pixels in y direction
|
||||
*/
|
||||
HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
|
||||
HDF5File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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);
|
||||
|
||||
/**
|
||||
@ -83,9 +87,10 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
* @param buffer buffer to write from
|
||||
* @param bsize size of buffer (not used)
|
||||
* @param fnum current image number
|
||||
* @param nump number of packets caught
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int WriteToFile(char* buffer, int bsize, uint64_t fnum);
|
||||
int WriteToFile(char* buffer, int bsize, uint64_t fnum, uint32_t nump);
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
@ -159,6 +164,9 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
/** Number of frames in file */
|
||||
uint32_t numFramesInFile;
|
||||
|
||||
/** Number of actual packets caught in file */
|
||||
uint64_t numActualPacketsInFile;
|
||||
|
||||
/** Number of files in an acquisition - to verify need of virtual file */
|
||||
int numFilesinAcquisition;
|
||||
|
||||
|
@ -13,12 +13,15 @@ using namespace std;
|
||||
|
||||
FILE* BinaryFile::masterfd = 0;
|
||||
|
||||
BinaryFile::BinaryFile(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr):
|
||||
BinaryFile::BinaryFile(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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):
|
||||
|
||||
File(ind, nd, fname, fpath, findex, frindexenable, owenable, maxf, dindex, nunits, nf, dr),
|
||||
File(ind, maxf, ppf, nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, portno),
|
||||
filefd(0),
|
||||
numFramesInFile(0)
|
||||
numFramesInFile(0),
|
||||
numActualPacketsInFile(0)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
PrintMembers();
|
||||
@ -41,14 +44,31 @@ slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
|
||||
|
||||
|
||||
int BinaryFile::CreateFile(uint64_t fnum) {
|
||||
//calculate packet loss
|
||||
int64_t loss = -1;
|
||||
if (numFramesInFile)
|
||||
loss = (numFramesInFile*(*packetsPerFrame)) - numActualPacketsInFile;
|
||||
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
|
||||
currentFileName = BinaryFileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
||||
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
||||
|
||||
if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
printf("%d Binary File created: %s\n", index, currentFileName.c_str());
|
||||
//first file, print entrire path
|
||||
if (loss == -1)
|
||||
printf("[%u]: Binary File created: %s\n", *udpPortNumber, currentFileName.c_str());
|
||||
//other files
|
||||
else {
|
||||
if (loss)
|
||||
cprintf(RED,"[%u]: Packet_Loss:%lu \tNew_File:%s\n", *udpPortNumber,loss, basename(currentFileName.c_str()));
|
||||
else
|
||||
cprintf(GREEN,"[%u]: Packet_Loss:%lu \tNew_File:%s\n", *udpPortNumber,loss, basename(currentFileName.c_str()));
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -62,12 +82,13 @@ void BinaryFile::CloseAllFiles() {
|
||||
BinaryFileStatic::CloseDataFile(masterfd);
|
||||
}
|
||||
|
||||
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
if (numFramesInFile >= maxFramesPerFile) {
|
||||
CloseCurrentFile();
|
||||
CreateFile(fnum);
|
||||
}
|
||||
numFramesInFile++;
|
||||
numActualPacketsInFile += nump;
|
||||
if (BinaryFileStatic::WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize)
|
||||
return OK;
|
||||
cprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum);
|
||||
@ -77,6 +98,10 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
|
||||
int BinaryFile::CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
|
||||
if (master && (*detIndex==0)) {
|
||||
masterFileName = BinaryFileStatic::CreateMasterFileName(filePath, fileNamePrefix, *fileIndex);
|
||||
printf("Master File: %s\n", masterFileName.c_str());
|
||||
|
@ -178,9 +178,9 @@ void DataProcessor::SetGeneralData(GeneralData* g) {
|
||||
generalData->Print();
|
||||
#endif
|
||||
if (file) {
|
||||
if (file->GetFileType() == BINARY)
|
||||
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
||||
else if (file->GetFileType() == HDF5) {
|
||||
file->SetPacketsPerFrame(&generalData->packetsPerFrame);
|
||||
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
||||
if (file->GetFileType() == HDF5) {
|
||||
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
|
||||
}
|
||||
}
|
||||
@ -202,17 +202,18 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
|
||||
//remember the pointer values before they are destroyed
|
||||
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
|
||||
char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0;
|
||||
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; uint32_t* dr = 0;
|
||||
file->GetMemberPointerValues(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr);
|
||||
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; uint32_t* dr = 0; uint32_t* port = 0;
|
||||
file->GetMemberPointerValues(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
|
||||
//create file writer with same pointers
|
||||
SetupFileWriter(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr);
|
||||
SetupFileWriter(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, GeneralData* g)
|
||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
GeneralData* g)
|
||||
{
|
||||
if (g)
|
||||
generalData = g;
|
||||
@ -223,14 +224,18 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
|
||||
switch(*fileFormatType){
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
file = new HDF5File(index, nd, fname, fpath, findex,
|
||||
frindexenable, owenable, generalData->maxFramesPerFile, dindex, nunits, nf, dr,
|
||||
file = new HDF5File(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
|
||||
nd, fname, fpath, findex,
|
||||
frindexenable, owenable,
|
||||
dindex, nunits, nf, dr, portno
|
||||
generalData->nPixelsX, generalData->nPixelsY);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
file = new BinaryFile(index, nd, fname, fpath, findex,
|
||||
frindexenable, owenable, generalData->maxFramesPerFile, dindex, nunits, nf, dr);
|
||||
file = new BinaryFile(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
|
||||
nd, fname, fpath, findex,
|
||||
frindexenable, owenable,
|
||||
dindex, nunits, nf, dr, portno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -323,7 +328,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
|
||||
|
||||
if (*fileWriteEnable)
|
||||
file->WriteToFile(buf, generalData->fifoBufferSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex);
|
||||
file->WriteToFile(buf, generalData->fifoBufferSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex, nump);
|
||||
|
||||
if (rawDataReadyCallBack) {
|
||||
rawDataReadyCallBack(
|
||||
|
@ -10,9 +10,13 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
File::File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr):
|
||||
File::File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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):
|
||||
index(ind),
|
||||
maxFramesPerFile(maxf),
|
||||
packetsPerFrame(ppf),
|
||||
numDetX(nd[0]),
|
||||
numDetY(nd[1]),
|
||||
fileNamePrefix(fname),
|
||||
@ -20,11 +24,12 @@ File::File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
fileIndex(findex),
|
||||
frameIndexEnable(frindexenable),
|
||||
overWriteEnable(owenable),
|
||||
maxFramesPerFile(maxf),
|
||||
detIndex(dindex),
|
||||
numUnitsPerDetector(nunits),
|
||||
numImages(nf),
|
||||
dynamicRange(dr)
|
||||
dynamicRange(dr),
|
||||
udpPortNumber(portno)
|
||||
|
||||
{
|
||||
master = index?false:true;
|
||||
}
|
||||
@ -38,28 +43,47 @@ string File::GetCurrentFileName() {
|
||||
void File::PrintMembers() {
|
||||
printf("\nGeneral Writer Variables:"
|
||||
"Index: %d\n"
|
||||
"Max Frames Per File: %u\n"
|
||||
"Packets per Frame: %u\n"
|
||||
"Number of Detectors in x dir: %d\n"
|
||||
"Number of Detectors in y dir: %d\n"
|
||||
"File Name Prefix: %s\n"
|
||||
"File Path: %s\n"
|
||||
"File Index: %lld\n"
|
||||
"File Index: %lu\n"
|
||||
"Frame Index Enable: %d\n"
|
||||
"Over Write Enable: %d\n"
|
||||
"Max Frames Per File: %d\n"
|
||||
|
||||
"Detector Index: %d\n"
|
||||
"Number of Units Per Detector: %d\n",
|
||||
"Number of Units Per Detector: %d\n"
|
||||
"Number of Images in Acquisition: %lu\n"
|
||||
"Dynamic Range: %u\n"
|
||||
"UDP Port number: %u\n"
|
||||
"Master File Name: %s\n"
|
||||
"Current File Name: %s\n",
|
||||
index,
|
||||
maxFramesPerFile,
|
||||
*packetsPerFrame,
|
||||
numDetX,
|
||||
numDetY,
|
||||
fileNamePrefix,
|
||||
filePath,
|
||||
(long long int)*fileIndex,
|
||||
*frameIndexEnable,
|
||||
*overWriteEnable,
|
||||
maxFramesPerFile,
|
||||
*fileIndex,
|
||||
(int)*frameIndexEnable,
|
||||
(int)*overWriteEnable,
|
||||
|
||||
*detIndex,
|
||||
*numUnitsPerDetector);
|
||||
*numUnitsPerDetector,
|
||||
*numImages,
|
||||
*dynamicRange,
|
||||
*udpPortNumber,
|
||||
masterFileName.c_str(),
|
||||
currentFileName.c_str());
|
||||
}
|
||||
|
||||
|
||||
void File::GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*& findex,
|
||||
bool*& frindexenable, bool*& owenable, int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr)
|
||||
bool*& frindexenable, bool*& owenable,
|
||||
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno)
|
||||
{
|
||||
nd[0] = numDetX;
|
||||
nd[1] = numDetY;
|
||||
@ -72,8 +96,14 @@ void File::GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*
|
||||
nunits = numUnitsPerDetector;
|
||||
nf = numImages;
|
||||
dr = dynamicRange;
|
||||
portno = udpPortNumber;
|
||||
}
|
||||
|
||||
void File::SetMaxFramesPerFile(uint32_t maxf) {
|
||||
maxFramesPerFile = maxf;
|
||||
}
|
||||
|
||||
|
||||
void File::SetPacketsPerFrame(const uint32_t* ppf) {
|
||||
packetsPerFrame = ppf;
|
||||
}
|
||||
|
@ -18,11 +18,13 @@ hid_t HDF5File::virtualfd = 0;
|
||||
|
||||
|
||||
|
||||
HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* frindexenable, bool* owenable, uint32_t maxf, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
|
||||
HDF5File::HDF5File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
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):
|
||||
|
||||
File(ind, nd, fname, fpath, findex, frindexenable, owenable, maxf, dindex, nunits, nf, dr),
|
||||
File(ind, maxf, ppf, nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, portno),
|
||||
filefd(0),
|
||||
dataspace(0),
|
||||
dataset(0),
|
||||
@ -30,6 +32,7 @@ HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
nPixelsX(nx),
|
||||
nPixelsY(ny),
|
||||
numFramesInFile(0),
|
||||
numActualPacketsInFile(0),
|
||||
numFilesinAcquisition(0),
|
||||
dataspace_para(0)
|
||||
{
|
||||
@ -81,8 +84,15 @@ void HDF5File::UpdateDataType() {
|
||||
|
||||
|
||||
int HDF5File::CreateFile(uint64_t fnum) {
|
||||
|
||||
//calculate packet loss
|
||||
int64_t loss = -1;
|
||||
if (numFramesInFile)
|
||||
loss = (numFramesInFile*(*packetsPerFrame)) - numActualPacketsInFile;
|
||||
|
||||
numFilesinAcquisition++;
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
currentFileName = HDF5FileStatic::CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
||||
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
||||
|
||||
@ -102,7 +112,18 @@ int HDF5File::CreateFile(uint64_t fnum) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
if (dataspace == NULL)
|
||||
cprintf(RED,"Got nothing!\n");
|
||||
printf("%d HDF5 File: %s\n", index, currentFileName.c_str());
|
||||
|
||||
//first file, print entrire path
|
||||
if (loss == -1)
|
||||
printf("[%u]: HDF5 File created: %s\n", *udpPortNumber, currentFileName.c_str());
|
||||
//other files
|
||||
else {
|
||||
if (loss)
|
||||
cprintf(RED,"[%u]: Packet_Loss:%lu \tNew_File:%s\n", *udpPortNumber,loss, basename(currentFileName.c_str()));
|
||||
else
|
||||
cprintf(GREEN,"[%u]: Packet_Loss:%lu \tNew_File:%s\n", *udpPortNumber,loss, basename(currentFileName.c_str()));
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -126,13 +147,13 @@ void HDF5File::CloseAllFiles() {
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
if (numFramesInFile >= maxFramesPerFile) {
|
||||
CloseCurrentFile();
|
||||
CreateFile(fnum);
|
||||
}
|
||||
numFramesInFile++;
|
||||
|
||||
numActualPacketsInFile += nump;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
|
||||
fnum%maxFramesPerFile, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
@ -154,6 +175,11 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
|
||||
int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
|
||||
if (master && (*detIndex==0)) {
|
||||
virtualfd = 0;
|
||||
masterFileName = HDF5FileStatic::CreateMasterFileName(filePath, fileNamePrefix, *fileIndex);
|
||||
|
@ -405,9 +405,9 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
|
||||
|
||||
detID = i;
|
||||
FILE_LOG(logINFO) << "Detector Position Id:" << detID;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
(*it)->SetupFileWriter((int*)numDet, fileName, filePath, &fileIndex, &frameIndexEnable,
|
||||
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, generalData);
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter((int*)numDet, fileName, filePath, &fileIndex, &frameIndexEnable,
|
||||
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,12 +519,12 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
if (missingpackets) {
|
||||
cprintf(RED, "\n[Port %d]\n",udpPortNum[i]);
|
||||
cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets);
|
||||
cprintf(RED, "Complete Frames\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught());
|
||||
cprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught());
|
||||
cprintf(RED, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught());
|
||||
}else{
|
||||
cprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]);
|
||||
cprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets);
|
||||
cprintf(GREEN, "Complete Frames\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught());
|
||||
cprintf(GREEN, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught());
|
||||
cprintf(GREEN, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user