From a2c26664eea2f9ba2d26b6663610f3f7f7674852 Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Fri, 6 Dec 2019 12:17:31 +0100 Subject: [PATCH] added and corrected data structures for rectangular pixels --- examples/moench03_T1_lab.config | 44 +-- .../moench03T1ReceiverDataNewRect.h | 3 + .../dataStructures/moench03T1ZmqDataNewRect.h | 306 ++++++++++++++++++ .../moenchExecutables/Makefile.zmq | 6 +- .../moenchExecutables/moenchZmqProcess.cpp | 5 + .../multiThreadedAnalogDetector.h | 16 +- slsDetectorCalibration/tiffIO.cpp | 4 +- 7 files changed, 353 insertions(+), 31 deletions(-) create mode 100644 slsDetectorCalibration/dataStructures/moench03T1ZmqDataNewRect.h diff --git a/examples/moench03_T1_lab.config b/examples/moench03_T1_lab.config index f56c01dca..41bcfd872 100644 --- a/examples/moench03_T1_lab.config +++ b/examples/moench03_T1_lab.config @@ -1,4 +1,4 @@ -hostname bchip011+ +hostname bchip064+ patword 0000 0000000000000000 patword 0001 0000000000000000 @@ -416,31 +416,31 @@ patwaittime2 0 ####mcp2011 -#0:rx_tcpport 1955 -#0:rx_udpip 10.1.1.102 -#0:detectorip 10.1.1.19 -#0:rx_udpport 32411 -####gui listening to -#zmqip 129.129.202.106 -#zmqport 50001 -####data streaming out of -#rx_zmqip 10.1.2.103 -#rx_zmqport 50003 - -#0:rx_hostname mpc2011 - -####pcmoench01 -0:rx_tcpport 1977 -0:rx_udpip 10.1.1.100 +0:rx_tcpport 1954 +0:rx_udpip 10.1.1.102 0:detectorip 10.1.1.19 -0:rx_udpport 32410 -####gui listening to (on receiver pc) -zmqip 129.129.202.92 +0:rx_udpport 32411 +####gui listening to +zmqip 129.129.202.106 zmqport 50001 ####data streaming out of -rx_zmqip 10.1.1.100 +rx_zmqip 10.1.2.103 rx_zmqport 50003 -0:rx_hostname pcmoench01 + +0:rx_hostname mpc2011 + +####pcmoench01 +#0:rx_tcpport 1977 +#0:rx_udpip 10.1.1.100 +#0:detectorip 10.1.1.19 +#0:rx_udpport 32410 +####gui listening to (on receiver pc) +#zmqip 129.129.202.92 +#zmqport 50001 +####data streaming out of +#rx_zmqip 10.1.1.100 +#rx_zmqport 50003 +#0:rx_hostname mx-test-1 diff --git a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNewRect.h b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNewRect.h index ad2e8df80..92a0e5a86 100644 --- a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNewRect.h +++ b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNewRect.h @@ -34,6 +34,9 @@ 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 */ +#ifndef VERSION_V1 + uint64_t packetCaught[8]; /**< is the version number of this structure format */ +#endif } sls_detector_header; diff --git a/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNewRect.h b/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNewRect.h new file mode 100644 index 000000000..1f1edadce --- /dev/null +++ b/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNewRect.h @@ -0,0 +1,306 @@ +#ifndef MOENCH03T1ZMQNEWRECT_H +#define MOENCH03T1ZMQNEWRECT_H +#include "slsDetectorData.h" + +#define VERT 1 + + + +class moench03T1ZmqDataNew : public slsDetectorData { + + private: + + int iframe; + int nadc; + int sc_width; + int sc_height; + const int nSamples; + const int offset; + + + public: + + + + /** + Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver + (160x160 pixels, 40 packets 1286 large etc.) + \param c crosstalk parameter for the output buffer + + */ +#ifdef HOR + moench03T1ZmqDataNew(int ns=5000): slsDetectorData(800, 200, ns*2*32), nSamples(ns), offset(sizeof(int)) { +#endif +#ifdef VERT + moench03T1ZmqDataNew(int ns=5000): slsDetectorData(200, 800, ns*2*32), nSamples(ns), offset(sizeof(int)) { +#endif + + int nadc=32; + int sc_width=25; + int sc_height=200; + + int adc_nr[32]={300,325,350,375,300,325,350,375, \ + 200,225,250,275,200,225,250,275,\ + 100,125,150,175,100,125,150,175,\ + 0,25,50,75,0,25,50,75}; + + int row, col; + + int isample; + int iadc; + int ix, iy; + + int npackets=40; + int i; + int adc4(0); + int pix; + + + int off=0; +#ifdef OFF_1 + off=1; +#endif + cout << "This is a MOENCH with rectangular pixels!" << endl; + + for (int ip=0; ip=nSamples*2*32) + cout << "Error: pointer " << pix << " out of range "<< endl; + ix=col; + iy=row; + //col and row have to do with data sequence + //ix and iy have to do with implant position +#ifdef HOR + if (row%2==off) { + ix=2*col; + iy=row/2; + } else { + ix=2*col+1; + iy=row/2; + } +#endif + +#ifdef VERT + if (col%2==off) { + ix=col/2; + iy=row*2+1; + } else { + ix=col/2; + iy=row*2; + } +#endif + dataMap[iy][ix]=pix; + } + } + } + } + + /* int ipacket; */ + /* int ibyte; */ + /* int ii=0; */ + /* for (ibyte=0; ibyte0) { */ +/* iframe++; */ +/* // cout << ib << "-" << endl; */ +/* return (char*)afifo_cont; */ +/* } else { */ +/* delete [] afifo_cont; */ +/* return NULL; */ +/* } */ +/* } */ +/* return NULL; */ +/* }; */ + + + virtual char *readNextFrame(ifstream &filebin) { + int ff=-1, np=-1; + return readNextFrame(filebin, ff, np); + }; + + virtual char *readNextFrame(ifstream &filebin, int &ff) { + int np=-1; + return readNextFrame(filebin, ff, np); + }; + + virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { + char *data=new char[32*2*nSamples]; + char *d=readNextFrame(filebin, ff, np, data); + if (d==NULL) {delete [] data; data=NULL;} + return data; + } + + + + + virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { + /* char *retval=0; */ + /* int nd; */ + /* int fnum = -1; */ + np=0; + /* int pn; */ + + + /* if (ff>=0) */ + /* fnum=ff; */ + + if (filebin.is_open()) { + if (filebin.read(data, 32*2*nSamples) ){ + // iframe++; + //ff=iframe; + return data; + } + } + return NULL; + + + + }; + + + + /** + + Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func + \param data pointer to the memory to be analyzed + \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot + \param dsize size of the memory slot to be analyzed + \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found + + */ + virtual char *findNextFrame(char *data, int &ndata, int dsize){ + if (dsize<32*2*nSamples) ndata=dsize; + else ndata=32*2*nSamples; + return data; + + } + + + + + + + // virtual int setFrameNumber(int ff){iframe=ff}; + + + + + + + + + + +int getPacketNumber(int x, int y) {return 0;}; + +}; + + + + +#endif + diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.zmq b/slsDetectorCalibration/moenchExecutables/Makefile.zmq index 820feb3ac..76df1692f 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.zmq +++ b/slsDetectorCalibration/moenchExecutables/Makefile.zmq @@ -5,11 +5,13 @@ LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 #DESTDIR?=../bin -all: moenchZmqProcess moenchZmqProcessHighZ +all: moenchZmqProcess moenchZmqProcessHighZ moenchZmqProcessRect moenchZmqProcess: moenchZmqProcess.cpp clean g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP - +moenchZmqProcessRect: moenchZmqProcess.cpp clean + g++ -o moenchZmqProcessRect moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DRECT + moenchZmqProcessHighZ: moenchZmqProcess.cpp clean g++ -o moenchZmqProcessHighZ moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DHIGHZ diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index d95e795e5..18761ef21 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -7,7 +7,12 @@ #include "sls_detector_defs.h" #include "ZmqSocket.h" +#ifndef RECT #include "moench03T1ZmqDataNew.h" +#endif +#ifdef RECT +#include "moench03T1ZmqDataNewRect.h" +#endif #include "moench03GhostSummation.h" #include "moench03CommonMode.h" #include diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index 5aaa31e51..791de8f0d 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -105,7 +105,7 @@ public: { stop=0; cout << "Detector number " << det->getId() << endl; cout << "common mode is " << det->getCommonModeSubtraction()<< endl; - cout << "ghos summation is " << det->getGhostSummation()<< endl; + cout << "ghost summation is " << det->getGhostSummation()<< endl; return (pthread_create(&_thread, NULL, processData, this) == 0); } @@ -123,7 +123,13 @@ public: return fifoFree->pop(ptr); } - virtual int isBusy() {return busy;} + virtual int isBusy() { + if (fifoData->isEmpty()) + busy=0; + else + busy=1; + return busy; + } //protected: /** Implement this method in your subclass with the code you want your thread to run. */ @@ -249,13 +255,13 @@ protected: } void * processData() { - busy=1; + // busy=1; while (!stop) { if (fifoData->isEmpty()) { - busy=0; + // busy=0; usleep(100); } else { - busy=1; + // busy=1; fifoData->pop(data); //blocking! det->processData(data); fifoFree->push(data); diff --git a/slsDetectorCalibration/tiffIO.cpp b/slsDetectorCalibration/tiffIO.cpp index 5b3d7b737..0f1189f6e 100644 --- a/slsDetectorCalibration/tiffIO.cpp +++ b/slsDetectorCalibration/tiffIO.cpp @@ -14,7 +14,7 @@ using namespace std; // } // } -void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){ +void *WriteToTiff(float * imgData, const char * imgname, int ncol, int nrow){ int sampleperpixel=1; // unsigned char * buff=NULL; //tsize_t linebytes; @@ -43,7 +43,7 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){ return NULL; }; -float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){ +float *ReadFromTiff( const char * imgname, uint32 &ncol, uint32 &nrow){ // unsigned char * buff=NULL; TIFF * tif = TIFFOpen(imgname,"r");