This commit is contained in:
Dhanya Maliakal
2016-10-18 12:08:11 +02:00
parent 9f28cc686c
commit 3a6d97b4f3
3 changed files with 47 additions and 21 deletions

View File

@ -5090,7 +5090,7 @@ void multiSlsDetector::startReceivingDataThread(){
int* image = new int[nel];
int len,idet = 0;
singleframe[ithread]=NULL;
int datavalue = 2;
/* int datavalue = 2;*/
threadStarted = true; //let calling function know thread started and obtained current
@ -5107,19 +5107,30 @@ void multiSlsDetector::startReceivingDataThread(){
//scan header-------------------------------------------------------------------
zmq_msg_init (&message);
//---- with end
len = zmq_msg_recv(&message, zmqsocket, 0);
if (len == -1) {
zmq_msg_close(&message);
cprintf(RED, "%d message null\n",ithread);
continue;
}
//----
/*
while(1){
len = zmq_msg_recv(&message, zmqsocket, ZMQ_DONTWAIT);
if(len>0)
break;//also comment out the next recv
/*
zmq_poll(&pollitem, 1, 0);
//zmq_poll(&pollitem, 1, 0);
//received something, get out
if(pollitem.revents & ZMQ_POLLIN){
pollitem.revents = 0;
break;
}
*/
//if(pollitem.revents & ZMQ_POLLIN){
// pollitem.revents = 0;
// break;
//}uncomment next recv
//received nothing
else if (receiverStoppedFlag){
//one more chance if receiver stopped
@ -5139,14 +5150,16 @@ void multiSlsDetector::startReceivingDataThread(){
usleep(4000);
}
if(datavalue){
*/
/*if(datavalue){
//len = zmq_msg_recv(&message, zmqsocket, 0);
if (len == -1) {
zmq_msg_close(&message);
cprintf(RED, "%d message null\n",ithread);
continue;
}
*/
// error if you print it
// cout << ithread << " header len:"<<len<<" value:"<< (char*)zmq_msg_data(&message)<<endl;
//cprintf(BLUE,"%d header %d\n",ithread,len);
@ -5193,8 +5206,19 @@ void multiSlsDetector::startReceivingDataThread(){
//cprintf(BLUE,"%d data %d\n",ithread,len);
//end of socket ("end")
if (len < 1024*256 ) {
if(!len) cprintf(RED,"Received no data in socket for %d\n", ithread);
//#ifdef VERYVERBOSE
cprintf(RED,"End of socket for %d\n", ithread);
//#endif
zmq_msg_close(&message);
singleframe[ithread] = NULL;
//break;
/*
cprintf(RED,"Received weird packet size %d in socket for %d\n", len, ithread);
memset((char*)(singleframe[ithread]),0xFF,singleDatabytes/numReadoutPerDetector);
*/
}
else{
//actual data
@ -5209,10 +5233,12 @@ void multiSlsDetector::startReceivingDataThread(){
}
}
}
}
/* }*/
sem_post(&sem_singledone[ithread]);//let multi know is ready
zmq_msg_close(&message); // close the message
datavalue = 2;
/* datavalue = 2;*/
}
cprintf(RED,"%d Closing socket\n",ithread);