mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-22 01:27:59 +02:00
runs, prints right in reciever
This commit is contained in:
@ -108,18 +108,14 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) {
|
||||
firstAcquisitionIndex = fnum;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n",
|
||||
index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << index << " First Acquisition Index: " << firstAcquisitionIndex <<
|
||||
"\tFirst Measurement Index: " << firstMeasurementIndex;
|
||||
}
|
||||
|
||||
|
||||
void DataStreamer::SetGeneralData(GeneralData* g) {
|
||||
generalData = g;
|
||||
#ifdef VERY_VERBOSE
|
||||
generalData->Print();
|
||||
#endif
|
||||
}
|
||||
|
||||
int DataStreamer::SetThreadPriority(int priority) {
|
||||
@ -138,7 +134,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
|
||||
try {
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
||||
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
||||
throw;
|
||||
}
|
||||
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
|
||||
@ -156,15 +152,13 @@ void DataStreamer::CloseZmqSocket() {
|
||||
void DataStreamer::ThreadExecution() {
|
||||
char* buffer=0;
|
||||
fifo->PopAddressToStream(buffer);
|
||||
#ifdef FIFODEBUG
|
||||
if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", "
|
||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||
|
||||
|
||||
//check dummy
|
||||
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
||||
#ifdef VERBOSE
|
||||
cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
|
||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||
StopProcessing(buffer);
|
||||
return;
|
||||
@ -180,20 +174,17 @@ void DataStreamer::ThreadExecution() {
|
||||
|
||||
|
||||
void DataStreamer::StopProcessing(char* buf) {
|
||||
#ifdef VERBOSE
|
||||
if (!index)
|
||||
cprintf(RED,"DataStreamer %d: Dummy\n", index);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
||||
|
||||
sls_receiver_header* header = (sls_receiver_header*) (buf);
|
||||
//send dummy header and data
|
||||
if (!SendHeader(header, 0, 0, 0, true))
|
||||
cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index);
|
||||
if (!SendHeader(header, 0, 0, 0, true)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq dummy header for streamer " << index;
|
||||
}
|
||||
|
||||
fifo->FreeAddress(buf);
|
||||
StopRunning();
|
||||
#ifdef VERBOSE
|
||||
FILE_LOG(logINFO) << index << ": Streaming Completed";
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << index << ": Streaming Completed";
|
||||
}
|
||||
|
||||
/** buf includes only the standard header */
|
||||
@ -201,14 +192,9 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
|
||||
sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
uint64_t fnum = header->detHeader.frameNumber;
|
||||
#ifdef VERBOSE
|
||||
cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||
|
||||
if (!measurementStartedFlag) {
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum);
|
||||
#endif
|
||||
RecordFirstIndices(fnum);
|
||||
}
|
||||
|
||||
@ -220,17 +206,16 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
//write imagesize
|
||||
|
||||
if (!SendHeader(header, generalData->imageSizeComplete,
|
||||
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
|
||||
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
|
||||
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) );
|
||||
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete))
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -238,14 +223,13 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
else {
|
||||
|
||||
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
|
||||
generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback
|
||||
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
|
||||
generalData->nPixelsX, generalData->nPixelsY, false)) {// new size possibly from callback
|
||||
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
(uint32_t)(*((uint32_t*)buf)) )) {// new size possibly from callback
|
||||
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user