mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +02:00
added and fixed gotthard 25um file and zmq photon finder
This commit is contained in:
parent
7602ffc5ac
commit
31589ce352
@ -50,9 +50,9 @@ public:
|
||||
for(int ix=0; ix<xpixels; ix++) {
|
||||
imod=ix%2;
|
||||
if (imod==0)
|
||||
dMap[0][ix] =ix+offset;
|
||||
dMap[0][ix] =ix+offset;
|
||||
else
|
||||
dMap[0][ix] =dataSize-2-ix;//+2*offset;
|
||||
dMap[0][ix] = 1280*2+2*offset+2*(1280-1-ix/2);//dataSize-2-ix;//+2*offset;
|
||||
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
|
||||
dMask[0][ix] = 0x0;
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o ../tiffIO.cpp
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
INCDIR=-I.. -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations -I../dataStructures
|
||||
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
#-L../../bin
|
||||
MAIN=gotthard25umOnTheFlyAnalysis.C
|
||||
MAIN=gotthard25umZmqAnalysis.C
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: gotthard25umOnTheFlyAnalysis
|
||||
all: gotthard25umOnTheFlyAnalysis gotthard25umZmq
|
||||
|
||||
gotthard25umOnTheFlyAnalysis: $(MAIN) $(INCS) clean
|
||||
g++ -o gotthard25umOnTheFlyAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
g++ -o gotthard25umOnTheAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
gotthard25umZmq: $(MAIN) $(INCS) clean
|
||||
g++ -o gotthard25umZmq $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DZMQ -L$(ZMQLIB) -lzmq
|
||||
|
||||
clean:
|
||||
rm -f gotthard25umOnTheFlyAnalysis
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
//#include "linearInterpolation.h"
|
||||
//#include "multiThreadedAnalogDetector.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
@ -27,9 +27,60 @@
|
||||
|
||||
|
||||
void *gotthardProcessFrame() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char fname0[10000], fname1[10000];
|
||||
char fformat[10000];
|
||||
strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000040000_0.raw");
|
||||
int fifosize=1000;
|
||||
strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
|
||||
sprintf(fname0,fformat,0,0);
|
||||
sprintf(fname1,fformat,1,1);
|
||||
|
||||
@ -65,9 +116,20 @@ void *gotthardProcessFrame() {
|
||||
|
||||
filter->setFrameMode(eFrame);
|
||||
|
||||
char buff[2*(48+1280*2)];
|
||||
char *buff0=buff;
|
||||
char *buff1=buff+48+1280*2;
|
||||
char *buff;//[2*(48+1280*2)];
|
||||
|
||||
|
||||
char *buff0;
|
||||
char *buff1;
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
|
||||
|
||||
int photons[1280*2];
|
||||
|
||||
@ -75,33 +137,16 @@ void *gotthardProcessFrame() {
|
||||
int ok=0;
|
||||
ifstream filebin0,filebin1;
|
||||
std::time_t end_time;
|
||||
|
||||
int16_t dout[1280*2];
|
||||
int iFrame=-1;
|
||||
int np=-1;
|
||||
// typedef struct {
|
||||
// uint64_t frameNumber; /**< is the frame number */
|
||||
// uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
// uint32_t packetNumber; /**< is the packet number */
|
||||
// uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
// uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
// uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
// uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
// uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
// uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
// uint32_t debug; /**< is for debugging purposes */
|
||||
// uint16_t roundRNumber; /**< is the round robin set number */
|
||||
// uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
// uint8_t version; /**< is the version number of this structure format */
|
||||
// } sls_detector_header;
|
||||
|
||||
|
||||
// multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
|
||||
nph=0;
|
||||
nph1=0;
|
||||
//int np;
|
||||
int iph;
|
||||
int data_ready=1;
|
||||
|
||||
int *image;
|
||||
|
||||
// filter->setROI(0,512,0,1);
|
||||
|
||||
@ -117,39 +162,49 @@ void *gotthardProcessFrame() {
|
||||
nf=0;
|
||||
iFrame=-1;
|
||||
while ((decoder->readNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) {
|
||||
filter->processData(buff, photons);
|
||||
cout << nf << " " << decoder->getFrameNumber(buff0) << " " << decoder->getFrameNumber(buff1) << " " << filter->getPhFrame() << " " << filter->getPhTot() << endl;
|
||||
//filter->processData(buff, photons);
|
||||
// cout << nf << " " << decoder->getFrameNumber(buff0) << " " << decoder->getFrameNumber(buff1) << " " << filter->getPhFrame() << " " << filter->getPhTot() << endl;
|
||||
// for (int i=0; i<1280*2; i++) {
|
||||
// filter->addToPedestal(buff,i,0);
|
||||
// dout[i]=filter->subtractPedestal(buff,i,0);
|
||||
// if (nf>10 && i<512)
|
||||
// if (i%2)
|
||||
// cout << nf << " " << i << " " << filter->getPedestal(i,0) << " " << det->getValue(buff,i,0) << " " << decoder->getValue(buff1,1280-1-i/2,0)<< " " << dout[i] << endl;
|
||||
// else
|
||||
// cout << nf << " " << i << " " << filter->getPedestal(i,0) << " " << det->getValue(buff,i,0) << " " << decoder->getValue(buff0,i/2,0)<< " " << dout[i] << endl;
|
||||
|
||||
// }
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
|
||||
nf++;
|
||||
}
|
||||
|
||||
// cout << id << " " << nf << endl;
|
||||
if (nf%1000==0) {
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
if (nf%10000==0) {
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<512; i++) {
|
||||
cout << image[i] << "\t";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
filter->clearImage();
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
}
|
||||
iFrame=-1;
|
||||
}
|
||||
|
||||
//delete [] buff;
|
||||
iFrame=-1;
|
||||
|
||||
|
||||
filebin0.close();
|
||||
filebin1.close();
|
||||
}
|
||||
else
|
||||
cout << "Could not open file " << fname0<< " or " << fname1 << endl;
|
||||
|
||||
|
||||
//mt->StopThreads();
|
||||
|
||||
// char tit[10000];
|
||||
//sprintf(tit,"/scratch/int_image_mt%d.tiff",nthreads);
|
||||
|
||||
//mt->writeInterpolatedImage(tit);
|
||||
// delete [] etah;
|
||||
|
||||
// delete interp;
|
||||
//delete decoder;
|
||||
//cout << "Read " << nf << " frames" << endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,386 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
//#ifdef ZMQ
|
||||
#include "ZmqSocket.h"
|
||||
//#endif
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
//#include <deque>
|
||||
//#include <list>
|
||||
//#include <queue>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
|
||||
#include "gotthardModuleDataNew.h"
|
||||
#include "gotthardDoubleModuleDataNew.h"
|
||||
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
//#include "linearInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#define NC 1280
|
||||
#define NR 1
|
||||
|
||||
#include "tiffIO.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
int main(int argc, char *argv[]){
|
||||
//void *gotthardProcessFrame() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int fifosize=1000;
|
||||
int nthreads=3;
|
||||
int nph, nph1;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
int nsubpix=1;
|
||||
float *etah=new float[etabins*etabins];
|
||||
int *heta, *himage;
|
||||
int offset=48;
|
||||
#ifdef ZMQ
|
||||
offset=0;
|
||||
#endif
|
||||
#ifndef ZMQ
|
||||
offset=48;
|
||||
#endif
|
||||
|
||||
|
||||
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
|
||||
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 200);
|
||||
filter->setROI(0,512,0,1);
|
||||
char *buff;//[2*(48+1280*2)];
|
||||
char *buff0;
|
||||
char *buff1;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
int photons[1280*2];
|
||||
int nf=0;
|
||||
int ok=0;
|
||||
std::time_t end_time;
|
||||
//int16_t dout[1280*2];
|
||||
int iFrame=-1;
|
||||
int np=-1;
|
||||
nph=0;
|
||||
nph1=0;
|
||||
//int np;
|
||||
int iph;
|
||||
int data_ready=1;
|
||||
int *image;
|
||||
|
||||
|
||||
|
||||
int length;
|
||||
int nnx, nny,nns;
|
||||
int nix, niy,nis;
|
||||
// infinite loop
|
||||
int ix, iy, isx, isy;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
|
||||
|
||||
|
||||
#ifdef ZMQ
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n",argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = nnx*nny*2;
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket0 = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket0->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ZmqSocket* zmqsocket1 = new ZmqSocket(socketip,portnum+1);
|
||||
if (zmqsocket1->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum+1, socketip);
|
||||
delete zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
zmqsocket0->Connect();
|
||||
printf("Zmq Client 0 at %s\n", zmqsocket0->GetZmqServerAddress());
|
||||
zmqsocket1->Connect();
|
||||
printf("Zmq Client 1 at %s\n", zmqsocket1->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
ZmqSocket* zmqsocket3 = 0;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
zmqsocket3 = new ZmqSocket(portnum2+1, socketip2);
|
||||
if (zmqsocket3->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2+1, socketip2);
|
||||
delete zmqsocket3;
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server 0 started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
zmqsocket3->Connect();
|
||||
printf("Zmq Server 1 started at %s\n", zmqsocket3->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint64_t acqIndex1 = -1;
|
||||
uint64_t frameIndex1 = -1;
|
||||
uint32_t subframeIndex1 = -1;
|
||||
uint64_t fileindex1 = -1;
|
||||
string filename1 = "";
|
||||
|
||||
uint64_t acqIndex0 = -1;
|
||||
uint64_t frameIndex0 = -1;
|
||||
uint32_t subframeIndex0 = -1;
|
||||
uint64_t fileindex0 = -1;
|
||||
string filename0 = "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char ofname[10000];
|
||||
FILE *fout=NULL;
|
||||
for (int i=0; i<nnx; i++)
|
||||
dout[i]=0;
|
||||
char fname0[10000], fname1[10000];
|
||||
int irun;
|
||||
|
||||
#ifndef ZMQ
|
||||
|
||||
char ff[10000];
|
||||
if (argc < 6 ) {
|
||||
cprintf(RED, "Help: %s [indir] [fformat] [runmin] [runmax] [out file format]\n",argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char *indir=argv[1];
|
||||
char *fformat=argv[2];
|
||||
int runmin=atoi(argv[3]);
|
||||
int runmax=atoi(argv[4]);
|
||||
char *outdir=argv[5];
|
||||
sprintf(ff,"%s/%s",indir,fformat);
|
||||
|
||||
// strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
|
||||
// sprintf(fname0,fformat,0,0);
|
||||
// sprintf(fname1,fformat,1,1);
|
||||
|
||||
ifstream filebin0,filebin1;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
|
||||
sprintf(fname0,ff,0,irun);
|
||||
sprintf(fname1,ff,1,irun);
|
||||
sprintf(ofname,outdir,irun);
|
||||
|
||||
filebin0.open((const char *)(fname0), ios::in | ios::binary);
|
||||
filebin1.open((const char *)(fname1), ios::in | ios::binary);
|
||||
if (filebin0.is_open() && filebin1.is_open()) {
|
||||
cout << "Opened file " << fname0<< endl;
|
||||
cout << "Opened file " << fname1<< endl;
|
||||
nf=0;
|
||||
iFrame=-1;
|
||||
while ((decoder->readNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef ZMQ
|
||||
|
||||
while(1) {
|
||||
if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
fout=fopen(ofname,"w");
|
||||
//cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<512; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
dout[i]=image[i];
|
||||
}
|
||||
fclose(fout);;
|
||||
}
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname0,filename0.c_str());
|
||||
strcpy(fname1,filename1.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,size/2);
|
||||
zmqsocket3->SendData(((char*)dout)+size/2,size/2);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
|
||||
cprintf(RED, "Received %d frames\n", nf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
filter->clearImage();
|
||||
// std::time(&end_time);
|
||||
// cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
if (acqIndex0!=acqIndex1)
|
||||
cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl;
|
||||
if (frameIndex0!=frameIndex1)
|
||||
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
|
||||
|
||||
|
||||
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
length += zmqsocket0->ReceiveData(0, buff1, size/2);
|
||||
irun=fileindex0;
|
||||
sprintf(ofname,"%s_%d.ph",filename0.c_str(),fileindex0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
|
||||
nf++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef ZMQ
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
fout=fopen(ofname,"w");
|
||||
//cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<512; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
}
|
||||
fclose(fout);;
|
||||
}
|
||||
filter->clearImage();
|
||||
|
||||
|
||||
|
||||
iFrame=-1;
|
||||
}
|
||||
|
||||
filebin0.close();
|
||||
filebin1.close();
|
||||
}
|
||||
else
|
||||
cout << "Could not open file " << fname0<< " or " << fname1 << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
}
|
@ -111,13 +111,13 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
}
|
||||
|
||||
#ifdef MYROOT1
|
||||
virtual TH2F *addToInterpolatedImage(char *data, single_photon_hit *clusters, int &nph)
|
||||
virtual TH2F *addToInterpolatedImage(char *data, int *val, int &nph)
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
virtual int *addToInterpolatedImage(char *data, single_photon_hit *clusters, int &nph)
|
||||
virtual int *addToInterpolatedImage(char *data, int *val, int &nph)
|
||||
#endif
|
||||
{
|
||||
nph=addFrame(data,clusters,0);
|
||||
nph=addFrame(data,val,0);
|
||||
if (interp)
|
||||
return interp->getInterpolatedImage();
|
||||
else
|
||||
@ -127,13 +127,13 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
virtual TH2F *addToFlatField(char *data, single_photon_hit *clusters, int &nph)
|
||||
virtual TH2F *addToFlatField(char *data, int *val, int &nph)
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
virtual int *addToFlatField(char *data, single_photon_hit *clusters, int &nph)
|
||||
virtual int *addToFlatField(char *data, int *val, int &nph)
|
||||
#endif
|
||||
{
|
||||
nph=addFrame(data,clusters,1);
|
||||
nph=addFrame(data,val,1);
|
||||
if (interp)
|
||||
return interp->getFlatField();
|
||||
else
|
||||
@ -149,8 +149,151 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
|
||||
|
||||
int nph=0;
|
||||
double val[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
int ir, ic;
|
||||
|
||||
int addFrame(char *data, single_photon_hit *clusters=NULL, int ff=0) {
|
||||
double int_x,int_y, eta_x, eta_y;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
if (iframe<nDark) {
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
}
|
||||
newFrame();
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
|
||||
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*cluster->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||
(clusters+nph)->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_RIGHT;
|
||||
(clusters+nph)->quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
(clusters+nph)->quad=TOP_LEFT;
|
||||
(clusters+nph)->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
(clusters+nph)->quad=TOP_RIGHT;
|
||||
(clusters+nph)->quadTot=tr;
|
||||
}
|
||||
|
||||
if (max>nSigma*cluster->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cluster->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*cluster->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
(clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
(clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (interp) {
|
||||
if (ff) {
|
||||
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
|
||||
} else {
|
||||
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
}
|
||||
} else
|
||||
image[ix+nx*iy]++;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
|
||||
} else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
nphFrame=nph;
|
||||
nphTot+=nph;
|
||||
//cout << nphFrame << endl;
|
||||
// cout <<"**********************************"<< endl;
|
||||
writeClusters();
|
||||
return nphFrame;
|
||||
|
||||
};
|
||||
|
||||
/*********************************************************
|
||||
int addFrame(char *data, int ff=0) {
|
||||
|
||||
double g=1;
|
||||
|
||||
@ -262,13 +405,6 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* cout << ix << " " << iy << " " << rest[iy][ix] <<" " << tot << " " << quadTot << endl; */
|
||||
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
|
||||
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) */
|
||||
/* cout << rest[iy+ir][ix+ic] << " " ; */
|
||||
/* cout << endl; */
|
||||
/* } */
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
cl->tot=tot;
|
||||
cl->x=ix;
|
||||
@ -322,7 +458,7 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
return nph;
|
||||
}
|
||||
|
||||
|
||||
******************************************/
|
||||
|
||||
|
||||
|
||||
@ -485,20 +621,20 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
|
||||
|
||||
|
||||
virtual void processData(char *data, frameMode i=eFrame, int *val=NULL) {
|
||||
virtual void processData(char *data, int *val=NULL) {
|
||||
if (interp){
|
||||
switch(i) {
|
||||
case ePedestal:
|
||||
addToPedestal(data);
|
||||
break;
|
||||
case eFlat:
|
||||
addFrame(data,NULL,1);
|
||||
break;
|
||||
default:
|
||||
addFrame(data,NULL,0);
|
||||
}
|
||||
} else
|
||||
singlePhotonDetector::processData(data,i,val);
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
addToPedestal(data);
|
||||
break;
|
||||
case eFlat:
|
||||
addFrame(data,val,1);
|
||||
break;
|
||||
default:
|
||||
addFrame(data,val,0);
|
||||
}
|
||||
} else
|
||||
singlePhotonDetector::processData(data,val);
|
||||
|
||||
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ class linearInterpolation : public slsInterpolation{
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (ns>2) {
|
||||
if (nSubPixels>2) {
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
}
|
||||
getInterpolatedPosition(x, y, etax,etay, corner, int_x, int_y);
|
||||
@ -41,14 +41,16 @@ class linearInterpolation : public slsInterpolation{
|
||||
};
|
||||
|
||||
|
||||
virtual int getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &etax, double &etay) {
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
if (ns>2) {
|
||||
double eta_x, eta_y;
|
||||
if (nSubPixels>2) {
|
||||
double cc[2][2];
|
||||
double *cluster[3];
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
int xoff, yoff;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
@ -74,10 +76,9 @@ class linearInterpolation : public slsInterpolation{
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
double eta_x, eta_y;
|
||||
calcEta(quadTot,cc,eta_x,eta_y);
|
||||
calcEta(totquad,cc,eta_x,eta_y);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
return getInterpolatedPosition(x,y,eta_x, eta_y,quad,int_x,int_y);
|
||||
|
||||
|
||||
|
||||
@ -113,20 +114,21 @@ class linearInterpolation : public slsInterpolation{
|
||||
dY=-1.;
|
||||
break;
|
||||
default:
|
||||
cout << "bad quadrant" << endl;
|
||||
dX=0.;
|
||||
dY=0.;
|
||||
}
|
||||
|
||||
|
||||
if (ns>2) {
|
||||
xpos_eta=(etax);
|
||||
ypos_eta=(etay);
|
||||
if (nSubPixels>2) {
|
||||
xpos_eta=(etax)+dX;
|
||||
ypos_eta=(etay)+dY;
|
||||
} else {
|
||||
xpos_eta=0;
|
||||
xpos_eta=0;
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
xpos_eta=0.5*dY+0.25;
|
||||
}
|
||||
int_x=((double)x) + dX + xpos_eta;
|
||||
int_y=((double)y) + dY + ypos_eta;
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
|
||||
return;
|
||||
};
|
||||
|
@ -6,16 +6,14 @@ INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../inte
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-L../../bin
|
||||
MAIN=moench03ZmqOnTheFly.cpp
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqClusterFinder
|
||||
#moench03ZmqOnTheFly
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating
|
||||
|
||||
|
||||
moench03ZmqOnTheFly: $(MAIN) $(INCS) clean
|
||||
g++ -o moench03ZmqOnTheFly $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
@ -125,7 +125,7 @@ int main(int argc, char *argv[]) {
|
||||
while(1) {
|
||||
|
||||
|
||||
cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
@ -155,8 +155,11 @@ int main(int argc, char *argv[]) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
@ -0,0 +1,217 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpixels=2;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 100,npx,npy);
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
int nix, niy,nis;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
int ix, iy, isx, isy;
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; iy++) {
|
||||
dout[iy*nnx+ix]=0;
|
||||
for (isx=0; isx<nis; isx++) {
|
||||
for (isy=0; isy<nis; isy++) {
|
||||
dout[iy*nnx+ix]+=detimage[(iy+isy)*nix+(ix+isx)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",filename.c_str(),fileindex);
|
||||
mt->writeImage(ofname);
|
||||
|
||||
}
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
cprintf(RED, "Received %d frames\n", iframe);
|
||||
}
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
iframe=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
|
||||
iframe++;
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ public analogDetector<uint16_t> {
|
||||
}
|
||||
}
|
||||
cout << iframe << " " << nph << endl;
|
||||
} else return getClusters(data);
|
||||
} else return getClusters(data, nph);
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
@ -410,7 +410,7 @@ public analogDetector<uint16_t> {
|
||||
|
||||
*/
|
||||
|
||||
int *getClusters(char *data) {
|
||||
int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
|
||||
int nph=0;
|
||||
@ -421,6 +421,9 @@ int *getClusters(char *data) {
|
||||
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
if (iframe<nDark) {
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
|
@ -1346,11 +1346,11 @@ int64_t setDelay(int64_t value){
|
||||
if (value!=-1) {
|
||||
value*=(1E-3*clkDivider[1]);//(1E-9*CLK_FREQ);
|
||||
}
|
||||
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*clkDivider[1]);//(1E-9*CLK_FREQ);
|
||||
}
|
||||
|
||||
int64_t getDelay(){
|
||||
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
||||
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-3*clkDivider[1]);//(1E-9*CLK_FREQ);
|
||||
}
|
||||
|
||||
int64_t setTrains(int64_t value){
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
|
||||
URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
|
||||
Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
|
||||
Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e
|
||||
Revision: 17
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 7602ffc5ac94c36e326a3bf939e85746e708c2ad
|
||||
Revision: 19
|
||||
Branch: developer
|
||||
Last Changed Author: Dhanya_Maliakal
|
||||
Last Changed Rev: 3397
|
||||
Last Changed Date: 2017-12-06 19:05:47.000000002 +0100 ./server_funcs.c
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3554
|
||||
Last Changed Date: 2017-12-15 10:38:26.000000002 +0100 ./firmware_funcs.c
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
|
||||
#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e"
|
||||
#define GITAUTH "Dhanya_Maliakal"
|
||||
#define GITREV 0x3397
|
||||
#define GITDATE 0x20171206
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "7602ffc5ac94c36e326a3bf939e85746e708c2ad"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3554
|
||||
#define GITDATE 0x20171215
|
||||
#define GITBRANCH "developer"
|
||||
|
Binary file not shown.
@ -129,8 +129,10 @@
|
||||
#define GET_PERIOD_LSB_REG 24<<11//0x76<<11
|
||||
#define GET_PERIOD_MSB_REG 25<<11//0x77<<11
|
||||
|
||||
#define SET_EXPTIME_LSB_REG 104<<11//0x78<<11
|
||||
#define SET_EXPTIME_MSB_REG 105<<11//0x79<<11
|
||||
//#define PATTERN_WAIT0_TIME_REG_LSB 114<<11
|
||||
//#define PATTERN_WAIT0_TIME_REG_MSB 115<<11
|
||||
#define SET_EXPTIME_LSB_REG 114<<11//0x78<<11
|
||||
#define SET_EXPTIME_MSB_REG 115<<11//0x79<<11
|
||||
#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11
|
||||
#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user