merge from 3.0 hotfixes done

This commit is contained in:
Dhanya Maliakal
2017-10-18 17:39:19 +02:00
6 changed files with 65 additions and 26 deletions

View File

@@ -33,7 +33,7 @@ pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
bool DataProcessor::SilentMode(false);
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable,
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*),
@@ -49,6 +49,7 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
streamingFrequency(freq),
streamingTimerInMs(timer),
currentFreqCount(0),
xcoord(0),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
@@ -214,30 +215,35 @@ int DataProcessor::SetThreadPriority(int priority) {
void DataProcessor::SetFileFormat(const fileFormat f) {
if (file->GetFileType() != f) {
if (file && file->GetFileType() != f) {
//remember the pointer values before they are destroyed
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0;
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; uint32_t* dr = 0; uint32_t* port = 0;
file->GetMemberPointerValues(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
//create file writer with same pointers
SetupFileWriter(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
SetupFileWriter(fileWriteEnable, nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
}
}
void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t* findex,
void DataProcessor::SetupFileWriter(bool fwe, int* nd, char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
GeneralData* g)
{
fileWriteEnable = fwe;
if (g)
generalData = g;
// fix xcoord as detector is not providing it right now
xcoord = ((NumberofDataProcessors > (*nunits)) ? index : ((*dindex) * (*nunits)) + index);
if (file)
delete file;
switch(*fileFormatType){
if (file) {
delete file; file = 0;
}
if (fileWriteEnable) {
switch(*fileFormatType){
#ifdef HDF5C
case HDF5:
file = new HDF5File(index, generalData->maxFramesPerFile, &generalData->packetsPerFrame,
@@ -253,11 +259,14 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
frindexenable, owenable,
dindex, nunits, nf, dr, portno, &SilentMode);
break;
}
}
}
// only the first file
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, uint64_t ap) {
if (file == NULL)
return FAIL;
file->CloseAllFiles();
if (file->CreateMasterFile(en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY,
at, st, ap) == FAIL)
@@ -274,7 +283,7 @@ void DataProcessor::CloseFiles() {
}
void DataProcessor::EndofAcquisition(uint64_t numf) {
if (*fileWriteEnable && file->GetFileType() == HDF5) {
if (file && file->GetFileType() == HDF5) {
file->EndofAcquisition(numf);
}
}
@@ -318,7 +327,8 @@ void DataProcessor::StopProcessing(char* buf) {
else
fifo->FreeAddress(buf);
file->CloseCurrentFile();
if (file)
file->CloseCurrentFile();
StopRunning();
#ifdef VERBOSE
FILE_LOG(logINFO) << index << ": Processing Completed";
@@ -361,7 +371,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);
if (rawDataReadyCallBack) {