fixed file write enable bug from the last patch

This commit is contained in:
Dhanya Maliakal 2017-10-18 12:29:46 +02:00
parent d30a839eff
commit 75b94e6614
4 changed files with 37 additions and 14 deletions

View File

@ -26,14 +26,14 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors * Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
* @param f address of Fifo pointer * @param f address of Fifo pointer
* @param ftype pointer to file format type * @param ftype pointer to file format type
* @param fwenable pointer to file writer enable * @param fwenable file writer enable
* @param dsEnable pointer to data stream enable * @param dsEnable pointer to data stream enable
* @param freq pointer to streaming frequency * @param freq pointer to streaming frequency
* @param timer pointer to timer if streaming frequency is random * @param timer pointer to timer if streaming frequency is random
* @param dataReadycb pointer to data ready call back function * @param dataReadycb pointer to data ready call back function
* @param pDataReadycb pointer to arguments of data ready call back function * @param pDataReadycb pointer to arguments of data ready call back function
*/ */
DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable, DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable,
uint32_t* freq, uint32_t* timer, 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, 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*), char*, uint32_t, void*),
@ -156,6 +156,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** /**
* Set up file writer object and call backs * Set up file writer object and call backs
* @param fwe file write enable
* @param nd pointer to number of detectors in each dimension * @param nd pointer to number of detectors in each dimension
* @param fname pointer to file name prefix * @param fname pointer to file name prefix
* @param fpath pointer to file path * @param fpath pointer to file path
@ -169,7 +170,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param portno pointer to udp port number * @param portno pointer to udp port number
* @param g address of GeneralData (Detector Data) pointer * @param g address of GeneralData (Detector Data) pointer
*/ */
void SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t* findex, void 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 = 0); bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno, GeneralData* g = 0);
@ -297,7 +298,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
fileFormat* fileFormatType; fileFormat* fileFormatType;
/** File Write Enable */ /** File Write Enable */
bool* fileWriteEnable; bool fileWriteEnable;
/** Pointer to Streaming frequency, if 0, sending random images with a timer */ /** Pointer to Streaming frequency, if 0, sending random images with a timer */
uint32_t* streamingFrequency; uint32_t* streamingFrequency;

View File

@ -59,6 +59,12 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
*/ */
void setFileFormat(slsReceiverDefs::fileFormat f); void setFileFormat(slsReceiverDefs::fileFormat f);
/**
* Set File Write Enable
* @param b true for file write enable, else false
*/
void setFileWriteEnable(const bool b);
/** /**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard) * Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* @param i index of adc enabled, else -1 if all enabled * @param i index of adc enabled, else -1 if all enabled

View File

@ -31,7 +31,7 @@ uint64_t DataProcessor::RunningMask(0x0);
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
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, 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, 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*), char*, uint32_t, void*),
@ -216,26 +216,27 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; uint32_t* dr = 0; uint32_t* port = 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); file->GetMemberPointerValues(nd, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr, port);
//create file writer with same pointers //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(bool fwe, int* nd, char* fname, char* fpath, uint64_t* findex,
void DataProcessor::SetupFileWriter(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, bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
GeneralData* g) GeneralData* g)
{ {
fileWriteEnable = fwe;
if (g) if (g)
generalData = g; generalData = g;
// fix xcoord as detector is not providing it right now // fix xcoord as detector is not providing it right now
xcoord = ((NumberofDataProcessors > (*nunits)) ? index : ((*dindex) * (*nunits)) + index); xcoord = ((NumberofDataProcessors > (*nunits)) ? index : ((*dindex) * (*nunits)) + index);
if (file)
delete file;
if (*fileWriteEnable) { if (file) {
delete file; file = 0;
}
if (fileWriteEnable) {
switch(*fileFormatType){ switch(*fileFormatType){
#ifdef HDF5C #ifdef HDF5C
case HDF5: case HDF5:

View File

@ -129,6 +129,21 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
} }
void UDPStandardImplementation::setFileWriteEnable(const bool b){
if (fileWriteEnable != b){
fileWriteEnable = b;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, fileName, filePath, &fileIndex, &frameIndexEnable,
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
}
}
FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable);
}
int UDPStandardImplementation::setShortFrameEnable(const int i) { int UDPStandardImplementation::setShortFrameEnable(const int i) {
if (myDetectorType != GOTTHARD) { if (myDetectorType != GOTTHARD) {
@ -315,7 +330,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
for ( int i=0; i < numThreads; ++i ) { for ( int i=0; i < numThreads; ++i ) {
listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange)); listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange));
dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType, dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType,
&fileWriteEnable, &dataStreamEnable, &frameToGuiFrequency, &frameToGuiTimerinMS, fileWriteEnable, &dataStreamEnable, &frameToGuiFrequency, &frameToGuiTimerinMS,
rawDataReadyCallBack,pRawDataReady)); rawDataReadyCallBack,pRawDataReady));
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) { if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")"; FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")";
@ -350,7 +365,7 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
detID = i; detID = i;
FILE_LOG(logINFO) << "Detector Position Id:" << detID; FILE_LOG(logINFO) << "Detector Position Id:" << detID;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter((int*)numDet, fileName, filePath, &fileIndex, &frameIndexEnable, dataProcessor[i]->SetupFileWriter( fileWriteEnable, (int*)numDet, fileName, filePath, &fileIndex, &frameIndexEnable,
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData); &overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
} }
} }