From 66c488b79abd1840d2d494e1a11ac91b0cb71173 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 20 Dec 2016 14:13:00 +0100 Subject: [PATCH] working so far --- slsReceiverSoftware/include/receiver_defs.h | 2 + .../src/UDPStandardImplementation.cpp | 139 +++++++++++------- 2 files changed, 84 insertions(+), 57 deletions(-) diff --git a/slsReceiverSoftware/include/receiver_defs.h b/slsReceiverSoftware/include/receiver_defs.h index b05ff314c..8c4351e81 100755 --- a/slsReceiverSoftware/include/receiver_defs.h +++ b/slsReceiverSoftware/include/receiver_defs.h @@ -44,6 +44,8 @@ typedef struct { } jfrau_packet_header_t; +#define WRITER_VERSION 1.0 + #define GOODBYE -200 #define DO_NOTHING 0 diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index ed00429ad..98cae8a49 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -597,9 +597,9 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i){ FILE_LOG(logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s"; - if(myDetectorType == EIGER) + if(myDetectorType == EIGER && fileFormatType == BINARY) for(int i=0; icreateAttribute("version",PredType::NATIVE_DOUBLE, dataspace); + attribute.write(PredType::NATIVE_DOUBLE, &dValue); + + //Create a group in the file Group group1( hdf5_fileId[ithread]->createGroup( "entry" )); - Group group2(group1.createGroup("data")); - Group group3(group1.createGroup("instrument")); - Group group4(group3.createGroup("detector")); + Group group2(group1.createGroup("data")); + Group group3(group1.createGroup("instrument")); + Group group4(group3.createGroup("detector")); + Group group5(group4.createGroup("detector specific")); + + int iValue=0; + StrType strdatatype(PredType::C_S1,256); + DataSet dataset; + //top + iValue = (flippedData[0]?0:1); + dataset = group5.createDataSet ( "top", PredType::NATIVE_INT, dataspace ); + dataset.write ( &iValue, PredType::NATIVE_INT); + //left + iValue = (ithread?0:1); + dataset = group5.createDataSet ( "left", PredType::NATIVE_INT, dataspace ); + dataset.write ( &iValue, PredType::NATIVE_INT); + //active + iValue = activated; + dataset = group5.createDataSet ( "active", PredType::NATIVE_INT, dataspace ); + dataset.write ( &iValue, PredType::NATIVE_INT); + //Dynamic Range + dataset = group4.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace ); + dataset.write ( &dynamicRange, PredType::NATIVE_INT); + attribute = dataset.createAttribute("unit",strdatatype, dataspace); + attribute.write(strdatatype, string("bits")); + //Ten Giga + iValue = tengigaEnable; + dataset = group4.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace ); + dataset.write ( &iValue, PredType::NATIVE_INT); + //Image Size + dataset = group4.createDataSet ( "image size", PredType::NATIVE_INT, dataspace ); + dataset.write ( &bufferSize, PredType::NATIVE_INT); + attribute = dataset.createAttribute("unit",strdatatype, dataspace); + attribute.write(strdatatype, string("bytes")); + //x + dataset = group4.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace ); + dataset.write ( &NX, PredType::NATIVE_INT); + //y + dataset = group4.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace ); + dataset.write ( &NY, PredType::NATIVE_INT); + //Total Frames + dataset = group4.createDataSet ( "total frames", PredType::STD_U64LE, dataspace ); + dataset.write ( &numberOfFrames, PredType::STD_U64LE); + //Exptime + dataset = group4.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace ); + dataset.write ( &acquisitionTime, PredType::STD_U64LE); + attribute = dataset.createAttribute("unit",strdatatype, dataspace); + attribute.write(strdatatype, string("ns")); + //Period + dataset = group4.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace ); + dataset.write ( &acquisitionPeriod, PredType::STD_U64LE); + attribute = dataset.createAttribute("unit",strdatatype, dataspace); + attribute.write(strdatatype, string("ns")); + //Timestamp + time_t t = time(0); + dataset = group4.createDataSet ( "timestamp", strdatatype, dataspace ); + dataset.write ( string(ctime(&t)), strdatatype ); - //Group group5(group1.createGroup("sample")); //group4.link(H5G_LINK_HARD,"/entry/data","/entry/instrument/detector/data"); group1.close(); group2.close(); group3.close(); group4.close(); - //group5.close(); + group5.close(); + //data //create property list for a dataset and set up fill values int fillvalue = -1; DSetCreatPropList plist; @@ -1749,25 +1817,11 @@ int UDPStandardImplementation::createNewFile(int ithread){ if(dynamicRange == 4) srcdims[1] = NX/2; hdf5_dataspaceId[ithread] = new DataSpace (3,srcdims); - - char dsetname[100]; sprintf(dsetname, "/entry/data/data_%06lld", (long long int)currentFrameNumber[ithread]+1); - //Create dataset and write it into the file hdf5_datasetId[ithread] = new DataSet (hdf5_fileId[ithread]->createDataSet( dsetname, hdf5_datatype, *hdf5_dataspaceId[ithread], plist)); - - /* - //create the data space for the attribute - hsize_t dims = 1; - DataSpace attr_dataspace = DataSpace (1, &dims); - //create file attribute - Attribute attribute = hdf5_datasetId[ithread]->createAttribute("Dynamic Range", - PredType::STD_I32LE, attr_dataspace); - //write the attribute data - attribute.write(PredType::STD_I32LE, &dynamicRange); - */ } catch(Exception error){ cprintf(RED,"Error in creating HDF5 handles in thread %d\n",ithread); @@ -2839,35 +2893,6 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){ //all threads need to close file, reset mask and exit loop if(fileWriteEnable && (cbAction > DO_NOTHING)){ - -#ifdef HDF5C - if(fileFormatType == HDF5){; -/* - if(hdf5_datasetId[ithread]){ - pthread_mutex_lock(&writeMutex); - try{ - Exception::dontPrint(); //to handle errors - hsize_t dims = 1; - //create the data space for the attribute - DataSpace attr_dataspace = DataSpace (1, &dims); - //create file attribute - Attribute attribute = hdf5_datasetId[ithread]->createAttribute( "Dynamic Range", - PredType::STD_I32LE, attr_dataspace); - //write the attribute data - attribute.write( PredType::STD_I32LE, &dynamicRange); - delete hdf5_datasetId[ithread]; - hdf5_datasetId[ithread] = 0; - } - catch(Exception error){ - cprintf(RED,"Error in creating attributes in thread %d\n",ithread); - error.printError(); - } - pthread_mutex_unlock(&writeMutex); - } - */ - } - else -#endif if(fileFormatType == BINARY && myDetectorType == EIGER){ updateFileHeader(ithread); fseek(sfilefd[ithread],0,0);