merge conflict fixed with developer(patches for file write disable, xcoord)

This commit is contained in:
Dhanya Maliakal
2017-10-19 15:35:34 +02:00
6 changed files with 66 additions and 28 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, bool* gpEnable, uint32_t* dr,
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*),
@ -50,8 +50,9 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
dynamicRange(dr),
streamingFrequency(freq),
streamingTimerInMs(timer),
tempBuffer(0),
currentFreqCount(0),
tempBuffer(0),
xcoord(0),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
@ -226,30 +227,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* 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, owenable, dindex, nunits, nf, dr, port);
//create file writer with same pointers
SetupFileWriter(nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, port);
SetupFileWriter(fileWriteEnable, nd, fname, fpath, findex, 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* 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,
@ -263,11 +269,14 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
nd, fname, fpath, findex, 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)
@ -284,7 +293,7 @@ void DataProcessor::CloseFiles() {
}
void DataProcessor::EndofAcquisition(uint64_t numf) {
if (*fileWriteEnable && file->GetFileType() == HDF5) {
if (file && file->GetFileType() == HDF5) {
file->EndofAcquisition(numf);
}
}
@ -328,7 +337,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";
@ -373,7 +383,10 @@ void DataProcessor::ProcessAnImage(char* buf) {
if (*gapPixelsEnable && (*dynamicRange!=4))
InsertGapPixels(buf + sizeof(sls_detector_header), *dynamicRange);
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) {