mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 07:20:01 +02:00
changes to receiver works for data compression. needs optimizing
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@699 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
0c3f1d95b9
commit
8e24fc7ef9
@ -40,6 +40,8 @@ using namespace std;
|
||||
#define SETTINGS_FILE_NOT_OPEN 0x0000000000000020ULL
|
||||
#define COULDNOT_START_RECEIVER 0x0000000000000040ULL // default error like starting threads
|
||||
#define COULDNOT_STOP_RECEIVER 0x0000000000000080ULL
|
||||
#define DETECTOR_TIMER_VALUE_NOT_SET 0x0000000000000100ULL
|
||||
#define RECEIVER_ACQ_PERIOD_NOT_SET 0x0000000000000200ULL
|
||||
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
@ -109,6 +111,12 @@ public:
|
||||
if(slsErrorMask&COULDNOT_STOP_RECEIVER)
|
||||
retval.append("Could not stop receiver.\n");
|
||||
|
||||
if(slsErrorMask&DETECTOR_TIMER_VALUE_NOT_SET)
|
||||
retval.append("Could not set one of timer values in detector.\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_ACQ_PERIOD_NOT_SET)
|
||||
retval.append("Could not set acquisition period in receiver.\n");
|
||||
|
||||
|
||||
return retval;
|
||||
|
||||
|
@ -4362,30 +4362,31 @@ int multiSlsDetector::stopReceiver(){
|
||||
|
||||
|
||||
slsDetectorDefs::runStatus multiSlsDetector::startReceiverReadout(){
|
||||
int i=0;
|
||||
runStatus s,s1;
|
||||
i=thisMultiDetector->masterPosition;
|
||||
if (thisMultiDetector->masterPosition>=0) {
|
||||
if (detectors[i]) {
|
||||
s1=detectors[i]->startReceiverReadout();
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
|
||||
runStatus s,s1;
|
||||
}
|
||||
}
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
s=detectors[i]->startReceiverReadout();
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if(s == ERROR)
|
||||
s1 = ERROR;
|
||||
if(s1 != s)
|
||||
s1 = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (thisMultiDetector->masterPosition>=0)
|
||||
if (detectors[thisMultiDetector->masterPosition]){
|
||||
s = detectors[thisMultiDetector->masterPosition]->startReceiverReadout();
|
||||
if(detectors[thisMultiDetector->masterPosition]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<thisMultiDetector->masterPosition));
|
||||
return s;
|
||||
}
|
||||
|
||||
if (detectors[0]) s=detectors[0]->startReceiverReadout();
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
s1=detectors[i]->startReceiverReadout();
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (s1==ERROR)
|
||||
s=ERROR;
|
||||
if (s1==IDLE && s!=IDLE)
|
||||
s=ERROR;
|
||||
|
||||
}
|
||||
return s;
|
||||
*stoppedFlag=1;
|
||||
return s;
|
||||
}
|
||||
|
||||
slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){
|
||||
|
@ -3464,8 +3464,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
|
||||
|
||||
int fnum=F_SET_TIMER;
|
||||
int64_t retval;
|
||||
uint64_t ut;
|
||||
int64_t retval = -1;
|
||||
int64_t ut = -2;
|
||||
char mess[100];
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
@ -3476,7 +3476,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl;
|
||||
#endif
|
||||
ut=t;
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
@ -3486,6 +3485,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
thisDetector->timerValue[index]=retval;
|
||||
@ -3524,6 +3524,26 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
setTotalProgress();
|
||||
}
|
||||
|
||||
//send acquisiton period to receiver
|
||||
if((index==FRAME_PERIOD) && (ret != FAIL) && (t != -1) && (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG)){
|
||||
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
|
||||
if(!retval)
|
||||
retval = timerValue[ACQUISITION_TIME];
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending/Getting acquisition period to/from receiver " << retval << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendInt(fnum,ut,retval);
|
||||
if(ut != retval){
|
||||
ret = FAIL;
|
||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
|
||||
}
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
return thisDetector->timerValue[index];
|
||||
|
||||
};
|
||||
@ -4793,13 +4813,21 @@ char* slsDetector::setDetectorIP(string detectorIP){
|
||||
|
||||
|
||||
char* slsDetector::setReceiver(string receiverIP){
|
||||
|
||||
if(getRunStatus()==RUNNING)
|
||||
stopAcquisition();
|
||||
|
||||
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
||||
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting up receiver with" << endl <<
|
||||
"file path:" << fileIO::getFilePath() << endl <<
|
||||
"file name:" << fileIO::getFileName() << endl <<
|
||||
"file index:" << fileIO::getFileIndex() << endl <<
|
||||
"frame index needed:" << ((setTimer(FRAME_NUMBER,-1)*setTimer(CYCLES_NUMBER,-1))>1) << endl <<
|
||||
"write enable:" << parentDet->enableWriteToFileMask() << endl <<
|
||||
"frame period:" << setTimer(FRAME_PERIOD,-1) << endl << endl;
|
||||
#endif
|
||||
setFilePath(fileIO::getFilePath());
|
||||
setFileName(fileIO::getFileName());
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
@ -4808,6 +4836,7 @@ char* slsDetector::setReceiver(string receiverIP){
|
||||
else
|
||||
setFrameIndex(-1);
|
||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
||||
setTimer(FRAME_PERIOD,setTimer(FRAME_PERIOD,-1));
|
||||
setUDPConnection();
|
||||
}
|
||||
|
||||
|
@ -3965,8 +3965,12 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
|
||||
if (action==PUT_ACTION) {
|
||||
if(!strcasecmp(args[1],"start"))
|
||||
myDet->startReceiver();
|
||||
else if(!strcasecmp(args[1],"stop"))
|
||||
else if(!strcasecmp(args[1],"stop")){
|
||||
myDet->startReceiverReadout();
|
||||
while(myDet->getReceiverStatus() != RUN_FINISHED)
|
||||
usleep(50000);
|
||||
myDet->stopReceiver();
|
||||
}
|
||||
else
|
||||
return helpReceiver(narg, args, action);
|
||||
}
|
||||
|
@ -336,13 +336,13 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
pthread_mutex_unlock(&mg);
|
||||
}else{
|
||||
pthread_mutex_lock(&mg);
|
||||
if(startReceiverReadout() == TRANSMITTING){
|
||||
while(getReceiverStatus() != RUN_FINISHED){
|
||||
pthread_mutex_unlock(&mg);
|
||||
usleep(50000);
|
||||
pthread_mutex_lock(&mg);
|
||||
}
|
||||
}
|
||||
startReceiverReadout();
|
||||
while(getReceiverStatus() != RUN_FINISHED){
|
||||
pthread_mutex_unlock(&mg);
|
||||
usleep(50000);
|
||||
pthread_mutex_lock(&mg);
|
||||
}
|
||||
|
||||
stopReceiver();
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class fileIOStatic {
|
||||
if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \
|
||||
if(i==-1)return 0; \
|
||||
else return i; \
|
||||
cout << "******************************** cannot parse frame index" << endl; \
|
||||
/*cout << "******************************** cannot parse frame index" << endl; \*/
|
||||
return 0; \
|
||||
};
|
||||
|
||||
|
@ -7,11 +7,13 @@
|
||||
|
||||
|
||||
#define BUF_SIZE (16*1024*1024) //16mb
|
||||
#define HEADER_SIZE_NUM_FRAMES 2
|
||||
#define HEADER_SIZE_NUM_PACKETS 1
|
||||
|
||||
|
||||
singlePhotonFilter::singlePhotonFilter(int nx, int ny,
|
||||
int fmask, int pmask, int foffset, int poffset, int pperf, int iValue,
|
||||
int16_t *m, int16_t *s, CircularFifo<char>* f, int d):
|
||||
int16_t *m, int16_t *s, CircularFifo<char>* f, int d, int* tfcaught, int* fcaught):
|
||||
#ifdef MYROOT1
|
||||
myTree(NULL),
|
||||
myFile(NULL),
|
||||
@ -52,8 +54,11 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
|
||||
currentThread(-1),
|
||||
thisThreadIndex(-1),
|
||||
fileIndex(0),
|
||||
fifo(f){
|
||||
|
||||
fifo(f),
|
||||
totalFramesCaught(tfcaught),
|
||||
framesCaught(fcaught),
|
||||
freeFifoCallBack(NULL),
|
||||
pFreeFifo(NULL){
|
||||
#ifndef MYROOT1
|
||||
photonHitList = new single_photon_hit[nChannelsX*nChannelsY];
|
||||
#endif
|
||||
@ -216,6 +221,7 @@ int singlePhotonFilter::writeToFile(){
|
||||
if(myFile){
|
||||
/*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/
|
||||
fwrite((void*)(photonHitList), 1, sizeof(single_photon_hit)*nHitsPerFrame, myFile);
|
||||
/*framesInFile += nHitsPerFrame;*/
|
||||
nHitsPerFrame = 0;
|
||||
//cout<<"Exiting writeToFile"<<endl;
|
||||
return OK;
|
||||
@ -257,6 +263,8 @@ void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfna
|
||||
strcpy(fileName,outfname);
|
||||
|
||||
fnum = 0; pnum = 0; ptot = 0; f0 = 0; firstTime = true; currentThread = -1;
|
||||
*framesCaught = 0;
|
||||
|
||||
//initialize
|
||||
for (int ir=0; ir<nChannelsX; ir++){
|
||||
for (int ic=0; ic<nChannelsY; ic++){
|
||||
@ -273,7 +281,25 @@ void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfna
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
rets
|
||||
case 0: waiting for next packet of new frame
|
||||
case 1: finished with full frame,
|
||||
start new frame
|
||||
case -1: last packet of current frame,
|
||||
invalidate remaining packets,
|
||||
start new frame
|
||||
case -2: first packet of new frame,
|
||||
invalidate remaining packets,
|
||||
check buffer needs to be pushed,
|
||||
start new frame with the current packet,
|
||||
then ret = 0
|
||||
case -3: last packet of new frame,
|
||||
invalidate remaining packets,
|
||||
check buffer needs to be pushed,
|
||||
start new frame with current packet,
|
||||
then ret = -1 (invalidate remaining packets and start a new frame)
|
||||
*/
|
||||
int singlePhotonFilter::verifyFrame(char *inData){
|
||||
ret = 0;
|
||||
pIndex = 0;
|
||||
@ -389,6 +415,7 @@ void singlePhotonFilter::findHits(){
|
||||
int dum;
|
||||
double tot; // total value of pixel
|
||||
char* isData;
|
||||
char* freeData;
|
||||
int16_t* myData;
|
||||
int index = thisThreadIndex;
|
||||
|
||||
@ -411,6 +438,7 @@ void singlePhotonFilter::findHits(){
|
||||
cout << "Could not set Thread " << index <<" cancel state to be disabled" << endl;
|
||||
|
||||
isData = mem0[index];
|
||||
freeData = isData;
|
||||
|
||||
pthread_mutex_lock(&running_mutex);
|
||||
threads_mask|=(1<<index);
|
||||
@ -420,19 +448,26 @@ void singlePhotonFilter::findHits(){
|
||||
while((dum = sem_wait(&smp[index]))!=0)
|
||||
cout<<"got data semwait:["<<index<<"]:"<<dum<<endl;
|
||||
|
||||
isData += HEADER_SIZE_NUM_FRAMES;
|
||||
|
||||
|
||||
myData = (int16_t*)isData;
|
||||
|
||||
//for all the frames in one buffer
|
||||
for (i=0; i < numFramesAlloted[index]; ++i){
|
||||
/*cout<<"mydata:"<<(void*)isData<<endl;*/
|
||||
|
||||
clusteriframe = (uint32_t)(*((uint32_t*)(isData)));
|
||||
//ignore frames which have less than 2 packets
|
||||
if((uint8_t)(*((uint8_t*)isData)) == packets_per_frame){
|
||||
|
||||
if(clusteriframe != 0xFFFFFFFF){
|
||||
clusteriframe = ((clusteriframe & frame_index_mask) >>frame_index_offset) - f0;
|
||||
(*framesCaught)++;
|
||||
(*totalFramesCaught)++;
|
||||
|
||||
|
||||
isData += HEADER_SIZE_NUM_PACKETS;
|
||||
clusteriframe = (((uint32_t)(*((uint32_t*)(isData)))& frame_index_mask) >>frame_index_offset);
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "scurrframnum:" << clusteriframe << endl;
|
||||
#endif
|
||||
clusteriframe -= f0;
|
||||
myData = (int16_t*)isData;
|
||||
|
||||
//for each pixel
|
||||
for (ir=0; ir<nChannelsX; ++ir){
|
||||
for (ic=0; ic<nChannelsY;++ic){
|
||||
@ -522,31 +557,37 @@ void singlePhotonFilter::findHits(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//else cout<<"***did not get whoel frame in single photon filter"<<endl;
|
||||
|
||||
}else{
|
||||
//cout<< "did no receiver fulll frame"<<endl;
|
||||
isData += HEADER_SIZE_NUM_PACKETS;
|
||||
}
|
||||
//calulate the average hits per frame
|
||||
nHitStat->Calc((double)nHitsPerFrame);
|
||||
|
||||
//write for each frame, not packet
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
writeToFile();
|
||||
fifo->push(isData);
|
||||
//fifo->push(isData);
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
|
||||
isData += 4096;
|
||||
myData += 2048;
|
||||
//increment offset
|
||||
isData += dataSize;
|
||||
|
||||
/*
|
||||
/*
|
||||
if ((clusteriframe%1000 == 0) && (clusteriframe != 0) ){
|
||||
cout << dec << "Frame: " << clusteriframe << " Hit Avg over last frames: " <<
|
||||
nHitStat->Mean() << " .. "<<nHitStat->StandardDeviation() << endl;
|
||||
cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
if(freeFifoCallBack)
|
||||
freeFifoCallBack(freeData,pFreeFifo);
|
||||
//fifo->push(freeData);//fifo->push(isData);
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
|
||||
//thread not running
|
||||
pthread_mutex_lock(&running_mutex);
|
||||
threads_mask^=(1<<index);
|
||||
pthread_mutex_unlock(&running_mutex);
|
||||
@ -554,6 +595,10 @@ void singlePhotonFilter::findHits(){
|
||||
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)!=0)
|
||||
cout << "Could not set Thread " << index <<" cancel state to be enabled" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
delete [] clusterData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
* @param s mask as to which adcs are inverted
|
||||
* @param f circular fifo buffer, which needs to be freed
|
||||
* @param d Size of data with the headers
|
||||
* @param tfcaught pointer to total frames caught
|
||||
* @param fcaught pointer to frames caught
|
||||
*/
|
||||
singlePhotonFilter(
|
||||
int nx,
|
||||
@ -94,7 +96,9 @@ public:
|
||||
int16_t *m,
|
||||
int16_t *s,
|
||||
CircularFifo<char>* f,
|
||||
int d);
|
||||
int d,
|
||||
int* tfcaught,
|
||||
int* fcaught);
|
||||
|
||||
/** virtual destructor */
|
||||
virtual ~singlePhotonFilter();
|
||||
@ -167,10 +171,24 @@ public:
|
||||
|
||||
/** reconstruct the frame with all the right packets
|
||||
* @param inData the data from socket to be verified
|
||||
* returns 0 if still waiting for next packet of same frame,
|
||||
* 1 if end of complete frame, -1 if end of incomplete frame,
|
||||
* -2 first packet of next frame, so push previous one; -3 last packet of current frame, push both frames
|
||||
* */
|
||||
* returns
|
||||
* 0: waiting for next packet of new frame
|
||||
* 1: finished with full frame,
|
||||
* start new frame
|
||||
* -1: last packet of current frame,
|
||||
* invalidate remaining packets,
|
||||
* start new frame
|
||||
* -2: first packet of new frame,
|
||||
* invalidate remaining packets,
|
||||
* check buffer needs to be pushed,
|
||||
* start new frame with the current packet,
|
||||
* then ret = 0
|
||||
* -3: last packet of new frame,
|
||||
* invalidate remaining packets,
|
||||
* check buffer needs to be pushed,
|
||||
* start new frame with current packet,
|
||||
* then ret = -1 (invalidate remaining packets and start a new frame)
|
||||
*/
|
||||
int verifyFrame(char *inData);
|
||||
|
||||
/**
|
||||
@ -200,6 +218,13 @@ public:
|
||||
* */
|
||||
int checkIfJobsDone();
|
||||
|
||||
/**
|
||||
* call back to free fifo
|
||||
* call back arguments are
|
||||
* fbuffer buffer address to be freed
|
||||
*/
|
||||
void registerCallBackFreeFifo(void (*func)(char*, void*),void *arg){freeFifoCallBack=func; pFreeFifo=arg;};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
@ -227,7 +252,7 @@ private:
|
||||
int nHitsPerFrame;
|
||||
|
||||
/** Maximum Number of hits written to file */
|
||||
const static int MAX_HITS_PER_FILE = 200000;
|
||||
const static int MAX_HITS_PER_FILE = 2000000;
|
||||
|
||||
/** Number of Channels in X direction */
|
||||
int nChannelsX;
|
||||
@ -376,6 +401,18 @@ private:
|
||||
|
||||
/** circular fifo buffer to be freed */
|
||||
CircularFifo<char>* fifo;
|
||||
|
||||
/**total frames caught */
|
||||
int* totalFramesCaught;
|
||||
|
||||
/** frames caught */
|
||||
int* framesCaught;
|
||||
|
||||
/** call back function */
|
||||
void (*freeFifoCallBack)(char*, void*);
|
||||
|
||||
/** call back arguments */
|
||||
void *pFreeFifo;
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define CIRCULARFIFO_H_
|
||||
|
||||
//#include "sls_detector_defs.h"
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
@ -35,6 +35,7 @@ public:
|
||||
CircularFifo(unsigned int Size) : tail(0), head(0){
|
||||
Capacity = Size + 1;
|
||||
array.resize(Capacity);
|
||||
sem_init(&free_mutex,0,0);
|
||||
}
|
||||
virtual ~CircularFifo() {}
|
||||
|
||||
@ -49,6 +50,7 @@ private:
|
||||
vector <Element*> array;
|
||||
volatile unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
sem_t free_mutex;
|
||||
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
};
|
||||
@ -70,6 +72,7 @@ bool CircularFifo<Element>::push(Element*& item_)
|
||||
{
|
||||
array[tail] = item_;
|
||||
tail = nextTail;
|
||||
sem_post(&free_mutex);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -86,8 +89,9 @@ bool CircularFifo<Element>::push(Element*& item_)
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::pop(Element*& item_)
|
||||
{
|
||||
if(head == tail)
|
||||
return false; // empty queue
|
||||
// if(head == tail)
|
||||
// return false; // empty queue
|
||||
sem_wait(&free_mutex);
|
||||
|
||||
item_ = array[head];
|
||||
head = increment(head);
|
||||
|
@ -11,15 +11,18 @@
|
||||
#define CREATE_FILES 1
|
||||
#define DO_EVERYTHING 2
|
||||
|
||||
#define BUF_SIZE (16*1024*1024) //16mb
|
||||
#define BUF_SIZE (16*1024*1024) //16mb
|
||||
#define SAMPLE_TIME_IN_NS 100000000//100ms
|
||||
#define MAX_JOBS_PER_THREAD 1000
|
||||
#define HEADER_SIZE_NUM_FRAMES 2
|
||||
#define HEADER_SIZE_NUM_PACKETS 1
|
||||
|
||||
|
||||
//all max frames defined in sls_detector_defs.h. 20000 gotthard, 100000 for short gotthard, 1000 for moench
|
||||
|
||||
|
||||
|
||||
//#define GOTTHARD_FIFO_SIZE 25000
|
||||
#define GOTTHARD_FIFO_SIZE 11
|
||||
#define GOTTHARD_ALIGNED_FRAME_SIZE 4096
|
||||
#define GOTTHARD_FIFO_SIZE 25000 //cannot be less than max jobs per thread = 1000
|
||||
/*#define GOTTHARD_ALIGNED_FRAME_SIZE 4096*/
|
||||
#define GOTTHARD_PACKETS_PER_FRAME 2
|
||||
#define GOTTHARD_ONE_PACKET_SIZE 1286
|
||||
#define GOTTHARD_BUFFER_SIZE (GOTTHARD_ONE_PACKET_SIZE*GOTTHARD_PACKETS_PER_FRAME) //1286*2
|
||||
@ -37,13 +40,9 @@
|
||||
#define GOTTHARD_PACKET_INDEX_MASK 0x1
|
||||
|
||||
|
||||
//#define GOTTHARD_NUM_JOBS_P_THREAD 5000//20000
|
||||
#define GOTTHARD_NUM_JOBS_P_THREAD 3//with 25 frames
|
||||
#define GOTTHARD_SHORT_NUM_JOBS_P_THREAD 2500//40000
|
||||
#define MOENCH_NUM_JOBS_P_THREAD 1000//10000
|
||||
|
||||
#define MOENCH_FIFO_SIZE 2500
|
||||
#define MOENCH_ALIGNED_FRAME_SIZE 65536
|
||||
#define MOENCH_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000
|
||||
/*#define MOENCH_ALIGNED_FRAME_SIZE 65536*/
|
||||
#define MOENCH_PACKETS_PER_FRAME 40
|
||||
#define MOENCH_ONE_PACKET_SIZE 1286
|
||||
#define MOENCH_BUFFER_SIZE (MOENCH_ONE_PACKET_SIZE*MOENCH_PACKETS_PER_FRAME) //1286*40
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -185,6 +185,18 @@ public:
|
||||
*/
|
||||
int startWriting();
|
||||
|
||||
/**
|
||||
* Creates new file
|
||||
*\returns OK for succces or FAIL for failure
|
||||
*/
|
||||
int createNewFile();
|
||||
|
||||
/**
|
||||
* Copy frames to gui
|
||||
* uses semaphore for nth frame mode
|
||||
*/
|
||||
void copyFrameToGui(char* startbuf);
|
||||
|
||||
/**
|
||||
* Returns the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
@ -198,24 +210,33 @@ public:
|
||||
*/
|
||||
int setShortFrame(int i);
|
||||
|
||||
/**
|
||||
* Set the variable to send every nth frame to gui
|
||||
* or if 0,send frame only upon gui request
|
||||
*/
|
||||
int setNFrameToGui(int i){if(i>=0) nFrameToGui = i; return nFrameToGui;};
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished */
|
||||
void startReadout();
|
||||
|
||||
/** enabl data compression, by saving only hits */
|
||||
void enableDataCompression(bool enable){dataCompression = enable;filter->enableCompression(enable);};
|
||||
void enableDataCompression(bool enable){dataCompression = enable;if(filter)filter->enableCompression(enable);};
|
||||
|
||||
/** get data compression, by saving only hits */
|
||||
bool getDataCompression(){ return dataCompression;};
|
||||
|
||||
/** Set Number of Jobs Per Thread */
|
||||
void setNumberOfJobsPerThread(int i){userDefinedNumJobsPerThread = i; numJobsPerThread = i;};
|
||||
/**
|
||||
* Set the variable to send every nth frame to gui
|
||||
* or if 0,send frame only upon gui request
|
||||
*/
|
||||
int setNFrameToGui(int i);
|
||||
|
||||
/** set acquisition period if a positive number */
|
||||
int64_t setAcquisitionPeriod(int64_t index);
|
||||
|
||||
/** set up fifo according to the new numjobsperthread */
|
||||
void setupFifoStructure ();
|
||||
|
||||
/** free fifo buffer, called back from single photon filter */
|
||||
static void freeFifoBufferCallBack (char* fbuffer, void *this_pointer){((slsReceiverFunctionList*)this_pointer)->freeFifoBuffer(fbuffer);};
|
||||
void freeFifoBuffer(char* fbuffer){fifofree->push(fbuffer);};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -264,15 +285,15 @@ private:
|
||||
/** Total packets caught for an entire acquisition (including all scans) */
|
||||
int totalPacketsCaught;
|
||||
|
||||
/** Frames currently in current file, starts new file when it reaches max */
|
||||
int framesInFile;
|
||||
|
||||
/** Frame index at start of an entire acquisition (including all scans) */
|
||||
uint32_t startAcquisitionIndex;
|
||||
|
||||
/** Actual current frame index of an entire acquisition (including all scans) */
|
||||
uint32_t acquisitionIndex;
|
||||
|
||||
/** Packets currently in current file, starts new file when it reaches max */
|
||||
int packetsInFile;
|
||||
|
||||
/** Previous Frame number from buffer */
|
||||
uint32_t prevframenum;
|
||||
|
||||
@ -375,8 +396,8 @@ private:
|
||||
/** Number of jobs per thread for data compression */
|
||||
int numJobsPerThread;
|
||||
|
||||
/** user defined number of jobs per thread for data compression */
|
||||
int userDefinedNumJobsPerThread;
|
||||
/** acquisition period */
|
||||
int64_t acquisitionPeriod;
|
||||
|
||||
/**
|
||||
callback arguments are
|
||||
|
@ -41,7 +41,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
string sLine,sargname;
|
||||
int iline = 0;
|
||||
bool dcompr = false;
|
||||
int jobthread = -1;
|
||||
/*int jobthread = -1;*/
|
||||
|
||||
|
||||
success=OK;
|
||||
@ -67,7 +67,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
getline(infile,sLine);
|
||||
iline++;
|
||||
#ifdef VERBOSE
|
||||
cout << str << endl;
|
||||
cout << sLine << endl;
|
||||
#endif
|
||||
if(sLine.find('#')!=string::npos){
|
||||
#ifdef VERBOSE
|
||||
@ -184,7 +184,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
}
|
||||
}
|
||||
}
|
||||
//jobstothread
|
||||
/*//jobstothread
|
||||
else if(!strcasecmp(argv[iarg],"-jobthread")){
|
||||
if(iarg+1==argc){
|
||||
cout << "no value given after -jobthread in command line. Exiting." << endl;
|
||||
@ -197,7 +197,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
success=FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
else{
|
||||
cout << "Unknown argument:" << argv[iarg] << endl;
|
||||
success=FAIL;
|
||||
@ -227,8 +227,8 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
cout << "Help Commands " << endl;
|
||||
cout << "type:\t\t Type of receiver. Default: Gotthard. Options: Moench" << endl;
|
||||
cout << "rx_tcpport:\t TCP Communication Port with the client. Default:1954. " << endl;
|
||||
cout << "compression:\t Data Compression. Saving only hits. Option:yes, no" << endl;
|
||||
cout << "jobthread:\t Number of jobs given to a thread for compression." << endl << endl;
|
||||
cout << "compression:\t Data Compression. Saving only hits. Option:yes, no" << endl << endl;;
|
||||
/*cout << "jobthread:\t Number of jobs given to a thread for compression." << endl << endl;*/
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +250,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
slsReceiverList = new slsReceiverFunctionList(myDetectorType);
|
||||
|
||||
if(dcompr) slsReceiverList->enableDataCompression(dcompr);
|
||||
if(jobthread!=-1) slsReceiverList->setNumberOfJobsPerThread(jobthread);
|
||||
/*if(jobthread!=-1) slsReceiverList->setNumberOfJobsPerThread(jobthread);*/
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Function table assigned." << endl;
|
||||
@ -318,6 +318,8 @@ int slsReceiverFuncs::function_table(){
|
||||
flist[F_GET_ID] = &slsReceiverFuncs::get_version;
|
||||
flist[F_CONFIGURE_MAC] = &slsReceiverFuncs::set_short_frame;
|
||||
flist[F_START_READOUT] = &slsReceiverFuncs::start_readout;
|
||||
flist[F_SET_TIMER] = &slsReceiverFuncs::set_acquisition_period;
|
||||
|
||||
|
||||
//General Functions
|
||||
flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver;
|
||||
@ -1427,6 +1429,55 @@ int slsReceiverFuncs::start_readout(){
|
||||
|
||||
|
||||
|
||||
int slsReceiverFuncs::set_acquisition_period() {
|
||||
ret=OK;
|
||||
int64_t retval = -1;
|
||||
int64_t index = -1;
|
||||
strcpy(mess,"Could not set acquisition period in receiver\n");
|
||||
|
||||
|
||||
// receive arguments
|
||||
if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){
|
||||
strcpy(mess,"Error reading from socket\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
retval=slsReceiverList->setAcquisitionPeriod(index);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if(ret!=FAIL)
|
||||
cout << "acquisition period:" << retval << endl;
|
||||
else
|
||||
cout << mess << endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(ret==OK && socket->differentClients){
|
||||
cout << "Force update" << endl;
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
socket->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
socket->SendDataOnly(mess,sizeof(mess));
|
||||
socket->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
//return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -147,6 +147,9 @@ public:
|
||||
* when fifo is empty later, sets status to run_finished */
|
||||
int start_readout();
|
||||
|
||||
/** set acquisition period to find the value of n */
|
||||
int set_acquisition_period();
|
||||
|
||||
|
||||
//General Functions
|
||||
/** Locks Receiver */
|
||||
|
@ -92,6 +92,25 @@ int receiverInterface::getInt(int fnum, int &retval){
|
||||
|
||||
|
||||
|
||||
int receiverInterface::sendInt(int fnum, int64_t &retval, int64_t arg){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
char mess[100] = "";
|
||||
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->SendDataOnly(&arg,sizeof(arg));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL){
|
||||
dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
||||
}
|
||||
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
dataSocket->Disconnect();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int receiverInterface::getInt(int fnum, int64_t &retval){
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
|
||||
|
@ -77,6 +77,15 @@ public:
|
||||
*/
|
||||
int getInt(int fnum, int &retval);
|
||||
|
||||
/**
|
||||
* Send an integer to receiver
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg value to send
|
||||
* \returns success of operation
|
||||
*/
|
||||
int sendInt(int fnum, int64_t &retval, int64_t arg);
|
||||
|
||||
/**
|
||||
* Get an integer value from receiver
|
||||
* @param fnum function enum to determine what parameter
|
||||
|
Loading…
x
Reference in New Issue
Block a user