in between stage

This commit is contained in:
Dhanya Maliakal
2017-04-04 11:20:38 +02:00
parent fb0b0b96ec
commit b401a6c33b
11 changed files with 142 additions and 129 deletions

View File

@ -1,10 +1,8 @@
/************************************************
* @file HDF5File.h
* @file HDF5File.cpp
* @short sets/gets properties for the HDF5 file,
* creates/closes the file and writes data to it
***********************************************/
#pragma once
#include "HDF5File.h"
#include "receiver_defs.h"
@ -13,16 +11,11 @@
using namespace std;
pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER;
H5File* HDF5File::masterfd = 0;
hid_t HDF5File::virtualfd = 0;
const int const HDF5File::NUM_PARAMETERS = 13;
const char * const HDF5File::PARAMETERS[] = {
"frameNumber", "expLength", "packetNumber", "bunchId", "timestamp", "modId",
"xCoord", "yCoord", "zCoord", "debug", "roundRNumber", "detType", "version"};
const DataType * const HDF5File::PARAMETER_DATATYPES[] = {
PredType::STD_U64LE, PredType::STD_U32LE, PredType::STD_U32LE, PredType::STD_U64LE, PredType::STD_U64LE, PredType::STD_U16LE,
PredType::STD_U16LE, PredType::STD_U16LE, PredType::STD_U16LE, PredType::STD_U32LE, PredType::STD_U16LE, PredType::STD_U8LE, PredType::STD_U8LE};
HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
@ -38,12 +31,13 @@ HDF5File::HDF5File(int ind, int* nd, char* fname, char* fpath, uint64_t* findex,
nPixelsY(ny),
numFramesInFile(0),
numFilesinAcquisition(0),
dataspace_para(0),
dataset_para(0)
dataspace_para(0)
{
#ifdef VERBOSE
PrintMembers();
#endif
for (int i = 0; i < HDF5FileStatic::NumberofParameters; ++i)
dataset_para[i] = 0;
}
@ -101,7 +95,6 @@ int HDF5File::CreateFile(uint64_t fnum) {
fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
datatype, filefd, dataspace, dataset,
HDF5_WRITER_VERSION, MAX_CHUNKED_IMAGES,
NUM_PARAMETERS, PARAMETERS, PARAMETER_DATATYPES,
dataspace_para, dataset_para) == FAIL) {
pthread_mutex_unlock(&Mutex);
return FAIL;
@ -114,7 +107,7 @@ int HDF5File::CreateFile(uint64_t fnum) {
void HDF5File::CloseCurrentFile() {
pthread_mutex_lock(&Mutex);
HDF5FileStatic::CloseDataFile(index, filefd, dataspace, dataset, NUM_PARAMETERS, dataset_para);
HDF5FileStatic::CloseDataFile(index, filefd);
pthread_mutex_unlock(&Mutex);
}
@ -122,7 +115,7 @@ void HDF5File::CloseCurrentFile() {
void HDF5File::CloseAllFiles() {
numFilesinAcquisition = 0;
pthread_mutex_lock(&Mutex);
HDF5FileStatic::CloseDataFile(index, filefd, dataspace, dataset, NUM_PARAMETERS, dataset_para);
HDF5FileStatic::CloseDataFile(index, filefd);
if (master && (*detIndex==0)) {
HDF5FileStatic::CloseMasterDataFile(masterfd);
HDF5FileStatic::CloseVirtualDataFile(virtualfd);
@ -138,17 +131,14 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
}
numFramesInFile++;
sls_detector_header* header = (sls_detector_header*) (buffer);
uint32_t snum = header->expLength;
uint64_t bid = header->expLength;
pthread_mutex_lock(&Mutex);
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
fnum%maxFramesPerFile, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
dataspace, dataset, datatype) == OK) {
sls_detector_header* header = (sls_detector_header*) (buffer);
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
fnum%maxFramesPerFile,
dataset_para, PARAMETER_DATATYPES,
&snum, &bid) == OK) {
dataset_para, header) == OK) {
pthread_mutex_unlock(&Mutex);
return OK;
}
@ -188,7 +178,7 @@ void HDF5File::EndofAcquisition(uint64_t numf) {
osfn << "/data";
if (*frameIndexEnable) osfn << "_f" << setfill('0') << setw(12) << 0;
string dsetname = osfn.str();
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName, dsetname, para1, para2);
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName, dsetname);
}
}
numFilesinAcquisition = 0;
@ -204,8 +194,7 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
filePath, fileNamePrefix, *fileIndex, *frameIndexEnable,
*detIndex, *numUnitsPerDetector,
maxFramesPerFile, numf,
"data", para1, para2,
datatype, datatype_para1, datatype_para2,
"data", datatype,
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
HDF5_WRITER_VERSION);
pthread_mutex_unlock(&Mutex);
@ -213,4 +202,3 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
}
return OK;
}