mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
adding printouts , resetting an image size for each listen image, if last image is not complete, it should be checked with rc==0 and not if itis transmitting, else it doesnt send last incomplete image
This commit is contained in:
parent
cbd1570a8c
commit
1c7ff1dd8c
@ -10,6 +10,8 @@
|
|||||||
#include "ansi.h"
|
#include "ansi.h"
|
||||||
//#include "sls_receiver_defs.h"
|
//#include "sls_receiver_defs.h"
|
||||||
|
|
||||||
|
//#define ZMQ_DETAIL
|
||||||
|
|
||||||
#include <zmq.h>
|
#include <zmq.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h> //gethostbyname()
|
#include <netdb.h> //gethostbyname()
|
||||||
@ -303,21 +305,23 @@ public:
|
|||||||
int len = ReceiveMessage(index, message);
|
int len = ReceiveMessage(index, message);
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
bool dummy = false;
|
bool dummy = false;
|
||||||
#ifdef VERBOSE
|
#ifdef ZMQ_DETAIL
|
||||||
cprintf( BLUE,"Header %d Length: %d Header:%s \n", index, len, (char*) zmq_msg_data (&message) );
|
cprintf( BLUE,"Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
|
||||||
#endif
|
#endif
|
||||||
if ( ParseHeader (index, len, message, acqIndex, frameIndex, subframeIndex, filename, dummy)) {
|
if ( ParseHeader (index, len, message, acqIndex, frameIndex, subframeIndex, filename, dummy)) {
|
||||||
zmq_msg_close (&message);
|
#ifdef ZMQ_DETAIL
|
||||||
#ifdef VERBOSE
|
cprintf( RED,"Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
|
||||||
cprintf( RED,"Parsed Header %d Length: %d Header:%s \n", index, len, (char*) zmq_msg_data (&message) );
|
|
||||||
#endif
|
#endif
|
||||||
|
zmq_msg_close (&message);
|
||||||
if (dummy) {
|
if (dummy) {
|
||||||
#ifdef VERBOSE
|
#ifdef ZMQ_DETAIL
|
||||||
cprintf(RED,"%d Received end of acquisition\n", index);
|
cprintf(RED,"%d [%d] Received end of acquisition\n", index, portno );
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
cprintf(GREEN,"%d data\n",index);
|
#ifdef ZMQ_DETAIL
|
||||||
|
cprintf(GREEN,"%d [%d] data\n",index, portno );
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,6 +275,9 @@ void DataProcessor::ThreadExecution() {
|
|||||||
|
|
||||||
//check dummy
|
//check dummy
|
||||||
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if (!index) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes);
|
||||||
|
#endif
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
return;
|
return;
|
||||||
@ -292,6 +295,10 @@ void DataProcessor::ThreadExecution() {
|
|||||||
|
|
||||||
|
|
||||||
void DataProcessor::StopProcessing(char* buf) {
|
void DataProcessor::StopProcessing(char* buf) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if (!index)
|
||||||
|
cprintf(RED,"DataProcessing %d: Dummy\n", index);
|
||||||
|
#endif
|
||||||
//stream or free
|
//stream or free
|
||||||
if (*dataStreamEnable)
|
if (*dataStreamEnable)
|
||||||
fifo->PushAddressToStream(buf);
|
fifo->PushAddressToStream(buf);
|
||||||
@ -318,7 +325,8 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
|
if (!index)
|
||||||
|
cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!measurementStartedFlag) {
|
if (!measurementStartedFlag) {
|
||||||
|
@ -183,11 +183,14 @@ void DataStreamer::ThreadExecution() {
|
|||||||
char* buffer=0;
|
char* buffer=0;
|
||||||
fifo->PopAddressToStream(buffer);
|
fifo->PopAddressToStream(buffer);
|
||||||
#ifdef FIFODEBUG
|
#ifdef FIFODEBUG
|
||||||
if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//check dummy
|
//check dummy
|
||||||
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
|
||||||
|
#endif
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
return;
|
return;
|
||||||
@ -203,7 +206,10 @@ void DataStreamer::ThreadExecution() {
|
|||||||
|
|
||||||
|
|
||||||
void DataStreamer::StopProcessing(char* buf) {
|
void DataStreamer::StopProcessing(char* buf) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if (!index)
|
||||||
|
cprintf(RED,"DataStreamer %d: Dummy\n", index);
|
||||||
|
#endif
|
||||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||||
//send dummy header and data
|
//send dummy header and data
|
||||||
if (!SendHeader(header, true))
|
if (!SendHeader(header, true))
|
||||||
@ -222,7 +228,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
|||||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||||
uint64_t fnum = header->frameNumber;
|
uint64_t fnum = header->frameNumber;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
|
cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!measurementStartedFlag) {
|
if (!measurementStartedFlag) {
|
||||||
|
@ -251,7 +251,7 @@ void Listener::ThreadExecution() {
|
|||||||
|
|
||||||
//udpsocket doesnt exist
|
//udpsocket doesnt exist
|
||||||
if (*activated && !udpSocket) {
|
if (*activated && !udpSocket) {
|
||||||
FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||||
(*((uint32_t*)buffer)) = 0;
|
(*((uint32_t*)buffer)) = 0;
|
||||||
StopListening(buffer);
|
StopListening(buffer);
|
||||||
return;
|
return;
|
||||||
@ -265,15 +265,16 @@ void Listener::ThreadExecution() {
|
|||||||
rc = CreateAnImage(buffer + generalData->fifoBufferHeaderSize);
|
rc = CreateAnImage(buffer + generalData->fifoBufferHeaderSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//done acquiring
|
|
||||||
|
/*//done acquiring
|
||||||
if ((*status == TRANSMITTING) || ( (!(*activated)) && (rc == 0)) ) {
|
if ((*status == TRANSMITTING) || ( (!(*activated)) && (rc == 0)) ) {
|
||||||
StopListening(buffer);
|
StopListening(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//error check, (should not be here) if not transmitting yet (previous if) rc should be > 0
|
//error check, (should not be here) if not transmitting yet (previous if) rc should be > 0
|
||||||
if (rc <= 0) {
|
if (rc <= 0) {
|
||||||
cprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
|
//cprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
|
||||||
StopListening(buffer);
|
StopListening(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -282,8 +283,10 @@ void Listener::ThreadExecution() {
|
|||||||
(*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier
|
(*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier
|
||||||
currentFrameIndex++;
|
currentFrameIndex++;
|
||||||
|
|
||||||
|
|
||||||
//push into fifo
|
//push into fifo
|
||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,11 +320,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
|
|
||||||
//reset to -1
|
//reset to -1
|
||||||
memset(buf, 0, fifohsize);
|
memset(buf, 0, fifohsize);
|
||||||
memset(buf + fifohsize, 0xFF, dsize);
|
memset(buf + fifohsize, 0xFF, generalData->imageSize);
|
||||||
new_header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
|
new_header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//look for carry over
|
//look for carry over
|
||||||
if (carryOverFlag) {
|
if (carryOverFlag) {
|
||||||
cprintf(RED,"%d carry flag\n",index);
|
cprintf(RED,"%d carry flag\n",index);
|
||||||
@ -422,6 +424,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
//------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
lastCaughtFrameIndex = fnum;
|
lastCaughtFrameIndex = fnum;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
//if (!index)
|
//if (!index)
|
||||||
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
|
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user