From a65920377c522b1e862e9b7c73a1e69f0fe96b70 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 5 Jul 2016 17:17:34 +0200 Subject: [PATCH] feature with header in file --- .../include/UDPStandardImplementation.h | 8 +++ .../src/UDPStandardImplementation.cpp | 56 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 521d6079b..8ab54a300 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -440,6 +440,11 @@ private: */ void createHeaders(char* wbuffer[]); + /** + * Updates the file header char aray, each time the corresp parameter is changed + */ + void updateFileHeader(); + /** * Called by handleWithoutDataCompression and handleWithCompression after writing to file * Copy frames for GUI and updates appropriate parameters for frequency frames to gui @@ -467,6 +472,7 @@ private: + /************************************************************************* * Class Members ********************************************************* *************************************************************************/ @@ -515,6 +521,8 @@ private: /** If file created successfully for all Writer Threads */ bool fileCreateSuccess; + char fileHeader[1000]; + diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 9c18ad243..614cfc8c7 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -138,6 +138,7 @@ void UDPStandardImplementation::initializeMembers(){ strcpy(completeFileName,""); maxPacketsPerFile = 0; fileCreateSuccess = false; + strcpy(fileHeader,""); //***acquisition indices parameters*** startAcquisitionIndex = 0; @@ -536,6 +537,8 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){ frameSize = onePacketSize * packetsPerFrame; maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame; + updateFileHeader(); + //new dynamic range, then restart threads and resetup fifo structure if(oldDynamicRange != dynamicRange){ @@ -591,6 +594,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){ "\nmaxPacketsPerFile:" << maxPacketsPerFile; + updateFileHeader(); //new enable, then restart threads and resetup fifo structure if(oldTenGigaEnable != tengigaEnable){ @@ -767,6 +771,10 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){ //allocate for latest data (frame copy for gui) latestData = new char[frameSize]; + //updates File Header + if(myDetectorType == EIGER) + updateFileHeader(); + FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d); return OK; @@ -1413,6 +1421,10 @@ int UDPStandardImplementation::createNewFile(){ numTotMissingPacketsInFile = 0; } + //write file header + if(myDetectorType == EIGER) + fwrite((void*)fileHeader, 1, strlen(fileHeader), sfilefd); + return OK; } @@ -2801,7 +2813,7 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ //overwriting port number and dynamic range *( (uint8_t*) wbuf_header->portIndex) = (uint8_t)port; - *( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange; + //*( (uint8_t*) wbuf_header->dynamicRange) = (uint8_t)dynamicRange; //DEBUGGING if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){ @@ -2820,6 +2832,48 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){ } +void UDPStandardImplementation::updateFileHeader(){ + int xpix=-1,ypix=-1; + + //create detector specific packet header + char packetheader[1000]; + strcpy(packetheader,""); + + //only for eiger right now + /*switch(myDetectorType){ + case EIGER: + */ sprintf(packetheader,"#Packet Header\n" + "Sub Frame Number 4 bytes\n" + "Missing Packet\t 2 bytes\n" + "Port Number\t 1 byte\n" + "Unused\t\t 1 byte\n\n" + "#Packet Footer\n" + "Frame Number\t 6 bytes\n" + "Packet Number\t 2 bytes\n"); + xpix = EIGER_PIXELS_IN_ONE_ROW; + ypix = EIGER_PIXELS_IN_ONE_COL; + /* break; + default: + break; + } +*/ + + //update file header + int length = sizeof(fileHeader); + while(length!=strlen(fileHeader)){ + length = strlen(fileHeader); + sprintf(fileHeader,"Header\t\t %d bytes\n" + "Dynamic Range\t %d\n" + "Packet\t\t %d bytes\n" + "x\t\t %d pixels\n" + "y\t\t %d pixels\n\n" + "%s", + length,dynamicRange,onePacketSize,xpix,ypix,packetheader); + } + +} + + void UDPStandardImplementation::copyFrameToGui(char* buffer[]){ FILE_LOG(logDEBUG) << __AT__ << " called";