size change in receiver call back API now streamed, gui allows smaller packet size than expected to be caught and replaced the rest with 0xFF

This commit is contained in:
maliakal_d 2018-03-21 17:08:38 +01:00
parent a1936cb884
commit a74e8f68f7
16 changed files with 83 additions and 54 deletions

View File

@ -103,12 +103,12 @@ void AcquisitionFinished(uint64_t frames, void*p){
* @param detType detector type see :: detectorType
* @param version version of standard header (structure format)
* @param datapointer pointer to data
* @param datasize data size in bytes
* @param datasize data size in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
* @param p pointer to object
*/
void GetData(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,
char* datapointer, uint32_t datasize, void* p){
char* datapointer, uint32_t* datasize, void* p){
PRINT_IN_COLOR (modId?modId:xCoord,
"#### %d GetData: ####\n"
@ -117,7 +117,8 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui
"version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId,
xCoord, yCoord, zCoord, debug, roundRNumber, detType, version,
((uint8_t)(*((uint8_t*)(datapointer)))), datasize);
((uint8_t)(*((uint8_t*)(datapointer)))), *datasize);
*datasize = 26000;
}

View File

@ -33,12 +33,14 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param freq pointer to streaming frequency
* @param timer pointer to timer if streaming frequency is random
* @param dataReadycb pointer to data ready call back function
* @param pDataReadycb pointer to arguments of data ready call back function
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer,
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),
void *pDataReadycb);
/**
@ -393,10 +395,11 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*);
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*);
void *pRawDataReady;

View File

@ -166,12 +166,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
/**
* Create and send Json Header
* @param header header of image
* @param size data size (could have been modified in call back)
* @param nx number of pixels in x dim
* @param ny number of pixels in y dim
* @param dummy true if its a dummy header
* @returns 0 if error, else 1
*/
int SendHeader(sls_detector_header* header, uint32_t nx = 0, uint32_t ny = 0, bool dummy = true);
int SendHeader(sls_detector_header* header, uint32_t size = 0, uint32_t nx = 0, uint32_t ny = 0, bool dummy = true);
/** type of thread */
static const std::string TypeName;

View File

@ -600,10 +600,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t,
uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t,
uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg);
@ -736,10 +738,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*);
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*);
void *pRawDataReady;

View File

@ -689,10 +689,10 @@ class UDPInterface {
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg) = 0;
char*, uint32_t*, void*),void *arg) = 0;
protected:

View File

@ -24,6 +24,7 @@ using namespace rapidjson;
#define MAX_STR_LENGTH 1000
//#define ZMQ_DETAIL
#define ROIVERBOSITY
class ZmqSocket {
@ -426,7 +427,15 @@ public:
memcpy(buf, (char*)zmq_msg_data(&message), size);
}
//incorrect size
//incorrect size (smaller)
else if (length < size){
#ifdef ROIVERBOSITY
cprintf(RED,"Error: Received smaller packet size %d for socket %d\n", length, index);
#endif
memcpy(buf, (char*)zmq_msg_data(&message), length);
memset(buf+length,0xFF,size-length);
}
//incorrect size (larger)
else {
cprintf(RED,"Error: Received weird packet size %d for socket %d\n", length, index);
memset(buf,0xFF,size);

View File

@ -91,10 +91,12 @@ class slsReceiver : private virtual slsReceiverDefs {
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t,
uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t,
uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg);

View File

@ -95,8 +95,10 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
*/
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t,
uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t,
uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg);
private:
@ -344,10 +346,11 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
* detType is the detector type see :: detectorType
* version is the version number of this structure format
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes
* dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*);
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*);
void *pRawDataReady;

View File

@ -69,7 +69,7 @@ public:
*/
void registerCallBackRawDataReady(void (*func)(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,
char* datapointer, uint32_t datasize, void*),void *arg);
char* datapointer, uint32_t* datasize, void*),void *arg);
//receiver object
slsReceiver* receiver;

View File

@ -35,8 +35,9 @@ bool DataProcessor::SilentMode(false);
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer,
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t,
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),
void *pDataReadycb) :
ThreadObject(NumberofDataProcessors),
@ -316,7 +317,7 @@ void DataProcessor::ThreadExecution() {
return;
}
ProcessAnImage(buffer + FIFO_HEADER_NUMBYTES);
ProcessAnImage(buffer);
//stream (if time/freq to stream) or free
if (*dataStreamEnable && SendToStreamer())
@ -348,7 +349,7 @@ void DataProcessor::StopProcessing(char* buf) {
/** buf includes only the standard header */
void DataProcessor::ProcessAnImage(char* buf) {
sls_detector_header* header = (sls_detector_header*) (buf);
sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
uint64_t fnum = header->frameNumber;
currentFrameIndex = fnum;
uint32_t nump = header->packetNumber;
@ -381,7 +382,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
}
if (*gapPixelsEnable && (*dynamicRange!=4))
InsertGapPixels(buf + sizeof(sls_detector_header), *dynamicRange);
InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), *dynamicRange);
// x coord is 0 for detector in pos [0,0,0]
if (xcoordin1D) {
@ -409,14 +410,14 @@ void DataProcessor::ProcessAnImage(char* buf) {
header->roundRNumber,
header->detType,
header->version,
buf + sizeof(sls_detector_header),
generalData->imageSize,
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header),
(uint32_t*)buf,
pRawDataReady);
}
if (file)
file->WriteToFile(buf, sizeof(sls_detector_header) + generalData->imageSize, fnum-firstMeasurementIndex, nump);
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES, sizeof(sls_detector_header) + (uint32_t)(*((uint32_t*)buf)), fnum-firstMeasurementIndex, nump);

View File

@ -200,7 +200,7 @@ void DataStreamer::ThreadExecution() {
return;
}
ProcessAnImage(buffer + FIFO_HEADER_NUMBYTES);
ProcessAnImage(buffer);
//free
fifo->FreeAddress(buffer);
@ -216,7 +216,7 @@ void DataStreamer::StopProcessing(char* buf) {
#endif
sls_detector_header* header = (sls_detector_header*) (buf);
//send dummy header and data
if (!SendHeader(header, 0, 0, true))
if (!SendHeader(header, 0, 0, 0, true))
cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index);
fifo->FreeAddress(buf);
@ -229,7 +229,7 @@ void DataStreamer::StopProcessing(char* buf) {
/** buf includes only the standard header */
void DataStreamer::ProcessAnImage(char* buf) {
sls_detector_header* header = (sls_detector_header*) (buf);
sls_detector_header* header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
uint64_t fnum = header->frameNumber;
#ifdef VERBOSE
cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
@ -245,11 +245,11 @@ void DataStreamer::ProcessAnImage(char* buf) {
//shortframe gotthard
if (completeBuffer) {
if (!SendHeader(header, generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), 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);
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize);
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback
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);
@ -259,11 +259,11 @@ void DataStreamer::ProcessAnImage(char* buf) {
//normal
else {
if (!SendHeader(header, generalData->nPixelsX, generalData->nPixelsY, false))
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);
if (!zmqSocket->SendData(buf + sizeof(sls_detector_header), generalData->imageSize))
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_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);
}
@ -271,7 +271,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
int DataStreamer::SendHeader(sls_detector_header* header, uint32_t nx, uint32_t ny, bool dummy) {
int DataStreamer::SendHeader(sls_detector_header* header, uint32_t size, uint32_t nx, uint32_t ny, bool dummy) {
if (dummy)
return zmqSocket->SendHeaderData(index, dummy,SLS_DETECTOR_JSON_HEADER_VERSION);
@ -280,7 +280,7 @@ int DataStreamer::SendHeader(sls_detector_header* header, uint32_t nx, uint32_t
uint64_t acquisitionIndex = header->frameNumber - firstAcquisitionIndex;
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex,
nx, ny,generalData->imageSize,
nx, ny, size,
acquisitionIndex, frameIndex, fileNametoStream,
header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp,
header->modId, header->xCoord, header->yCoord, header->zCoord,

View File

@ -614,8 +614,10 @@ void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uin
pAcquisitionFinished=arg;
}
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg){
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t,
uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t,
uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg){
rawDataReadyCallBack=func;
pRawDataReady=arg;
}

View File

@ -42,7 +42,7 @@ void AcquisitionFinished(uint64_t frames, void*p){
void GetData(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,
char* datapointer, uint32_t datasize, void* p){
char* datapointer, uint32_t* datasize, void* p){
PRINT_IN_COLOR (xCoord,
"#### %d GetData: ####\n"
@ -51,7 +51,7 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui
"version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId,
xCoord, yCoord, zCoord, debug, roundRNumber, detType, version,
((uint8_t)(*((uint8_t*)(datapointer)))), datasize);
((uint8_t)(*((uint8_t*)(datapointer)))), *datasize);
}
*/

View File

@ -150,8 +150,10 @@ void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, voi
}
void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg){
void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t,
uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg){
//tcpipInterface
if(udp_interface)
udp_interface->registerCallBackRawDataReady(func,arg);

View File

@ -170,8 +170,10 @@ void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)
pAcquisitionFinished=arg;
}
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t, void*),void *arg){
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t,
uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t,
uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
char*, uint32_t*, void*),void *arg){
rawDataReadyCallBack=func;
pRawDataReady=arg;
}

View File

@ -31,7 +31,7 @@ void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(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,
char* datapointer, uint32_t datasize, void*), void *arg){
char* datapointer, uint32_t* datasize, void*), void *arg){
receiver->registerCallBackRawDataReady(func,arg);
}