file writer class should be created only if file write enabled, x coord fixed to reflect hardcoded values as detector does not send this value yet

This commit is contained in:
maliakal_d 2017-10-10 16:54:50 +02:00
parent c37d3feae9
commit d30a839eff
2 changed files with 33 additions and 18 deletions

View File

@ -311,6 +311,9 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** timer beginning stamp for random streaming */ /** timer beginning stamp for random streaming */
struct timespec timerBegin; struct timespec timerBegin;
/** x coord hardcoded, as detector does not send them yet **/
uint16_t xcoord;
//acquisition start //acquisition start

View File

@ -47,6 +47,7 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
streamingFrequency(freq), streamingFrequency(freq),
streamingTimerInMs(timer), streamingTimerInMs(timer),
currentFreqCount(0), currentFreqCount(0),
xcoord(0),
acquisitionStartedFlag(false), acquisitionStartedFlag(false),
measurementStartedFlag(false), measurementStartedFlag(false),
firstAcquisitionIndex(0), firstAcquisitionIndex(0),
@ -208,7 +209,7 @@ int DataProcessor::SetThreadPriority(int priority) {
void DataProcessor::SetFileFormat(const fileFormat f) { void DataProcessor::SetFileFormat(const fileFormat f) {
if (file->GetFileType() != f) { if (file && file->GetFileType() != f) {
//remember the pointer values before they are destroyed //remember the pointer values before they are destroyed
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0; int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0; char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0;
@ -228,30 +229,37 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
if (g) if (g)
generalData = g; generalData = g;
// fix xcoord as detector is not providing it right now
xcoord = ((NumberofDataProcessors > (*nunits)) ? index : ((*dindex) * (*nunits)) + index);
if (file) if (file)
delete file; delete file;
switch(*fileFormatType){ if (*fileWriteEnable) {
switch(*fileFormatType){
#ifdef HDF5C #ifdef HDF5C
case HDF5: case HDF5:
file = new HDF5File(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame, file = new HDF5File(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
nd, fname, fpath, findex, nd, fname, fpath, findex,
frindexenable, owenable, frindexenable, owenable,
dindex, nunits, nf, dr, portno, dindex, nunits, nf, dr, portno,
generalData->nPixelsX, generalData->nPixelsY); generalData->nPixelsX, generalData->nPixelsY);
break; break;
#endif #endif
default: default:
file = new BinaryFile(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame, file = new BinaryFile(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
nd, fname, fpath, findex, nd, fname, fpath, findex,
frindexenable, owenable, frindexenable, owenable,
dindex, nunits, nf, dr, portno); dindex, nunits, nf, dr, portno);
break; break;
}
} }
} }
// only the first file // only the first file
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, uint64_t ap) { int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, uint64_t ap) {
if (file == NULL)
return FAIL;
file->CloseAllFiles(); file->CloseAllFiles();
if (file->CreateMasterFile(en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY, if (file->CreateMasterFile(en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY,
at, st, ap) == FAIL) at, st, ap) == FAIL)
@ -268,7 +276,7 @@ void DataProcessor::CloseFiles() {
} }
void DataProcessor::EndofAcquisition(uint64_t numf) { void DataProcessor::EndofAcquisition(uint64_t numf) {
if (*fileWriteEnable && file->GetFileType() == HDF5) { if (file && file->GetFileType() == HDF5) {
file->EndofAcquisition(numf); file->EndofAcquisition(numf);
} }
} }
@ -312,7 +320,8 @@ void DataProcessor::StopProcessing(char* buf) {
else else
fifo->FreeAddress(buf); fifo->FreeAddress(buf);
file->CloseCurrentFile(); if (file)
file->CloseCurrentFile();
StopRunning(); StopRunning();
#ifdef VERBOSE #ifdef VERBOSE
FILE_LOG(logINFO) << index << ": Processing Completed"; FILE_LOG(logINFO) << index << ": Processing Completed";
@ -355,7 +364,10 @@ void DataProcessor::ProcessAnImage(char* buf) {
} }
if (*fileWriteEnable) // fix x coord that is currently not provided by detector
header->xCoord = xcoord;
if (file)
file->WriteToFile(buf, generalData->imageSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex, nump); file->WriteToFile(buf, generalData->imageSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex, nump);
if (rawDataReadyCallBack) { if (rawDataReadyCallBack) {