mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
compression extended to client side with r_compression
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@742 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
792e0f3845
commit
a892a8854c
@ -29,6 +29,7 @@ using namespace std;
|
||||
#define FILE_PATH_DOES_NOT_EXIST 0x0400000000000000ULL
|
||||
#define COULDNOT_CREATE_UDP_SOCKET 0x0200000000000000ULL
|
||||
#define COULDNOT_CREATE_FILE 0x0100000000000000ULL
|
||||
#define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL
|
||||
|
||||
|
||||
|
||||
@ -84,6 +85,9 @@ public:
|
||||
if(slsErrorMask&COULDNOT_CREATE_FILE)
|
||||
retval.append("Could not create file to start receiver.\nCheck permissions of output directory\n");
|
||||
|
||||
if(slsErrorMask&COULDNOT_ENABLE_COMPRESSION)
|
||||
retval.append("Could not enable/disable data compression in receiver.\nThread creation failed.\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -134,7 +134,9 @@ enum {
|
||||
|
||||
F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */
|
||||
|
||||
F_READ_RECEIVER_FREQUENCY /**< sets the frequency of receiver sending frames to gui */
|
||||
F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */
|
||||
|
||||
F_ENABLE_COMPRESSION /**< enable compression in receiver */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
};
|
||||
|
@ -4734,3 +4734,17 @@ int multiSlsDetector::setReadReceiverFrequency(int getFromReceiver,int i){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::enableReceiverCompression(int i){
|
||||
int ret=-100,ret1;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
|
||||
if (detectors[idet]){
|
||||
ret1=detectors[idet]->enableReceiverCompression(i);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if(ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1209,6 +1209,12 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
/** updates the multidetector offsets */
|
||||
void updateOffsets();
|
||||
|
||||
/** enable/disable or get data compression in receiver
|
||||
* @param i is -1 to get, 0 to disable and 1 to enable
|
||||
/returns data compression in receiver
|
||||
*/
|
||||
int enableReceiverCompression(int i = -1);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -6486,3 +6486,21 @@ int slsDetector::setReadReceiverFrequency(int getFromReceiver,int i){
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::enableReceiverCompression(int i){
|
||||
int fnum=F_ENABLE_COMPRESSION;
|
||||
int ret = FAIL;
|
||||
int retval=-1;
|
||||
|
||||
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Getting/Enabling/Disabling Receiver Compression with argument " << i << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendInt(fnum,retval,i);
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULDNOT_ENABLE_COMPRESSION));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1609,6 +1609,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int setReadReceiverFrequency(int getFromReceiver, int i=-1);
|
||||
|
||||
/** enable/disable or get data compression in receiver
|
||||
* @param i is -1 to get, 0 to disable and 1 to enable
|
||||
/returns data compression in receiver
|
||||
*/
|
||||
int enableReceiverCompression(int i = -1);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -847,6 +847,11 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="r_compression"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
|
||||
i++;
|
||||
|
||||
|
||||
numberOfCommands=i;
|
||||
|
||||
// #ifdef VERBOSE
|
||||
@ -4005,6 +4010,17 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
|
||||
sprintf(answer,"%d",myDet->setReadReceiverFrequency(1));
|
||||
return string(answer);
|
||||
|
||||
}
|
||||
else if(cmd=="r_compression"){
|
||||
if (action==PUT_ACTION){
|
||||
if (!sscanf(args[1],"%d",&ival))
|
||||
return string("Could not scan receiver compression input ")+string(args[1]);
|
||||
if(ival>=0)
|
||||
sprintf(answer,"%d",myDet->enableReceiverCompression(ival));
|
||||
}else
|
||||
sprintf(answer,"%d",myDet->enableReceiverCompression());
|
||||
return string(answer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -683,7 +683,11 @@ virtual ROI* getROI(int &n)=0;
|
||||
virtual int setReadReceiverFrequency(int getFromReceiver, int i=-1)=0;
|
||||
|
||||
|
||||
|
||||
/** enable/disable or get data compression in receiver
|
||||
* @param i is -1 to get, 0 to disable and 1 to enable
|
||||
/returns data compression in receiver
|
||||
*/
|
||||
virtual int enableReceiverCompression(int i = -1)=0;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -77,6 +77,8 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
||||
sfilefd(NULL),
|
||||
writerthreads_mask(0x0),
|
||||
listening_thread_running(0),
|
||||
killListeningThread(0),
|
||||
killAllWritingThreads(0),
|
||||
cbAction(DO_EVERYTHING),
|
||||
startAcquisitionCallBack(NULL),
|
||||
pStartAcquisition(NULL),
|
||||
@ -317,8 +319,8 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
|
||||
|
||||
|
||||
|
||||
/******************* need to look at exit strategy **************************/
|
||||
void slsReceiverFunctionList::enableDataCompression(bool enable){
|
||||
|
||||
int slsReceiverFunctionList::enableDataCompression(bool enable){
|
||||
cout << "Data compression ";
|
||||
if(enable)
|
||||
cout << "enabled" << endl;
|
||||
@ -341,13 +343,15 @@ void slsReceiverFunctionList::enableDataCompression(bool enable){
|
||||
|
||||
if(createWriterThreads() == FAIL){
|
||||
cout << "ERROR: Could not create writer threads" << endl;
|
||||
exit (-1);
|
||||
return FAIL;
|
||||
}
|
||||
setThreadPriorities();
|
||||
|
||||
|
||||
if(enable)
|
||||
setupFilter();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -583,15 +587,18 @@ int slsReceiverFunctionList::createUDPSocket(){
|
||||
|
||||
|
||||
int slsReceiverFunctionList::createListeningThreads(bool destroy){
|
||||
void* status;
|
||||
|
||||
killListeningThread = 0;
|
||||
|
||||
if(!destroy){
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
listening_thread_running = 0;
|
||||
pthread_mutex_unlock(&(status_mutex));
|
||||
|
||||
if(!destroy){
|
||||
//listening thread
|
||||
cout << "Creating Listening Thread" << endl;
|
||||
sem_init(&listensmp,0,0);
|
||||
sem_init(&listensmp,0,1);
|
||||
if(pthread_create(&listening_thread, NULL,startListeningThread, (void*) this)){
|
||||
cout << "Could not create listening thread" << endl;
|
||||
return FAIL;
|
||||
@ -601,11 +608,12 @@ int slsReceiverFunctionList::createListeningThreads(bool destroy){
|
||||
#endif
|
||||
}else{
|
||||
cout<<"Destroying Listening Thread"<<endl;
|
||||
killListeningThread = 1;
|
||||
sem_post(&listensmp);
|
||||
sem_destroy(&listensmp);
|
||||
cout << "Threads destroyed" << endl;
|
||||
if(pthread_cancel(listening_thread)!=0)
|
||||
cout << "Unable to cancel listening Thread " << endl;
|
||||
pthread_join(listening_thread, &status);
|
||||
killListeningThread = 0;
|
||||
cout << "Listening thread destroyed" << endl;
|
||||
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -619,21 +627,24 @@ int slsReceiverFunctionList::createListeningThreads(bool destroy){
|
||||
|
||||
int slsReceiverFunctionList::createWriterThreads(bool destroy){
|
||||
int i;
|
||||
void* status;
|
||||
|
||||
if(!destroy){
|
||||
killAllWritingThreads = 0;
|
||||
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
writerthreads_mask = 0x0;
|
||||
pthread_mutex_unlock(&(status_mutex));
|
||||
|
||||
|
||||
if(!destroy){
|
||||
|
||||
//start writer threads
|
||||
cout << "Creating Writer Threads";
|
||||
|
||||
currentWriterThreadIndex = -1;
|
||||
|
||||
for(i = 0; i < numWriterThreads; ++i){
|
||||
sem_init(&writersmp[i],0,0);
|
||||
sem_init(&writersmp[i],0,1);
|
||||
thread_started = 0;
|
||||
currentWriterThreadIndex = i;
|
||||
if(pthread_create(&writing_thread[i], NULL,startWritingThread, (void*) this)){
|
||||
@ -652,12 +663,14 @@ int slsReceiverFunctionList::createWriterThreads(bool destroy){
|
||||
|
||||
}else{
|
||||
cout << "Destroying Writer Thread" << endl;
|
||||
killAllWritingThreads = 1;
|
||||
for(i = 0; i < numWriterThreads; ++i){
|
||||
sem_post(&writersmp[i]);
|
||||
sem_destroy(&writersmp[i]);
|
||||
if(pthread_cancel(writing_thread[i])!=0)
|
||||
cout << "Unable to cancel Thread of index" << i << endl;
|
||||
pthread_join(writing_thread[i],&status);
|
||||
cout <<"."<<flush;
|
||||
}
|
||||
killAllWritingThreads = 0;
|
||||
cout << endl << "Writer threads destroyed" << endl;
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -714,9 +727,11 @@ int slsReceiverFunctionList::setupWriter(){
|
||||
guiDataReady=0;
|
||||
strcpy(guiFileName,"");
|
||||
cbAction = DO_EVERYTHING;
|
||||
writerthreads_mask = 0x0;
|
||||
int ret,ret1 = OK;
|
||||
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
writerthreads_mask = 0x0;
|
||||
pthread_mutex_unlock(&status_mutex);
|
||||
|
||||
//printouts
|
||||
cout << "Max Packets Per File:" << maxPacketsPerFile << endl;
|
||||
@ -745,7 +760,9 @@ int slsReceiverFunctionList::setupWriter(){
|
||||
ret = createNewFile();
|
||||
else{
|
||||
for(int i=0;i<numWriterThreads;i++){
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
ret1 = createCompressionFile(i,0);
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
if(ret1 == FAIL)
|
||||
ret = FAIL;
|
||||
}
|
||||
@ -845,6 +862,9 @@ int slsReceiverFunctionList::createNewFile(){
|
||||
|
||||
|
||||
void slsReceiverFunctionList::closeFile(int ithr){
|
||||
#ifdef VERBOSE
|
||||
cout << "In closeFile for thread " << ithr << endl;
|
||||
#endif
|
||||
if(!dataCompression){
|
||||
//close file
|
||||
if(sfilefd){
|
||||
@ -936,8 +956,14 @@ int slsReceiverFunctionList::startReceiver(char message[]){
|
||||
|
||||
//start listening /writing
|
||||
sem_post(&listensmp);
|
||||
|
||||
/*int k;*/
|
||||
|
||||
for(int i=0; i < numWriterThreads; ++i){
|
||||
|
||||
/*sem_getvalue(&writersmp[i],&k);*/
|
||||
sem_post(&writersmp[i]);
|
||||
/*sem_getvalue(&writersmp[i],&k);*/
|
||||
}
|
||||
cout << "Receiver Started.\nStatus:" << status << endl;
|
||||
|
||||
@ -1207,6 +1233,9 @@ int slsReceiverFunctionList::startListening(){
|
||||
|
||||
sem_wait(&listensmp);
|
||||
|
||||
//make sure its not exiting thread
|
||||
if(killListeningThread)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -1260,12 +1289,14 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
|
||||
while((1<<ithread)&writerthreads_mask){
|
||||
|
||||
#ifdef VERYDEBUG
|
||||
cout << ithread << " ***waiting to pop out of fifo" << endl;
|
||||
#endif
|
||||
//pop
|
||||
fifo->pop(wbuf);
|
||||
numpackets = (uint16_t)(*((uint16_t*)wbuf));
|
||||
#ifdef VERYDEBUG
|
||||
cout << "numpackets:" << dec << numpackets << endl;
|
||||
cout << ithread << " numpackets:" << dec << numpackets << endl;
|
||||
cout << ithread << " *** popped from fifo " << numpackets << endl;
|
||||
#endif
|
||||
|
||||
@ -1277,23 +1308,25 @@ int slsReceiverFunctionList::startWriting(){
|
||||
//last dummy packet
|
||||
if(numpackets == 0xFFFF){
|
||||
#ifdef VERYDEBUG
|
||||
cout << "**********************popped last dummy frame:" << (void*)wbuf << " from thread " << ithread << endl;
|
||||
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuf << endl;
|
||||
#endif
|
||||
|
||||
//free fifo
|
||||
while(!fifoFree->push(wbuf));
|
||||
#ifdef VERYDEBUG
|
||||
cout << "fifo freed:" << (void*)wbuf << " from thread " << ithread << endl;
|
||||
cout << ithread << " fifo freed:" << (void*)wbuf << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//all threads need to close file, reset mask and exit loop
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
closeFile(ithread);
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
writerthreads_mask^=(1<<ithread);
|
||||
#ifdef VERYDEBUG
|
||||
cout <<"Resetting mask of current thread " << ithread << ". New Mask: " << writerthreads_mask << endl;
|
||||
cout << ithread << " Resetting mask of current thread. New Mask: " << writerthreads_mask << endl;
|
||||
#endif
|
||||
pthread_mutex_unlock(&status_mutex);
|
||||
|
||||
@ -1423,7 +1456,9 @@ int slsReceiverFunctionList::startWriting(){
|
||||
if (thisEvent==PHOTON_MAX) {
|
||||
|
||||
iFrame=receiverdata[ithread]->getFrameNumber(buff);
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
myTree[ithread]->Fill();
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
//cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl;
|
||||
}
|
||||
}
|
||||
@ -1431,13 +1466,13 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
nf++;
|
||||
|
||||
pthread_mutex_lock(&write_mutex);
|
||||
pthread_mutex_lock(&progress_mutex);
|
||||
|
||||
packetsInFile += packetsPerFrame;
|
||||
packetsCaught += packetsPerFrame;
|
||||
totalPacketsCaught += packetsPerFrame;
|
||||
|
||||
pthread_mutex_unlock(&write_mutex);
|
||||
pthread_mutex_unlock(&progress_mutex);
|
||||
if(!once){
|
||||
copyFrameToGui(buff);
|
||||
once = 1;
|
||||
@ -1460,9 +1495,16 @@ int slsReceiverFunctionList::startWriting(){
|
||||
}
|
||||
}
|
||||
|
||||
/*int k;
|
||||
sem_getvalue(&writersmp[ithread],&k);
|
||||
cout<<ithread<<" waiting for sem:"<<k <<endl;*/
|
||||
//wait
|
||||
sem_wait(&writersmp[ithread]);
|
||||
|
||||
if(killAllWritingThreads)
|
||||
pthread_exit(NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1472,6 +1514,15 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void slsReceiverFunctionList::writeToFile_withoutCompression(char* buf,int numpackets){
|
||||
int packetsToSave, offset,tempframenum,lastpacket;
|
||||
|
||||
|
@ -168,8 +168,9 @@ public:
|
||||
int64_t setAcquisitionPeriod(int64_t index);
|
||||
|
||||
/** enabl data compression, by saving only hits
|
||||
/returns if failed
|
||||
*/
|
||||
void enableDataCompression(bool enable);
|
||||
int enableDataCompression(bool enable);
|
||||
|
||||
/** get data compression, by saving only hits
|
||||
*/
|
||||
@ -465,8 +466,27 @@ private:
|
||||
/** total frame count the listening thread has listened to */
|
||||
int totalListeningFrameCount;
|
||||
|
||||
/** mask showing which threads are running */
|
||||
volatile uint32_t writerthreads_mask;
|
||||
|
||||
/** 0 if listening thread is idle, 1 otherwise */
|
||||
int listening_thread_running;
|
||||
|
||||
/** variable used to self terminate threads waiting for semaphores */
|
||||
int killListeningThread;
|
||||
|
||||
/** variable used to self terminate threads waiting for semaphores */
|
||||
int killAllWritingThreads;
|
||||
|
||||
|
||||
//filter
|
||||
singlePhotonDetector<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
slsReceiverData<uint16_t> *receiverdata[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
moenchCommonMode *cmSub;
|
||||
|
||||
bool commonModeSubtractionEnable;
|
||||
|
||||
|
||||
//semaphores
|
||||
@ -477,6 +497,7 @@ private:
|
||||
/** semaphore to synchronize writer threads */
|
||||
sem_t writersmp[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
|
||||
//mutex
|
||||
/** guiDataReady mutex */
|
||||
pthread_mutex_t dataReadyMutex;
|
||||
@ -491,6 +512,20 @@ private:
|
||||
pthread_mutex_t write_mutex;
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
/** Tree where the hits are stored */
|
||||
TTree *myTree[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
/** File where the tree is saved */
|
||||
TFile *myFile[MAX_NUM_WRITER_THREADS];
|
||||
#endif
|
||||
|
||||
/** File Descriptor */
|
||||
FILE *sfilefd;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
callback arguments are
|
||||
filepath
|
||||
@ -533,34 +568,9 @@ private:
|
||||
* 2 we open, close, write file, callback does not do anything */
|
||||
int cbAction;
|
||||
|
||||
//filter
|
||||
singlePhotonDetector<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
slsReceiverData<uint16_t> *receiverdata[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
moenchCommonMode *cmSub;
|
||||
|
||||
bool commonModeSubtractionEnable;
|
||||
|
||||
public:
|
||||
|
||||
#ifdef MYROOT1
|
||||
/** Tree where the hits are stored */
|
||||
TTree *myTree[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
/** File where the tree is saved */
|
||||
TFile *myFile[MAX_NUM_WRITER_THREADS];
|
||||
#endif
|
||||
|
||||
|
||||
/** File Descriptor */
|
||||
FILE *sfilefd;
|
||||
|
||||
/** mask showing which threads are running */
|
||||
volatile uint32_t writerthreads_mask;
|
||||
|
||||
/** 0 if listening thread is idle, 1 otherwise */
|
||||
int listening_thread_running;
|
||||
|
||||
/**
|
||||
callback arguments are
|
||||
|
@ -24,9 +24,6 @@ int slsReceiverFuncs::socketDescriptor(-1);
|
||||
|
||||
|
||||
slsReceiverFuncs::~slsReceiverFuncs() {
|
||||
/*if(file_des != -1){close(file_des);file_des = -1;}
|
||||
//shutdown(socketDescriptor,SHUT_RDWR);
|
||||
close(socketDescriptor);*/
|
||||
if(socket) delete socket;
|
||||
closeFile(0);
|
||||
}
|
||||
@ -45,7 +42,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
string sLine,sargname;
|
||||
int iline = 0;
|
||||
bool dcompr = false;
|
||||
/*int jobthread = -1;*/
|
||||
|
||||
|
||||
success=OK;
|
||||
@ -115,9 +111,14 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//compression
|
||||
else if(sargname=="compression"){
|
||||
if(sstr.good()) {
|
||||
sstr >> sargname;
|
||||
if((!strcasecmp(sargname.c_str(),"yes"))||(!strcasecmp(sargname.c_str(),"y")))
|
||||
dcompr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
@ -176,10 +177,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
cout << "no value given after -compression in command line. Exiting." << endl;
|
||||
success=FAIL;
|
||||
}else {
|
||||
if(!strcasecmp(argv[iarg+1],"yes")){
|
||||
dcompr = true;
|
||||
iarg++;
|
||||
}else if(!strcasecmp(argv[iarg+1],"no")){
|
||||
if((!strcasecmp(argv[iarg+1],"yes"))||(!strcasecmp(argv[iarg+1],"y"))){
|
||||
dcompr = true;
|
||||
iarg++;
|
||||
}else{
|
||||
@ -188,20 +186,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
}
|
||||
}
|
||||
}
|
||||
/*//jobstothread
|
||||
else if(!strcasecmp(argv[iarg],"-jobthread")){
|
||||
if(iarg+1==argc){
|
||||
cout << "no value given after -jobthread in command line. Exiting." << endl;
|
||||
success=FAIL;
|
||||
}else {
|
||||
if(sscanf(argv[iarg+1],"%d",&jobthread)){
|
||||
iarg++;
|
||||
}else{
|
||||
cout << "could not decode value for jobthread in command line. \n\nExiting." << endl;
|
||||
success=FAIL;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
else{
|
||||
cout << "Unknown argument:" << argv[iarg] << endl;
|
||||
success=FAIL;
|
||||
@ -232,7 +216,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
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 << endl;;
|
||||
/*cout << "jobthread:\t Number of jobs given to a thread for compression." << endl << endl;*/
|
||||
}
|
||||
|
||||
|
||||
@ -256,8 +239,8 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
//Catch signal SIGINT to close files properly
|
||||
signal(SIGINT,staticCloseFile);
|
||||
|
||||
/*if(dcompr)*/ slsReceiverList->enableDataCompression(dcompr);
|
||||
/*if(jobthread!=-1) slsReceiverList->setNumberOfJobsPerThread(jobthread);*/
|
||||
if(dcompr)
|
||||
slsReceiverList->enableDataCompression(dcompr);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Function table assigned." << endl;
|
||||
@ -326,7 +309,7 @@ int slsReceiverFuncs::function_table(){
|
||||
flist[F_CONFIGURE_MAC] = &slsReceiverFuncs::set_short_frame;
|
||||
flist[F_START_READOUT] = &slsReceiverFuncs::start_readout;
|
||||
flist[F_SET_TIMER] = &slsReceiverFuncs::set_acquisition_period;
|
||||
|
||||
flist[F_ENABLE_COMPRESSION] = &slsReceiverFuncs::enable_compression;
|
||||
|
||||
//General Functions
|
||||
flist[F_LOCK_SERVER] = &slsReceiverFuncs::lock_receiver;
|
||||
@ -405,7 +388,7 @@ void slsReceiverFuncs::closeFile(int p){
|
||||
cout<<"Closing Files... "<<endl;
|
||||
slsReceiverList->closeFile();
|
||||
cout << "Goodbye!" << endl;
|
||||
exit(1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void slsReceiverFuncs::staticCloseFile(int p){
|
||||
@ -545,7 +528,7 @@ int slsReceiverFuncs::set_file_index() {
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -598,7 +581,7 @@ int slsReceiverFuncs::set_frame_index() {
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -655,7 +638,7 @@ int slsReceiverFuncs::setup_udp(){
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -922,7 +905,7 @@ int slsReceiverFuncs::set_short_frame() {
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -1301,7 +1284,7 @@ int slsReceiverFuncs::set_read_frequency(){
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}/*
|
||||
@ -1351,7 +1334,7 @@ int slsReceiverFuncs::enable_file_write(){
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -1453,7 +1436,7 @@ int slsReceiverFuncs::set_acquisition_period() {
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
@ -1488,6 +1471,53 @@ int slsReceiverFuncs::set_acquisition_period() {
|
||||
|
||||
|
||||
|
||||
int slsReceiverFuncs::enable_compression() {
|
||||
ret=OK;
|
||||
int enable=-1;
|
||||
int retval=-100;
|
||||
strcpy(mess,"Could not enable/disable compression for receiver\n");
|
||||
|
||||
// receive arguments
|
||||
if(socket->ReceiveDataOnly(&enable,sizeof(enable)) < 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(enable >= 0){
|
||||
if (lockStatus==1 && socket->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if(slsReceiverList->getStatus()==RUNNING){
|
||||
strcpy(mess,"Cannot enable/disable compression while status is running\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
ret = slsReceiverList->enableDataCompression(enable);
|
||||
}
|
||||
|
||||
retval=slsReceiverList->getDataCompression();
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -154,6 +154,9 @@ public:
|
||||
/** set acquisition period to find the value of n */
|
||||
int set_acquisition_period();
|
||||
|
||||
/** enable compression */
|
||||
int enable_compression();
|
||||
|
||||
|
||||
//General Functions
|
||||
/** Locks Receiver */
|
||||
|
Loading…
x
Reference in New Issue
Block a user