diff --git a/CMakeLists.txt b/CMakeLists.txt index 14f4ecf85..116d270cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ option (USE_TEXTCLIENT "Text Client" OFF) option (USE_RECEIVER "Receiver" OFF) option (USE_GUI "GUI" OFF) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-misleading-indentation") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -Wall -Wno-misleading-indentation") find_package(Qt4) find_package(Qwt 6) diff --git a/RELEASE.txt b/RELEASE.txt index 9c4042e6f..8b1378917 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -1,113 +1 @@ -SLS Detector Package 3.1.1 released on 2018-03-12 -================================================= - - - -INTRODUCTION - -This document describes the differences between 3.1.0 and 3.1.0 releases. - -The conda package of the binaries can be downloaded from - - https://github.com/slsdetectorgroup/sls_detector_software.git - -The Python interface to the software package (including the package) is at - - https://github.com/slsdetectorgroup/sls_detector.git - -Manual (both HTML and pdf versions) are provided in - manual/docs/ - -Documentation from Source Code can be found for the Command Line and for the API in - html: - manual/docs/html/slsDetectorClientDocs/index.html - manual/docs/html/slsDetectorUsersDocs/index.html - pdf: - manual/docs/pdf/slsDetectorClientDocs.pdf - manual/docs/pdf/slsDetectorUsersDocs.pdf - -Example including binaries for detector and receiver user classes can be found in - - manual/manual-api - -User documentation can also be accessed directly at this location: - - https://www.psi.ch/detectors/users-support - -If you have any software related questions or comments, please send them to: - - dhanya.thattil@psi.ch - anna.bergamaschi@psi.ch - -If you have any python related questions or comments, please send them to: - - erik.frojdh@psi.ch - - -CONTENTS - -- Firmware Requirements -- Changes in User Interface -- New Features -- Resolved Issues -- Known Issues - - - -Firmware Requirements -===================== - - Please refer to the link below for more details on the firmware versions. - https://www.psi.ch/detectors/firmware. - - Gotthard - ======== - Minimum compatible version : 11.01.2013 - Latest version : 08.02.2018 (50um and 25um Master) - 09.02.2018 (25 um Slave) - - -Can not be upgraded remotely. - - - Eiger - ===== - Minimum compatible version : 16 - Latest version : 20 - - -Can be upgraded remotely via bit files. - - - Jungfrau - ======== - Minimum compatible version : 13.11.2017 - Latest version : 13.11.2017 - - -Can be upgraded remotely via sls_detector_put programfpga . - - - -Changes in User Interface -========================= - - - - -New Features -============ - - - -Resolved Issues -=============== - - -Known Issues -============ - - - - - - - diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp index 25924e808..e39663d3d 100644 --- a/manual/manual-api/mainReceiver.cpp +++ b/manual/manual-api/mainReceiver.cpp @@ -86,6 +86,7 @@ void AcquisitionFinished(uint64_t frames, void*p){ cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); } + /** * Get Receiver Data Call back * Prints in different colors(for each receiver process) the different headers for each image call back. @@ -94,6 +95,42 @@ void AcquisitionFinished(uint64_t frames, void*p){ * @param packetNumber number of packets caught for this frame * @param bunchId bunch id from beamline * @param timestamp time stamp in 10MHz clock (not implemented for most) + * @param modId module id (not implemented for most) + * @param xCoord x coordinates (detector id in 1D) + * @param yCoord y coordinates (not implemented) + * @param zCoord z coordinates (not implemented) + * @param debug debug values if any + * @param roundRNumber (not implemented) + * @param detType detector type see :: detectorType + * @param version version of standard header (structure format) + * @param datapointer pointer to data + * @param datasize data size in bytes. + * @param p pointer to object + */ +void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t datasize, void* p){ + + PRINT_IN_COLOR (modId?modId:xCoord, + "#### %d GetData: ####\n" + "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t" + "xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t" + "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", + xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, + xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, + ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); +} + + + +/** + * Get Receiver Data Call back (modified) + * Prints in different colors(for each receiver process) the different headers for each image call back. + * @param frameNumber frame number + * @param expLength real time exposure length (in 100ns) or sub frame number (Eiger 32 bit mode only) + * @param packetNumber number of packets caught for this frame + * @param bunchId bunch id from beamline + * @param timestamp time stamp in 10MHz clock (not implemented for most) * @param modId module id (not implemented for most) * @param xCoord x coordinates (detector id in 1D) * @param yCoord y coordinates (not implemented) @@ -103,12 +140,14 @@ void AcquisitionFinished(uint64_t frames, void*p){ * @param detType detector type see :: detectorType * @param version version of standard header (structure format) * @param datapointer pointer to data - * @param datasize data size in bytes + * @param datasize data size in bytes. + * @param revDatasize new data size in bytes after the callback. + * This will be the size written/streamed. (only smaller value is allowed). * @param p pointer to object */ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, - char* datapointer, uint32_t datasize, void* p){ + char* datapointer, uint32_t &revDatasize, void* p){ PRINT_IN_COLOR (modId?modId:xCoord, "#### %d GetData: ####\n" @@ -117,11 +156,15 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, - ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); + ((uint8_t)(*((uint8_t*)(datapointer)))), revDatasize); + + // if data is modified, eg ROI and size is reduced + revDatasize = 26000; } + /** * Example of main program using the slsReceiverUsers class * @@ -209,7 +252,8 @@ int main(int argc, char *argv[]) { /* - Call back for raw data */ cprintf(BLUE, "Registering GetData() \n"); - receiver->registerCallBackRawDataReady(GetData,NULL); + if (withCallback == 1) receiver->registerCallBackRawDataReady(GetData,NULL); + else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,NULL); } diff --git a/manual/manual-client/Eiger_short.tex b/manual/manual-client/Eiger_short.tex index d133b7730..2c704cf74 100644 --- a/manual/manual-client/Eiger_short.tex +++ b/manual/manual-client/Eiger_short.tex @@ -82,8 +82,8 @@ The receiver is a process run on a PC closely connected to the detector. Open on where xxxx, yyyy are the tcp port numbers. Use 1955 and 1956 for example. Note that in older version of the software {\tt{--mode 1}} was used only for the ``bottom'' half module. Now, the receiver for the bottom is open without arguments anymore, but still in the configuration file one needs to write {\tt{n:flippeddatax 1}}, where {\tt{n}} indicated the half module number, 1 if it is a module. \\ Open as many receiver as half module boards. A single module has two half module boards. -From the software version 3.0.1, one can decide weather start a zmq callback from the receiver to the client (for example to visualize data in the slsDetectorGui or another gui). If the zmq steam is not required (cased of the command line for example, one can switch off the streaming with {\tt{./sls\_detector\_put rx\_datastream 0}}, enable it with {\tt{./sls\_detector\_put rx\_datastream 1}}. In the case of inizialising the stream to use the slsDetectorGui, nothing needs to be taken care of by the user. If instead you want to stream the streaming on different channels, the zmq port of the client can be set stealing from the slsDetectorGui stream having {\tt{./sls\_detector\_put n:zmqport 300y}}, where n is each half module independently, matching the receiver stream {\tt{./sls\_detector\_put n:rx\_zmqport 300y}}. - +From the software version 3.0.1, one can decide weather start a zmq callback from the receiver to the client (for example to visualize data in the slsDetectorGui or another gui). If the zmq steam is not required (cased of the command line for example, one can switch off the streaming with {\tt{./sls\_detector\_put rx\_datastream 0}}, enable it with {\tt{./sls\_detector\_put rx\_datastream 1}}. In the case of inizialising the stream to use the slsDetectorGui, nothing needs to be taken care of by the user. If instead you want to stream the streaming on different channels, the zmq port of the client can be set stealing from the slsDetectorGui stream having {\tt{./sls\_detector\_put zmqport 300y}}. Note taht if this is done globally (not for every half module n independently, then the client automatically takes into account that for every half module, there are 2 zmq stream. The receiver stream {\tt{./sls\_detector\_put rx\_zmqport 300y}} has to match such that the GUI can work. +If one desires to set the zmqport manually, he offset has to be taken into account: {\tt{./sls\_detector\_put 0:rx\_zmqport 300y}}, {\tt{./sls\_detector\_put 1:rx\_zmqport 300y+2}} and so on.. There is an example code that can be compiled in {\tt{manual/manual-api/mainReceiver.cpp}} and gives the executable {\tt{./detReceiver}}, use it with two or more receivers to open all receivers in one single terminal: {\tt{./detReceiver startTCPPort numReceivers withCallback}}, where startTCPPort assumes the other ports are consecutively increased. @@ -694,7 +694,15 @@ Start the server again: \begin{verbatim} ./eigerDetectorServer & \end{verbatim} +\textbf{Note that the server appropiate for the software version used is located inside the package: {\tt{slsDetectorsPackage/serverBin/eigerDetectorServerxx.yy.}}}. +To copy the detector server on many boards, a script can be implemented on the lines of: +\begin{verbatim} +for i in beb111 beb070; +do ssh root@$i killall eigerDetectorServer; +scp eigerDetectorServer root@$i:~/executables/eigerDetectorServer ; +ssh root@$i sync; done +\end{verbatim} \section{Loading firmware bitfiles} @@ -835,6 +843,10 @@ It is connected to the TCPport which the receiver uses: %%%#To display only open UDP ports try the following command: netstat -vaun \end{itemize} +\subsection{Zmq socket is blocked} +It is connected to the TCPport which is used. In rare cases, it might be that the TCP port crashes. To find out which process uses the TCPPOrt do: \textbf{netstat -nlp | grep xxxx}, where xxxx is the tcpport number. To display open ports and established TCP connections, enter: \textbf{netstat -vatn}. Kill the process. + + \subsection{Client has \textbf{shmget error}} Note that occasionally if there is a shared memory of a different size (from an older software version), it will return also a line like this: \begin{verbatim} diff --git a/serverBin/eigerDetectorServer_developer b/serverBin/eigerDetectorServer_developer new file mode 120000 index 000000000..cdf68b803 --- /dev/null +++ b/serverBin/eigerDetectorServer_developer @@ -0,0 +1 @@ +../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer \ No newline at end of file diff --git a/serverBin/eigerDetectorServerv3.1.0.16.1 b/serverBin/eigerDetectorServerv3.1.0.16.1 deleted file mode 120000 index 2c90d8002..000000000 --- a/serverBin/eigerDetectorServerv3.1.0.16.1 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.16.1 \ No newline at end of file diff --git a/serverBin/eigerDetectorServerv3.1.0.21.0 b/serverBin/eigerDetectorServerv3.1.0.21.0 deleted file mode 120000 index c40e61628..000000000 --- a/serverBin/eigerDetectorServerv3.1.0.21.0 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.21.0 \ No newline at end of file diff --git a/serverBin/gotthardDetectorServer_developer b/serverBin/gotthardDetectorServer_developer new file mode 120000 index 000000000..e79cc3f57 --- /dev/null +++ b/serverBin/gotthardDetectorServer_developer @@ -0,0 +1 @@ +../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer \ No newline at end of file diff --git a/serverBin/gotthardDetectorServerv3.1.0.1 b/serverBin/gotthardDetectorServerv3.1.0.1 deleted file mode 120000 index 499ae8c21..000000000 --- a/serverBin/gotthardDetectorServerv3.1.0.1 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.1.0.1 \ No newline at end of file diff --git a/serverBin/jungfrauDetectorServer_developer b/serverBin/jungfrauDetectorServer_developer new file mode 120000 index 000000000..447282d24 --- /dev/null +++ b/serverBin/jungfrauDetectorServer_developer @@ -0,0 +1 @@ +../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer \ No newline at end of file diff --git a/serverBin/jungfrauDetectorServerv3.0.0.12 b/serverBin/jungfrauDetectorServerv3.0.0.12 deleted file mode 120000 index d74eee6d3..000000000 --- a/serverBin/jungfrauDetectorServerv3.0.0.12 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.12 \ No newline at end of file diff --git a/serverBin/jungfrauDetectorServerv3.1.0.2 b/serverBin/jungfrauDetectorServerv3.1.0.2 deleted file mode 120000 index e5ad646f3..000000000 --- a/serverBin/jungfrauDetectorServerv3.1.0.2 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.1.0.2 \ No newline at end of file diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h index 7f5f6d352..a47b7c5aa 100644 --- a/slsDetectorCalibration/analogDetector.h +++ b/slsDetectorCalibration/analogDetector.h @@ -10,6 +10,17 @@ #include "tiffIO.h" +#ifdef ROOTSPECTRUM +#include +#include +#include +#include +#include +#include +#include +#include +#endif + using namespace std; #ifndef FRAMEMODE_DEF @@ -66,11 +77,30 @@ template class analogDetector { thr=0; myFile=NULL; fm=new pthread_mutex_t ; +#ifdef ROOTSPECTRUM + hs=new TH2F("hs","hs",2000,-100,10000,nx*ny,-0.5,nx*ny-0.5); +#ifdef ROOTCLUST + hs3=new TH2F("hs3","hs3",2000,-100,3*3*10000,nx*ny,-0.5,nx*ny-0.5); + hs5=new TH2F("hs5","hs5",2000,-100,5*5*10000,nx*ny,-0.5,nx*ny-0.5); + hs7=new TH2F("hs7","hs7",2000,-100,7*7*10000,nx*ny,-0.5,nx*ny-0.5); + hs9=new TH2F("hs9","hs9",2000,-100,9*9*10000,nx*ny,-0.5,nx*ny-0.5); +#endif +#endif }; /** destructor. Deletes the pdestalSubtraction array and the image */ - virtual ~analogDetector() {for (int i=0; i class analogDetector { } } image=new int[nx*ny]; - +#ifdef ROOTSPECTRUM + hs=(TH2F*)(orig->hs)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); +#ifdef ROOTCLUST + hs3=(TH2F*)(orig->hs3)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs5=(TH2F*)(orig->hs5)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs7=(TH2F*)(orig->hs7)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs9=(TH2F*)(orig->hs9)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); +#endif +#endif + } @@ -220,6 +259,15 @@ template class analogDetector { image[iy*nx+ix]=0; } if (cmSub) cmSub->Clear(); +#ifdef ROOTSPECTRUM + hs->Reset(); +#ifdef ROOTCLUST + hs3->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs5->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs7->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); + hs9->Reset();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5); +#endif +#endif }; /** resets the commonModeSubtraction and increases the frame index */ @@ -265,25 +313,13 @@ template class analogDetector { /* }; */ }; } - + double getCommonMode(int ix, int iy) { if (cmSub) return cmSub->getCommonMode(ix, iy); else return 0; } - /* virtual void addToCommonMode(double val, int ix, int iy=0){ */ - - /* if (ix>=0 && ix=0 && iyisGood(ix, iy)==0) return; */ - /* if (getNumpedestals(ix,iy)>0) { */ - /* cmSub->addToCommonMode(val-getPedestal(ix,iy), ix, iy); */ - /* } */ - /* }; */ - - /* } */ - /* } */ - + virtual void addToCommonMode(char *data){ if (cmSub) { for (int ix=xmin; ix class analogDetector { } } } - /** + /** gets pedestal (and common mode) \param ix pixel x coordinate \param iy pixel y coordinate @@ -319,6 +355,7 @@ template class analogDetector { else return -1; }; + /** gets pedestal rms (i.e. noise) \param ix pixel x coordinate @@ -382,7 +419,6 @@ template class analogDetector { - /** sets pedestal @@ -451,17 +487,45 @@ template class analogDetector { virtual void *writeImage(const char * imgname) { float *gm=NULL; void *ret; +#ifdef ROOTSPECTRUM + + TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5); + +#endif gm=new float[nx*ny]; for (int ix=0; ixSetBinContent(ix+1, iy+1,image[iy*nx+ix]); +#endif } } ret=WriteToTiff(gm, imgname, ny, nx); delete [] gm; +#ifdef ROOTSPECTRUM + char rootfn[10000]; + sprintf(rootfn,"%s.root",imgname); + TFile *f=new TFile(rootfn,"RECREATE"); + hs->Write("hs"); +#ifdef ROOTCLUST + hs3->Write("hs3"); + hs5->Write("hs5"); + hs7->Write("hs7"); + hs9->Write("hs9"); +#endif + hmap->Write("hmap"); + + + f->Close(); + delete f; + delete hmap; +#endif return ret; } - +#ifdef ROOTSPECTRUM + TH2F *getSpectrum(){return hs;}; +#endif /** write 32bit tiff file containing the pedestals \param imgname file name to be written @@ -471,15 +535,43 @@ template class analogDetector { virtual void *writePedestals(const char * imgname) { float *gm=NULL; void *ret; - gm=new float[nx*ny]; - for (int ix=0; ixgetCommonMode(); */ + /* else */ + gm[iy*nx+ix]=stat[iy][ix].getPedestal(); +#ifdef ROOTSPECTRUM + hmap->SetBinContent(ix+1, iy+1,gm[iy*nx+ix]); +#endif } - ret=WriteToTiff(gm, imgname, ny, nx); - delete [] gm; - return ret; + } + ret=WriteToTiff(gm, imgname, ny, nx); + delete [] gm; + +#ifdef ROOTSPECTRUM + char rootfn[10000]; + sprintf(rootfn,"%s.root",imgname); + TFile *f=new TFile(rootfn,"RECREATE"); + hs->Write("hs"); +#ifdef ROOTCLUST + hs3->Write("hs3"); + hs5->Write("hs5"); + hs7->Write("hs7"); + hs9->Write("hs9"); +#endif + hmap->Write("hmap"); + f->Close(); + delete f; + delete hmap; +#endif + return ret; } /** @@ -590,19 +682,24 @@ template class analogDetector { \param data pointer to the data */ - virtual void addToPedestal(char *data, int cm=0) { + virtual void addToPedestal(char *data, int cm=0) { newFrame(); + if (cmSub) { addToCommonMode(data); } + // cout << xmin << " " << xmax << endl; + // cout << ymin << " " << ymax << endl; for (int ix=xmin; ix class analogDetector { } +#ifdef ROOTSPECTRUM + delete hs; + hs=new TH2F("hs","hs",2000,-100,10000,(xmax-xmin)*(ymax-ymin),-0.5,(xmax-xmin)*(ymax-ymin)-0.5); +#ifdef ROOTCLUST + delete hs3; + hs3=new TH2F("hs3","hs3",2000,-100,3*3*10000,(xmax-xmin)*(ymax-ymin),-0.5,(xmax-xmin)*(ymax-ymin)-0.5); + delete hs5; + hs5=new TH2F("hs5","hs5",2000,-100,5*5*10000,(xmax-xmin)*(ymax-ymin),-0.5,(xmax-xmin)*(ymax-ymin)-0.5); + delete hs7; + hs7=new TH2F("hs7","hs7",2000,-100,7*7*10000,(xmax-xmin)*(ymax-ymin),-0.5,(xmax-xmin)*(ymax-ymin)-0.5); + delete hs9; + hs9=new TH2F("hs9","hs9",2000,-100,9*9*10000,(xmax-xmin)*(ymax-ymin),-0.5,(xmax-xmin)*(ymax-ymin)-0.5); +#endif +#endif }; /** @@ -671,9 +782,16 @@ template class analogDetector { val=dataSign*det->getValue(data, ix, iy); else val=((double*)data)[iy*nx+ix]; - /* if (cm && cmSub) */ - /* val-=getCommonMode(ix,iy); */ - addToPedestal(val,ix,iy, cm); + + /* if (ix==10 && iy==10) */ + /* cout << ix << " " << iy << " " << val ; */ + /* if (ix==100 && iy==100) */ + /* cout << ix << " " << iy << " " << val; */ + addToPedestal(val,ix,iy); + /* if (ix==10 && iy==10) */ + /* cout <<" " << getPedestal(ix,iy)<< endl; */ + /* if (ix==100 && iy==100) */ + /* cout << " " << getPedestal(ix,iy)<< endl; */ } return ; @@ -685,19 +803,19 @@ template class analogDetector { \param data pointer to the data \param val pointer where the pedestal subtracted data should be added. If NULL, the internal image is used \returns pointer to the pedestal subtracted data - */ - - - virtual double *subtractPedestal(char *data, double *val=NULL, int cm=0) { + */ + // virtual int *subtractPedestal(char *data, int *val=NULL) { + + virtual int *subtractPedestal(char *data, int *val=NULL, int cm=0) { newFrame(); - + if (val==NULL) - val=new double[nx*ny]; - + val=image;//new double[nx*ny]; + for (int ix=xmin; ix class analogDetector { virtual double subtractPedestal(char *data, int ix, int iy=0, int cm=0) { double g=1.; + double val; if (ix>=0 && ix=0 && iygetValue(data, ix, iy)-getPedestal(ix,iy, cm))/g; - } + + if (det) + val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm))/g; else - return (((double*)data)[iy*nx+ix]-getPedestal(ix,iy,cm))/g; - } + val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g; + +#ifdef ROOTSPECTRUM + hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin)); +#ifdef ROOTCLUST + double v3=0,v5=0,v7=0,v9=0; + for (int iix=-4; iix<5; iix++) + for (int iiy=-4; iiy<5; iiy++) { + if (det) + val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g; + else + val= (((double*)data)[(iy+iiy)*nx+ix+iix]-getPedestal(ix+iix,iy+iiy,cm))/g; + + if (iix>-4 && iiy>-4 && iix<4 && iiy<4) { + if (iix>-3 && iiy>-3 && iix<3 && iiy<3){ + if (iix>-2 && iiy>-2 && iix<2 && iiy<2){ + v3+=val; + } + v5+=val; + } + v7+=val; + } + v9+=val; + } + hs3->Fill(v3,(iy-ymin)*(xmax-xmin)+(ix-xmin)); + hs5->Fill(v5,(iy-ymin)*(xmax-xmin)+(ix-xmin)); + hs7->Fill(v7,(iy-ymin)*(xmax-xmin)+(ix-xmin)); + hs9->Fill(v9,(iy-ymin)*(xmax-xmin)+(ix-xmin)); + +#endif +#endif + return val; + } }; @@ -755,22 +904,23 @@ template class analogDetector { virtual int getNPhotons(char *data, int ix, int iy=0) { int nph=0; - double v; - int cm=0; - if (cmSub) cm=1; + double v; if (ix>=0 && ix=0 && iyFill(v,(iy-ymin)*(xmax-xmin)+(ix-xmin)); */ +/* #endif */ if (thr>0) { v+=0.5*thr; nph=v/thr; - return nph; - } else { - // cout << v << endl; - //if (v>0) - return v; - //else - //return 0; - } + if (nph>0) + return nph; + return 0; + } + return v; } return 0; }; @@ -783,20 +933,19 @@ template class analogDetector { */ int *getNPhotons(char *data, int *nph=NULL) { - // double val; - if (nph==NULL) - nph=image; - newFrame(); + double val; + if (nph==NULL) + nph=image; + newFrame(); + addToCommonMode(data); - addToCommonMode(data); - - for (int ix=xmin; ix class analogDetector { image[iy*nx+ix]=0; } } +#ifdef ROOTSPECTRUM + //cout << "reset histogram " << endl; + if (hs) + hs->Reset(); +#ifdef ROOTCLUST + + if (hs3) + hs3->Reset(); + if (hs5) + hs5->Reset(); + if (hs7) + hs7->Reset(); + if (hs9) + hs9->Reset(); +#endif + //cout << "done " << endl; +#endif }; /** sets/gets number of samples for moving average pedestal calculation @@ -872,10 +1038,12 @@ template class analogDetector { virtual void processData(char *data,int *val=NULL) { switch(fMode) { case ePedestal: + // cout << "ped " << endl; addToPedestal(data); break; default: - getNPhotons(data,val); + //subtractPedestal(data); + getNPhotons(data); } }; @@ -897,13 +1065,13 @@ template class analogDetector { \param f file pointer \returns current file pointer */ - FILE *setFilePointer(FILE *f){myFile=f; return myFile;}; +FILE *setFilePointer(FILE *f){myFile=f; return myFile;}; /** gets file pointer where to write the clusters to \returns current file pointer */ - FILE *getFilePointer(){return myFile;}; - void setMutex(pthread_mutex_t *m){fm=m;}; +FILE *getFilePointer(){return myFile;}; + void setMutex(pthread_mutex_t *m){fm=m;}; protected: slsDetectorData *det; /**< slsDetectorData to be used */ @@ -925,7 +1093,15 @@ template class analogDetector { // int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */ frameMode fMode; /**< current detector frame mode */ FILE *myFile; /**< file pointer to write to */ - +#ifdef ROOTSPECTRUM + TH2F *hs; +#ifdef ROOTCLUST + TH2F *hs3; + TH2F *hs5; + TH2F *hs7; + TH2F *hs9; +#endif +#endif pthread_mutex_t *fm; }; diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index 4b325f5b0..f4ce14964 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -133,44 +133,6 @@ - - - - 30 - 289 - 319 - 31 - - - - - 0 - 0 - - - - Qt::NoFocus - - - Starts or Stops Acquisition - - - Start - - - - :/icons/images/start.png:/icons/images/start.png - - - Shift+Space - - - true - - - false - - @@ -999,6 +961,107 @@ Frame period between exposures. + + + + 30 + 297 + 318 + 30 + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Starts Acquisition + + + Start + + + + :/icons/images/start.png:/icons/images/start.png + + + Shift+Space + + + false + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 70 + 16777215 + + + + Qt::NoFocus + + + Stops Acquisition + + + Stop + + + + :/icons/images/stop.png:/icons/images/stop.png + + + Shift+Space + + + false + + + false + + + + + spinNumMeasurements diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 241c8e944..e16c6ae46 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -99,7 +99,7 @@ - 0 + 4 @@ -548,7 +548,7 @@ 25 5 - 314 + 335 26 @@ -587,7 +587,7 @@ Displays minimum, maximum and sum of values for each plot. - 100 + 10 10 @@ -596,7 +596,7 @@ Displays minimum, maximum and sum of values for each plot. - true + false @@ -614,6 +614,43 @@ Displays minimum, maximum and sum of values for each plot. + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + false + + + + 0 + 0 + + + + <nobr> +Displays minimum, maximum and sum of values for each plot. +<nobr> + + + Gap Pixels + + + @@ -1695,7 +1732,7 @@ Displays minimum, maximum and sum of values for each plot. 10 20 - 331 + 357 26 @@ -2522,7 +2559,7 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo 10 12 - 331 + 365 36 diff --git a/slsDetectorGui/gitInfo.txt b/slsDetectorGui/gitInfo.txt index 1bbd95ac6..cd47a074f 100644 --- a/slsDetectorGui/gitInfo.txt +++ b/slsDetectorGui/gitInfo.txt @@ -1,9 +1,18 @@ Path: slsDetectorsPackage/slsDetectorGui URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git +<<<<<<< HEAD Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b Revision: 492 Branch: developer Last Changed Author: Anna_Bergamaschi Last Changed Rev: 3731 Last Changed Date: 2018-03-15 12:27:06.000000002 +0100 ./src/qTabMeasurement.cpp +======= +Repsitory UUID: fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41 +Revision: 493 +Branch: developer +Last Changed Author: Dhanya_Thattil +Last Changed Rev: 3747 +Last Changed Date: 2018-03-27 17:30:53.000000002 +0200 ./include/qTabMeasurement.h +>>>>>>> 7cd35f24b87501374fbaf45693a2adf16dfae3e3 diff --git a/slsDetectorGui/include/gitInfoGui.h b/slsDetectorGui/include/gitInfoGui.h index 23872fbe7..fccb5d12c 100644 --- a/slsDetectorGui/include/gitInfoGui.h +++ b/slsDetectorGui/include/gitInfoGui.h @@ -1,6 +1,7 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b" -#define GITAUTH "Anna_Bergamaschi" -#define GITREV 0x3731 -#define GITDATE 0x20180315 + +#define GITREPUUID "fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41" +#define GITAUTH "Dhanya_Thattil" +#define GITREV 0x3747 +#define GITDATE 0x20180327 #define GITBRANCH "developer" diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 63f9e5b07..54a4a2542 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -617,7 +617,6 @@ void saveErrorSignal(QString); void AcquisitionErrorSignal(QString); void UpdatePlotSignal(); void GainPlotSignal(bool); -void AcquisitionFinishedSignal(); }; diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index 8b925a343..362fba590 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -50,14 +50,14 @@ public: */ void SetExpertMode(bool enable); - /** Returns the status of the Start/Stop Acquisition button + /** Returns the status of the acquisition in gui */ - bool GetStartStatus(){return btnStartStop->isChecked();}; + bool GetStartStatus(){return (!btnStart->isEnabled());}; /** Click the Start/Stop Acquisition button * This is used if this command came from gui client */ - void ClickStartStop(){btnStartStop->click();myPlot->SetClientInitiated();}; + void ClickStartStop(){startAcquisition();myPlot->SetClientInitiated();}; /** Returns progress bar value */ int GetProgress(){return progressBar->value();}; @@ -65,10 +65,6 @@ public: public slots: - /** Unconnects start/stop button when acquisition is finished - */ - void AcquisitionFinished(); - /** update plot is finished, * changes start/stop text and enables/disables all widgets */ @@ -131,9 +127,13 @@ private slots: */ void setRunIndex(int index); - /** starts/stops Acquisition + /** starts Acquisition */ - void startStopAcquisition(); + void startAcquisition(); + + /** stops Acquisition + */ + void stopAcquisition(); /** Set number of frames * @param val number of frames to be set @@ -193,8 +193,6 @@ private: QPalette red; /** expert mode */ bool expertMode; - QIcon *iconStart; - QIcon *iconStop; /** to access items in settings combobox */ QStandardItemModel* model; diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 92fcae92a..b2dbbd208 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -174,6 +174,9 @@ private slots: /** Set histogram options */ void SetHistogramOptions(); + /** Enable Gap pixels */ + void EnableGapPixels(bool enable); + signals: void DisableZoomSignal(bool); void ResetZMinZMaxSignal(bool,bool,double,double); diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 83be041bf..766dac696 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -99,8 +99,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, int& ret, break; case 'v': - tempval = GITREV; - tempval = (tempval <<32) | GITDATE; + tempval = GITDATE; cout << "SLS Detector GUI " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; return; @@ -337,7 +336,6 @@ void qDetectorMain::Initialization(){ // Plotting // When the acquisition is finished, must update the meas tab connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); - connect(myPlot, SIGNAL(AcquisitionFinishedSignal()), tab_measurement, SLOT(AcquisitionFinished())); connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished())); //This should not be called as it will change file name to measurement when run finished //connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh())); @@ -666,8 +664,7 @@ void qDetectorMain::ExecuteHelp(QAction *action){ cout << "About: Common GUI for Mythen, Eiger, Gotthard, Jungfrau, Moench and Propix detectors" << endl; #endif char version[200]; - long long unsigned int retval= GITREV; - retval= (retval <<32) | GITDATE; + long long unsigned int retval= GITDATE; sprintf(version,"%llx",retval); string thisGUIVersion = string(version); diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 7385097fb..6ad3e2ec8 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1296,7 +1296,6 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ #ifdef VERBOSE cout << "\nEntering Acquisition Finished with status " ; #endif - emit AcquisitionFinishedSignal(); QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); #ifdef VERBOSE cout << status.toAscii().constData() << " and progress " << currentProgress << endl; diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index b6e28ce0e..fa246e84a 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -94,12 +94,6 @@ void qTabMeasurement::SetupWidgetWindow(){ chkFile->setChecked(myDet->enableWriteToFile()); dispFileName->setEnabled(myDet->enableWriteToFile()); - - //creating the icons for the buttons - iconStart = new QIcon(":/icons/images/start.png"); - iconStop = new QIcon(":/icons/images/stop.png"); - - //Timer to update the progress bar progressTimer = new QTimer(this); @@ -267,8 +261,10 @@ void qTabMeasurement::Initialization(){ connect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName())); //File Index connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - //Start/Stop Acquisition - connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition())); + //Start Acquisition + connect(btnStart, SIGNAL(clicked()), this, SLOT(startAcquisition())); + //Stop Acquisition + connect(btnStop, SIGNAL(clicked()), this, SLOT(stopAcquisition())); //Timing Mode connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));// //progress bar @@ -309,75 +305,53 @@ void qTabMeasurement::Enable(bool enable){ frameNotTimeResolved->setEnabled(enable); //shortcut each time, else it doesnt work a second time - btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); + btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::startStopAcquisition(){ - if(btnStartStop->isChecked()){ - - //if file write enabled and output dir doesnt exist - if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){ - if(qDefs::Message(qDefs::QUESTION, - "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", - "qTabMeasurement::startStopAcquisition") == slsDetectorDefs::FAIL){ - disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - btnStartStop->click(); - connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - return; - }else{ - //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui - disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - chkFile->setChecked(false); - EnableFileWrite(false); - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - } - } +void qTabMeasurement::startAcquisition(){ + btnStart->setEnabled(false); + //if file write enabled and output dir doesnt exist + if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){ + if(qDefs::Message(qDefs::QUESTION, + "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", + "qTabMeasurement::startAcquisition") == slsDetectorDefs::FAIL){ + btnStart->setEnabled(true); + return; + }else{ + //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + chkFile->setChecked(false); + EnableFileWrite(false); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + } + } #ifdef VERBOSE - cout << endl << endl << "Starting Acquisition" << endl; + cout << endl << endl << "Starting Acquisition" << endl; #endif - //btnStartStop->setStyleSheet("color:red"); - btnStartStop->setText("Stop"); - btnStartStop->setIcon(*iconStop); - lblProgressIndex->setText(QString::number(0)); - Enable(0); - progressBar->setValue(0); - progressTimer->start(100); + lblProgressIndex->setText(QString::number(0)); + Enable(0); + progressBar->setValue(0); + progressTimer->start(100); - emit StartSignal(); - }else{ -#ifdef VERBOSE - cout << "Stopping Acquisition" << endl<< endl; -#endif - //emit StopSignal(); commented out to prevent undefined state - myDet->stopAcquisition(); - /* commented out to prevent undefined state - myDet->waitForReceiverReadToFinish(); - UpdateProgress(); - //spin index - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - spinIndex->setValue(myDet->getFileIndex()); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - progressTimer->stop(); - btnStartStop->setText("Start"); - btnStartStop->setIcon(*iconStart); - btnStartStop->setChecked(false); - Enable(1);*/ - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::startStopAcquisition"); + emit StartSignal(); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::startAcquisition"); } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::AcquisitionFinished(){ - disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - btnStartStop->setText("Wait"); +void qTabMeasurement::stopAcquisition(){ +#ifdef VERBOSE + cout << "Stopping Acquisition" << endl<< endl; +#endif + myDet->stopAcquisition(); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::stopAcquisition"); } @@ -391,12 +365,8 @@ void qTabMeasurement::UpdateFinished(){ connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); progressTimer->stop(); - /*disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); done in AcquisitionFinished() already */ - btnStartStop->setText("Start"); - btnStartStop->setIcon(*iconStart); - btnStartStop->setChecked(false); Enable(1); - connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + btnStart->setEnabled(true); qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateFinished"); } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 3f599ed78..cbcda6ec5 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -156,9 +156,6 @@ void qTabPlot::SetupWidgetWindow(){ stackedWidget->setCurrentIndex(0); stackedWidget_2->setCurrentIndex(0); - //gain plot - chkGainPlot->setEnabled(false); - // Depending on whether the detector is 1d or 2d switch(myDet->getDetectorsType()){ case slsDetectorDefs::MYTHEN: @@ -174,6 +171,7 @@ void qTabPlot::SetupWidgetWindow(){ pagePedestal_2->setEnabled(false); chkBinary->setEnabled(false); chkBinary_2->setEnabled(false); + chkGapPixels->setEnabled(true); break; case slsDetectorDefs::GOTTHARD: isOriginallyOneD = true; @@ -202,6 +200,12 @@ void qTabPlot::SetupWidgetWindow(){ //disable histogram initially boxHistogram->hide(); + if (chkGapPixels->isEnabled()) { + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet,"qTabPlot::SetupWidgetWindow"); + chkGapPixels->setChecked((ret == 1) ? true : false); + } + qDefs::checkErrorMessage(myDet,"qTabPlot::SetupWidgetWindow"); } @@ -376,6 +380,10 @@ void qTabPlot::Initialization(){ //gainplot if (chkGainPlot->isEnabled()) connect(chkGainPlot, SIGNAL(toggled(bool)),myPlot, SIGNAL(GainPlotSignal(bool))); + + // gap pixels + if (chkGapPixels->isEnabled()) + connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); } @@ -1471,6 +1479,24 @@ void qTabPlot::SetHistogramOptions(){ +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabPlot::EnableGapPixels(bool enable) { +#ifdef VERBOSE + cout << "Setting Gap pixels to " << enable << endl; +#endif + disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + + myDet->enableGapPixels(enable); + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); + chkGapPixels->setChecked((ret == 1) ? true : false); + + connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); +} + + //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -1487,6 +1513,14 @@ void qTabPlot::Refresh(){ comboFrequency->setCurrentIndex(1);*/ SetFrequency(); + if (chkGapPixels->isEnabled()) { + disconnect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + int ret = myDet->enableGapPixels(-1); + qDefs::checkErrorMessage(myDet,"qTabPlot::Refresh"); + chkGapPixels->setChecked((ret == 1) ? true : false); + connect(chkGapPixels, SIGNAL(toggled(bool)),this, SLOT(EnableGapPixels(bool))); + } + }else{ boxFrequency->setEnabled(false); disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index 01a73ae7d..03730964f 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -24,6 +24,7 @@ using namespace std; // 0xFFF0000000000000ULL #define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL #define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL +#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL // sls errors #define CRITICAL_ERROR_MASK 0xFFFFFFF @@ -91,6 +92,7 @@ using namespace std; #define RESTREAM_STOP_FROM_RECEIVER 0x0000000800000000ULL #define TEMPERATURE_CONTROL 0x0000001000000000ULL #define AUTO_COMP_DISABLE 0x0000002000000000ULL +#define CONFIG_FILE 0x0000004000000000ULL // 0x000000FFFFFFFFFFULL @@ -289,6 +291,8 @@ public: if(slsErrorMask&AUTO_COMP_DISABLE) retval.append("Could not set/get auto comparator disable\n"); + if(slsErrorMask&CONFIG_FILE) + retval.append("Could not load/write config file\n"); //------------------------------------------------------ length of message diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer index 5e0f545e2..c2c348a0a 100755 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt index bfe91ab6f..37168cb6b 100644 --- a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt +++ b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 06cdf8ad9204fd306cb1017b91e67452c61715d4 -Revision: 323 +Repsitory UUID: da010a03d725b6f18020d2142d58771534414274 +Revision: 328 Branch: developer Last Changed Author: Erik_Frojdh -Last Changed Rev: 3671 -Last Changed Date: 2018-03-13 10:28:12.000000002 +0100 ./FebRegisterDefs.h +Last Changed Rev: 3751 +Last Changed Date: 2018-04-03 16:29:39.000000002 +0200 ./xparameters.h diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h index 00181c6cb..37d82e952 100644 --- a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h +++ b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "06cdf8ad9204fd306cb1017b91e67452c61715d4" +#define GITREPUUID "da010a03d725b6f18020d2142d58771534414274" #define GITAUTH "Erik_Frojdh" -#define GITREV 0x3671 -#define GITDATE 0x20180313 +#define GITREV 0x3751 +#define GITDATE 0x20180403 #define GITBRANCH "developer" diff --git a/slsDetectorSoftware/gitInfo.txt b/slsDetectorSoftware/gitInfo.txt index fbb660bd3..2a9dec6de 100644 --- a/slsDetectorSoftware/gitInfo.txt +++ b/slsDetectorSoftware/gitInfo.txt @@ -1,9 +1,18 @@ Path: slsDetectorsPackage/slsDetectorSoftware URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git +<<<<<<< HEAD Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b Revision: 1846 Branch: developer Last Changed Author: Anna_Bergamaschi Last Changed Rev: 3731 Last Changed Date: 2018-03-15 12:30:34.000000002 +0100 ./threadFiles/ThreadPool.o +======= +Repsitory UUID: b8bdbf4da61f95b88893b02ddabc2491b16fa10f +Revision: 1852 +Branch: developer +Last Changed Author: Dhanya_Thattil +Last Changed Rev: 3746 +Last Changed Date: 2018-03-27 10:47:02.000000002 +0200 ./slsDetector/slsDetector.o +>>>>>>> 7cd35f24b87501374fbaf45693a2adf16dfae3e3 diff --git a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c index 7487d054d..26c15915b 100755 --- a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c @@ -1289,6 +1289,7 @@ int64_t setExposureTime(int64_t value){ /* time is in ns */ if (value!=-1) value*=(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ); + setPatternWaitTime(0,value); return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ); } diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt b/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt index b25adf0e5..e76daa760 100644 --- a/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt +++ b/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 3da6a6df6556312f7467407a8b5691bdc478424e -Revision: 21 +Repsitory UUID: 807189a4923dc257d812c9974f1a4a4d143c2f70 +Revision: 23 Branch: developer -Last Changed Author: Dhanya_Thattil -Last Changed Rev: 3597 -Last Changed Date: 2018-02-07 10:44:13.000000002 +0100 ./server_funcs.h +Last Changed Author: Anna_Bergamaschi +Last Changed Rev: 3734 +Last Changed Date: 2018-04-17 12:35:10.000000002 +0200 ./firmware_funcs.c diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h index 826314e3a..c613be18a 100644 --- a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h +++ b/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "3da6a6df6556312f7467407a8b5691bdc478424e" -#define GITAUTH "Dhanya_Thattil" -#define GITREV 0x3597 -#define GITDATE 0x20180207 +#define GITREPUUID "807189a4923dc257d812c9974f1a4a4d143c2f70" +#define GITAUTH "Anna_Bergamaschi" +#define GITREV 0x3734 +#define GITDATE 0x20180417 #define GITBRANCH "developer" diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 7fed40ec4..995b38685 100755 Binary files a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt b/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt index 2cffea544..889923a98 100644 --- a/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt +++ b/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 06cdf8ad9204fd306cb1017b91e67452c61715d4 -Revision: 122 +Repsitory UUID: da010a03d725b6f18020d2142d58771534414274 +Revision: 135 Branch: developer Last Changed Author: Erik_Frojdh -Last Changed Rev: 3671 -Last Changed Date: 2018-03-13 10:29:31.000000002 +0100 ./Makefile.virtual +Last Changed Rev: 3751 +Last Changed Date: 2018-04-03 16:29:40.000000002 +0200 ./RegisterDefs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h index 00181c6cb..37d82e952 100644 --- a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h +++ b/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "06cdf8ad9204fd306cb1017b91e67452c61715d4" +#define GITREPUUID "da010a03d725b6f18020d2142d58771534414274" #define GITAUTH "Erik_Frojdh" -#define GITREV 0x3671 -#define GITDATE 0x20180313 +#define GITREV 0x3751 +#define GITDATE 0x20180403 #define GITBRANCH "developer" diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c index b8d0f2f07..bcdd99749 100644 --- a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1250,6 +1250,10 @@ void configurePll() { #endif u_int32_t val; int32_t phase=0, inv=0; + // ensuring PLL is never configured with same phase + if (clkPhase[1] == 0) { + return; + } printf("Configuring PLL with phase in %d\n", clkPhase[1]); if (clkPhase[1]>0) { diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h index e9657d6a4..61b5e7b31 100644 --- a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -101,8 +101,8 @@ enum NETWORKINDEX { TXN_FRAME }; #define CONFIG_QUARTER_SPEED (CONFIG_TDMA_DISABLE_VAL + CONFIG_QUARTER_SPEED_10MHZ_VAL + CONFIG_MODE_1_X_10GBE_VAL) #define ADC_OFST_HALF_SPEED_VAL (0x20) //adc pipeline #define ADC_OFST_QUARTER_SPEED_VAL (0x0f) -#define ADC_PHASE_HALF_SPEED (0x41) -#define ADC_PHASE_QUARTER_SPEED (0x19) +#define ADC_PHASE_HALF_SPEED (0x48) //72 +#define ADC_PHASE_QUARTER_SPEED (0x48) //72 /* Maybe not required for jungfrau */ #define NTRIMBITS (6) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index c415be085..6009bc8c9 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -24,7 +24,7 @@ ID: $Id$ #include #include #include -using namespace std; + char ans[MAX_STR_LENGTH]; @@ -57,7 +57,7 @@ int multiSlsDetector::freeSharedMemory() { int multiSlsDetector::initSharedMemory(int id=0) { - + key_t mem_key=DEFAULT_SHM_KEY+MAXDET+id; int shm_id; int sz; @@ -76,20 +76,20 @@ int multiSlsDetector::initSharedMemory(int id=0) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return shm_id; } - + /** thisMultiDetector pointer is set to the memory address of the shared memory */ thisMultiDetector = (sharedMultiSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ - + if (thisMultiDetector == (void*)-1) { std::cout<<"*** shmat error (server) ***" << std::endl; return shm_id; } /** shm_id returns -1 is shared memory initialization fails - */ + */ return shm_id; @@ -191,7 +191,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) /** set binsize*/ thisMultiDetector->binSize=0.001; thisMultiDetector->stoppedFlag=0; - + thisMultiDetector->threadedProcessing=1; thisMultiDetector->actionMask=0; @@ -205,7 +205,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) for (int iscan=0; iscanscanMode[iscan]=0; strcpy(thisMultiDetector->scanScript[iscan],"none"); strcpy(thisMultiDetector->scanParameter[iscan],"none"); @@ -223,8 +223,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) stoppedFlag=&thisMultiDetector->stoppedFlag; threadedProcessing=&thisMultiDetector->threadedProcessing; actionMask=&thisMultiDetector->actionMask; - actionScript=thisMultiDetector->actionScript; - actionParameter=thisMultiDetector->actionParameter; + actionScript=thisMultiDetector->actionScript; + actionParameter=thisMultiDetector->actionParameter; nScanSteps=thisMultiDetector->nScanSteps; scanMode=thisMultiDetector->scanMode; scanScript=thisMultiDetector->scanScript; @@ -343,7 +343,7 @@ int multiSlsDetector::addSlsDetector(int id, int pos) { if (slsDetector::exists(id)==0) { cout << "Detector " << id << " does not exist - You should first create it to determine type etc." << endl; } - + #ifdef VERBOSE cout << "Adding detector " << id << " in position " << pos << endl; #endif @@ -353,21 +353,21 @@ int multiSlsDetector::addSlsDetector(int id, int pos) { if (pos>j) pos=thisMultiDetector->numberOfDetectors; - + //check that it is not already in the list - + for (int i=0; inumberOfDetectors; ++i) { //check that it is not already in the list, in that case move to new position if (detectors[i]) { - if (detectors[i]->getDetectorId()==id) { + if (detectors[i]->getDetectorId()==id) { cout << "Detector " << id << "already part of the multiDetector in position " << i << "!" << endl << "Remove it before adding it back in a new position!"<< endl; return -1; } } } - + if (pos!=thisMultiDetector->numberOfDetectors) { @@ -386,10 +386,10 @@ int multiSlsDetector::addSlsDetector(int id, int pos) { detectors[pos]=new slsDetector(pos, id, this); thisMultiDetector->detectorIds[pos]=detectors[pos]->getDetectorId(); ++thisMultiDetector->numberOfDetectors; - + thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes(); thisMultiDetector->dataBytesInclGapPixels+=detectors[pos]->getDataBytesInclGapPixels(); - + thisMultiDetector->numberOfChannels+=detectors[pos]->getTotalNumberOfChannels(); thisMultiDetector->maxNumberOfChannels+=detectors[pos]->getMaxNumberOfChannels(); @@ -646,7 +646,7 @@ string multiSlsDetector::getHostname(int pos) { } } return s; - + } @@ -667,7 +667,7 @@ slsDetectorDefs::detectorType multiSlsDetector::getDetectorsType(int pos) { string multiSlsDetector::sgetDetectorsType(int pos) { - + string s=string(""); #ifdef VERBOSE cout << "returning type" << pos << endl; @@ -690,14 +690,14 @@ string multiSlsDetector::sgetDetectorsType(int pos) { } } return s; - + } int multiSlsDetector::getDetectorId(int pos) { - + #ifdef VERBOSE cout << "Getting detector ID " << pos << endl; #endif @@ -705,7 +705,7 @@ int multiSlsDetector::getDetectorId(int pos) { if (pos>=0) { if (detectors[pos]) return detectors[pos]->getDetectorId(); - } + } return -1; } @@ -721,12 +721,12 @@ int multiSlsDetector::setDetectorId(int ival, int pos){ return -1; } return -1; - + } int multiSlsDetector::addSlsDetector(const char *name, int pos) { - + detectorType t=getDetectorType(string(name)); int online=0; slsDetector *s=NULL; @@ -741,13 +741,13 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) { if (detectors[i]) { if (detectors[i]->getHostname()==string(name)) { cout << "Detector " << name << "already part of the multiDetector in position " << i << "!" << endl<< "Remove it before adding it back in a new position!"<< endl; - return -1; + return -1; } } } - + //checking that the detector doesn't already exists - + for (id=0; id0) { #ifdef VERBOSE @@ -776,7 +776,7 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) { #endif online=1; } - } + } #ifdef VERBOSE else cout << "Adding detector by type " << getDetectorType(t) << endl; @@ -790,7 +790,7 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) { break; } } - + #ifdef VERBOSE cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl; #endif @@ -823,12 +823,12 @@ int multiSlsDetector::addSlsDetector(detectorType t, int pos) { break; } } - + #ifdef VERBOSE cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl; #endif - slsDetector *s=new slsDetector(pos, t, id, this); - s=NULL; + new slsDetector(pos, t, id, this); + #ifdef VERBOSE cout << "Adding it to the multi detector structure" << endl; #endif @@ -855,15 +855,15 @@ int multiSlsDetector::getDetectorOffset(int pos, int &ox, int &oy) { } int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) { - - + + int ret=FAIL; - + if (pos>=0 && posnumberOfDetectors) { if (detectors[pos]) { if (ox!=-1) thisMultiDetector->offsetX[pos]=ox; - if (oy!=-1) + if (oy!=-1) thisMultiDetector->offsetY[pos]=oy; ret=OK; } @@ -875,12 +875,12 @@ int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) { int multiSlsDetector::removeSlsDetector(char *name){ for (int id=0; idnumberOfDetectors; ++id) { - if (detectors[id]) { - if (detectors[id]->getHostname()==string(name)) { - removeSlsDetector(id); - } - } - } + if (detectors[id]) { + if (detectors[id]->getHostname()==string(name)) { + removeSlsDetector(id); + } + } + } return thisMultiDetector->numberOfDetectors; }; @@ -889,7 +889,7 @@ int multiSlsDetector::removeSlsDetector(char *name){ int multiSlsDetector::removeSlsDetector(int pos) { int j; - + #ifdef VERBOSE cout << "Removing detector in position " << pos << endl; #endif @@ -910,7 +910,7 @@ int multiSlsDetector::removeSlsDetector(int pos) { //j=pos; for (j=mi; jdataBytes-=detectors[j]->getDataBytes(); @@ -947,7 +947,7 @@ int multiSlsDetector::removeSlsDetector(int pos) { - + int multiSlsDetector::setMaster(int i) { int ret=-1, slave=0; @@ -991,7 +991,7 @@ int multiSlsDetector::setMaster(int i) { } } - + } // check return value @@ -1026,10 +1026,10 @@ int multiSlsDetector::setMaster(int i) { } if (slave>0 && ret<0) ret=-2; - + if (ret<0) ret=-1; - + thisMultiDetector->masterPosition=ret; return thisMultiDetector->masterPosition; @@ -1042,17 +1042,17 @@ int multiSlsDetector::setMaster(int i) { // MASTER_TRIGGERS, /**< the master triggers the other detectors */ // SLAVE_STARTS_WHEN_MASTER_STOPS /**< the slave acquires when the master finishes, to avoid deadtime */ // } - -/** + +/** Sets/gets the synchronization mode of the various detectors \param sync syncronization mode \returns current syncronization mode */ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { - + synchronizationMode ret=GET_SYNCHRONIZATION_MODE, ret1=GET_SYNCHRONIZATION_MODE; - + for (int id=0; idnumberOfDetectors; ++id) { if (detectors[id]) { ret1=detectors[id]->setSynchronization(sync); @@ -1066,11 +1066,11 @@ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchr } } - + thisMultiDetector->syncMode=ret; return thisMultiDetector->syncMode; - + } @@ -1191,10 +1191,10 @@ int multiSlsDetector::exists() { - + int multiSlsDetector::getThresholdEnergy(int pos) { - + int i, posmin, posmax; int ret1=-100, ret; @@ -1216,15 +1216,15 @@ int multiSlsDetector::getThresholdEnergy(int pos) { ret1=ret; else if (ret<(ret1-200) || ret>(ret1+200)) ret1=-1; - + } - + } thisMultiDetector->currentThresholdEV=ret1; return ret1; -} +} int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) { @@ -1273,7 +1273,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise thisMultiDetector->currentThresholdEV=ret; return ret; } - + @@ -1656,7 +1656,7 @@ int multiSlsDetector::startReadOut(){ } return ret1; - + }; @@ -1747,7 +1747,7 @@ int* multiSlsDetector::readFrame(){ int n; int* retval=new int[nel]; int *retdet, *p=retval; - + /** probably it's always better to have one integer per channel in any case! */ for (int id=0; idnumberOfDetectors; ++id) { @@ -1779,7 +1779,7 @@ int* multiSlsDetector::readFrame(){ int* multiSlsDetector::readAll(){ - + /** Thread for each detector?!?!?! */ // int fnum=F_READ_ALL; @@ -1791,7 +1791,7 @@ int* multiSlsDetector::readAll(){ std::cout<< "Reading all frames "<< std::endl; #endif if (thisMultiDetector->onlineFlag==ONLINE_FLAG) { - + for (int id=0; idnumberOfDetectors; ++id) { if (detectors[id]) { detectors[id]->readAllNoWait(); @@ -1812,14 +1812,14 @@ int* multiSlsDetector::readAll(){ if (detectors[id]) { detectors[id]->disconnectControl(); } - } - + } + } #ifdef VERBOSE std::cout<< "received "<< i<< " frames" << std::endl; //#else - // std::cout << std::endl; + // std::cout << std::endl; #endif return dataQueueFront(); // check what we return! @@ -1842,7 +1842,7 @@ int* multiSlsDetector::startAndReadAll(){ return NULL; } startAndReadAllNoWait(); - + while ((retval=getDataFromDetector())){ ++i; #ifdef VERBOSE @@ -1858,17 +1858,17 @@ int* multiSlsDetector::startAndReadAll(){ detectors[id]->disconnectControl(); } } - + } #ifdef VERBOSE std::cout<< "MMMM recieved "<< i<< " frames" << std::endl; //#else - // std::cout << std::endl; + // std::cout << std::endl; #endif return dataQueueFront(); // check what we return! - + }; @@ -1940,7 +1940,7 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() { } for (int i=0; inumberOfDetectors; ++i) { - s1=detectors[i]->getRunStatus(); + s1=detectors[i]->getRunStatus(); if(detectors[i]->getErrorMask()) setErrorMask(getErrorMask()|(1<masterPosition>=0) if (detectors[thisMultiDetector->masterPosition]){ - ret1 = detectors[thisMultiDetector->masterPosition]->getTimeLeft(index); + ret1 = detectors[thisMultiDetector->masterPosition]->getTimeLeft(index); if(detectors[thisMultiDetector->masterPosition]->getErrorMask()) setErrorMask(getErrorMask()|(1<masterPosition)); return ret1; } - + for (i=0; inumberOfDetectors; ++i) { if (detectors[i]) { ret=detectors[i]->getTimeLeft(index); @@ -2077,9 +2077,9 @@ int64_t multiSlsDetector::getTimeLeft(timerIndex index){ ret1=-1; } } - + return ret1; - + } @@ -2087,9 +2087,9 @@ int64_t multiSlsDetector::getTimeLeft(timerIndex index){ int multiSlsDetector::setSpeed(speedVariable index, int value){ int i; int ret1=-100, ret; - - + + for (i=0; inumberOfDetectors; ++i) { if (detectors[i]) { ret=detectors[i]->setSpeed(index,value); @@ -2101,9 +2101,9 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){ ret1=FAIL; } } - + return ret1; - + } @@ -2119,9 +2119,9 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){ int multiSlsDetector::getDataBytes(){ - int ret=0; + int ret=0; for (int ip=0; ipnumberOfDetectors; ++ip) { - if (detectors[ip]) + if (detectors[ip]) ret+=detectors[ip]->getDataBytes(); } return ret; @@ -2146,7 +2146,7 @@ int multiSlsDetector::setDynamicRange(int n, int pos){ imi=pos; ima=pos+1; } - + for (i=imi; igetDataBytes()/sizeof(int); detp+=n; // if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) { @@ -2561,7 +2561,7 @@ double* multiSlsDetector::decodeData(int *datain, int &nn, double *fdata) { return dataout; } - + //Correction /* enum correctionFlags { @@ -2605,13 +2605,13 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){ if (fname=="default") { fname=string(thisMultiDetector->flatFieldFile); - } - + } + thisMultiDetector->correctionMask&=~(1<flatFieldDir,fname.c_str()); nch=readDataFile(string(ffffname),data); - + if (nch>thisMultiDetector->numberOfChannels) nch=thisMultiDetector->numberOfChannels; - + if (nch>0) { - + //???? bad ff chans? int nm=getNMods(); int chpm[nm]; @@ -2651,18 +2651,18 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){ fillBadChannelMask(); if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) { strcpy(thisMultiDetector->flatFieldFile,fname.c_str()); - - + + thisMultiDetector->correctionMask|=(1<correctionMask&(1<getMaxMods(); } - - + + } } return getNMods(); @@ -3059,14 +3059,14 @@ int multiSlsDetector::setBadChannelCorrection(string fname){ if (fname=="default") fname=string(thisMultiDetector->badChanFile); - - - + + + ret=setBadChannelCorrection(fname, nbad, badlist); //#ifdef VERBOSE - cout << "multi: file contained " << ret << " badchans" << endl; + cout << "multi: file contained " << ret << " badchans" << endl; //#endif if (ret==0) { thisMultiDetector->correctionMask&=~(1<0) { thisMultiDetector->correctionMask|=(1<=detectors[idet]->getMaxNumberOfChannels()) { @@ -3119,7 +3119,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { } } if (nbaddet>0) { - + if (detectors[idet]) { #ifdef VERBOSE cout << "setting " << nbaddet << " badchans to detector " << idet << endl; @@ -3143,7 +3143,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { setErrorMask(getErrorMask()|(1<numberOfDetectors; ++i) { @@ -3157,8 +3157,8 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { } } thisMultiDetector->correctionMask&=~(1<correctionMask&(1<correctionMask&(1<correctionMask&(1<< ANGULAR_CONVERSION)) { return 1; - } + } return 0; - + } @@ -3540,7 +3540,7 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { int ret, ret1=-100; int id=-1, im=-1; int dmi=0, dma=thisMultiDetector->numberOfDetectors; - + if (decodeNMod(imod, id, im)>=0) { dmi=id; dma=id+1; @@ -3557,7 +3557,7 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { } } return ret1; - + } @@ -3572,9 +3572,9 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) { double multiSlsDetector::setAngularConversionParameter(angleConversionParameter c, double v) { double ret=slsDetectorUtils::setAngularConversionParameter(c,v); for (int idet=0; idetnumberOfDetectors; ++idet) { - + if (detectors[idet]) { - + detectors[idet]->setAngularConversionParameter(c,v); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<numberOfDetectors; ++idet) { - + // if (detectors[idet]) { // #ifdef EPICS // // cout << "convert angle det " << idet << endl; @@ -3618,7 +3618,7 @@ double multiSlsDetector::setAngularConversionParameter(angleConversionParameter int multiSlsDetector::getBadChannelCorrection(int *bad) { //int ichan; int *bd, nd, ntot=0, choff=0;; - + if (((thisMultiDetector->correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0) return 0; //else @@ -3644,7 +3644,7 @@ int multiSlsDetector::getBadChannelCorrection(int *bad) { delete [] bd; } else ntot+=nd; - + } } return ntot; @@ -3669,7 +3669,7 @@ int multiSlsDetector::exitServer() { /** returns the detector trimbit/settings directory */ char* multiSlsDetector::getSettingsDir() { string s0="", s1="", s; - + //char ans[1000]; for (int idet=0; idetnumberOfDetectors; ++idet) { @@ -3849,7 +3849,7 @@ char* multiSlsDetector::setCalDir(string s){ } return getCalDir(); -} +} /** returns the location of the calibration files @@ -3947,7 +3947,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ return getNetworkParameter(p); -} +} int multiSlsDetector::setPort(portType t, int p) { @@ -3990,7 +3990,7 @@ int multiSlsDetector::lockServer(int p) { string multiSlsDetector::getLastClientIP() { string s0="", s1="",s ; - + for (int idet=0; idetnumberOfDetectors; ++idet) { if (detectors[idet]) { s=detectors[idet]->getLastClientIP(); @@ -4049,7 +4049,7 @@ slsDetectorDefs::externalCommunicationMode multiSlsDetector::setExternalCommunic if(detectors[0]->getErrorMask()) setErrorMask(getErrorMask()|(1<<0)); - + for (int idet=1; idetnumberOfDetectors; ++idet) { if (detectors[idet]) { ret1=detectors[idet]->setExternalCommunicationMode(pol); @@ -4108,7 +4108,7 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(ext string multiSlsDetector::getSettingsFile() { string s0="", s1="",s ; - + for (int idet=0; idetnumberOfDetectors; ++idet) { if (detectors[idet]) { s=detectors[idet]->getSettingsFile(); @@ -4327,7 +4327,7 @@ int multiSlsDetector::getMaxMods() { int ret=0, ret1; - + for (int idet=0; idetnumberOfDetectors; ++idet) { if (detectors[idet]) { ret1=detectors[idet]->getMaxMods(); @@ -4390,7 +4390,7 @@ int multiSlsDetector::getMaxMod(dimension d){ int multiSlsDetector::getMaxNumberOfModules(dimension d) { int ret=0, ret1; - + for (int idet=0; idetnumberOfDetectors; ++idet) { if (detectors[idet]) { ret1=detectors[idet]->getMaxNumberOfModules(d); @@ -4543,12 +4543,12 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) { cout <<" C---------" << id << " position " << im << endl; #endif return -1; - + } - + int64_t multiSlsDetector::getId(idMode mode, int imod) { int id, im; @@ -4563,6 +4563,17 @@ int64_t multiSlsDetector::getId(idMode mode, int imod) { } } + ret = -100; int64_t ret1; + for (int idet=0; idetnumberOfDetectors; ++idet) + if (detectors[idet]){ + ret1=detectors[idet]->getId(mode, imod); + if(ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } + return ret; + return -1; } @@ -4799,7 +4810,7 @@ int multiSlsDetector::setAllTrimbits(int val, int imod){ return -1; } } - + // multi if(!threadpool){ cout << "Error in creating threadpool. Exiting" << endl; @@ -5113,14 +5124,14 @@ int multiSlsDetector::readConfigurationFile(string const fname){ while (ssstr.good()) { ssstr >> sargname; //if (ssstr.good()) { -#ifdef VERBOSE +#ifdef VERBOSE std::cout<< iargval << " " << sargname << std::endl; #endif strcpy(myargs[iargval], sargname.c_str()); args[iargval]=myargs[iargval]; -#ifdef VERBOSE +#ifdef VERBOSE std::cout<< "--" << iargval << " " << args[iargval] << std::endl; #endif @@ -5149,6 +5160,7 @@ int multiSlsDetector::readConfigurationFile(string const fname){ } else { std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; + setErrorMask(getErrorMask()|MULTI_CONFIG_FILE_ERROR); return FAIL; } #ifdef VERBOSE @@ -5168,7 +5180,7 @@ int multiSlsDetector::readConfigurationFile(string const fname){ return OK; -}; +}; @@ -5255,6 +5267,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){ #endif } else { std::cout<< "Error opening configuration file " << fname << " for writing" << std::endl; + setErrorMask(getErrorMask()|MULTI_CONFIG_FILE_ERROR); ret = FAIL; } @@ -5286,7 +5299,7 @@ int multiSlsDetector::writeDataFile(string fname, double *data, double *err, dou ofstream outfile; - int choff=0, off=0; //idata, + int choff=0, off=0; //idata, double *pe=err, *pa=ang; int nch_left=nch, n;//, nd; @@ -5300,9 +5313,9 @@ int multiSlsDetector::writeDataFile(string fname, double *data, double *err, dou outfile.open (fname.c_str(),ios_base::out); if (outfile.is_open()) { - + for (int i=0; inumberOfDetectors; ++i) { - + if (detectors[i]) { n=detectors[i]->getTotalNumberOfChannels(); if (nch_leftgetMaxNumberOfChannels(); - + off+=n; - + if (pe) pe=err+off; - + if (pa) pa=ang+off; - + } - + } outfile.close(); return OK; @@ -5384,7 +5397,7 @@ int multiSlsDetector::readDataFile(string fname, double *data, double *err, doub #endif ifstream infile; - int iline=0;//ichan, + int iline=0;//ichan, //int interrupt=0; string str; int choff=0, off=0; @@ -6416,7 +6429,7 @@ string multiSlsDetector::getReceiverLastClientIP() { s=detectors[idet]->getReceiverLastClientIP(); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<numberOfDetectors; ++idet) { if (detectors[idet]) { @@ -6734,14 +6751,14 @@ int multiSlsDetector::setReceiverSilentMode(int i){ - /** opens pattern file and sends pattern to CTB + /** opens pattern file and sends pattern to CTB @param fname pattern file to open @returns OK/FAIL */ int multiSlsDetector::setCTBPattern(string fname) { uint64_t word; - + int addr=0; FILE *fd=fopen(fname.c_str(),"r"); @@ -6754,11 +6771,11 @@ int multiSlsDetector::setCTBPattern(string fname) { // cout << hex << addr << " " << word << dec << endl; ++addr; } - + fclose(fd); } else return -1; - + @@ -6767,7 +6784,7 @@ int multiSlsDetector::setCTBPattern(string fname) { } - + /** Writes a pattern word to the CTB @param addr address of the word, -1 is I/O control register, -2 is clk control register @param word 64bit word to be written, -1 gets @@ -6787,7 +6804,7 @@ uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) { } return ret; } - + @@ -6825,7 +6842,7 @@ int multiSlsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { */ int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) { - + int ret=-100,ret1; for (int idet=0; idetnumberOfDetectors; ++idet) @@ -6998,4 +7015,3 @@ bool multiSlsDetector::isAcquireReady() { thisMultiDetector->acquiringFlag = true; return OK; } - diff --git a/slsDetectorSoftware/slsDetector/gitInfoLib.h b/slsDetectorSoftware/slsDetector/gitInfoLib.h index 23872fbe7..6e7baa985 100644 --- a/slsDetectorSoftware/slsDetector/gitInfoLib.h +++ b/slsDetectorSoftware/slsDetector/gitInfoLib.h @@ -1,6 +1,8 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b" -#define GITAUTH "Anna_Bergamaschi" -#define GITREV 0x3731 -#define GITDATE 0x20180315 + +#define GITREPUUID "b8bdbf4da61f95b88893b02ddabc2491b16fa10f" +#define GITAUTH "Dhanya_Thattil" +#define GITREV 0x3746 +#define GITDATE 0x20180327 + #define GITBRANCH "developer" diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 89d80025d..1b4cdfcfd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -2246,8 +2246,7 @@ int64_t slsDetector::getId( idMode mode, int imod){ #endif if (mode==THIS_SOFTWARE_VERSION) { ret=OK; - retval=GITREV; - retval=(retval<<32) | GITDATE; + retval=GITDATE; } else if (mode==RECEIVER_VERSION) { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (connectData() == OK){ @@ -7265,6 +7264,7 @@ int slsDetector::readConfigurationFile(string const fname){ infile.close(); } else { std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; + setErrorMask((getErrorMask())|(CONFIG_FILE)); return FAIL; } #ifdef VERBOSE @@ -7362,6 +7362,7 @@ int slsDetector::writeConfigurationFile(string const fname){ } else { std::cout<< "Error opening configuration file " << fname << " for writing" << std::endl; + setErrorMask((getErrorMask())|(CONFIG_FILE)); return FAIL; } #ifdef VERBOSE diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index f99f69747..01b349d32 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -718,7 +718,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { */ /*! \page config - - clkdivider [i] sets/gets the readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. MYTHEN[???]. \c Returns \c (int) + - clkdivider [i] sets/gets the readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. MYTHEN[???]. \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="clkdivider"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; @@ -774,7 +774,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { ++i; /*! \page config - - adcphase [i] Sets/gets the ADC clock frequency in MHz. For the new chiptestboard!\c Returns \c (int) + - adcphase [i] Sets/gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER) \c Returns \c (int) */ descrToFuncMap[i].m_pFuncName="adcphase"; // descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; @@ -5830,7 +5830,6 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { } - myDet->setOnline(ONLINE_FLAG); ret=myDet->setSpeed(index,t); @@ -5849,21 +5848,23 @@ string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { - os << "clkdivider c \t sets readout clock divider" << std::endl; + os << "clkdivider c \t sets readout clock divider. For Jungfrau, it also overwrites adcphase to recommended default" << std::endl; os << "setlength c\t sets the length of the set/reset signals (in clock cycles)" << std::endl; os << "waitstates c \t sets the waitstates of the bus interface" << std::endl; os << "totdivider c\t sets the clock divider in tot mode" << std::endl; os << "totdutycycle c\t sets the duty cycle of the tot clock" << std::endl; + os << "adcphase c\t Sets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER)" << std::endl; os << std::endl; } if (action==GET_ACTION || action==HELP_ACTION) { - os << "clkdivider \t gets readout clock divider" << std::endl; + os << "clkdivider \t gets readout clock divider. For Jungfrau, it also overwrites adcphase to recommended default" << std::endl; os << "setlength \t gets the length of the set/reset signals (in clock cycles)" << std::endl; os << "waitstates \t gets the waitstates of the bus interface" << std::endl; os << "totdivider \t gets the clock divider in tot mode" << std::endl; os << "totdutycycle \t gets the duty cycle of the tot clock" << std::endl; + os << "adcphase \t gets phase of the sampling clock. For JUNGFRAU, setting speed (clkdivider) overwrites adcphase to its default recommended value. (Not for EIGER)" << std::endl; os << std::endl; } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 87909bfe8..11a3f800b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -275,8 +275,9 @@ int64_t slsDetectorUsers::getThisSoftwareVersion(){ return myDetector->getThisSoftwareVersion(); } - - +int slsDetectorUsers::enableGapPixels(int enable) { + return myDetector->enableGapPixels(enable); +} void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg){ myDetector->registerDataCallback(userCallback,pArg); @@ -382,3 +383,19 @@ int slsDetectorUsers::setReceiverSilentMode(int i) { int slsDetectorUsers::setHighVoltage(int i) { return myDetector->setHighVoltage(i); } + +int slsDetectorUsers::resetFramesCaughtInReceiver() { + return myDetector->resetFramesCaught(); +} + +int slsDetectorUsers::setReceiverFifoDepth(int i) { + return myDetector->setReceiverFifoDepth(i); +} + +int slsDetectorUsers::setFlowControl10G(int i) { + return myDetector->setFlowControl10G(i); +} + +int slsDetectorUsers::setTenGigabitEthernet(int i) { + return myDetector->enableTenGigabitEthernet(i); +} diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index 1289afd9c..9b6c2c297 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -77,7 +77,7 @@ You can find examples of how this classes can be instatiated in mainClient.cpp @libdoc The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written. */ /** - @short Class for detector functionalitiesto embed the detector controls in the users custom interface e.g. EPICS, Lima etc. + @short Class for detector functionalities to embed the detector controls in the users custom interface e.g. EPICS, Lima etc. */ @@ -270,7 +270,7 @@ class slsDetectorUsers */ int getDetectorSize(int &x0, int &y0, int &nx, int &ny); /** - @short setsthe maximum detector size + @short gets the maximum detector size \param x0 horizontal position origin in channel number \param y0 vertical position origin in channel number \param nx number of channels in horiziontal @@ -528,6 +528,14 @@ class slsDetectorUsers */ int64_t getThisSoftwareVersion(); + /** + * Enable gap pixels, only for Eiger and for 8,16 and 32 bit mode. + * 4 bit mode gap pixels only in gui call back (registerDataCallback) + * @param enable 1 sets, 0 unsets, -1 gets + * @return gap pixel enable or -1 for error + */ + int enableGapPixels(int enable=-1); + /** @short register calbback for accessing detector final data \param func function to be called at the end of the acquisition. gets detector status and progress index as arguments @@ -658,17 +666,45 @@ class slsDetectorUsers /** * set receiver in silent mode * @param i 1 sets, 0 unsets (-1 gets) - * @return silent mode of receiver + * @returns silent mode of receiver */ int setReceiverSilentMode(int i); /** * set high voltage * @param i > 0 sets, 0 unsets, (-1 gets) - * @return high voltage + * @returns high voltage */ int setHighVoltage(int i); + /** + * reset frames caught in receiver + * should be called before startReceiver() + * @retuns OK or FAIL + */ + int resetFramesCaughtInReceiver(); + + /** + * set receiver fifo depth + * @param i number of images in fifo depth (-1 gets) + * @returns receiver fifo depth + */ + int setReceiverFifoDepth(int i = -1); + + /** + * set flow control for 10Gbe (Eiger only) + * @param i 1 sets, 0 unsets (-1 gets) + * @return flow control enable for 10 Gbe + */ + int setFlowControl10G(int i = -1); + + /** + * enable/disable 10GbE (Eiger only) + * @param i 1 sets, 0 unsets (-1 gets) + * @return 10GbE enable + */ + int setTenGigabitEthernet(int i = -1); + /************************************************************************ STATIC FUNCTIONS diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 1ac5e5b14..a84b71850 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -259,6 +259,19 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual string setNetworkParameter(networkParameter i, string s)=0; + int setFlowControl10G(int i = -1) { + string sret=""; + if (i != -1) { + ostringstream o; + o << ((i >= 1) ? 1 : 0); + string sval = o.str(); + sret = setNetworkParameter(FLOW_CONTROL_10G, sval); + } else + sret = getNetworkParameter(FLOW_CONTROL_10G); + + return atoi(sret.c_str()); + } + /** changes/gets the port number \param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT diff --git a/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp b/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp index e2fefcb21..d0525f9a6 100644 --- a/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp +++ b/slsDetectorSoftware/slsDetectorClient/sls_detector_client.cpp @@ -10,8 +10,7 @@ int main(int argc, char *argv[]) { for (int i = 1; i < argc; ++i ) { if (!(strcmp (argv[i],"--version")) || !(strcmp (argv[i],"-v"))) { - int64_t tempval = GITREV; - tempval = (tempval <<32) | GITDATE; + int64_t tempval = GITDATE; cout << argv[0] << " " << GITBRANCH << " (0x" << hex << tempval << ")" << endl; return 0; } diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index 5dca4b587..fab206e9b 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -41,6 +41,9 @@ char mess[MAX_STR_LENGTH]; int dataBytes = 10; int isControlServer = 0; int debugflag = 0; +#ifdef EIGERD +uint32_t dhcpipad = 0; +#endif /* initialization functions */ @@ -66,6 +69,9 @@ void init_detector(int controlserver) { if (controlserver) { isControlServer = 1; initControlServer(); +#ifdef EIGERD + dhcpipad = getDetectorIP(); +#endif } else initStopServer(); #endif @@ -647,7 +653,7 @@ int get_id(int file_des) { n = receiveData(file_des,&arg,sizeof(arg),INT32); if (n < 0) return printSocketReadError(); - if (arg == MODULE_FIRMWARE_VERSION) { + if (arg == MODULE_SERIAL_NUMBER) { n = receiveData(file_des,&imod,sizeof(imod),INT32); if (n < 0) return printSocketReadError(); } @@ -3678,16 +3684,19 @@ int configure_mac(int file_des) { printf("WARNING: Matched detectormac to the hardware mac now\n"); printf("*************************************************\n"); } + + // always remember the ip sent from the client (could be for 10g(if not dhcp)) + if (detipad != getDetectorIP()) + dhcpipad = detipad; + //only for 1Gbe if(!enableTenGigabitEthernet(-1)){ - if (detipad != getDetectorIP()){ - printf("*************************************************\n"); - printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),detipad); - detipad = getDetectorIP(); - printf("WARNING: Matched detector ip to the hardware ip now\n"); - printf("*************************************************\n"); - } - } + printf("*************************************************\n"); + printf("WARNING: Using DHCP IP for Configuring MAC\n"); + printf("*************************************************\n"); + detipad = getDetectorIP(); + } else + detipad = dhcpipad; #endif retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); if(retval==-1) { diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt index 9df6e54a1..811a55fc1 100644 --- a/slsReceiverSoftware/gitInfo.txt +++ b/slsReceiverSoftware/gitInfo.txt @@ -1,9 +1,18 @@ Path: slsDetectorsPackage/slsReceiverSoftware URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git +<<<<<<< HEAD Repsitory UUID: ab06c33107ecfeb4741d49407903ff80286cf75b Revision: 765 Branch: developer Last Changed Author: Anna_Bergamaschi Last Changed Rev: 3731 Last Changed Date: 2018-03-15 12:27:06.000000002 +0100 ./src/slsReceiverTCPIPInterface.cpp +======= +Repsitory UUID: b8bdbf4da61f95b88893b02ddabc2491b16fa10f +Revision: 767 +Branch: developer +Last Changed Author: Dhanya_Thattil +Last Changed Rev: 3746 +Last Changed Date: 2018-03-27 10:43:44.000000002 +0200 ./src/slsReceiverTCPIPInterface.cpp +>>>>>>> 7cd35f24b87501374fbaf45693a2adf16dfae3e3 diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 4fd7654fd..db559e0d2 100644 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -33,12 +33,18 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { * @param freq pointer to streaming frequency * @param timer pointer to timer if streaming frequency is random * @param dataReadycb pointer to data ready call back function - * @param pDataReadycb pointer to arguments of data ready call back function + * @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). */ DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, uint32_t* freq, uint32_t* timer, - void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, + uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*), + void (*dataModifyReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, + uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*), void *pDataReadycb); /** @@ -376,27 +382,55 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { //call back - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes - */ - void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t, void*); + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void (*rawDataReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*); + + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h index fb66aeb9c..a08183a1e 100644 --- a/slsReceiverSoftware/include/DataStreamer.h +++ b/slsReceiverSoftware/include/DataStreamer.h @@ -166,12 +166,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { /** * Create and send Json Header * @param header header of image + * @param size data size (could have been modified in call back) * @param nx number of pixels in x dim * @param ny number of pixels in y dim * @param dummy true if its a dummy header * @returns 0 if error, else 1 */ - int SendHeader(sls_detector_header* header, uint32_t nx = 0, uint32_t ny = 0, bool dummy = true); + int SendHeader(sls_detector_header* header, uint32_t size = 0, uint32_t nx = 0, uint32_t ny = 0, bool dummy = true); /** type of thread */ static const std::string TypeName; diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index ca1e6acdf..144fff951 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -583,29 +583,53 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg); - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes - */ - void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t, void*),void *arg); - + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*),void *arg); + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); protected: @@ -719,27 +743,55 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter void *pAcquisitionFinished; - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes - */ - void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t, void*); + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void (*rawDataReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*); + + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 0af8edbe1..a058ea301 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -689,11 +689,37 @@ class UDPInterface { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes + * dataSize in bytes is the size of the data in bytes. */ - virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg) = 0; + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + virtual void registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg) = 0; + protected: private: diff --git a/slsReceiverSoftware/include/ZmqSocket.h b/slsReceiverSoftware/include/ZmqSocket.h index dd260dffb..8fc063670 100644 --- a/slsReceiverSoftware/include/ZmqSocket.h +++ b/slsReceiverSoftware/include/ZmqSocket.h @@ -24,6 +24,7 @@ using namespace rapidjson; #define MAX_STR_LENGTH 1000 //#define ZMQ_DETAIL +#define ROIVERBOSITY class ZmqSocket { @@ -426,7 +427,15 @@ public: memcpy(buf, (char*)zmq_msg_data(&message), size); } - //incorrect size + //incorrect size (smaller) + else if (length < size){ +#ifdef ROIVERBOSITY + cprintf(RED,"Error: Received smaller packet size %d for socket %d\n", length, index); +#endif + memcpy(buf, (char*)zmq_msg_data(&message), length); + memset(buf+length,0xFF,size-length); + } + //incorrect size (larger) else { cprintf(RED,"Error: Received weird packet size %d for socket %d\n", length, index); memset(buf,0xFF,size); diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h index 23872fbe7..d94293f8c 100644 --- a/slsReceiverSoftware/include/gitInfoReceiver.h +++ b/slsReceiverSoftware/include/gitInfoReceiver.h @@ -1,6 +1,7 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "ab06c33107ecfeb4741d49407903ff80286cf75b" -#define GITAUTH "Anna_Bergamaschi" -#define GITREV 0x3731 -#define GITDATE 0x20180315 + +#define GITREPUUID "b8bdbf4da61f95b88893b02ddabc2491b16fa10f" +#define GITAUTH "Dhanya_Thattil" +#define GITREV 0x3746 +#define GITDATE 0x20180327 #define GITBRANCH "developer" diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h index 348d90e8e..efd0050b9 100644 --- a/slsReceiverSoftware/include/slsReceiver.h +++ b/slsReceiverSoftware/include/slsReceiver.h @@ -91,11 +91,37 @@ class slsReceiver : private virtual slsReceiverDefs { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes + * dataSize in bytes is the size of the data in bytes. */ - void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, + uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, + uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg); + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); + private: diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index 83e6198db..7e33d6e77 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -95,9 +95,36 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { * dataPointer is the pointer to the data * dataSize in bytes is the size of the data in bytes */ - void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, + uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, + uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg); + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); + + private: /** @@ -344,10 +371,36 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes + * dataSize in bytes is the size of the data in bytes. */ - void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, + uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*); + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + */ + void (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/slsReceiverUsers.h b/slsReceiverSoftware/include/slsReceiverUsers.h index c2dd0bc0d..b257e64a0 100644 --- a/slsReceiverSoftware/include/slsReceiverUsers.h +++ b/slsReceiverSoftware/include/slsReceiverUsers.h @@ -70,7 +70,17 @@ public: void registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, char* datapointer, uint32_t datasize, void*),void *arg); + + /** + @sort register callback to be called when data are available (to process and/or save the data). + \param func raw data ready callback. arguments are frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, dataPointer, revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + \returns nothing + */ + void registerCallBackRawDataModifyReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t &revDatasize, void*),void *arg); + //receiver object slsReceiver* receiver; }; diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index e2dfc9d8a..99835b6ed 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -35,8 +35,13 @@ bool DataProcessor::SilentMode(false); DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, uint32_t* freq, uint32_t* timer, - void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, + uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*), + void (*dataModifyReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, + uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*), void *pDataReadycb) : ThreadObject(NumberofDataProcessors), @@ -61,6 +66,7 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* d numFramesCaught(0), currentFrameIndex(0), rawDataReadyCallBack(dataReadycb), + rawDataModifyReadyCallBack(dataModifyReadycb), pRawDataReady(pDataReadycb) { if(ThreadObject::CreateThread()){ @@ -316,7 +322,7 @@ void DataProcessor::ThreadExecution() { return; } - ProcessAnImage(buffer + FIFO_HEADER_NUMBYTES); + ProcessAnImage(buffer); //stream (if time/freq to stream) or free if (*dataStreamEnable && SendToStreamer()) @@ -348,7 +354,7 @@ void DataProcessor::StopProcessing(char* buf) { /** buf includes only the standard header */ void DataProcessor::ProcessAnImage(char* buf) { - sls_detector_header* header = (sls_detector_header*) (buf); + sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES); uint64_t fnum = header->frameNumber; currentFrameIndex = fnum; uint32_t nump = header->packetNumber; @@ -381,7 +387,7 @@ void DataProcessor::ProcessAnImage(char* buf) { } if (*gapPixelsEnable && (*dynamicRange!=4)) - InsertGapPixels(buf + sizeof(sls_detector_header), *dynamicRange); + InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), *dynamicRange); // x coord is 0 for detector in pos [0,0,0] if (xcoordin1D) { @@ -409,14 +415,36 @@ void DataProcessor::ProcessAnImage(char* buf) { header->roundRNumber, header->detType, header->version, - buf + sizeof(sls_detector_header), - generalData->imageSize, + buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), + (uint32_t)(*((uint32_t*)buf)), pRawDataReady); } + else if (rawDataModifyReadyCallBack) {cprintf(BG_GREEN,"Calling rawdatamodify\n"); + uint32_t revsize = (uint32_t)(*((uint32_t*)buf)); + rawDataModifyReadyCallBack( + header->frameNumber, + header->expLength, + header->packetNumber, + header->bunchId, + header->timestamp, + header->modId, + header->xCoord, + header->yCoord, + header->zCoord, + header->debug, + header->roundRNumber, + header->detType, + header->version, + buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), + revsize, + pRawDataReady); + (*((uint32_t*)buf)) = revsize; + } + if (file) - file->WriteToFile(buf, sizeof(sls_detector_header) + generalData->imageSize, fnum-firstMeasurementIndex, nump); + file->WriteToFile(buf + FIFO_HEADER_NUMBYTES, sizeof(sls_detector_header) + (uint32_t)(*((uint32_t*)buf)), fnum-firstMeasurementIndex, nump); diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index 8946c6e40..3dfced933 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -200,7 +200,7 @@ void DataStreamer::ThreadExecution() { return; } - ProcessAnImage(buffer + FIFO_HEADER_NUMBYTES); + ProcessAnImage(buffer); //free fifo->FreeAddress(buffer); @@ -216,7 +216,7 @@ void DataStreamer::StopProcessing(char* buf) { #endif sls_detector_header* header = (sls_detector_header*) (buf); //send dummy header and data - if (!SendHeader(header, 0, 0, true)) + if (!SendHeader(header, 0, 0, 0, true)) cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index); fifo->FreeAddress(buf); @@ -229,7 +229,7 @@ void DataStreamer::StopProcessing(char* buf) { /** buf includes only the standard header */ void DataStreamer::ProcessAnImage(char* buf) { - sls_detector_header* header = (sls_detector_header*) (buf); + sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES); uint64_t fnum = header->frameNumber; #ifdef VERBOSE cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); @@ -245,11 +245,11 @@ void DataStreamer::ProcessAnImage(char* buf) { //shortframe gotthard if (completeBuffer) { - if (!SendHeader(header, generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) + if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", (long long int) fnum, index); - memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize); + memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", (long long int) fnum, index); @@ -259,11 +259,11 @@ void DataStreamer::ProcessAnImage(char* buf) { //normal else { - if (!SendHeader(header, generalData->nPixelsX, generalData->nPixelsY, false)) + if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", (long long int) fnum, index); - if (!zmqSocket->SendData(buf + sizeof(sls_detector_header), generalData->imageSize)) + if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", (long long int) fnum, index); } @@ -271,7 +271,7 @@ void DataStreamer::ProcessAnImage(char* buf) { -int DataStreamer::SendHeader(sls_detector_header* header, uint32_t nx, uint32_t ny, bool dummy) { +int DataStreamer::SendHeader(sls_detector_header* header, uint32_t size, uint32_t nx, uint32_t ny, bool dummy) { if (dummy) return zmqSocket->SendHeaderData(index, dummy,SLS_DETECTOR_JSON_HEADER_VERSION); @@ -280,7 +280,7 @@ int DataStreamer::SendHeader(sls_detector_header* header, uint32_t nx, uint32_t uint64_t acquisitionIndex = header->frameNumber - firstAcquisitionIndex; return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex, - nx, ny,generalData->imageSize, + nx, ny, size, acquisitionIndex, frameIndex, fileNametoStream, header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp, header->modId, header->xCoord, header->yCoord, header->zCoord, diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 4ac209004..cf3c3265d 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -30,6 +30,7 @@ UDPBaseImplementation::UDPBaseImplementation(){ acquisitionFinishedCallBack = NULL; pAcquisitionFinished = NULL; rawDataReadyCallBack = NULL; + rawDataModifyReadyCallBack = NULL; pRawDataReady = NULL; } @@ -614,10 +615,19 @@ void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uin pAcquisitionFinished=arg; } -void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, +void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg){ rawDataReadyCallBack=func; pRawDataReady=arg; } +void UDPBaseImplementation::registerCallBackRawDataModifyReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t&, void*),void *arg){ + rawDataModifyReadyCallBack=func; + pRawDataReady=arg; +} //#endif diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index bf6aa324c..ecf061c44 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -367,7 +367,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) { listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange)); dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, - rawDataReadyCallBack,pRawDataReady)); + rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady)); if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) { FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; for (vector::const_iterator it = listener.begin(); it != listener.end(); ++it) diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp index 0086df416..91c22db9a 100644 --- a/slsReceiverSoftware/src/main.cpp +++ b/slsReceiverSoftware/src/main.cpp @@ -42,7 +42,7 @@ void AcquisitionFinished(uint64_t frames, void*p){ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, - char* datapointer, uint32_t datasize, void* p){ + char* datapointer, uint32_t* datasize, void* p){ PRINT_IN_COLOR (xCoord, "#### %d GetData: ####\n" @@ -51,7 +51,7 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, - ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); + ((uint8_t)(*((uint8_t*)(datapointer)))), *datasize); } */ diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp index baae6b1c8..838554bb3 100644 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ b/slsReceiverSoftware/src/slsReceiver.cpp @@ -150,7 +150,9 @@ void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, voi } -void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, +void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg){ //tcpipInterface if(udp_interface) @@ -160,3 +162,13 @@ void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, } +void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*),void *arg){ + //tcpipInterface + if(udp_interface) + udp_interface->registerCallBackRawDataModifyReady(func,arg); + else + tcpipInterface->registerCallBackRawDataModifyReady(func,arg); +} diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 22c123ce7..ae24c75f4 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -46,6 +46,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* acquisitionFinishedCallBack = NULL; pAcquisitionFinished = NULL; rawDataReadyCallBack = NULL; + rawDataModifyReadyCallBack = NULL; pRawDataReady = NULL; unsigned short int port_no=portNumber; @@ -152,8 +153,7 @@ void slsReceiverTCPIPInterface::stop(){ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){ - int64_t retval = GITREV; - retval= (retval <<32) | GITDATE; + int64_t retval = GITDATE; return retval; } @@ -170,12 +170,21 @@ void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func) pAcquisitionFinished=arg; } -void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, +void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, char*, uint32_t, void*),void *arg){ rawDataReadyCallBack=func; pRawDataReady=arg; } +void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg){ + rawDataModifyReadyCallBack=func; + pRawDataReady=arg; +} @@ -785,6 +794,8 @@ int slsReceiverTCPIPInterface::set_detector_type(){ receiverBase->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished); if(rawDataReadyCallBack) receiverBase->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady); + if(rawDataModifyReadyCallBack) + receiverBase->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady); } myDetectorType = dr; ret = receiverBase->setDetectorType(myDetectorType); diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp index bab16867f..ab19b9bac 100644 --- a/slsReceiverSoftware/src/slsReceiverUsers.cpp +++ b/slsReceiverSoftware/src/slsReceiverUsers.cpp @@ -35,3 +35,8 @@ void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(uint64_t frameN receiver->registerCallBackRawDataReady(func,arg); } +void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t& revDatasize, void*), void *arg){ + receiver->registerCallBackRawDataModifyReady(func,arg); +}