From 85c958facf27c242fcd19b42084e09bfe397e734 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 30 Jul 2020 18:05:47 +0200 Subject: [PATCH] WIP det dependant master file attribtes --- slsReceiverSoftware/src/Implementation.cpp | 1 + .../src/masterFileAttributes.h | 116 ++++++++++++++++++ slsReceiverSoftware/src/receiver_defs.h | 7 +- slsSupportLib/include/ToString.h | 2 + slsSupportLib/src/ToString.cpp | 10 ++ 5 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 slsReceiverSoftware/src/masterFileAttributes.h diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 0bb059f82..0e56c1163 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -7,6 +7,7 @@ #include "ToString.h" #include "ZmqSocket.h" //just for the zmq port define #include "file_utils.h" +#include "masterFileAttributes.h" #include //eperm #include diff --git a/slsReceiverSoftware/src/masterFileAttributes.h b/slsReceiverSoftware/src/masterFileAttributes.h new file mode 100644 index 000000000..5b0a4a702 --- /dev/null +++ b/slsReceiverSoftware/src/masterFileAttributes.h @@ -0,0 +1,116 @@ +#pragma once + +#include "sls_detector_defs.h" +#include "logger.h" +#include "ToString.h" + +// versions +#define HDF5_WRITER_VERSION (6.1) // 1 decimal places +#define BINARY_WRITER_VERSION (6.1) // 1 decimal places + +class masterFileAttributes { + + public: + double version{0.0}; + slsDetectorDefs::detectorType detType{slsDetectorDefs::GENERIC}; + uint32_t imageSize{0}; + slsDetectorDefs::xy nPixels{}; + uint32_t maxFramesPerFile{0}; + uint64_t totalFrames{0}; + uint64_t exptimeNs{0}; + uint64_t periodNs{0}; + uint32_t dynamicRange{0}; + uint32_t tenGiga{0}; + uint64_t subExptimeNs{0}; + uint64_t subPeriodNs{0}; + uint32_t quadEnable{0}; + uint32_t adcmask{0}; + uint32_t analogFlag{0}; + uint32_t digitalFlag{0}; + uint32_t dbitoffset{0}; + uint64_t dbitlist{0}; + slsDetectorDefs::ROI roi{}; + uint64_t exptime1Ns{0}; + uint64_t exptime2Ns{0}; + uint64_t exptime3Ns{0}; + uint64_t gateDelay1Ns{0}; + uint64_t gateDelay2Ns{0}; + uint64_t gateDelay3Ns{0}; + uint32_t gates; + /* + double version{0.0}; + slsDetectorDefs::detectorType myDetectorType{slsDetectorDefs::GENERIC}; + uint32_t imageSize{0}; + uint32_t nPixelsX{0}; + uint32_t nPixelsY{0}; + uint32_t maxFramesPerFile{0}; + uint64_t totalFrames{0}; + uint64_t exptimeNs{0}; + uint64_t periodNs{0}; +*/ + /* eiger + uint32_t dynamicRange{0}; + uint32_t tenGiga{0}; + uint64_t subExptimeNs{0}; + uint64_t subPeriodNs{0}; + uint32_t quadEnable{0}; + */ + /** moench + uint32_t tenGiga{0}; + uint32_t adcmask{0}; + */ + /* ctb + uint32_t tenGiga{0}; + uint32_t adcmask{0}; + uint32_t analogFlag{0}; + uint32_t digitalFlag{0}; + uint32_t dbitoffset{0}; + uint64_t dbitlist{0}; + */ + /* gotthard + uint32_t roiXmin{0}; + uint32_t roiXmax{0}; + */ + /* mythen3 + uint32_t dynamicRange{0}; + uint32_t tenGiga{0}; + uint64_t exptime1Ns{0}; + uint64_t exptime2Ns{0}; + uint64_t exptime3Ns{0}; + uint64_t gateDelay1Ns{0}; + uint64_t gateDelay2Ns{0}; + uint64_t gateDelay3Ns{0}; + uint32_t gates; +*/ + masterFileAttributes(){}; + virtual ~masterFileAttributes(){}; + + std::string GetBinaryMasterFileAttributes() { + std::ostringstream oss; + oss << "Version : " << std::setprecision(2) << version << '\n' + << "Detector Type : " << sls::ToString(detType) << '\n' + << "Image Size : " << imageSize << " bytes" << '\n' + << "nPixels : " << sls::ToString(nPixels) << " pixels" << '\n' + << "Max Frames Per File : " << maxFramesPerFile << '\n' + << "Total Frames : " << totalFrames << '\n' + << "Exptime (ns) : " << exptimeNs << '\n' + << "Period (ns) : " << periodNs << '\n'; + return oss.str(); + }; + + // hdf5 +}; + +class GotthardMasterFileAttributes : public masterFileAttributes { + + public: + GotthardMasterFileAttributes() {}; + + std::string GetBinaryMasterFileAttributes() { + std::ostringstream oss; + oss << masterFileAttributes::GetBinaryMasterFileAttributes() + << "Roi (xmin, xmax) : " << sls::ToString(roi) << '\n'; + return oss.str(); + }; +}; + diff --git a/slsReceiverSoftware/src/receiver_defs.h b/slsReceiverSoftware/src/receiver_defs.h index 7a5e91c1e..e2397e97a 100755 --- a/slsReceiverSoftware/src/receiver_defs.h +++ b/slsReceiverSoftware/src/receiver_defs.h @@ -39,10 +39,6 @@ // hdf5 #define MAX_CHUNKED_IMAGES (1) -// versions -#define HDF5_WRITER_VERSION (6.0) // 1 decimal places -#define BINARY_WRITER_VERSION (6.0) // 1 decimal places - // parameters to calculate fifo depth #define SAMPLE_TIME_IN_NS (100000000) // 100ms #define MAX_EIGER_ROWS_PER_READOUT (256) @@ -57,6 +53,9 @@ #define STREAMER_PRIORITY (10) #define TCP_PRIORITY (10) + +#define HDF5_WRITER_VERSION (6.1) // 1 decimal places +#define BINARY_WRITER_VERSION (6.1) // 1 decimal places struct masterAttributes { double version; uint32_t detectorType; diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index 5654ef7ed..fb2c2747f 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -39,6 +39,8 @@ std::string ToString(const std::vector &vec); std::string ToString(const defs::burstMode s); std::string ToString(const defs::timingSourceType s); +std::string ToString(const slsDetectorDefs::xy &coord); +std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord); std::string ToString(const slsDetectorDefs::ROI &roi); std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi); std::string ToString(const slsDetectorDefs::rxParameters &r); diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 18a55af0d..334192deb 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -3,6 +3,16 @@ namespace sls { +std::string ToString(const slsDetectorDefs::xy &coord) { + std::ostringstream oss; + oss << '[' << coord.x << ", " << coord.y << ']'; + return oss.str(); +} + +std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord) { + return os << ToString(coord); +} + std::string ToString(const slsDetectorDefs::ROI &roi) { std::ostringstream oss; oss << '[' << roi.xmin << ", " << roi.xmax << ']';