mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 15:50:03 +02:00
receiver master file includes quad, gap pixels enable, version updated for binary and hdf5
This commit is contained in:
parent
633c646239
commit
4d99ce8c52
@ -58,19 +58,10 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param en ten giga enable
|
||||
* @param size image size
|
||||
* @param nx number of pixels in x direction
|
||||
* @param ny number of pixels in y direction
|
||||
* @param at acquisition time
|
||||
* @param st sub exposure time
|
||||
* @param sp sub period
|
||||
* @param ap acquisition period
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
|
||||
uint64_t ap);
|
||||
int CreateMasterFile(masterAttributes& attr);
|
||||
|
||||
/**
|
||||
* Close Current File
|
||||
|
@ -100,26 +100,11 @@ class BinaryFileStatic {
|
||||
* @param fd pointer to file handle
|
||||
* @param fname master file name
|
||||
* @param owenable overwrite enable
|
||||
* @param dr dynamic range
|
||||
* @param tenE ten giga enable
|
||||
* @param size image size
|
||||
* @param nPixelsX number of pixels in x direction
|
||||
* @param nPixelsY number of pixels in y direction
|
||||
* @param nf number of images
|
||||
* @param maxf maximum frames per file
|
||||
* @param acquisitionTime acquisition time
|
||||
* @param acquisitionPeriod acquisition period
|
||||
* @param subexposuretime sub exposure time
|
||||
* @param subperiod sub period
|
||||
* @param version version of software for binary writing
|
||||
* @param attr master file attributes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
|
||||
uint32_t dr, bool tenE, uint32_t size,
|
||||
uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
|
||||
uint32_t maxf,
|
||||
uint64_t acquisitionTime, uint64_t subexposuretime,
|
||||
uint64_t subperiod, uint64_t acquisitionPeriod, double version)
|
||||
masterAttributes& attr)
|
||||
{
|
||||
if(!owenable){
|
||||
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
|
||||
@ -136,17 +121,20 @@ class BinaryFileStatic {
|
||||
char message[MAX_MASTER_FILE_LENGTH];
|
||||
sprintf(message,
|
||||
"Version : %.1f\n"
|
||||
"Detector Type : %d\n"
|
||||
"Dynamic Range : %d\n"
|
||||
"Ten Giga : %d\n"
|
||||
"Image Size : %d bytes\n"
|
||||
"row : %d pixels\n"
|
||||
"col : %d pixels\n"
|
||||
"Max. Frames Per File : %u\n"
|
||||
"nPixelsX : %d pixels\n"
|
||||
"nPixelsY : %d pixels\n"
|
||||
"Max Frames Per File : %u\n"
|
||||
"Total Frames : %lld\n"
|
||||
"Exptime (ns) : %lld\n"
|
||||
"SubExptime (ns) : %lld\n"
|
||||
"SubPeriod(ns) : %lld\n"
|
||||
"Period (ns) : %lld\n"
|
||||
"Gap Pixels Enable : %d\n"
|
||||
"Quad Enable : %d\n"
|
||||
"Timestamp : %s\n\n"
|
||||
|
||||
"#Frame Header\n"
|
||||
@ -165,18 +153,21 @@ class BinaryFileStatic {
|
||||
"Header Version : 1 byte\n"
|
||||
"Packets Caught Mask : 64 bytes\n"
|
||||
,
|
||||
version,
|
||||
dr,
|
||||
tenE,
|
||||
size,
|
||||
nPixelsX,
|
||||
nPixelsY,
|
||||
maxf,
|
||||
(long long int)nf,
|
||||
(long long int)acquisitionTime,
|
||||
(long long int)subexposuretime,
|
||||
(long long int)subperiod,
|
||||
(long long int)acquisitionPeriod,
|
||||
attr.version,
|
||||
attr.detectorType,
|
||||
attr.dynamicRange,
|
||||
attr.tenGiga,
|
||||
attr.imageSize,
|
||||
attr.nPixelsX,
|
||||
attr.nPixelsY,
|
||||
attr.maxFramesPerFile,
|
||||
(long long int)attr.totalFrames,
|
||||
(long long int)attr.exptimeNs,
|
||||
(long long int)attr.subExptimeNs,
|
||||
(long long int)attr.subPeriodNs,
|
||||
(long long int)attr.periodNs,
|
||||
attr.gapPixelsEnable,
|
||||
attr.quadEnable,
|
||||
ctime(&t));
|
||||
if (strlen(message) > MAX_MASTER_FILE_LENGTH) {
|
||||
cprintf(RED,"Master File Size %d is greater than max str size %d\n",
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "ThreadObject.h"
|
||||
#include "receiver_defs.h"
|
||||
|
||||
class GeneralData;
|
||||
class Fifo;
|
||||
@ -176,16 +177,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
/**
|
||||
* Create New File
|
||||
* @param en ten giga enable
|
||||
* @param nf number of frames
|
||||
* @param at acquisition time
|
||||
* @param st sub exposure time
|
||||
* @param sp sub period
|
||||
* @param ap acquisition period
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st,
|
||||
uint64_t sp, uint64_t ap);
|
||||
int CreateNewFile(masterAttributes& attr);
|
||||
|
||||
/**
|
||||
* Closes files
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "logger.h"
|
||||
#include "receiver_defs.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -121,19 +122,10 @@ class File : private virtual slsReceiverDefs {
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param en ten giga enable
|
||||
* @param size image size
|
||||
* @param nx number of pixels in x direction
|
||||
* @param ny number of pixels in y direction
|
||||
* @param at acquisition time
|
||||
* @param st sub exposure time
|
||||
* @param sp sub period
|
||||
* @param ap acquisition period
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
virtual int CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st,
|
||||
uint64_t sp, uint64_t ap) {
|
||||
virtual int CreateMasterFile(masterAttributes& attr) {
|
||||
cprintf(RED,"This is a generic function CreateMasterFile that "
|
||||
"should be overloaded by a derived class\n");
|
||||
return OK;
|
||||
|
@ -93,19 +93,10 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param en ten giga enable
|
||||
* @param size image size
|
||||
* @param nx number of pixels in x direction
|
||||
* @param ny number of pixels in y direction
|
||||
* @param at acquisition time
|
||||
* @param st sub exposure time
|
||||
* @param sp sub period
|
||||
* @param ap acquisition period
|
||||
* @param attr master file attributes
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
|
||||
uint64_t ap);
|
||||
int CreateMasterFile(masterAttributes& attr);
|
||||
|
||||
/**
|
||||
* End of Acquisition
|
||||
|
@ -294,26 +294,12 @@ public:
|
||||
* Create master file
|
||||
* @param fname master file name
|
||||
* @param owenable overwrite enable
|
||||
* @param dr dynamic range
|
||||
* @param tenE ten giga enable
|
||||
* @param size image size
|
||||
* @param nx number of pixels in x direction
|
||||
* @param ny number of pixels in y direction
|
||||
* @param nf number of images
|
||||
* @param maxf maximum frames per file
|
||||
* @param acquisitionTime acquisition time
|
||||
* @param subexposuretime sub exposure time
|
||||
* @param subperiod sub period
|
||||
* @param acquisitionPeriod acquisition period
|
||||
* @param attr master file attributes
|
||||
* @param version version of software for hdf5 writing
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
|
||||
uint32_t dr, bool tenE, uint32_t size,
|
||||
uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf,
|
||||
uint32_t maxf,
|
||||
uint64_t acquisitionTime, uint64_t subexposuretime,
|
||||
uint64_t subperiod, uint64_t acquisitionPeriod, double version)
|
||||
masterAttributes& attr)
|
||||
{
|
||||
try {
|
||||
Exception::dontPrint(); //to handle errors
|
||||
@ -340,7 +326,7 @@ public:
|
||||
|
||||
//create attributes
|
||||
//version
|
||||
dValue=version;
|
||||
dValue=attr.version;
|
||||
attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace);
|
||||
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||
|
||||
@ -352,63 +338,75 @@ public:
|
||||
Group group5( group3.createGroup("detector") );
|
||||
Group group6( group1.createGroup("sample") );
|
||||
|
||||
//Detector Type
|
||||
dataset = group5.createDataSet ( "detector type", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &(attr.detectorType), PredType::NATIVE_INT);
|
||||
|
||||
//Dynamic Range
|
||||
dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &dr, PredType::NATIVE_INT);
|
||||
dataset.write ( &(attr.dynamicRange), PredType::NATIVE_INT);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("bits"));
|
||||
|
||||
//Ten Giga
|
||||
iValue = tenE;
|
||||
iValue = attr.tenGiga;
|
||||
dataset = group5.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &iValue, PredType::NATIVE_INT);
|
||||
|
||||
//Image Size
|
||||
dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &size, PredType::NATIVE_INT);
|
||||
dataset.write ( &(attr.imageSize), PredType::NATIVE_INT);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("bytes"));
|
||||
|
||||
//x
|
||||
dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &nPixelsx, PredType::NATIVE_INT);
|
||||
dataset.write ( &(attr.nPixelsX), PredType::NATIVE_INT);
|
||||
|
||||
//y
|
||||
dataset = group5.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &nPixelsy, PredType::NATIVE_INT);
|
||||
dataset.write ( &(attr.nPixelsY), PredType::NATIVE_INT);
|
||||
|
||||
//Maximum frames per file
|
||||
dataset = group5.createDataSet ( "maximum frames per file", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &maxf, PredType::NATIVE_INT);
|
||||
dataset.write ( &(attr.maxFramesPerFile), PredType::NATIVE_INT);
|
||||
|
||||
//Total Frames
|
||||
dataset = group5.createDataSet ( "total frames", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &nf, PredType::STD_U64LE);
|
||||
dataset.write ( &(attr.totalFrames), PredType::STD_U64LE);
|
||||
|
||||
//Exptime
|
||||
dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &acquisitionTime, PredType::STD_U64LE);
|
||||
dataset.write ( &(attr.exptimeNs), PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//SubExptime
|
||||
dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &subexposuretime, PredType::STD_U64LE);
|
||||
dataset.write ( &(attr.subExptimeNs), PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//SubPeriod
|
||||
dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &subperiod, PredType::STD_U64LE);
|
||||
dataset.write ( &(attr.subPeriodNs), PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//Period
|
||||
dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &acquisitionPeriod, PredType::STD_U64LE);
|
||||
dataset.write ( &(attr.periodNs), PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//Gap Pixels Enable
|
||||
dataset = group5.createDataSet ( "gap pixels enable", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
|
||||
|
||||
//Quad Enable
|
||||
dataset = group5.createDataSet ( "quad enable", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
|
||||
|
||||
//Timestamp
|
||||
time_t t = time(0);
|
||||
dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace );
|
||||
|
@ -28,8 +28,8 @@
|
||||
#define MAX_CHUNKED_IMAGES 1
|
||||
|
||||
//versions
|
||||
#define HDF5_WRITER_VERSION 3.0 //1 decimal places
|
||||
#define BINARY_WRITER_VERSION 3.0 //1 decimal places
|
||||
#define HDF5_WRITER_VERSION 4.0 //1 decimal places
|
||||
#define BINARY_WRITER_VERSION 4.0 //1 decimal places
|
||||
|
||||
|
||||
//parameters to calculate fifo depth
|
||||
@ -48,3 +48,21 @@
|
||||
#define STREAMER_PRIORITY 10
|
||||
#define TCP_PRIORITY 10
|
||||
|
||||
|
||||
struct masterAttributes {
|
||||
double version;
|
||||
uint32_t detectorType;
|
||||
uint32_t dynamicRange;
|
||||
uint32_t tenGiga;
|
||||
uint32_t imageSize;
|
||||
uint32_t nPixelsX;
|
||||
uint32_t nPixelsY;
|
||||
uint32_t maxFramesPerFile;
|
||||
uint64_t totalFrames;
|
||||
uint64_t exptimeNs;
|
||||
uint64_t subExptimeNs;
|
||||
uint64_t subPeriodNs;
|
||||
uint64_t periodNs;
|
||||
uint32_t gapPixelsEnable;
|
||||
uint32_t quadEnable;
|
||||
};
|
||||
|
@ -114,9 +114,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
|
||||
}
|
||||
|
||||
|
||||
int BinaryFile::CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
|
||||
uint64_t ap) {
|
||||
int BinaryFile::CreateMasterFile(masterAttributes& attr) {
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
@ -127,10 +125,9 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
attr.version = BINARY_WRITER_VERSION;
|
||||
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
*overWriteEnable,
|
||||
*dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile,
|
||||
at, st, sp, ap, BINARY_WRITER_VERSION);
|
||||
*overWriteEnable, attr);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
@ -249,14 +249,11 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
||||
}
|
||||
|
||||
// only the first file
|
||||
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st,
|
||||
uint64_t sp, uint64_t ap) {
|
||||
int DataProcessor::CreateNewFile(masterAttributes& attr) {
|
||||
if (file == NULL)
|
||||
return FAIL;
|
||||
file->CloseAllFiles();
|
||||
if (file->CreateMasterFile(en, generalData->imageSize,
|
||||
generalData->nPixelsX, generalData->nPixelsY,
|
||||
at, st, sp, ap) == FAIL)
|
||||
if (file->CreateMasterFile(attr) == FAIL)
|
||||
return FAIL;
|
||||
if (file->CreateFile(currentFrameIndex) == FAIL)
|
||||
return FAIL;
|
||||
|
@ -243,9 +243,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
|
||||
uint64_t ap) {
|
||||
int HDF5File::CreateMasterFile(masterAttributes& attr) {
|
||||
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
@ -260,11 +258,9 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
pthread_mutex_lock(&Mutex);
|
||||
attr.version = HDF5_WRITER_VERSION;
|
||||
int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
*overWriteEnable,
|
||||
*dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile,
|
||||
at, st, sp, ap,
|
||||
HDF5_WRITER_VERSION);
|
||||
*overWriteEnable, attr);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
}
|
||||
|
@ -876,9 +876,23 @@ int UDPStandardImplementation::CreateUDPSockets() {
|
||||
|
||||
int UDPStandardImplementation::SetupWriter() {
|
||||
bool error = false;
|
||||
masterAttributes attr;
|
||||
attr.detectorType = myDetectorType;
|
||||
attr.dynamicRange = dynamicRange;
|
||||
attr.tenGiga = tengigaEnable;
|
||||
attr.imageSize = generalData->imageSize;
|
||||
attr.nPixelsX = generalData->nPixelsX;
|
||||
attr.nPixelsY = generalData->nPixelsY;
|
||||
attr.maxFramesPerFile = framesPerFile;
|
||||
attr.totalFrames = numberOfFrames;
|
||||
attr.exptimeNs = acquisitionTime;
|
||||
attr.subExptimeNs = subExpTime;
|
||||
attr.subPeriodNs = subPeriod;
|
||||
attr.periodNs = acquisitionPeriod;
|
||||
attr.gapPixelsEnable = gapPixelsEnable;
|
||||
attr.quadEnable = quadEnable;
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i)
|
||||
if (dataProcessor[i]->CreateNewFile(tengigaEnable,
|
||||
numberOfFrames, acquisitionTime, subExpTime, subPeriod, acquisitionPeriod) == FAIL) {
|
||||
if (dataProcessor[i]->CreateNewFile(attr) == FAIL) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user