From 1211d024281cbcb15951f17f6476e8c4f63ddb12 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 31 Jul 2020 16:19:34 +0200 Subject: [PATCH] hdf5 dependant master attributes --- slsReceiverSoftware/src/HDF5File.cpp | 320 +-------------------- slsReceiverSoftware/src/HDF5File.h | 4 +- slsReceiverSoftware/src/MasterAttributes.h | 306 +++++++++++++++++++- slsReceiverSoftware/src/receiver_defs.h | 2 +- 4 files changed, 312 insertions(+), 320 deletions(-) diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index 342f74b22..24157ee8a 100644 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -153,7 +153,7 @@ void HDF5File::WriteToFile(char *buffer, int bufferSize, } void HDF5File::CreateMasterFile(bool masterFileWriteEnable, - MasterAttributes &attr) { + MasterAttributes *attr) { // beginning of every acquisition numFramesInFile = 0; @@ -459,7 +459,7 @@ void HDF5File::CreateDataFile() { } } -void HDF5File::CreateMasterDataFile(MasterAttributes &attr) { +void HDF5File::CreateMasterDataFile(MasterAttributes *attr) { std::ostringstream os; os << *filePath << "/" << *fileNamePrefix << "_master" @@ -469,7 +469,6 @@ void HDF5File::CreateMasterDataFile(MasterAttributes &attr) { if (!(*silentMode)) { LOG(logINFO) << "Master File: " << masterFileName; } - masterFileAttributes.version = HDF5_WRITER_VERSION; std::lock_guard lock(HDF5File::hdf5Lib); @@ -486,15 +485,6 @@ void HDF5File::CreateMasterDataFile(MasterAttributes &attr) { masterfd = new H5File(masterFileName.c_str(), H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, flist); - // create attributes - // version - { - double dValue = masterFileAttributes.version; - DataSpace dataspace = DataSpace(H5S_SCALAR); - Attribute attribute = masterfd->createAttribute( - "version", PredType::NATIVE_DOUBLE, dataspace); - attribute.write(PredType::NATIVE_DOUBLE, &dValue); - } // Create a group in the file Group group1(masterfd->createGroup("entry")); Group group2(group1.createGroup("data")); @@ -503,309 +493,7 @@ void HDF5File::CreateMasterDataFile(MasterAttributes &attr) { Group group5(group3.createGroup("detector")); Group group6(group1.createGroup("sample")); - // Dynamic Range - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "dynamic range", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.dynamicRange), - PredType::NATIVE_INT); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("bits")); - } - - // Ten Giga - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - int iValue = masterFileAttributes.tenGiga; - DataSet dataset = group5.createDataSet( - "ten giga enable", PredType::NATIVE_INT, dataspace); - dataset.write(&iValue, PredType::NATIVE_INT); - } - - // Image Size - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "image size", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.imageSize), - PredType::NATIVE_INT); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("bytes")); - } - - // x - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "number of pixels in x axis", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.nPixelsX), - PredType::NATIVE_INT); - } - - // y - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "number of pixels in y axis", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.nPixelsY), - PredType::NATIVE_INT); - } - - // Maximum frames per file - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "maximum frames per file", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.maxFramesPerFile), - PredType::NATIVE_INT); - } - - // Total Frames - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "total frames", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.totalFrames), - PredType::STD_U64LE); - } - - // Exptime - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "exposure time", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.exptimeNs), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // SubExptime - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "sub exposure time", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.subExptimeNs), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // SubPeriod - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "sub period", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.subPeriodNs), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // Period - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "acquisition period", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.periodNs), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // Quad Enable - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "quad enable", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.quadEnable), - PredType::NATIVE_INT); - } - - // Analog Flag - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "analog flag", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.analogFlag), - PredType::NATIVE_INT); - } - - // Digital Flag - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "digital flag", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.digitalFlag), - PredType::NATIVE_INT); - } - - // ADC Mask - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "adc mask", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.adcmask), - PredType::NATIVE_INT); - } - - // Dbit Offset - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "dbit offset", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.dbitoffset), - PredType::NATIVE_INT); - } - - // Dbit List - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "dbit bitset list", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.dbitlist), - PredType::STD_U64LE); - } - - // Roi xmin - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "roi xmin", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.roiXmin), - PredType::NATIVE_INT); - } - - // Roi xmax - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "roi xmax", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.roiXmax), - PredType::NATIVE_INT); - } - - // Exptime1 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "exposure time1", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.exptime1Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // Exptime2 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "exposure time2", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.exptime2Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // Exptime3 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "exposure time3", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.exptime3Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // GateDelay1 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "gate delay1", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.gateDelay1Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // GateDelay2 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "gate delay2", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.gateDelay2Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // GateDelay3 - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = group5.createDataSet( - "gate delay3", PredType::STD_U64LE, dataspace); - dataset.write(&(masterFileAttributes.gateDelay3Ns), - PredType::STD_U64LE); - DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); - StrType strdatatype(PredType::C_S1, 256); - Attribute attribute = - dataset.createAttribute("unit", strdatatype, dataspaceAttr); - attribute.write(strdatatype, std::string("ns")); - } - - // Dbit Offset - { - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = - group5.createDataSet("gates", PredType::NATIVE_INT, dataspace); - dataset.write(&(masterFileAttributes.gates), PredType::NATIVE_INT); - } - - // Timestamp - { - time_t t = time(nullptr); - StrType strdatatype(PredType::C_S1, 256); - DataSpace dataspace = DataSpace(H5S_SCALAR); - DataSet dataset = - group5.createDataSet("timestamp", strdatatype, dataspace); - dataset.write(std::string(ctime(&t)), strdatatype); - } - + attr->WriteMasterHDF5Attributes(masterfd, &group5); masterfd->close(); } catch (const Exception &error) { @@ -893,7 +581,7 @@ void HDF5File::CreateVirtualDataFile(uint32_t maxFramesPerFile, uint64_t numf) { if (H5Pset_fill_value(dcpl, GetDataTypeinC(datatype), &fill_value) < 0) throw sls::RuntimeError( "Could not create fill value in virtual file " + vname); - hid_t dcpl_para[parameterNames.size()]; + std::vector dcpl_para(parameterNames.size()); for (unsigned int i = 0; i < parameterNames.size(); ++i) { dcpl_para[i] = H5Pcreate(H5P_DATASET_CREATE); if (dcpl_para[i] < 0) diff --git a/slsReceiverSoftware/src/HDF5File.h b/slsReceiverSoftware/src/HDF5File.h index dfac6013d..110f50810 100644 --- a/slsReceiverSoftware/src/HDF5File.h +++ b/slsReceiverSoftware/src/HDF5File.h @@ -51,7 +51,7 @@ class HDF5File : private virtual slsDetectorDefs, public File { void WriteToFile(char *buffer, int bufferSize, uint64_t currentFrameNumber, uint32_t numPacketsCaught); void CreateMasterFile(bool masterFileWriteEnable, - MasterAttributes &attr) override; + MasterAttributes *attr) override; void EndofAcquisition(bool anyPacketsCaught, uint64_t numImagesCaught); private: @@ -61,7 +61,7 @@ class HDF5File : private virtual slsDetectorDefs, public File { sls_receiver_header *rheader); void ExtendDataset(); void CreateDataFile(); - void CreateMasterDataFile(MasterAttributes &attr); + void CreateMasterDataFile(MasterAttributes *attr); void CreateVirtualDataFile(uint32_t maxFramesPerFile, uint64_t numf); void LinkVirtualInMaster(std::string fname, std::string dsetname); hid_t GetDataTypeinC(DataType dtype); diff --git a/slsReceiverSoftware/src/MasterAttributes.h b/slsReceiverSoftware/src/MasterAttributes.h index 1ab114665..0fc520e8d 100644 --- a/slsReceiverSoftware/src/MasterAttributes.h +++ b/slsReceiverSoftware/src/MasterAttributes.h @@ -93,9 +93,118 @@ class MasterAttributes { }; #ifdef HDF5C - virtual void Write + virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group) { + LOG(logERROR) << "WriteMasterHdf5Attributes should have been called " + "by a child class"; + }; + + void WriteHDF5Attributes(H5File *fd, Group *group){ + // clang-format off + // version + { + double version = BINARY_WRITER_VERSION; + DataSpace dataspace = DataSpace(H5S_SCALAR); + Attribute attribute = fd->createAttribute( + "version", PredType::NATIVE_DOUBLE, dataspace); + attribute.write(PredType::NATIVE_DOUBLE, &version); + } + // timestamp + { + time_t t = time(nullptr); + StrType strdatatype(PredType::C_S1, 256); + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = + group->createDataSet("timestamp", strdatatype, dataspace); + dataset.write(std::string(ctime(&t)), strdatatype); + } + // detector type + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("detector type", strdatatype, dataspace); + dataset.write(sls::ToString(detType), strdatatype); + } + // Image Size + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "image size", PredType::NATIVE_INT, dataspace); + dataset.write(&imageSize, PredType::NATIVE_INT); + DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + Attribute attribute = + dataset.createAttribute("unit", strdatatype, dataspaceAttr); + attribute.write(strdatatype, std::string("bytes")); + } + //TODO: make this into an array? + // x + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "number of pixels in x axis", PredType::NATIVE_INT, dataspace); + dataset.write(&nPixels.x, PredType::NATIVE_INT); + } + // y + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "number of pixels in y axis", PredType::NATIVE_INT, dataspace); + dataset.write(&nPixels.y, PredType::NATIVE_INT); + } + // Maximum frames per file + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "maximum frames per file", PredType::NATIVE_INT, dataspace); + dataset.write(&maxFramesPerFile, PredType::NATIVE_INT); + } + // Total Frames + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "total frames", PredType::STD_U64LE, dataspace); + dataset.write(&totalFrames, PredType::STD_U64LE); + } + }; + + void WriteHDF5Exptime(H5File *fd, Group *group) { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("exposure time", strdatatype, dataspace); + dataset.write(sls::ToString(exptime), strdatatype); + }; + + void WriteHDF5Period(H5File *fd, Group *group) { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("acquisition period", strdatatype, dataspace); + dataset.write(sls::ToString(period), strdatatype); + }; + + void WriteHDF5DynamicRange(H5File *fd, Group *group) { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "dynamic range", PredType::NATIVE_INT, dataspace); + dataset.write(&dynamicRange, PredType::NATIVE_INT); + DataSpace dataspaceAttr = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + Attribute attribute = + dataset.createAttribute("unit", strdatatype, dataspaceAttr); + attribute.write(strdatatype, std::string("bits")); + }; + + void WriteHDF5TenGiga(H5File *fd, Group *group) { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "ten giga enable", PredType::NATIVE_INT, dataspace); + dataset.write(&tenGiga, PredType::NATIVE_INT); + }; #endif }; +// clang-format on class GotthardMasterAttributes : public MasterAttributes { public: @@ -110,6 +219,28 @@ class GotthardMasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + // Roi xmin + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "roi xmin", PredType::NATIVE_INT, dataspace); + dataset.write(&roi.xmin, PredType::NATIVE_INT); + } + // Roi xmax + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "roi xmax", PredType::NATIVE_INT, dataspace); + dataset.write(&roi.xmax, PredType::NATIVE_INT); + } + }; +#endif }; class JungfrauMasterAttributes : public MasterAttributes { @@ -124,6 +255,14 @@ class JungfrauMasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + }; +#endif }; class EigerMasterAttributes : public MasterAttributes { @@ -145,6 +284,39 @@ class EigerMasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5DynamicRange(fd, group); + MasterAttributes::WriteHDF5TenGiga(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + // SubExptime + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = group->createDataSet("sub exposure time", + strdatatype, dataspace); + dataset.write(sls::ToString(subExptime), strdatatype); + } + // SubPeriod + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("sub period", strdatatype, dataspace); + dataset.write(sls::ToString(subPeriod), strdatatype); + } + // Quad + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = + group->createDataSet("quad", PredType::NATIVE_INT, dataspace); + dataset.write(&quad, PredType::NATIVE_INT); + } + }; +#endif }; class Mythen3MasterAttributes : public MasterAttributes { @@ -173,6 +345,70 @@ class Mythen3MasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5DynamicRange(fd, group); + MasterAttributes::WriteHDF5TenGiga(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + // Exptime1 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("exposure time1", strdatatype, dataspace); + dataset.write(sls::ToString(exptime1), strdatatype); + } + // Exptime2 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("exposure time2", strdatatype, dataspace); + dataset.write(sls::ToString(exptime2), strdatatype); + } + // Exptime3 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("exposure time3", strdatatype, dataspace); + dataset.write(sls::ToString(exptime3), strdatatype); + } + // GateDelay1 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("gate delay1", strdatatype, dataspace); + dataset.write(sls::ToString(gateDelay1), strdatatype); + } + // GateDelay2 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("gate delay2", strdatatype, dataspace); + dataset.write(sls::ToString(gateDelay2), strdatatype); + } + // GateDelay3 + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + StrType strdatatype(PredType::C_S1, 256); + DataSet dataset = + group->createDataSet("gate delay3", strdatatype, dataspace); + dataset.write(sls::ToString(gateDelay3), strdatatype); + } + // Gates + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = + group->createDataSet("gates", PredType::STD_U32LE, dataspace); + dataset.write(&gates, PredType::STD_U64LE); + } + }; +#endif }; class Gotthard2MasterAttributes : public MasterAttributes { @@ -187,6 +423,14 @@ class Gotthard2MasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + }; +#endif }; class MoenchMasterAttributes : public MasterAttributes { @@ -204,6 +448,22 @@ class MoenchMasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + MasterAttributes::WriteHDF5TenGiga(fd, group); + // ADC Mask + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "adc mask", PredType::NATIVE_INT, dataspace); + dataset.write(&adcmask, PredType::NATIVE_INT); + } + }; +#endif }; class CtbMasterAttributes : public MasterAttributes { @@ -225,4 +485,48 @@ class CtbMasterAttributes : public MasterAttributes { std::string message = oss.str(); MasterAttributes::WriteBinaryAttributes(fd, message); }; + +#ifdef HDF5C + void WriteMasterHDF5Attributes(H5File *fd, Group *group) override { + MasterAttributes::WriteHDF5Attributes(fd, group); + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + MasterAttributes::WriteHDF5TenGiga(fd, group); + // ADC Mask + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "adc mask", PredType::NATIVE_INT, dataspace); + dataset.write(&adcmask, PredType::NATIVE_INT); + } + // Analog Flag + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "analog flag", PredType::NATIVE_INT, dataspace); + dataset.write(&analog, PredType::NATIVE_INT); + } + // Digital Flag + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "digital flag", PredType::NATIVE_INT, dataspace); + dataset.write(&digital, PredType::NATIVE_INT); + } + // Dbit Offset + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "dbit offset", PredType::NATIVE_INT, dataspace); + dataset.write(&dbitoffset, PredType::NATIVE_INT); + } + // Dbit List + { + DataSpace dataspace = DataSpace(H5S_SCALAR); + DataSet dataset = group->createDataSet( + "dbit bitset list", PredType::STD_U64LE, dataspace); + dataset.write(&dbitlist, PredType::STD_U64LE); + } + }; +#endif }; \ No newline at end of file diff --git a/slsReceiverSoftware/src/receiver_defs.h b/slsReceiverSoftware/src/receiver_defs.h index ba7ca56fb..e22fb6380 100755 --- a/slsReceiverSoftware/src/receiver_defs.h +++ b/slsReceiverSoftware/src/receiver_defs.h @@ -86,4 +86,4 @@ struct masterAttributes { uint64_t gateDelay3Ns; uint32_t gates; }; -*/ \ No newline at end of file +*/