mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
fixing the standard header pointers for it to work
This commit is contained in:
parent
a1fc93b398
commit
6d7fb07a4c
@ -190,11 +190,15 @@ public:
|
||||
* @param dummy true if end of acquistion else false
|
||||
* @returns 0 if error, else 1
|
||||
*/
|
||||
int SendHeaderData (uint32_t jsonversion, uint32_t dynamicrange, uint32_t npixelsx, uint32_t npixelsy,
|
||||
uint64_t acqIndex, uint64_t fIndex, char* fname, bool dummy,
|
||||
uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
|
||||
uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber,
|
||||
uint8_t detType, uint8_t version) {
|
||||
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0,
|
||||
uint32_t npixelsx = 0, uint32_t npixelsy = 0,
|
||||
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
|
||||
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
|
||||
uint64_t bunchId = 0, uint64_t timestamp = 0,
|
||||
uint16_t modId = 0, uint16_t xCoord = 0, uint16_t yCoord = 0, uint16_t zCoord = 0,
|
||||
uint32_t debug = 0, uint16_t roundRNumber = 0,
|
||||
uint8_t detType = 0, uint8_t version = 0) {
|
||||
|
||||
|
||||
char buf[MAX_STR_LENGTH] = "";
|
||||
/** Json Header Format */
|
||||
@ -206,7 +210,7 @@ public:
|
||||
"\"acqIndex\":%llu, "
|
||||
"\"fIndex\":%llu, "
|
||||
"\"fname\":\"%s\", "
|
||||
"\"data\": %d, "
|
||||
"\"data\": %d, "
|
||||
|
||||
"\"frameNumber\":%llu, "
|
||||
"\"expLength\":%u, "
|
||||
@ -224,15 +228,16 @@ public:
|
||||
"}\n\0";
|
||||
int length = sprintf(buf, jsonHeaderFormat,
|
||||
jsonversion, dynamicrange, npixelsx, npixelsy,
|
||||
acqIndex, fIndex, fname, dummy?1:0,
|
||||
frameNumber, expLength, packetNumber, bunchId, timestamp,
|
||||
modId, xCoord, yCoord, zCoord, debug, roundRNumber,
|
||||
detType, version);
|
||||
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
|
||||
frameNumber, expLength, packetNumber, bunchId, timestamp,
|
||||
modId, xCoord, yCoord, zCoord, debug, roundRNumber,
|
||||
detType, version);
|
||||
#ifdef VERBOSE
|
||||
printf("%d Streamer: buf:%s\n", index, buf);
|
||||
if(!index)
|
||||
printf("%d Streamer: buf:%s\n", index, buf);
|
||||
#endif
|
||||
|
||||
if(zmq_send (socketDescriptor, buf, length, ZMQ_SNDMORE) < 0) {
|
||||
if(zmq_send (socketDescriptor, buf, length, dummy?0:ZMQ_SNDMORE) < 0) {
|
||||
PrintError ();
|
||||
return 0;
|
||||
}
|
||||
@ -266,6 +271,10 @@ public:
|
||||
PrintError ();
|
||||
cprintf (BG_RED,"Error: Could not read header for socket %d\n",index);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
else
|
||||
cprintf( RED,"Message %d Length: %d Header:%s \n", index, length, (char*) zmq_msg_data (&message) );
|
||||
#endif
|
||||
return length;
|
||||
};
|
||||
|
||||
@ -287,10 +296,13 @@ public:
|
||||
int len = ReceiveMessage(index, message);
|
||||
if ( len > 0 ) {
|
||||
bool dummy = false;
|
||||
#ifdef VERBOSE
|
||||
cprintf( RED,"Header %d Length: %d Header:%s \n", index, length, (char*) zmq_msg_data (&message) );
|
||||
#endif
|
||||
if ( ParseHeader (index, len, message, acqIndex, frameIndex, subframeIndex, filename, dummy)) {
|
||||
zmq_msg_close (&message);
|
||||
#ifdef VERBOSE
|
||||
cprintf( RED,"%d Length: %d Header:%s \n", index, length, (char*) zmq_msg_data (&message) );
|
||||
cprintf( RED,"Parsed Header %d Length: %d Header:%s \n", index, len, (char*) zmq_msg_data (&message) );
|
||||
#endif
|
||||
if (dummy) {
|
||||
#ifdef VERBOSE
|
||||
@ -352,6 +364,12 @@ public:
|
||||
int ParseHeader(const int index, int length, zmq_msg_t& message, uint64_t &acqIndex,
|
||||
uint64_t &frameIndex, uint32_t &subframeIndex, string &filename, bool& dummy)
|
||||
{
|
||||
|
||||
acqIndex = -1;
|
||||
frameIndex = -1;
|
||||
subframeIndex = -1;
|
||||
dummy = true;
|
||||
|
||||
Document d;
|
||||
if ( d.Parse( (char*) zmq_msg_data (&message), zmq_msg_size (&message)).HasParseError() ) {
|
||||
cprintf( RED,"%d Could not parse. len:%d: Message:%s \n", index, length, (char*) zmq_msg_data (&message) );
|
||||
@ -366,23 +384,25 @@ public:
|
||||
}
|
||||
|
||||
int temp = d["data"].GetUint();
|
||||
dummy = temp ? true : false;
|
||||
if (dummy) {
|
||||
dummy = temp ? false : true;
|
||||
if (!dummy) {
|
||||
acqIndex = d["acqIndex"].GetUint64();
|
||||
frameIndex = d["fIndex"].GetUint64();
|
||||
subframeIndex = -1;
|
||||
if(d["bitmode"].GetInt()==32 && d["detType"].GetUint() == slsReceiverDefs::EIGER) {
|
||||
if(d["bitmode"].GetUint()==32 && d["detType"].GetUint() == slsReceiverDefs::EIGER) {
|
||||
subframeIndex = d["expLength"].GetUint();
|
||||
}
|
||||
filename = d["fname"].GetString();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Data: " << temp << endl;
|
||||
cout << "Acquisition index: " << acqIndex << endl;
|
||||
cout << "Frame index: " << frameIndex << endl;
|
||||
cout << "Subframe index: " << subframeIndex << endl;
|
||||
cout << "File name: " << filename << endl;
|
||||
#endif
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
cprintf(BLUE,"%d Dummy:%d\n"
|
||||
"\tAcqIndex:%lu\n"
|
||||
"\tFrameIndex:%lu\n"
|
||||
"\tSubIndex:%u\n"
|
||||
"\tBitMode:%u\n"
|
||||
"\tDetType:%u\n",
|
||||
index, (int)dummy, acqIndex, frameIndex, subframeIndex,
|
||||
d["bitmode"].GetUint(),d["detType"].GetUint());
|
||||
#endif
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
@ -294,7 +294,7 @@ void DataProcessor::StopProcessing(char* buf) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** buf includes only the standard header */
|
||||
void DataProcessor::ProcessAnImage(char* buf) {
|
||||
numFramesCaught++;
|
||||
numTotalFramesCaught++;
|
||||
@ -302,12 +302,12 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
uint64_t fnum = header->frameNumber;
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
|
||||
#endif
|
||||
|
||||
if (!measurementStartedFlag) {
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
|
||||
#endif
|
||||
RecordFirstIndices(fnum);
|
||||
}
|
||||
|
@ -215,18 +215,18 @@ void DataStreamer::StopProcessing(char* buf) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** buf includes only the standard header */
|
||||
void DataStreamer::ProcessAnImage(char* buf) {
|
||||
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
uint64_t fnum = header->frameNumber;
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
|
||||
#endif
|
||||
|
||||
if (!measurementStartedFlag) {
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum);
|
||||
#endif
|
||||
RecordFirstIndices(fnum);
|
||||
//restart timer
|
||||
@ -293,15 +293,18 @@ bool DataStreamer::CheckCount() {
|
||||
|
||||
int DataStreamer::SendHeader(sls_detector_header* header, bool dummy) {
|
||||
|
||||
if (dummy)
|
||||
return zmqSocket->SendHeaderData(index, dummy,SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
|
||||
uint64_t frameIndex = header->frameNumber - firstMeasurementIndex;
|
||||
uint64_t acquisitionIndex = header->frameNumber - firstAcquisitionIndex;
|
||||
|
||||
return zmqSocket->SendHeaderData(SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange,
|
||||
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange,
|
||||
generalData->nPixelsX_Streamer, generalData->nPixelsY_Streamer,
|
||||
acquisitionIndex, frameIndex, fileNametoStream, dummy,
|
||||
|
||||
acquisitionIndex, frameIndex, fileNametoStream,
|
||||
header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp,
|
||||
header->modId, header->xCoord, header->yCoord, header->zCoord, header->debug, header->roundRNumber,
|
||||
header->modId, header->xCoord, header->yCoord, header->zCoord,
|
||||
header->debug, header->roundRNumber,
|
||||
header->detType, header->version
|
||||
);
|
||||
);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ void Listener::StopListening(char* buf) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* buf includes the header */
|
||||
uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
uint32_t rc = 0;
|
||||
uint64_t fnum = 0, bid = 0;
|
||||
@ -322,7 +322,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
memcpy(buf + generalData->fifoBufferHeaderSize + (pnum * dsize), carryOverPacket + generalData->headerSizeinPacket, dsize);
|
||||
//writer header
|
||||
if(isHeaderEmpty) {
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
memset(header, 0, sizeof(sls_detector_header));
|
||||
header->frameNumber = fnum;
|
||||
if (generalData->myDetectorType == EIGER && *dynamicRange == 32)
|
||||
@ -331,16 +331,9 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
if (generalData->myDetectorType == JUNGFRAU)
|
||||
header->bunchId = bid;
|
||||
/*header->xCoord = index; given by det packet, also for ycoord, zcoord */
|
||||
/*header->detType = (uint8_t) generalData->myDetectorType; given by det packet */
|
||||
header->detType = (uint8_t) generalData->myDetectorType; /*given by det packet */
|
||||
header->version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
|
||||
#ifdef VERBOSE
|
||||
if(!ithread)
|
||||
cprintf(BLUE,
|
||||
"framenumber:%llu\tsubfnum:%u\tpnum:%u\tbunchid:%llu\txcoord:%u\tdettype:%u\tversion:%u\n",
|
||||
header->frameNumber, header->expLength, header->packetNumber,
|
||||
header->bunchId, header->xCoord, header->detType, header->version);
|
||||
#endif
|
||||
isHeaderEmpty = false;
|
||||
}
|
||||
expectpnum = pnum+1; //for jungfrau
|
||||
@ -366,7 +359,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
lastCaughtFrameIndex = fnum;
|
||||
#ifdef VERBOSE
|
||||
if (!index)
|
||||
cprintf(GREEN,"Listening %d: fnum:%lld, pnum:%d\n", index, (long long int)fnum, pnum);
|
||||
cprintf(GREEN,"Listening %d: fnum:%lu, pnum:%d\n", index,fnum, pnum);
|
||||
#endif
|
||||
if (!measurementStartedFlag)
|
||||
RecordFirstIndices(fnum);
|
||||
@ -393,7 +386,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
//copy packet
|
||||
memcpy(buf + generalData->fifoBufferHeaderSize + (pnum * dsize), listeningPacket + generalData->headerSizeinPacket, dsize);
|
||||
if(isHeaderEmpty) {
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
memset(header, 0, sizeof(sls_detector_header));
|
||||
header->frameNumber = fnum;
|
||||
if (generalData->myDetectorType == EIGER && *dynamicRange == 32)
|
||||
@ -402,7 +395,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
if (generalData->myDetectorType == JUNGFRAU)
|
||||
header->bunchId = bid;
|
||||
/*header->xCoord = index; given by det packet, also for ycoord, zcoord */
|
||||
/*header->detType = (uint8_t) generalData->myDetectorType; given by det packet */
|
||||
header->detType = (uint8_t) generalData->myDetectorType; /*given by det packet */
|
||||
header->version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
isHeaderEmpty = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user