From f818ac46b87ef9bcf146438514857eaa614e66cd Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 6 Jan 2022 15:15:42 +0100 Subject: [PATCH 1/3] int64_t in receiver missing packets --- CMakeLists.txt | 3 +++ slsReceiverSoftware/src/Implementation.cpp | 15 +++++---------- slsReceiverSoftware/src/Implementation.h | 2 +- slsReceiverSoftware/src/Listener.cpp | 4 ++-- slsReceiverSoftware/src/Listener.h | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8774bd733..02cdad9cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,9 @@ if (NOT TARGET libzmq) endif() endif() +get_target_property(VAR libzmq INTERFACE_INCLUDE_DIRECTORIES) +message(STATUS "zmq: ${VAR}") + if (SLS_USE_TESTS) enable_testing() add_subdirectory(tests) diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 4e68049a7..8ed01eeb4 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -473,9 +473,9 @@ double Implementation::getProgress() const { ((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames)); } -std::vector Implementation::getNumMissingPackets() const { - std::vector mp(numThreads); - for (int i = 0; i < numThreads; i++) { +std::vector Implementation::getNumMissingPackets() const { + std::vector mp(numThreads); + for (int i = 0; i < numThreads; ++i) { int np = generalData->packetsPerFrame; uint64_t totnp = np; // ReadNRows @@ -595,12 +595,7 @@ void Implementation::stopReceiver() { LOG(logINFO) << "Status: " << sls::ToString(status); { // statistics - auto tmp = getNumMissingPackets(); - // convert to signed missing packets (to get excess) - std::vector mp; - for (auto val : tmp) { - mp.push_back(static_cast(val)); - } + auto mp = getNumMissingPackets(); // print summary uint64_t tot = 0; for (int i = 0; i < numThreads; i++) { @@ -609,7 +604,7 @@ void Implementation::stopReceiver() { std::string mpMessage = std::to_string(mp[i]); if (mp[i] < 0) { mpMessage = - std::to_string(abs(mp[i])) + std::string(" (Extra)"); + std::to_string(std::abs(mp[i])) + std::string(" (Extra)"); } TLogLevel lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN; diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 5e5baf863..b50280832 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -83,7 +83,7 @@ class Implementation : private virtual slsDetectorDefs { uint64_t getFramesCaught() const; uint64_t getAcquisitionIndex() const; double getProgress() const; - std::vector getNumMissingPackets() const; + std::vector getNumMissingPackets() const; void setScan(slsDetectorDefs::scanParameters s); void startReceiver(); void setStoppedFlag(bool stopped); diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index c1ed94185..3dc7a5559 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -40,8 +40,8 @@ uint64_t Listener::GetLastFrameIndexCaught() const { return lastCaughtFrameIndex; } -uint64_t Listener::GetNumMissingPacket(bool stoppedFlag, - uint64_t numPackets) const { +int64_t Listener::GetNumMissingPacket(bool stoppedFlag, + uint64_t numPackets) const { if (!stoppedFlag) { return (numPackets - numPacketsCaught); } diff --git a/slsReceiverSoftware/src/Listener.h b/slsReceiverSoftware/src/Listener.h index 8cdc4b930..18dbf3ef5 100644 --- a/slsReceiverSoftware/src/Listener.h +++ b/slsReceiverSoftware/src/Listener.h @@ -63,8 +63,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { */ uint64_t GetLastFrameIndexCaught() const; - /** Get number of missing packets */ - uint64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const; + /** Get number of missing packets, returns negative values in case to extra packet */ + int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const; /** * Set Fifo pointer to the one given From 2aaf59adb3de2cd3043f6d810ac68d2876948f16 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 6 Jan 2022 16:44:19 +0100 Subject: [PATCH 2/3] added libtiff as dependency for Moench --- docs/src/dependencies.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/dependencies.rst b/docs/src/dependencies.rst index 6b4117d5c..03a192f3f 100644 --- a/docs/src/dependencies.rst +++ b/docs/src/dependencies.rst @@ -34,6 +34,12 @@ Python bindings * pybind11 (packaged in libs/) +----------------------- +Moench executables +----------------------- + + * libtiff + ----------------------- Documentation ----------------------- From 7871a78c8f2b4a5fc120bd39b0b71c1ba250fe8e Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Fri, 14 Jan 2022 13:39:40 +0100 Subject: [PATCH 3/3] updates to work with ctb and moench04 --- ctbGui/patternGenerator/generator.c | 6 +- .../dataStructures/moench04CtbReceiverData.h | 2 +- .../dataStructures/moench04CtbZmq10GbData.h | 117 ++++++++++++++++-- 3 files changed, 111 insertions(+), 14 deletions(-) diff --git a/ctbGui/patternGenerator/generator.c b/ctbGui/patternGenerator/generator.c index c6c7406a8..3e36a7756 100644 --- a/ctbGui/patternGenerator/generator.c +++ b/ctbGui/patternGenerator/generator.c @@ -69,14 +69,14 @@ void setoutput(int bit) { mask=mask< { row=200+i/sc_width; } dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1); - if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32) + if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32+sizeof(sls_detector_header)) cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; } } diff --git a/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h b/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h index 64b0587a8..63d162792 100644 --- a/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h +++ b/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h @@ -4,6 +4,46 @@ #define MOENCH04ZMQ10GBDATA_H #include "slsDetectorData.h" +#ifndef SLS_DETECTOR_HEADER +#define SLS_DETECTOR_HEADER + +//#define VERSION_V2 + /** + @short structure for a Detector Packet or Image Header + @li frameNumber is the frame number + @li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + @li packetNumber is the packet number + @li bunchId is the bunch id from beamline + @li timestamp is the time stamp with 10 MHz clock + @li modId is the unique module id (unique even for left, right, top, bottom) + @li xCoord is the x coordinate in the complete detector system + @li yCoord is the y coordinate in the complete detector system + @li zCoord is the z coordinate in the complete detector system + @li debug is for debugging purposes + @li roundRNumber is the round robin set number + @li detType is the detector type see :: detectorType + @li version is the version number of this structure format + */ + typedef struct { + uint64_t frameNumber; /**< is the frame number */ + uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */ + uint32_t packetNumber; /**< is the packet number */ + uint64_t bunchId; /**< is the bunch id from beamline */ + uint64_t timestamp; /**< is the time stamp with 10 MHz clock */ + uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */ + uint16_t xCoord; /**< is the x coordinate in the complete detector system */ + uint16_t yCoord; /**< is the y coordinate in the complete detector system */ + uint16_t zCoord; /**< is the z coordinate in the complete detector system */ + uint32_t debug; /**< is for debugging purposes */ + uint16_t roundRNumber; /**< is the round robin set number */ + uint8_t detType; /**< is the detector type see :: detectorType */ + uint8_t version; /**< is the version number of this structure format */ + uint64_t packetCaught[8]; /**< is the version number of this structure format */ + + } sls_detector_header; +#endif + + @@ -17,7 +57,7 @@ class moench04CtbZmq10GbData : public slsDetectorData { int sc_height; const int aSamples; const int dSamples; - + int off; public: @@ -31,8 +71,16 @@ class moench04CtbZmq10GbData : public slsDetectorData { */ //moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) { +#ifndef RAWDATA moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData(400, 400, (nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) { - + int off=0; +#endif +#ifdef RAWDATA + moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData(400, 400, sizeof(sls_detector_header)+((nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8)), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) { + int off=sizeof(sls_detector_header); + cout << "hh" << dataSize << endl; + cout << sizeof(sls_detector_header)+ ((nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8) << endl; +#endif /* int ds; */ /* if (nas && nds) */ /* if (nds>nas) */ @@ -93,10 +141,10 @@ class moench04CtbZmq10GbData : public slsDetectorData { row=200+i/sc_width; } if (nds>0) - dataMap[row][col]=((nadc+4)*i+iadc)*2;//+16*(ip+1); + dataMap[row][col]=((nadc+4)*i+iadc)*2+off;//+16*(ip+1); else - dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1); - if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32) + dataMap[row][col]=(nadc*i+iadc)*2+off;//+16*(ip+1); + if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32+off) cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; } } @@ -184,9 +232,24 @@ class moench04CtbZmq10GbData : public slsDetectorData { /* }; */ +#ifdef RAWDATA + int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;}; + + /** + + Returns the packet number for the given dataset. purely virtual func + \param buff pointer to the dataset + \returns packet number number + + + + */ + int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;}; +#endif +#ifndef RAWDATA int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;}; - +#endif /** Returns the packet number for the given dataset. purely virtual func @@ -239,7 +302,6 @@ class moench04CtbZmq10GbData : public slsDetectorData { /* return NULL; */ /* }; */ - virtual char *readNextFrame(ifstream &filebin) { int ff=-1, np=-1; return readNextFrame(filebin, ff, np); @@ -257,6 +319,8 @@ class moench04CtbZmq10GbData : public slsDetectorData { return data; } +#ifndef RAWDATA + @@ -285,6 +349,42 @@ class moench04CtbZmq10GbData : public slsDetectorData { }; +#endif + + +#ifdef RAWDATA + + + + + virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { + char *retval=0; + int nd; + int fnum = -1; + np=0; + int pn; + + // cout << dataSize << endl; + if (ff>=0) + fnum=ff; + + if (filebin.is_open()) { + if (filebin.read(data, dataSize) ){ + ff=getFrameNumber(data); + np=getPacketNumber(data); + return data; + } + } + return NULL; + + + + }; + + + +#endif + /** @@ -301,9 +401,6 @@ class moench04CtbZmq10GbData : public slsDetectorData { return data; } - - - //int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;}; };