mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'dhanya_devel'
This commit is contained in:
commit
c5f8067735
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||
URL: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
||||
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
||||
Repsitory UUID: e019a6ce7d96d4ac9cb5762b7137245aedb4d5b8
|
||||
Revision: 22
|
||||
Branch: master
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 22
|
||||
Last Changed Date: 2014-10-15 09:22:40 +0200
|
||||
Repsitory UUID: 879c5e2ee129acfd70aba4ae6fab829cc5409350
|
||||
Revision: 67
|
||||
Branch: gemma
|
||||
Last Changed Author: Maliakal_Dhanya
|
||||
Last Changed Rev: 67
|
||||
Last Changed Date: 2014-12-08 09:17:56 +0100
|
||||
|
@ -47,7 +47,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
*/
|
||||
virtual ~UDPStandardImplementation();
|
||||
|
||||
|
||||
void configure(map<string, string> config_map);
|
||||
|
||||
/**
|
||||
* delete and free member parameters
|
||||
|
@ -92,6 +92,22 @@ UDPStandardImplementation::UDPStandardImplementation()
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::configure(map<string, string> config_map){
|
||||
FILE_LOG(logWARNING) << __AT__ << " called";
|
||||
|
||||
map<string, string>::const_iterator pos;
|
||||
pos = config_map.find("mode");
|
||||
if (pos != config_map.end() ){
|
||||
int b;
|
||||
if(!sscanf(pos->second.c_str(), "%d", &b)){
|
||||
cout << "Warning: Could not parse mode. Assuming top mode." << endl;
|
||||
b = 0;
|
||||
}
|
||||
bottom = b!= 0;
|
||||
cout << "bottom:"<< bottom << endl;
|
||||
}
|
||||
};
|
||||
|
||||
void UDPStandardImplementation::initializeMembers(){
|
||||
myDetectorType = GENERIC;
|
||||
maxPacketsPerFile = 0;
|
||||
@ -849,8 +865,10 @@ void UDPStandardImplementation::setupFifoStructure(){
|
||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL)
|
||||
if (guiData == NULL){
|
||||
guiData = latestData;
|
||||
//cout <<"gui data not null anymore" << endl;
|
||||
}
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
@ -859,10 +877,12 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
|
||||
//could not get gui data
|
||||
if(!guiDataReady){
|
||||
//cout<<"gui data not ready"<<endl;
|
||||
*raw = NULL;
|
||||
}
|
||||
//data ready, set guidata to receive new data
|
||||
else{
|
||||
//cout<<"gui data ready"<<endl;
|
||||
*raw = guiData;
|
||||
guiData = NULL;
|
||||
|
||||
@ -870,10 +890,12 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
guiDataReady = 0;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
if((nFrameToGui) && (writerthreads_mask)){
|
||||
//cout<<"gonna post"<<endl;
|
||||
/*if(nFrameToGui){*/
|
||||
//release after getting data
|
||||
sem_post(&smp);
|
||||
}
|
||||
//cout<<"done post"<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -885,7 +907,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
|
||||
//random read when gui not ready
|
||||
//random read when gui not ready , also command line doesnt have nthframetogui
|
||||
if((!nFrameToGui) && (!guiData)){
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady=0;
|
||||
@ -894,6 +916,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
||||
|
||||
//random read or nth frame read, gui needs data now
|
||||
else{
|
||||
//cout <<"gui needs data now"<<endl;
|
||||
/*
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui)
|
||||
@ -928,8 +951,11 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui)
|
||||
if(nFrameToGui){
|
||||
//cout<<"waiting after copying"<<endl;
|
||||
sem_wait(&smp);
|
||||
//cout<<"done waiting"<<endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -946,12 +972,12 @@ int UDPStandardImplementation::createUDPSockets(){
|
||||
port[1] = server_port[1];
|
||||
|
||||
/** eiger specific */
|
||||
/*
|
||||
|
||||
if(bottom){
|
||||
port[0] = server_port[1];
|
||||
port[1] = server_port[0];
|
||||
}
|
||||
*/
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
if (strchr(eth,'.')!=NULL)
|
||||
strcpy(eth,"");
|
||||
@ -1412,7 +1438,10 @@ void UDPStandardImplementation::closeFile(int ithr){
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pre:
|
||||
* Post: eiger req. time for 32bit before acq start
|
||||
* */
|
||||
|
||||
int UDPStandardImplementation::startReceiver(char message[]){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
@ -1475,24 +1504,26 @@ int UDPStandardImplementation::startReceiver(char message[]){
|
||||
for(i=0; i < numWriterThreads; ++i)
|
||||
sem_post(&writersmp[i]);
|
||||
|
||||
|
||||
//usleep(5000000);
|
||||
cout << "Receiver Started.\nStatus:" << status << endl;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pre: status is running, semaphores have been instantiated,
|
||||
* Post: udp sockets shut down, status is idle, sempahores destroyed
|
||||
* */
|
||||
|
||||
int UDPStandardImplementation::stopReceiver(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
|
||||
if(status != IDLE){
|
||||
//#ifdef VERBOSE
|
||||
cout << "Stopping Receiver" << endl;
|
||||
//#endif
|
||||
|
||||
if(status == RUNNING)
|
||||
startReadout();
|
||||
|
||||
while(status == TRANSMITTING)
|
||||
@ -1508,13 +1539,19 @@ int UDPStandardImplementation::stopReceiver(){
|
||||
pthread_mutex_unlock(&(status_mutex));
|
||||
|
||||
cout << "Receiver Stopped.\nStatus:" << status << endl << endl;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pre: status is running, udp sockets have been initialized,
|
||||
* stop receiver initiated
|
||||
* Post:udp sockets closed, status is transmitting
|
||||
* */
|
||||
void UDPStandardImplementation::startReadout(){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
|
||||
@ -1522,15 +1559,19 @@ void UDPStandardImplementation::startReadout(){
|
||||
cout << "Start Receiver Readout" << endl;
|
||||
//#endif
|
||||
|
||||
if(status == RUNNING){
|
||||
|
||||
//wait so that all packets which take time has arrived
|
||||
usleep(5000);
|
||||
|
||||
/********************************************/
|
||||
//usleep(10000000);
|
||||
//usleep(2000000);
|
||||
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
status = TRANSMITTING;
|
||||
pthread_mutex_unlock(&status_mutex);
|
||||
cout << "Status: Transmitting" << endl;
|
||||
}
|
||||
|
||||
//kill udp socket to tell the listening thread to push last packet
|
||||
shutDownUDPSockets();
|
||||
@ -1613,6 +1654,7 @@ int UDPStandardImplementation::startListening(){
|
||||
|
||||
/* if(!ithread){*/
|
||||
rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize);
|
||||
//cout<<"value:"<<htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum)<<endl;
|
||||
expected = maxBufferSize;
|
||||
/*}else{
|
||||
while(1) usleep(100000000);
|
||||
@ -1815,11 +1857,12 @@ int UDPStandardImplementation::startWriting(){
|
||||
#endif
|
||||
//pop
|
||||
for(i=0;i<numListeningThreads;++i){
|
||||
//cout<<"writer gonna pop from fifo:"<<i<<endl;
|
||||
fifo[i]->pop(wbuf[i]);
|
||||
numpackets = (uint16_t)(*((uint16_t*)wbuf[i]));
|
||||
#ifdef VERYDEBUG
|
||||
cout << ithread << " numpackets:" << dec << numpackets << endl;
|
||||
#endif
|
||||
//#ifdef VERYDEBUG
|
||||
cout << ithread << " numpackets:" << dec << numpackets << "for fifo :"<< i << endl;
|
||||
//#endif
|
||||
}
|
||||
|
||||
#ifdef VERYDEBUG
|
||||
@ -1878,7 +1921,9 @@ int UDPStandardImplementation::startWriting(){
|
||||
|
||||
|
||||
if(myDetectorType == EIGER) {
|
||||
//cout<<"gonna copy frame"<<endl;
|
||||
copyFrameToGui(wbuf,currframenum);
|
||||
//cout<<"copied frame"<<endl;
|
||||
for(i=0;i<numListeningThreads;++i){
|
||||
while(!fifoFree[i]->push(wbuf[i]));
|
||||
#ifdef VERYDEBUG
|
||||
@ -1991,7 +2036,7 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
|
||||
startAcquisitionIndex=startFrameIndex;
|
||||
currframenum = startAcquisitionIndex;
|
||||
acqStarted = true;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
||||
cout << "startAcquisitionIndex:" << hex << startAcquisitionIndex<<endl;
|
||||
}
|
||||
//for scans, cuz currfraenum resets
|
||||
else if (myDetectorType == EIGER){
|
||||
@ -2100,7 +2145,7 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
|
||||
|
||||
int i,j;
|
||||
#ifdef VERYDEBUG
|
||||
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[wIndex] << endl;
|
||||
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[0] << endl;
|
||||
#endif
|
||||
|
||||
//free fifo
|
||||
|
@ -65,6 +65,13 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
|
||||
switch(c){
|
||||
|
||||
case 'm':
|
||||
int b;
|
||||
sscanf(optarg, "%d", &b);
|
||||
bottom = b != 0;
|
||||
configuration_map["mode"] = optarg;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
fname = optarg;
|
||||
//cout << long_options[option_index].name << " " << optarg << endl;
|
||||
@ -86,7 +93,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
string help_message = """\nSLS Receiver Server\n\n""";
|
||||
help_message += """usage: slsReceiver --config config_fname [--rx_tcpport port]\n\n""";
|
||||
help_message += """\t--config:\t configuration filename for SLS Detector receiver\n""";
|
||||
help_message += """\t--mode:\t ???\n""";
|
||||
help_message += """\t--mode:\t 1 for bottom and 0 for top\n""";
|
||||
help_message += """\t--rx_tcpport:\t TCP Communication Port with the client. Default: 1954.\n\n""";
|
||||
help_message += """\t--rest_hostname:\t Receiver hostname:port. It applies only to REST receivers, and indicates the hostname of the REST backend. Default: localhost:8081.\n\n""";
|
||||
|
||||
@ -120,10 +127,10 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
}
|
||||
|
||||
if (success==OK){
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << " with mode " << bottom << endl;
|
||||
udp_interface = UDPInterface::create(udp_interface_type);
|
||||
udp_interface->configure(configuration_map);
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no, bottom);
|
||||
//tcp ip interface
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user