mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 05:47:14 +02:00
bug fixed, rapidjson parse error
This commit is contained in:
@ -1053,6 +1053,7 @@ void UDPStandardImplementation::stopReceiver(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//semaphore destroy
|
//semaphore destroy
|
||||||
|
cout<<"gonna destroy writerguisemphore"<<endl;
|
||||||
for(int i=0; i < numberofWriterThreads; i++){
|
for(int i=0; i < numberofWriterThreads; i++){
|
||||||
sem_destroy(&writerGuiSemaphore[i]);
|
sem_destroy(&writerGuiSemaphore[i]);
|
||||||
sem_destroy(&dataCallbackWriterSemaphore[i]);
|
sem_destroy(&dataCallbackWriterSemaphore[i]);
|
||||||
@ -1665,7 +1666,8 @@ void* UDPStandardImplementation::startWritingThread(void* this_pointer){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data call back thread started %d\n",currentThreadIndex);
|
void UDPStandardImplementation::startDataCallback(){
|
||||||
|
cprintf(MAGENTA,"start data call back thread started %d\n",currentThreadIndex);
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
//set current thread value index
|
//set current thread value index
|
||||||
@ -1711,6 +1713,7 @@ void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data
|
|||||||
|
|
||||||
//let the writer thread continue, while we process carry over if any
|
//let the writer thread continue, while we process carry over if any
|
||||||
sem_post(&writerGuiSemaphore[ithread]);
|
sem_post(&writerGuiSemaphore[ithread]);
|
||||||
|
if(!ithread) cout<<"*** posted writerguisemiphore (callback)"<<endl;
|
||||||
//wait for receiver to send more data
|
//wait for receiver to send more data
|
||||||
sem_wait(&dataCallbackWriterSemaphore[ithread]);
|
sem_wait(&dataCallbackWriterSemaphore[ithread]);
|
||||||
|
|
||||||
@ -1723,20 +1726,24 @@ void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data
|
|||||||
/*if (checkJoinThread()){for different scans
|
/*if (checkJoinThread()){for different scans
|
||||||
break;
|
break;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
ostringstream header;
|
ostringstream header;
|
||||||
header << "{\"htype\":[\"chunk-1.0\"], "
|
header << "{\"htype\":[\"chunk-1.0\"], "
|
||||||
<< "\"type\":" << "\"" << type << "\", "
|
<< "\"type\":" << "\"" << type << "\", "
|
||||||
<< "\"shape\":" << shape
|
<< "\"shape\":" << shape
|
||||||
<< "}";
|
<< "}";
|
||||||
|
//cout<<ithread << "header:"<< header.str()<<endl;
|
||||||
//send header
|
//send header
|
||||||
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
||||||
sleep(1);
|
|
||||||
//send data
|
//send data
|
||||||
zmq_send (zmqsocket, "end", 3, 0);
|
zmq_send (zmqsocket, "end", 3, 0);
|
||||||
|
|
||||||
pthread_mutex_lock(&statusMutex);
|
pthread_mutex_lock(&statusMutex);
|
||||||
dataCallbackThreadsMask^=(1<<ithread);
|
dataCallbackThreadsMask^=(1<<ithread);
|
||||||
pthread_mutex_unlock(&statusMutex);
|
pthread_mutex_unlock(&statusMutex);
|
||||||
|
|
||||||
|
sem_post(&writerGuiSemaphore[ithread]);
|
||||||
|
if(!ithread) cout<<"*** posted writerguisemiphore (callback dummy)"<<endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1784,9 +1791,9 @@ void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data
|
|||||||
<< "\"type\":" << "\"" << type << "\", "
|
<< "\"type\":" << "\"" << type << "\", "
|
||||||
<< "\"shape\":" << shape
|
<< "\"shape\":" << shape
|
||||||
<< "}";
|
<< "}";
|
||||||
|
//cout<<ithread << "header:"<< header.str()<<endl;
|
||||||
//send header
|
//send header
|
||||||
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
||||||
sleep(1);
|
|
||||||
//send data
|
//send data
|
||||||
zmq_send(zmqsocket, buffer, oneframesize, 0);
|
zmq_send(zmqsocket, buffer, oneframesize, 0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1809,9 +1816,9 @@ void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data
|
|||||||
<< "\"type\":" << "\"" << type << "\", "
|
<< "\"type\":" << "\"" << type << "\", "
|
||||||
<< "\"shape\":" << shape
|
<< "\"shape\":" << shape
|
||||||
<< "}";
|
<< "}";
|
||||||
|
//cout<<ithread << "header:"<< header.str()<<endl;
|
||||||
//send header
|
//send header
|
||||||
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
zmq_send(zmqsocket, header.str().c_str(), header.str().length(), ZMQ_SNDMORE);
|
||||||
sleep(1);
|
|
||||||
//send data
|
//send data
|
||||||
zmq_send(zmqsocket, buffer, oneframesize, 0);
|
zmq_send(zmqsocket, buffer, oneframesize, 0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1836,18 +1843,17 @@ void UDPStandardImplementation::startDataCallback(){cprintf(MAGENTA,"start data
|
|||||||
|
|
||||||
}/*--end of loop for each buffer (inner loop)*/
|
}/*--end of loop for each buffer (inner loop)*/
|
||||||
|
|
||||||
//free resources
|
|
||||||
usleep(1000*1000);
|
|
||||||
delete[] buffer;
|
|
||||||
zmq_unbind(zmqsocket, hostName);
|
|
||||||
zmq_close(zmqsocket);
|
|
||||||
zmq_ctx_destroy(context);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//end of acquisition, wait for next acquisition/change of parameters
|
//end of acquisition, wait for next acquisition/change of parameters
|
||||||
sem_wait(&dataCallbackSemaphore[ithread]);
|
sem_wait(&dataCallbackSemaphore[ithread]);
|
||||||
|
|
||||||
|
//free resources (only at the next start so that socket not closed before client gets end of packet)
|
||||||
|
delete[] buffer;
|
||||||
|
zmq_unbind(zmqsocket, hostName);
|
||||||
|
zmq_close(zmqsocket);
|
||||||
|
zmq_ctx_destroy(context);
|
||||||
|
|
||||||
|
|
||||||
//check to exit thread (for change of parameters) - only EXIT possibility
|
//check to exit thread (for change of parameters) - only EXIT possibility
|
||||||
if(killAllDataCallbackThreads){
|
if(killAllDataCallbackThreads){
|
||||||
@ -2498,7 +2504,9 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){
|
|||||||
|
|
||||||
if(dataStreamEnable){
|
if(dataStreamEnable){
|
||||||
//ensure previous frame was processed
|
//ensure previous frame was processed
|
||||||
|
if(!ithread) cout<<"*** waiting for writerguisemiphore (stopwriting)"<<endl;
|
||||||
sem_wait(&writerGuiSemaphore[ithread]);
|
sem_wait(&writerGuiSemaphore[ithread]);
|
||||||
|
if(!ithread) cout<<"*** got post for writerguisemiphore (stopwriting)"<<endl;
|
||||||
guiNumPackets[ithread] = dummyPacketValue;
|
guiNumPackets[ithread] = dummyPacketValue;
|
||||||
//let it know its got data
|
//let it know its got data
|
||||||
sem_post(&dataCallbackWriterSemaphore[ithread]);
|
sem_post(&dataCallbackWriterSemaphore[ithread]);
|
||||||
@ -2801,8 +2809,9 @@ void UDPStandardImplementation::copyFrameToGui(int ithread, char* buffer, uint32
|
|||||||
cprintf(GREEN,"Writing_Thread: CopyingFrame: Going to copy data\n");
|
cprintf(GREEN,"Writing_Thread: CopyingFrame: Going to copy data\n");
|
||||||
#endif
|
#endif
|
||||||
//ensure previous frame was processed
|
//ensure previous frame was processed
|
||||||
|
if(!ithread) cout<<"*** waiting for writerguisemiphore (copyfrmae)"<<endl;
|
||||||
sem_wait(&writerGuiSemaphore[ithread]);
|
sem_wait(&writerGuiSemaphore[ithread]);
|
||||||
|
if(!ithread) cout<<"*** got post for writerguisemiphore (copyframe)"<<endl;
|
||||||
//copy date
|
//copy date
|
||||||
guiNumPackets[ithread] = numpackets;
|
guiNumPackets[ithread] = numpackets;
|
||||||
strcpy(guiFileName[ithread],completeFileName[ithread]);
|
strcpy(guiFileName[ithread],completeFileName[ithread]);
|
||||||
|
Reference in New Issue
Block a user