crazy amount of changes, both necessary and unnecessary;need to narrow down the real change later

This commit is contained in:
Dhanya Maliakal 2017-04-27 13:58:25 +02:00
parent b1de501bef
commit 9e2f2697c7

View File

@ -5158,7 +5158,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename){ int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename){
bool data = true;
zmq_msg_t header_message; zmq_msg_t header_message;
//scan header------------------------------------------------------------------- //scan header-------------------------------------------------------------------
@ -5179,6 +5179,14 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
rapidjson::ParseResult result = d.Parse( (char*)zmq_msg_data(&header_message), len); rapidjson::ParseResult result = d.Parse( (char*)zmq_msg_data(&header_message), len);
if (!result) { if (!result) {
cprintf(RED,"%d Could not parse. len:%d: Message:%s \n", isocket, len, (char*)zmq_msg_data(&header_message) ); cprintf(RED,"%d Could not parse. len:%d: Message:%s \n", isocket, len, (char*)zmq_msg_data(&header_message) );
fflush( stdout );
char* buf = (char*)zmq_msg_data(&header_message);
for(int i= 0;i < len; ++i) {
cprintf(RED,"%02x ",buf[i]);
}
printf("\n");
fflush( stdout );
} }
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
// htype is an array of strings // htype is an array of strings
@ -5195,38 +5203,47 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
cout << isocket << "type: " << d["type"].GetString() << endl; cout << isocket << "type: " << d["type"].GetString() << endl;
#endif #endif
if(d["acqIndex"].GetUint64()!= (uint64_t)-1){ //!isocket && int temp = d["data"].GetUint64();
data = temp?true:false;
if(data){ //!isocket &&
acqIndex = d["acqIndex"].GetUint64(); acqIndex = d["acqIndex"].GetUint64();
frameIndex = d["fIndex"].GetUint64(); frameIndex = d["fIndex"].GetUint64();
subframeIndex = -1; subframeIndex = -1;
if(d["bitmode"].GetInt()==32 && d["detType"].GetUint()== EIGER) { if(d["bitmode"].GetInt()==32 && d["detType"].GetUint()== EIGER) {
subframeIndex = d["expLength"].GetUint(); subframeIndex = d["expLength"].GetUint();
} }
filename = d["fname"].GetString(); filename.assign(d["fname"].GetString());
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Acquisition index: " << acqIndex << endl; cout << "Acquisition index: " << acqIndex << endl;
cout << "Frame index: " << frameIndex << endl; cout << "Frame index: " << frameIndex << endl;
cout << "Subframe index: " << subframeIndex << endl; cout << "Subframe index: " << subframeIndex << endl;
cout << "File name: " << filename << endl; cout << "File name: " << filename << endl;
#endif #endif
if(frameIndex == (long long unsigned int)-1) cprintf(RED,"multi frame index -1!!\n"); // if(frameIndex == (long long unsigned int)-1) cprintf(RED,"multi frame index -1!!\n");
} }
// close the message // close the message
zmq_msg_close(&header_message); zmq_msg_close(&header_message);
//end of acquisition
if(!data){
//cprintf(RED,"%d Received end of acquisition \n", isocket);
return FAIL;
}
//scan data------------------------------------------------------------------- //scan data-------------------------------------------------------------------
zmq_msg_t data_message; zmq_msg_t data_message;
zmq_msg_init (&data_message); zmq_msg_init (&data_message);
len = zmq_msg_recv(&data_message, zmqsocket[isocket], 0); len = zmq_msg_recv(&data_message, zmqsocket[isocket], 0);
//cprintf(GREEN,"%d data %d\n",isocket,len); //cprintf(GREEN,"%d data %d\n",isocket,len); fflush(stdout);
//end of socket ("end\0") //end of socket ("end\0")
if(len == 4){ /* if(len == 4){
zmq_msg_close(&data_message); // close the message zmq_msg_close(&data_message); // close the message
//cprintf(RED,"%d Received end of acquisition len:%d\n", isocket, len); //cprintf(RED,"%d Received end of acquisition len:%d\n", isocket, len);
return FAIL; return FAIL;
} }*/
//crappy image //crappy image
if (len < size ) { if (len < size ) {
@ -5345,7 +5362,7 @@ void multiSlsDetector::readFrameFromReceiver(){
//get individual images //get individual images
if(FAIL == getData(isocket, jungfrau, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){ if(FAIL == getData(isocket, jungfrau, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
dataThreadMask^=(1<<isocket); dataThreadMask^=(1<<isocket);
continue; continue;
} }