diff --git a/slsReceiverSoftware/src/MasterAttributes.cpp b/slsReceiverSoftware/src/MasterAttributes.cpp index acdc27f4a..d265693eb 100644 --- a/slsReceiverSoftware/src/MasterAttributes.cpp +++ b/slsReceiverSoftware/src/MasterAttributes.cpp @@ -168,11 +168,11 @@ void MasterAttributes::GetFinalBinaryAttributes( #ifdef HDF5C void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); // timestamp { time_t t = std::time(nullptr); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); H5::DataSet dataset = group->createDataSet("Timestamp", strdatatype, dataspace); @@ -182,7 +182,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, // detector type { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::DataSet dataset = group->createDataSet("Detector Type", strdatatype, dataspace); strcpy_safe(c, ToString(detType)); @@ -191,7 +190,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, // timing mode { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::DataSet dataset = group->createDataSet("Timing Mode", strdatatype, dataspace); strcpy_safe(c, ToString(timingMode)); @@ -219,7 +217,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, "Image Size", H5::PredType::NATIVE_INT, dataspace); dataset.write(&imageSize, H5::PredType::NATIVE_INT); H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::Attribute attribute = dataset.createAttribute("Unit", strdatatype, dataspaceAttr); strcpy_safe(c, "bytes"); @@ -250,7 +247,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, // Frame Discard Policy { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::DataSet dataset = group->createDataSet("Frame Discard Policy", strdatatype, dataspace); strcpy_safe(c, ToString(frameDiscardMode)); @@ -266,7 +262,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, // Scan Parameters { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::DataSet dataset = group->createDataSet("Scan Parameters", strdatatype, dataspace); strcpy_safe(c, ToString(scanParams)); @@ -282,7 +277,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, // Receiver Roi { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 1024); H5::DataSet dataset = group->createDataSet( "receiver roi", H5::PredType::NATIVE_INT, dataspace); strcpy_safe(c, ToString(receiverRoi)); @@ -292,7 +286,6 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; // Total Frames in file { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); @@ -307,6 +300,7 @@ void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); H5::DataSet dataset = group->createDataSet("Additional JSON Header", strdatatype, dataspace); + char c[sizeof(strdatatype)]{}; strcpy_safe(c, ToString(additionalJsonHeader)); dataset.write(c, strdatatype); } @@ -314,20 +308,20 @@ void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, void MasterAttributes::WriteHDF5Exptime(H5::H5File *fd, H5::Group *group) { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Exposure Time", strdatatype, dataspace); - char c[1024]{}; + char c[HSTR_LEN]{}; strcpy_safe(c, ToString(exptime)); dataset.write(c, strdatatype); } void MasterAttributes::WriteHDF5Period(H5::H5File *fd, H5::Group *group) { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Acquisition Period", strdatatype, dataspace); - char c[1024]{}; + char c[HSTR_LEN]{}; strcpy_safe(c, ToString(period)); dataset.write(c, strdatatype); } @@ -338,10 +332,10 @@ void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) { "Dynamic Range", H5::PredType::NATIVE_INT, dataspace); dataset.write(&dynamicRange, H5::PredType::NATIVE_INT); H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::Attribute attribute = dataset.createAttribute("Unit", strdatatype, dataspaceAttr); - char c[1024] = "bits"; + char c[HSTR_LEN] = "bits"; attribute.write(strdatatype, c); } @@ -369,13 +363,13 @@ void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) { void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); H5::DataSet dataset = group->createDataSet( "Threshold Energy", H5::PredType::NATIVE_INT, dataspace); dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT); H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::Attribute attribute = dataset.createAttribute("Unit", strdatatype, dataspaceAttr); strcpy_safe(c, "eV"); @@ -384,9 +378,9 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 1024); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Threshold Energies", strdatatype, dataspace); strcpy_safe(c, ToString(thresholdAllEnergyeV)); @@ -394,9 +388,9 @@ void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, } void MasterAttributes::WriteHDF5SubExpTime(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Sub Exposure Time", strdatatype, dataspace); strcpy_safe(c, ToString(subExptime)); @@ -404,9 +398,9 @@ void MasterAttributes::WriteHDF5SubExpTime(H5::H5File *fd, H5::Group *group) { } void MasterAttributes::WriteHDF5SubPeriod(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Sub Period", strdatatype, dataspace); strcpy_safe(c, ToString(subPeriod)); @@ -422,9 +416,9 @@ void MasterAttributes::WriteHDF5SubQuad(H5::H5File *fd, H5::Group *group) { void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 1024); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Rate Corrections", strdatatype, dataspace); strcpy_safe(c, ToString(ratecorr)); @@ -439,9 +433,9 @@ void MasterAttributes::WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group) { } void MasterAttributes::WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Exposure Times", strdatatype, dataspace); strcpy_safe(c, ToString(exptimeArray)); @@ -450,9 +444,9 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group) { void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd, H5::Group *group) { - char c[1024]{}; + char c[HSTR_LEN]{}; H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Gate Delays", strdatatype, dataspace); strcpy_safe(c, ToString(gateDelayArray)); @@ -468,10 +462,10 @@ void MasterAttributes::WriteHDF5Gates(H5::H5File *fd, H5::Group *group) { void MasterAttributes::WriteHDF5BurstMode(H5::H5File *fd, H5::Group *group) { H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); - H5::StrType strdatatype(H5::PredType::C_S1, 256); + H5::StrType strdatatype(H5::PredType::C_S1, HSTR_LEN); H5::DataSet dataset = group->createDataSet("Burst Mode", strdatatype, dataspace); - char c[1024]{}; + char c[HSTR_LEN]{}; strcpy_safe(c, ToString(burstMode)); dataset.write(c, strdatatype); } diff --git a/slsReceiverSoftware/src/MasterAttributes.h b/slsReceiverSoftware/src/MasterAttributes.h index 0e3c168ae..49ca9b263 100644 --- a/slsReceiverSoftware/src/MasterAttributes.h +++ b/slsReceiverSoftware/src/MasterAttributes.h @@ -151,7 +151,13 @@ class MasterAttributes { rapidjson::PrettyWriter *w); #ifdef HDF5C void WriteXilinxCtbHDF5Attributes(H5::H5File *fd, H5::Group *group); +#endif + private: +#ifdef HDF5C + static const int HSTR_LEN = 1024; #endif }; + + } // namespace sls