mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
got rid of parameters such as compression and det type in receiver, theymust be sent from client to receiver
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@817 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
58d3de174f
commit
1b2aba80a5
@ -31,6 +31,7 @@ using namespace std;
|
|||||||
#define COULDNOT_CREATE_FILE 0x0100000000000000ULL
|
#define COULDNOT_CREATE_FILE 0x0100000000000000ULL
|
||||||
#define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL
|
#define COULDNOT_ENABLE_COMPRESSION 0x0080000000000000ULL
|
||||||
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
|
#define RECEIVER_DET_HOSTNAME_NOT_SET 0x0040000000000000ULL
|
||||||
|
#define RECEIVER_DET_HOSTTYPE_NOT_SET 0x0020000000000000ULL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +95,8 @@ public:
|
|||||||
if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET)
|
if(slsErrorMask&RECEIVER_DET_HOSTNAME_NOT_SET)
|
||||||
retval.append("Could not send the detector hostname to the receiver.\n");
|
retval.append("Could not send the detector hostname to the receiver.\n");
|
||||||
|
|
||||||
|
if(slsErrorMask&RECEIVER_DET_HOSTTYPE_NOT_SET)
|
||||||
|
retval.append("Could not send the detector type to the receiver.\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,6 +303,25 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int
|
|||||||
cout << "Cannot connect to server " << name << " over port " << cport << endl;
|
cout << "Cannot connect to server " << name << " over port " << cport << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//receiver
|
||||||
|
if((t != GENERIC) && (setReceiverOnline()==ONLINE_FLAG)) {
|
||||||
|
int k;
|
||||||
|
retval = FAIL;
|
||||||
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl;
|
||||||
|
#endif
|
||||||
|
if (connectData() == OK)
|
||||||
|
retval=thisReceiver->sendInt(fnum,k,(int)t);
|
||||||
|
if(retval==FAIL){
|
||||||
|
cout << "ERROR: Could not send detector type to receiver" << endl;
|
||||||
|
setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
delete s;
|
delete s;
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
@ -1365,6 +1384,24 @@ int slsDetector::setDetectorType(detectorType const type){
|
|||||||
thisDetector->myDetectorType=retType;
|
thisDetector->myDetectorType=retType;
|
||||||
|
|
||||||
|
|
||||||
|
//receiver
|
||||||
|
if((retType != GENERIC) && (setReceiverOnline()==ONLINE_FLAG)) {
|
||||||
|
retval = FAIL;
|
||||||
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl;
|
||||||
|
#endif
|
||||||
|
if (connectData() == OK)
|
||||||
|
retval=thisReceiver->sendInt(fnum,arg,(int)thisDetector->myDetectorType);
|
||||||
|
if(retval==FAIL){
|
||||||
|
cout << "ERROR: Could not send detector type to receiver" << endl;
|
||||||
|
setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return retType;
|
return retType;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4878,8 +4915,10 @@ char* slsDetector::setReceiver(string receiverIP){
|
|||||||
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
||||||
|
|
||||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout << "Setting up receiver with" << endl;
|
std::cout << "Setting up receiver with" << endl;
|
||||||
|
std::cout << "detector type:" << slsDetectorBase::getDetectorType(thisDetector->myDetectorType) << endl;
|
||||||
|
std::cout << "detector hostname:" << thisDetector->hostname << endl;
|
||||||
std::cout << "file path:" << fileIO::getFilePath() << endl;
|
std::cout << "file path:" << fileIO::getFilePath() << endl;
|
||||||
std::cout << "file name:" << fileIO::getFileName() << endl;
|
std::cout << "file name:" << fileIO::getFileName() << endl;
|
||||||
std::cout << "file index:" << fileIO::getFileIndex() << endl;
|
std::cout << "file index:" << fileIO::getFileIndex() << endl;
|
||||||
@ -4889,27 +4928,28 @@ char* slsDetector::setReceiver(string receiverIP){
|
|||||||
std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl;
|
std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << endl;
|
||||||
std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl;
|
std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << endl;
|
||||||
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl;
|
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl << endl;
|
||||||
|
/** enable compresison, */
|
||||||
#endif
|
//#endif
|
||||||
if(thisDetector->myDetectorType == EIGER)
|
if(setDetectorType()!= GENERIC){
|
||||||
setDetectorHostname();
|
setDetectorHostname();
|
||||||
setFilePath(fileIO::getFilePath());
|
setFilePath(fileIO::getFilePath());
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
setFileIndex(fileIO::getFileIndex());
|
setFileIndex(fileIO::getFileIndex());
|
||||||
enableWriteToFile(parentDet->enableWriteToFileMask());
|
enableWriteToFile(parentDet->enableWriteToFileMask());
|
||||||
overwriteFile(parentDet->enableOverwriteMask());
|
overwriteFile(parentDet->enableOverwriteMask());
|
||||||
|
|
||||||
if ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1)
|
if ((thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER])>1)
|
||||||
setFrameIndex(0);
|
setFrameIndex(0);
|
||||||
else
|
else
|
||||||
setFrameIndex(-1);
|
setFrameIndex(-1);
|
||||||
|
|
||||||
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
|
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
|
||||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
||||||
setDynamicRange(thisDetector->dynamicRange);
|
setDynamicRange(thisDetector->dynamicRange);
|
||||||
//set scan tag
|
//set scan tag
|
||||||
if(thisDetector->myDetectorType != EIGER){
|
if(thisDetector->myDetectorType != EIGER){
|
||||||
setUDPConnection();
|
setUDPConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6630,3 +6670,4 @@ void slsDetector::setDetectorHostname(){
|
|||||||
setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET));
|
setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,122 +29,39 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
slsReceiverFunctionList::slsReceiverFunctionList():
|
||||||
receiver(NULL),
|
receiver(NULL),
|
||||||
myDetectorType(det),
|
server_port(DEFAULT_UDP_PORTNO),
|
||||||
status(IDLE),
|
thread_started(0),
|
||||||
udpSocket(NULL),
|
udpSocket(NULL),
|
||||||
server_port(DEFAULT_UDP_PORTNO),
|
eth(NULL),
|
||||||
eth(NULL),
|
latestData(NULL),
|
||||||
maxPacketsPerFile(0),
|
guiFileName(NULL),
|
||||||
enableFileWrite(1),
|
mem0(NULL),
|
||||||
overwrite(1),
|
fifo(NULL),
|
||||||
fileIndex(0),
|
fifoFree(NULL){
|
||||||
scanTag(0),
|
|
||||||
frameIndexNeeded(0),
|
|
||||||
acqStarted(false),
|
|
||||||
measurementStarted(false),
|
|
||||||
startFrameIndex(0),
|
|
||||||
frameIndex(0),
|
|
||||||
packetsCaught(0),
|
|
||||||
totalPacketsCaught(0),
|
|
||||||
packetsInFile(0),
|
|
||||||
startAcquisitionIndex(0),
|
|
||||||
acquisitionIndex(0),
|
|
||||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
|
||||||
frameIndexMask(GOTTHARD_FRAME_INDEX_MASK),
|
|
||||||
packetIndexMask(GOTTHARD_PACKET_INDEX_MASK),
|
|
||||||
frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET),
|
|
||||||
acquisitionPeriod(SAMPLE_TIME_IN_NS),
|
|
||||||
numberOfFrames(0),
|
|
||||||
dynamicRange(0),
|
|
||||||
shortFrame(-1),
|
|
||||||
currframenum(0),
|
|
||||||
prevframenum(0),
|
|
||||||
bufferSize(GOTTHARD_BUFFER_SIZE),
|
|
||||||
latestData(NULL),
|
|
||||||
guiDataReady(0),
|
|
||||||
guiData(NULL),
|
|
||||||
guiFileName(NULL),
|
|
||||||
nFrameToGui(0),
|
|
||||||
fifosize(GOTTHARD_FIFO_SIZE),
|
|
||||||
numJobsPerThread(-1),
|
|
||||||
mem0(NULL),
|
|
||||||
dataCompression(false),
|
|
||||||
fifo(NULL),
|
|
||||||
fifoFree(NULL),
|
|
||||||
buffer(NULL),
|
|
||||||
numWriterThreads(1),
|
|
||||||
thread_started(0),
|
|
||||||
currentWriterThreadIndex(-1),
|
|
||||||
totalListeningFrameCount(0),
|
|
||||||
writerthreads_mask(0x0),
|
|
||||||
listening_thread_running(0),
|
|
||||||
killListeningThread(0),
|
|
||||||
killAllWritingThreads(0),
|
|
||||||
sfilefd(NULL),
|
|
||||||
startAcquisitionCallBack(NULL),
|
|
||||||
pStartAcquisition(NULL),
|
|
||||||
acquisitionFinishedCallBack(NULL),
|
|
||||||
pAcquisitionFinished(NULL),
|
|
||||||
rawDataReadyCallBack(NULL),
|
|
||||||
pRawDataReady(NULL),
|
|
||||||
cbAction(DO_EVERYTHING){
|
|
||||||
|
|
||||||
maxPacketsPerFile = MAX_FRAMES_PER_FILE * packetsPerFrame;
|
|
||||||
|
|
||||||
|
|
||||||
//moench variables
|
|
||||||
if(myDetectorType == MOENCH){
|
|
||||||
fifosize = MOENCH_FIFO_SIZE;
|
|
||||||
bufferSize = MOENCH_BUFFER_SIZE;
|
|
||||||
packetsPerFrame = MOENCH_PACKETS_PER_FRAME;
|
|
||||||
maxPacketsPerFile = MOENCH_MAX_FRAMES_PER_FILE * MOENCH_PACKETS_PER_FRAME;
|
|
||||||
frameIndexMask = MOENCH_FRAME_INDEX_MASK;
|
|
||||||
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
|
|
||||||
packetIndexMask = MOENCH_PACKET_INDEX_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(myDetectorType == EIGER){
|
|
||||||
receiver = EigerReceiver::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
//variable initialization
|
|
||||||
onePacketSize = bufferSize/packetsPerFrame;
|
|
||||||
eth = new char[MAX_STR_LENGTH];
|
|
||||||
guiFileName = new char[MAX_STR_LENGTH];
|
|
||||||
latestData = new char[bufferSize];
|
|
||||||
strcpy(eth,"");
|
|
||||||
strcpy(guiFileName,"");
|
|
||||||
strcpy(latestData,"");
|
|
||||||
strcpy(savefilename,"");
|
|
||||||
strcpy(filePath,"");
|
|
||||||
|
|
||||||
strcpy(fileName,"run");
|
|
||||||
if(myDetectorType == EIGER)
|
|
||||||
receiver->setFileName(fileName);
|
|
||||||
|
|
||||||
cmSub = NULL;
|
|
||||||
for(int i=0;i<numWriterThreads;i++){
|
for(int i=0;i<numWriterThreads;i++){
|
||||||
commonModeSubtractionEnable = false;
|
|
||||||
singlePhotonDet[i] = NULL;
|
singlePhotonDet[i] = NULL;
|
||||||
receiverdata[i] = NULL;
|
receiverdata[i] = NULL;
|
||||||
#ifdef MYROOT1
|
|
||||||
myTree[i] = (NULL);
|
|
||||||
myFile[i] = (NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startAcquisitionCallBack = NULL;
|
||||||
|
pStartAcquisition = NULL;
|
||||||
|
acquisitionFinishedCallBack = NULL;
|
||||||
|
pAcquisitionFinished = NULL;
|
||||||
|
rawDataReadyCallBack = NULL;
|
||||||
|
pRawDataReady = NULL;
|
||||||
|
|
||||||
setupFifoStructure();
|
initializeMembers();
|
||||||
|
|
||||||
|
//mutex
|
||||||
pthread_mutex_init(&dataReadyMutex,NULL);
|
pthread_mutex_init(&dataReadyMutex,NULL);
|
||||||
pthread_mutex_init(&status_mutex,NULL);
|
pthread_mutex_init(&status_mutex,NULL);
|
||||||
pthread_mutex_init(&progress_mutex,NULL);
|
pthread_mutex_init(&progress_mutex,NULL);
|
||||||
pthread_mutex_init(&write_mutex,NULL);
|
pthread_mutex_init(&write_mutex,NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
||||||
if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
|
if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
|
||||||
cout << "\nWARNING: Could not change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl;
|
cout << "\nWARNING: Could not change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl;
|
||||||
@ -158,13 +75,184 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
|||||||
sysctl -w net.core.rmem_max=16777216
|
sysctl -w net.core.rmem_max=16777216
|
||||||
sysctl -w net.core.netdev_max_backlog=250000
|
sysctl -w net.core.netdev_max_backlog=250000
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//threads
|
|
||||||
|
slsReceiverFunctionList::~slsReceiverFunctionList(){
|
||||||
|
createListeningThreads(true);
|
||||||
|
createWriterThreads(true);
|
||||||
|
deleteMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void slsReceiverFunctionList::deleteMembers(){
|
||||||
|
//kill threads
|
||||||
|
if(thread_started){
|
||||||
|
createListeningThreads(true);
|
||||||
|
createWriterThreads(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<numWriterThreads;i++){
|
||||||
|
if(singlePhotonDet[i]){
|
||||||
|
delete singlePhotonDet[i];
|
||||||
|
singlePhotonDet[i] = NULL;
|
||||||
|
}
|
||||||
|
if(receiverdata[i]){
|
||||||
|
delete receiverdata[i];
|
||||||
|
receiverdata[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(udpSocket) {delete udpSocket; udpSocket = NULL;}
|
||||||
|
if(eth) {delete [] eth; eth = NULL;}
|
||||||
|
if(latestData) {delete [] latestData; latestData = NULL;}
|
||||||
|
if(guiFileName) {delete [] guiFileName; guiFileName = NULL;}
|
||||||
|
if(mem0) {free(mem0); mem0 = NULL;}
|
||||||
|
if(fifo) {delete fifo; fifo = NULL;}
|
||||||
|
if(fifoFree) {delete fifoFree; fifoFree = NULL;}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void slsReceiverFunctionList::initializeMembers(){
|
||||||
|
myDetectorType = GENERIC;
|
||||||
|
maxPacketsPerFile = 0;
|
||||||
|
enableFileWrite = 1;
|
||||||
|
overwrite = 1;
|
||||||
|
fileIndex = 0;
|
||||||
|
scanTag = 0;
|
||||||
|
frameIndexNeeded = 0;
|
||||||
|
acqStarted = false;
|
||||||
|
measurementStarted = false;
|
||||||
|
startFrameIndex = 0;
|
||||||
|
frameIndex = 0;
|
||||||
|
packetsCaught = 0;
|
||||||
|
totalPacketsCaught = 0;
|
||||||
|
packetsInFile = 0;
|
||||||
|
startAcquisitionIndex = 0;
|
||||||
|
acquisitionIndex = 0;
|
||||||
|
packetsPerFrame = 0;
|
||||||
|
frameIndexMask = 0;
|
||||||
|
packetIndexMask = 0;
|
||||||
|
frameIndexOffset = 0;
|
||||||
|
acquisitionPeriod = SAMPLE_TIME_IN_NS;
|
||||||
|
numberOfFrames = 0;
|
||||||
|
dynamicRange = 0;
|
||||||
|
shortFrame = -1;
|
||||||
|
currframenum = 0;
|
||||||
|
prevframenum = 0;
|
||||||
|
bufferSize = 0;
|
||||||
|
onePacketSize = 0;
|
||||||
|
guiDataReady = 0;
|
||||||
|
nFrameToGui = 0;
|
||||||
|
fifosize = 0;
|
||||||
|
numJobsPerThread = -1;
|
||||||
|
dataCompression = false;
|
||||||
|
numWriterThreads = 1;
|
||||||
|
thread_started = 0;
|
||||||
|
currentWriterThreadIndex = -1;
|
||||||
|
totalListeningFrameCount = 0;
|
||||||
|
writerthreads_mask = 0x0;
|
||||||
|
listening_thread_running = 0;
|
||||||
|
killListeningThread = 0;
|
||||||
|
killAllWritingThreads = 0;
|
||||||
|
cbAction = DO_EVERYTHING;
|
||||||
|
|
||||||
|
udpSocket = NULL;
|
||||||
|
eth = NULL;
|
||||||
|
latestData = NULL;
|
||||||
|
guiFileName = NULL;
|
||||||
|
mem0 = NULL;
|
||||||
|
fifo = NULL;
|
||||||
|
fifoFree = NULL;
|
||||||
|
buffer = NULL;
|
||||||
|
guiData = NULL;
|
||||||
|
sfilefd = NULL;
|
||||||
|
cmSub = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
//diff threads
|
||||||
|
for(int i=0;i<numWriterThreads;i++){
|
||||||
|
commonModeSubtractionEnable = false;
|
||||||
|
singlePhotonDet[i] = NULL;
|
||||||
|
receiverdata[i] = NULL;
|
||||||
|
#ifdef MYROOT1
|
||||||
|
myTree[i] = (NULL);
|
||||||
|
myFile[i] = (NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
guiFileName = new char[MAX_STR_LENGTH];
|
||||||
|
eth = new char[MAX_STR_LENGTH];
|
||||||
|
strcpy(eth,"");
|
||||||
|
strcpy(detHostname,"");
|
||||||
|
strcpy(guiFileName,"");
|
||||||
|
strcpy(savefilename,"");
|
||||||
|
strcpy(filePath,"");
|
||||||
|
strcpy(fileName,"run");
|
||||||
|
|
||||||
|
|
||||||
|
//status
|
||||||
pthread_mutex_lock(&status_mutex);
|
pthread_mutex_lock(&status_mutex);
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
pthread_mutex_unlock(&(status_mutex));
|
pthread_mutex_unlock(&(status_mutex));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int slsReceiverFunctionList::setDetectorType(detectorType det){
|
||||||
|
|
||||||
|
deleteMembers();
|
||||||
|
initializeMembers();
|
||||||
|
|
||||||
|
myDetectorType = det;
|
||||||
|
|
||||||
|
switch(myDetectorType){
|
||||||
|
case GOTTHARD:
|
||||||
|
cout << endl << "***** This is a GOTTHARD Receiver *****" << endl << endl;
|
||||||
|
break;
|
||||||
|
case MOENCH:
|
||||||
|
cout << endl << "***** This is a MOENCH Receiver *****" << endl << endl;
|
||||||
|
break;
|
||||||
|
case EIGER:
|
||||||
|
cout << endl << "***** This is a EIGER Receiver *****" << endl << endl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cout << endl << "***** Unknown Receiver *****" << endl << endl;
|
||||||
|
return FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//moench variables
|
||||||
|
if(myDetectorType == GOTTHARD){
|
||||||
|
fifosize = GOTTHARD_FIFO_SIZE;
|
||||||
|
bufferSize = GOTTHARD_BUFFER_SIZE;
|
||||||
|
packetsPerFrame = GOTTHARD_PACKETS_PER_FRAME;
|
||||||
|
maxPacketsPerFile = MAX_FRAMES_PER_FILE * GOTTHARD_PACKETS_PER_FRAME;
|
||||||
|
frameIndexMask = GOTTHARD_FRAME_INDEX_MASK;
|
||||||
|
frameIndexOffset = GOTTHARD_FRAME_INDEX_OFFSET;
|
||||||
|
packetIndexMask = GOTTHARD_PACKET_INDEX_MASK;
|
||||||
|
}else if(myDetectorType == MOENCH){
|
||||||
|
fifosize = MOENCH_FIFO_SIZE;
|
||||||
|
bufferSize = MOENCH_BUFFER_SIZE;
|
||||||
|
packetsPerFrame = MOENCH_PACKETS_PER_FRAME;
|
||||||
|
maxPacketsPerFile = MOENCH_MAX_FRAMES_PER_FILE * MOENCH_PACKETS_PER_FRAME;
|
||||||
|
frameIndexMask = MOENCH_FRAME_INDEX_MASK;
|
||||||
|
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
|
||||||
|
packetIndexMask = MOENCH_PACKET_INDEX_MASK;
|
||||||
|
}
|
||||||
|
else if(myDetectorType == EIGER){
|
||||||
|
if(receiver == NULL)
|
||||||
|
receiver = EigerReceiver::create();
|
||||||
|
receiver->setFileName(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
onePacketSize = bufferSize/packetsPerFrame;
|
||||||
|
latestData = new char[bufferSize];
|
||||||
|
|
||||||
|
|
||||||
|
setupFifoStructure();
|
||||||
|
|
||||||
if(createListeningThreads() == FAIL){
|
if(createListeningThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create listening thread" << endl;
|
cout << "ERROR: Could not create listening thread" << endl;
|
||||||
exit (-1);
|
exit (-1);
|
||||||
@ -176,30 +264,12 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
|||||||
}
|
}
|
||||||
|
|
||||||
setThreadPriorities();
|
setThreadPriorities();
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
slsReceiverFunctionList::~slsReceiverFunctionList(){
|
|
||||||
createListeningThreads(true);
|
|
||||||
createWriterThreads(true);
|
|
||||||
for(int i=0;i<numWriterThreads;i++){
|
|
||||||
if(singlePhotonDet[i])
|
|
||||||
delete singlePhotonDet[i];
|
|
||||||
if(receiverdata[i])
|
|
||||||
delete receiverdata[i];
|
|
||||||
}
|
|
||||||
if(udpSocket) delete udpSocket;
|
|
||||||
if(eth) delete [] eth;
|
|
||||||
if(latestData) delete [] latestData;
|
|
||||||
if(guiFileName) delete [] guiFileName;
|
|
||||||
if(mem0) free(mem0);
|
|
||||||
if(fifo) delete fifo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*Frame indices and numbers caught*/
|
/*Frame indices and numbers caught*/
|
||||||
@ -356,10 +426,17 @@ slsDetectorDefs::runStatus slsReceiverFunctionList::getStatus(){
|
|||||||
|
|
||||||
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
|
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
|
||||||
if(strlen(c)){
|
if(strlen(c)){
|
||||||
if(receiver->getDetectorHostname()== NULL)
|
if(myDetectorType == EIGER){
|
||||||
receiver->initialize(c);
|
if(receiver->getDetectorHostname()== NULL)
|
||||||
|
receiver->initialize(c);
|
||||||
|
}else
|
||||||
|
strcpy(detHostname,c);
|
||||||
}
|
}
|
||||||
return receiver->getDetectorHostname();
|
|
||||||
|
if(myDetectorType == EIGER)
|
||||||
|
return receiver->getDetectorHostname();
|
||||||
|
else
|
||||||
|
return detHostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -722,6 +799,8 @@ int slsReceiverFunctionList::createUDPSocket(){
|
|||||||
if (strchr(eth,'.')!=NULL)
|
if (strchr(eth,'.')!=NULL)
|
||||||
strcpy(eth,"");
|
strcpy(eth,"");
|
||||||
|
|
||||||
|
if(udpSocket){delete udpSocket; udpSocket = NULL;}
|
||||||
|
|
||||||
//if no eth, listen to all
|
//if no eth, listen to all
|
||||||
if(!strlen(eth)){
|
if(!strlen(eth)){
|
||||||
cout<<"warning:eth is empty.listening to all"<<endl;
|
cout<<"warning:eth is empty.listening to all"<<endl;
|
||||||
@ -834,6 +913,7 @@ int slsReceiverFunctionList::createWriterThreads(bool destroy){
|
|||||||
cout <<"."<<flush;
|
cout <<"."<<flush;
|
||||||
}
|
}
|
||||||
killAllWritingThreads = 0;
|
killAllWritingThreads = 0;
|
||||||
|
thread_started = 0;
|
||||||
cout << endl << "Writer threads destroyed" << endl;
|
cout << endl << "Writer threads destroyed" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,13 +39,29 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
slsReceiverFunctionList(detectorType det);
|
slsReceiverFunctionList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~slsReceiverFunctionList();
|
virtual ~slsReceiverFunctionList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete and free member parameters
|
||||||
|
*/
|
||||||
|
void deleteMembers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize member parameters
|
||||||
|
*/
|
||||||
|
void initializeMembers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set receiver type
|
||||||
|
* @param det detector type
|
||||||
|
* Returns success or FAIL
|
||||||
|
*/
|
||||||
|
int setDetectorType(detectorType det);
|
||||||
|
|
||||||
|
|
||||||
//Frame indices and numbers caught
|
//Frame indices and numbers caught
|
||||||
@ -363,6 +379,9 @@ private:
|
|||||||
/** detector type */
|
/** detector type */
|
||||||
detectorType myDetectorType;
|
detectorType myDetectorType;
|
||||||
|
|
||||||
|
/** detector hostname */
|
||||||
|
char detHostname[MAX_STR_LENGTH];
|
||||||
|
|
||||||
/** status of receiver */
|
/** status of receiver */
|
||||||
runStatus status;
|
runStatus status;
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
ifstream infile;
|
ifstream infile;
|
||||||
string sLine,sargname;
|
string sLine,sargname;
|
||||||
int iline = 0;
|
int iline = 0;
|
||||||
bool dcompr = false;
|
|
||||||
|
|
||||||
|
|
||||||
success=OK;
|
success=OK;
|
||||||
@ -98,30 +97,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//type
|
|
||||||
else if(sargname=="type"){
|
|
||||||
if(sstr.good()) {
|
|
||||||
sstr >> sargname;
|
|
||||||
if(!strcasecmp(sargname.c_str(),"gotthard"))
|
|
||||||
slsReceiverFuncs::myDetectorType = GOTTHARD;
|
|
||||||
else if(!strcasecmp(sargname.c_str(),"moench"))
|
|
||||||
slsReceiverFuncs::myDetectorType = MOENCH;
|
|
||||||
else if(!strcasecmp(sargname.c_str(),"eiger"))
|
|
||||||
slsReceiverFuncs::myDetectorType = EIGER;
|
|
||||||
else{
|
|
||||||
cout << "could not decode detector type in config file.\nOptions are:\ngotthard\nmoench.\n\nExiting." << endl;
|
|
||||||
success=FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//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();
|
infile.close();
|
||||||
@ -137,33 +112,12 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//parse command line for type etc.. more priority
|
//parse command line for port etc.. more priority
|
||||||
if(success == OK){
|
if(success == OK){
|
||||||
for(int iarg=1;iarg<argc;iarg++){
|
for(int iarg=1;iarg<argc;iarg++){
|
||||||
|
|
||||||
//type
|
|
||||||
if(!strcasecmp(argv[iarg],"-type")){
|
|
||||||
if(iarg+1==argc){
|
|
||||||
cout << "no detector type given after -type in command line. Exiting." << endl;
|
|
||||||
success=FAIL;
|
|
||||||
}else{
|
|
||||||
if(!strcasecmp(argv[iarg+1],"gotthard")){
|
|
||||||
slsReceiverFuncs::myDetectorType = GOTTHARD;
|
|
||||||
iarg++;
|
|
||||||
}else if(!strcasecmp(argv[iarg+1],"moench")){
|
|
||||||
slsReceiverFuncs::myDetectorType = MOENCH;
|
|
||||||
iarg++;
|
|
||||||
}else if(!strcasecmp(argv[iarg+1],"eiger")){
|
|
||||||
slsReceiverFuncs::myDetectorType = EIGER;
|
|
||||||
iarg++;
|
|
||||||
}else{
|
|
||||||
cout << "could not decode detector type in command line. \nOptions are:\ngotthard\nmoench.\n\nExiting." << endl;
|
|
||||||
success=FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//tcp port
|
//tcp port
|
||||||
else if(!strcasecmp(argv[iarg],"-rx_tcpport")){
|
if(!strcasecmp(argv[iarg],"-rx_tcpport")){
|
||||||
if(iarg+1==argc){
|
if(iarg+1==argc){
|
||||||
cout << "no port given after -rx_tcpport in command line. Exiting." << endl;
|
cout << "no port given after -rx_tcpport in command line. Exiting." << endl;
|
||||||
success=FAIL;
|
success=FAIL;
|
||||||
@ -177,21 +131,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//compression
|
|
||||||
else if(!strcasecmp(argv[iarg],"-compression")){
|
|
||||||
if(iarg+1==argc){
|
|
||||||
cout << "no value given after -compression in command line. Exiting." << endl;
|
|
||||||
success=FAIL;
|
|
||||||
}else {
|
|
||||||
if((!strcasecmp(argv[iarg+1],"yes"))||(!strcasecmp(argv[iarg+1],"y"))){
|
|
||||||
dcompr = true;
|
|
||||||
iarg++;
|
|
||||||
}else{
|
|
||||||
cout << "could not decode value for compression in command line. \n\nExiting." << endl;
|
|
||||||
success=FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
else{
|
||||||
cout << "Unknown argument:" << argv[iarg] << endl;
|
cout << "Unknown argument:" << argv[iarg] << endl;
|
||||||
success=FAIL;
|
success=FAIL;
|
||||||
@ -200,31 +139,10 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(success == OK){
|
|
||||||
//display detector message
|
|
||||||
switch(myDetectorType){
|
|
||||||
case GOTTHARD:
|
|
||||||
cout << "This is a GOTTHARD Receiver" << endl;
|
|
||||||
break;
|
|
||||||
case MOENCH:
|
|
||||||
cout << "This is a MOENCH Receiver" << endl;
|
|
||||||
break;
|
|
||||||
case EIGER:
|
|
||||||
cout << "This is a EIGER Receiver" << endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cout << "Unknown Receiver" << endl;
|
|
||||||
success=FAIL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//help
|
//help
|
||||||
else{
|
if(success != OK){
|
||||||
cout << "Help Commands " << endl;
|
cout << "Help Commands " << endl;
|
||||||
cout << "type:\t\t Type of receiver. Default: Gotthard. Options: Gotthard, Moench, Eiger" << endl;
|
cout << "rx_tcpport:\t TCP Communication Port with the client. Default:1954. " << endl << 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;;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -243,17 +161,14 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
strcpy(mess,"dummy message");
|
strcpy(mess,"dummy message");
|
||||||
|
|
||||||
function_table();
|
function_table();
|
||||||
slsReceiverList = new slsReceiverFunctionList(myDetectorType);
|
#ifdef VERBOSE
|
||||||
|
cout << "Function table assigned." << endl;
|
||||||
|
#endif
|
||||||
|
slsReceiverList = new slsReceiverFunctionList();
|
||||||
|
|
||||||
//Catch signal SIGINT to close files properly
|
//Catch signal SIGINT to close files properly
|
||||||
signal(SIGINT,staticCloseFile);
|
signal(SIGINT,staticCloseFile);
|
||||||
|
|
||||||
if(dcompr)
|
|
||||||
slsReceiverList->enableDataCompression(dcompr);
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Function table assigned." << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
file_des=socket->getFileDes();
|
file_des=socket->getFileDes();
|
||||||
socketDescriptor=socket->getsocketDescriptor();
|
socketDescriptor=socket->getsocketDescriptor();
|
||||||
@ -300,6 +215,8 @@ int slsReceiverFuncs::function_table(){
|
|||||||
for (int i=0;i<numberOfFunctions;i++)
|
for (int i=0;i<numberOfFunctions;i++)
|
||||||
flist[i]=&slsReceiverFuncs::M_nofunc;
|
flist[i]=&slsReceiverFuncs::M_nofunc;
|
||||||
|
|
||||||
|
|
||||||
|
flist[F_GET_DETECTOR_TYPE] = &slsReceiverFuncs::set_detector_type;
|
||||||
flist[F_SET_FILE_NAME] = &slsReceiverFuncs::set_file_name;
|
flist[F_SET_FILE_NAME] = &slsReceiverFuncs::set_file_name;
|
||||||
flist[F_SET_FILE_PATH] = &slsReceiverFuncs::set_file_dir;
|
flist[F_SET_FILE_PATH] = &slsReceiverFuncs::set_file_dir;
|
||||||
flist[F_SET_FILE_INDEX] = &slsReceiverFuncs::set_file_index;
|
flist[F_SET_FILE_INDEX] = &slsReceiverFuncs::set_file_index;
|
||||||
@ -410,6 +327,58 @@ void slsReceiverFuncs::staticCloseFile(int p){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int slsReceiverFuncs::set_detector_type(){
|
||||||
|
ret=OK;
|
||||||
|
int retval=FAIL;
|
||||||
|
detectorType dr;
|
||||||
|
strcpy(mess,"Could not set detector type range\n");
|
||||||
|
|
||||||
|
|
||||||
|
// receive arguments
|
||||||
|
if(socket->ReceiveDataOnly(&dr,sizeof(dr)) < 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){
|
||||||
|
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
myDetectorType = dr;
|
||||||
|
ret=slsReceiverList->setDetectorType(dr);
|
||||||
|
retval = myDetectorType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
if(ret!=FAIL)
|
||||||
|
cout << "detector type" << dr << 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +93,9 @@ public:
|
|||||||
/** Unrecognized Function */
|
/** Unrecognized Function */
|
||||||
int M_nofunc();
|
int M_nofunc();
|
||||||
|
|
||||||
|
/** Set detector type */
|
||||||
|
int set_detector_type();
|
||||||
|
|
||||||
/** Set File name without frame index, file index and extension */
|
/** Set File name without frame index, file index and extension */
|
||||||
int set_file_name();
|
int set_file_name();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user