mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
slsReciever, slsDetector: configurable number of images per file, removed all the receiver threads from using generalData->maxframesperfile, yet to do: infinite images, bug fix, virtual hdf5 has -1 for all pixels in last image
This commit is contained in:
parent
dcce66ee9f
commit
8b39443197
@ -5636,6 +5636,42 @@ string multiSlsDetector::setFileName(string s) {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setReceiverFramesPerFile(int f) {
|
||||
int ret=-100;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
//return storage values
|
||||
int* iret[thisMultiDetector->numberOfDetectors];
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func1_t<int,int>(&slsDetector::setReceiverFramesPerFile,
|
||||
detectors[idet],f,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
if (ret==-100)
|
||||
ret=*iret[idet];
|
||||
else if (ret!=*iret[idet])
|
||||
ret=-1;
|
||||
delete iret[idet];
|
||||
}else ret=-1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f) {
|
||||
int ret=-100, ret1;
|
||||
|
||||
|
@ -1279,6 +1279,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
string setFileName(string s="");
|
||||
|
||||
/**
|
||||
Sets the max frames per file in receiver
|
||||
@param f max frames per file
|
||||
\returns max frames per file in receiver
|
||||
*/
|
||||
int setReceiverFramesPerFile(int f = -1);
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
|
@ -803,6 +803,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
thisDetector->receiver_zmqport = 0;
|
||||
thisDetector->receiver_upstream = false;
|
||||
thisDetector->receiver_read_freq = 0;
|
||||
thisDetector->receiver_framesPerFile = -1;
|
||||
|
||||
for (int ia=0; ia<MAX_ACTIONS; ++ia) {
|
||||
strcpy(thisDetector->actionScript[ia],"none");
|
||||
@ -938,6 +939,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
if (thisReceiver != NULL)
|
||||
delete thisReceiver;
|
||||
thisReceiver = new receiverInterface(dataSocket);
|
||||
setReceiverFramesPerFile();
|
||||
|
||||
// zmq ports
|
||||
if (posId != -1) {
|
||||
@ -6417,6 +6419,7 @@ string slsDetector::setReceiver(string receiverIP){
|
||||
std::cout << "rx streaming port:" << thisDetector->receiver_zmqport << endl;
|
||||
std::cout << "r_readfreq:" << thisDetector->receiver_read_freq << endl << endl;
|
||||
std::cout << "rx_datastream:" << enableDataStreamingFromReceiver(-1) << endl << endl;
|
||||
std::cout << "r_framesperfile:" << thisDetector->receiver_framesPerFile << endl;
|
||||
/** enable compresison, */
|
||||
#endif
|
||||
if(setDetectorType()!= GENERIC){
|
||||
@ -6431,6 +6434,7 @@ string slsDetector::setReceiver(string receiverIP){
|
||||
setFileName(fileIO::getFileName());
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
setFileFormat(fileIO::getFileFormat());
|
||||
setReceiverFramesPerFile(thisDetector->receiver_framesPerFile);
|
||||
pthread_mutex_lock(&ms);
|
||||
int imask = parentDet->enableWriteToFileMask();
|
||||
pthread_mutex_unlock(&ms);
|
||||
@ -8585,8 +8589,31 @@ string slsDetector::setFileName(string s) {
|
||||
}
|
||||
|
||||
|
||||
int slsDetector::setReceiverFramesPerFile(int f) {
|
||||
int fnum = F_SET_RECEIVER_FRAMES_PER_FILE;
|
||||
int ret = FAIL;
|
||||
int retval = -1;
|
||||
int arg = f;
|
||||
|
||||
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending frames per file to receiver " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret!=FAIL && retval > -1){
|
||||
thisDetector->receiver_framesPerFile = retval;
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
return thisDetector->receiver_framesPerFile;
|
||||
}
|
||||
|
||||
slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f){
|
||||
int fnum=F_SET_RECEIVER_FILE_FORMAT;
|
||||
int ret = FAIL;
|
||||
|
@ -287,7 +287,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
int dataBytesInclGapPixels;
|
||||
/** additional json header */
|
||||
char receiver_additionalJsonHeader[MAX_STR_LENGTH];
|
||||
|
||||
/** frames per file in receiver */
|
||||
int receiver_framesPerFile;
|
||||
|
||||
|
||||
} sharedSlsDetector;
|
||||
@ -1671,6 +1672,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
string setFileName(string s="");
|
||||
|
||||
/**
|
||||
Sets the max frames per file in receiver
|
||||
@param f max frames per file
|
||||
\returns max frames per file in receiver
|
||||
*/
|
||||
int setReceiverFramesPerFile(int f = -1);
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
|
@ -1754,7 +1754,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
|
||||
|
||||
|
||||
|
||||
/* Acquisition actions */
|
||||
|
||||
/*! \page actions Actions
|
||||
@ -2217,6 +2216,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
/*! \page receiver
|
||||
- <b>r_framesperfile</b> sets/gets the frames per file in receiver. 0 means infinite or all frames in a single file. \c Returns \c (int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName="r_framesperfile"; //OK
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver;
|
||||
++i;
|
||||
|
||||
/* pattern generator */
|
||||
|
||||
/*! \page ctb Chiptest board
|
||||
@ -6369,6 +6375,16 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
|
||||
sprintf(answer,"%d",myDet->setReceiverSilentMode());
|
||||
return string(answer);
|
||||
|
||||
} else if(cmd=="r_framesperfile") {
|
||||
if (action==PUT_ACTION){
|
||||
if (sscanf(args[1],"%d",&ival)) {
|
||||
myDet->setReceiverFramesPerFile(ival);
|
||||
} else return string("could not scan max frames per file\n");
|
||||
}
|
||||
char answer[100];
|
||||
memset(answer, 0, 100);
|
||||
sprintf(answer,"%s %d",answer, myDet->setReceiverFramesPerFile());
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
|
||||
@ -6388,6 +6404,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
|
||||
os << "tengiga \t sets system to be configure for 10Gbe if set to 1, else 1Gbe if set to 0" << std::endl;
|
||||
os << "rx_fifodepth [val]\t sets receiver fifo depth to val" << std::endl;
|
||||
os << "r_silent [i]\t sets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets." << std::endl;
|
||||
os << "r_framesperfile \t gets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION){
|
||||
os << "receiver \t returns the status of receiver - can be running or idle" << std::endl;
|
||||
@ -6397,6 +6414,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
|
||||
os << "tengiga \t returns 1 if the system is configured for 10Gbe else 0 for 1Gbe" << std::endl;
|
||||
os << "rx_fifodepth \t returns receiver fifo depth" << std::endl;
|
||||
os << "r_silent \t returns receiver silent mode enable. 1 is silent, 0 not silent." << std::endl;
|
||||
os << "r_framesperfile s\t sets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
@ -793,6 +793,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual string setFileName(string s="")=0;
|
||||
|
||||
/**
|
||||
Sets the max frames per file in receiver
|
||||
@param f max frames per file
|
||||
\returns max frames per file in receiver
|
||||
*/
|
||||
virtual int setReceiverFramesPerFile(int f = -1) = 0;
|
||||
|
||||
|
||||
/**
|
||||
Sets up the file format
|
||||
@param f file format
|
||||
|
@ -21,7 +21,7 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
@ -34,7 +34,7 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
* @param portno pointer to udp port number for logging
|
||||
* @param smode pointer to silent mode
|
||||
*/
|
||||
BinaryFile(int ind, uint32_t maxf,
|
||||
BinaryFile(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode);
|
||||
|
@ -34,6 +34,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param freq pointer to streaming frequency
|
||||
* @param timer pointer to timer if streaming frequency is random
|
||||
* @param dataReadycb pointer to data ready call back function
|
||||
* @param dataModifyReadycb pointer to data ready call back function with modified
|
||||
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
||||
*/
|
||||
DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
@ -154,6 +155,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* Set up file writer object and call backs
|
||||
* @param fwe file write enable
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
* @param findex pointer to file index
|
||||
@ -165,8 +167,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param portno pointer to udp port number
|
||||
* @param g address of GeneralData (Detector Data) pointer
|
||||
*/
|
||||
void 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 = 0);
|
||||
void SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname,
|
||||
char* fpath, uint64_t* findex,
|
||||
bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* portno, GeneralData* g = 0);
|
||||
|
||||
/**
|
||||
* Create New File
|
||||
@ -326,7 +330,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
|
||||
|
||||
|
||||
//acquisition start
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
@ -21,7 +21,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
@ -34,7 +34,7 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param portno pointer to udp port number for logging
|
||||
* @param smode pointer to silent mode
|
||||
*/
|
||||
File(int ind, uint32_t maxf,
|
||||
File(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode);
|
||||
@ -64,6 +64,7 @@ class File : private virtual slsReceiverDefs {
|
||||
/**
|
||||
* Get Member Pointer Values before the object is destroyed
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
* @param findex pointer to file index
|
||||
@ -74,15 +75,10 @@ class File : private virtual slsReceiverDefs {
|
||||
* @param dr pointer to dynamic range
|
||||
* @param portno pointer to dynamic range
|
||||
*/
|
||||
void GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*& findex, bool*& owenable,
|
||||
void GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath,
|
||||
uint64_t*& findex, bool*& owenable,
|
||||
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno);
|
||||
|
||||
/**
|
||||
* Set Max frames per file
|
||||
* @param maxf maximum frames per file
|
||||
*/
|
||||
void SetMaxFramesPerFile(uint32_t maxf);
|
||||
|
||||
/**
|
||||
* Create file
|
||||
* @param fnum current frame index to include in file name
|
||||
@ -172,7 +168,7 @@ class File : private virtual slsReceiverDefs {
|
||||
int index;
|
||||
|
||||
/** Maximum frames per file */
|
||||
uint32_t maxFramesPerFile;
|
||||
uint32_t* maxFramesPerFile;
|
||||
|
||||
/** Master File Name */
|
||||
std::string masterFileName;
|
||||
|
@ -27,7 +27,7 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
* Constructor
|
||||
* creates the File Writer
|
||||
* @param ind self index
|
||||
* @param maxf max frames per file
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param fname pointer to file name prefix
|
||||
* @param fpath pointer to file path
|
||||
@ -42,7 +42,7 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
* @param ny number of pixels in y direction
|
||||
* @param smode pointer to silent mode
|
||||
*/
|
||||
HDF5File(int ind, uint32_t maxf,
|
||||
HDF5File(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
uint32_t nx, uint32_t ny,
|
||||
|
@ -32,10 +32,11 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param dr pointer to dynamic range
|
||||
* @param us pointer to udp socket buffer size
|
||||
* @param as pointer to actual udp socket buffer size
|
||||
* @param fpf pointer to frames per file
|
||||
*/
|
||||
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* us, uint32_t* as);
|
||||
uint32_t* us, uint32_t* as, uint32_t* fpf);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -237,6 +238,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** actual UDP Socket Buffer Size (double due to kernel bookkeeping) */
|
||||
uint32_t* actualUDPSocketBufferSize;
|
||||
|
||||
/** frames per file */
|
||||
uint32_t* framesPerFile;
|
||||
|
||||
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
|
@ -97,6 +97,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
uint64_t getFileIndex() const;
|
||||
|
||||
/**
|
||||
* Get Frames per File
|
||||
* @return Frames per File
|
||||
*/
|
||||
uint32_t getFramesPerFile() const;
|
||||
|
||||
/**
|
||||
* Get Scan Tag
|
||||
* @return scan tag //FIXME: needed? (unsigned integer?)
|
||||
@ -356,6 +362,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void setFileIndex(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Frames per File
|
||||
* @param i Frames per File
|
||||
*/
|
||||
void setFramesPerFile(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set Scan Tag
|
||||
* @param i scan tag //FIXME: needed? (unsigned integer?)
|
||||
@ -739,6 +751,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
char filePath[MAX_STR_LENGTH];
|
||||
/** File Index */
|
||||
uint64_t fileIndex;
|
||||
/** Frames per file */
|
||||
uint32_t framesPerFile;
|
||||
/** Scan Tag */
|
||||
int scanTag;
|
||||
/** File Write enable */
|
||||
|
@ -181,10 +181,16 @@ class UDPInterface {
|
||||
|
||||
/**
|
||||
* Get File Index
|
||||
* @return NULL or file index of acquisition
|
||||
* @return file index of acquisition
|
||||
*/
|
||||
virtual uint64_t getFileIndex() const = 0;
|
||||
|
||||
/**
|
||||
* Get Frames per File
|
||||
* @return Frames per File
|
||||
*/
|
||||
virtual uint32_t getFramesPerFile() const = 0;
|
||||
|
||||
/**
|
||||
* Get Scan Tag
|
||||
* @return scan tag //FIXME: needed? (unsigned integer?)
|
||||
@ -443,6 +449,12 @@ class UDPInterface {
|
||||
*/
|
||||
virtual void setFileIndex(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Frames per File
|
||||
* @param i Frames per File
|
||||
*/
|
||||
virtual void setFramesPerFile(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Scan Tag
|
||||
* @param i scan tag //FIXME: needed? (unsigned integer?)
|
||||
|
@ -35,6 +35,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
|
||||
|
||||
//*** Overloaded Functions called by TCP Interface ***
|
||||
|
||||
/**
|
||||
* Get Total Frames Caught for an entire acquisition (including all scans)
|
||||
* @return total number of frames caught for entire acquisition
|
||||
|
@ -306,7 +306,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** get real udp socket buffer size */
|
||||
int get_real_udp_socket_buffer_size();
|
||||
|
||||
|
||||
/** set frames per file */
|
||||
int set_frames_per_file();
|
||||
|
||||
/** detector type */
|
||||
detectorType myDetectorType;
|
||||
|
@ -66,6 +66,7 @@ enum recFuncs{
|
||||
F_ADDITIONAL_JSON_HEADER, /** < additional json header */
|
||||
F_RECEIVER_UDP_SOCK_BUF_SIZE, /** < UDP socket buffer size */
|
||||
F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, /** < real UDP socket buffer size */
|
||||
F_SET_RECEIVER_FRAMES_PER_FILE, /** < receiver frames per file */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
@ -14,7 +14,7 @@ using namespace std;
|
||||
|
||||
FILE* BinaryFile::masterfd = 0;
|
||||
|
||||
BinaryFile::BinaryFile(int ind, uint32_t maxf,
|
||||
BinaryFile::BinaryFile(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode):
|
||||
@ -34,7 +34,7 @@ BinaryFile::~BinaryFile() {
|
||||
|
||||
void BinaryFile::PrintMembers() {
|
||||
File::PrintMembers();
|
||||
FILE_LOG(logINFO) << "Max Frames Per File: " << maxFramesPerFile;
|
||||
FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
|
||||
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ void BinaryFile::CloseAllFiles() {
|
||||
}
|
||||
|
||||
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
if (numFramesInFile >= maxFramesPerFile) {
|
||||
if (numFramesInFile >= (*maxFramesPerFile)) {
|
||||
CloseCurrentFile();
|
||||
CreateFile(fnum);
|
||||
}
|
||||
|
@ -23,10 +23,12 @@ using namespace std;
|
||||
const string DataProcessor::TypeName = "DataProcessor";
|
||||
|
||||
|
||||
DataProcessor::DataProcessor(int ind, Fifo*& f, fileFormat* ftype, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
DataProcessor::DataProcessor(int ind, 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,
|
||||
uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t,
|
||||
uint8_t, uint8_t,
|
||||
char*, uint32_t, void*),
|
||||
void (*dataModifyReadycb)(uint64_t, uint32_t, uint32_t, uint64_t,
|
||||
uint64_t, uint16_t, uint16_t, uint16_t, uint16_t,
|
||||
@ -179,7 +181,6 @@ void DataProcessor::SetGeneralData(GeneralData* g) {
|
||||
generalData->Print();
|
||||
#endif
|
||||
if (file) {
|
||||
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
||||
if (file->GetFileType() == HDF5) {
|
||||
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
|
||||
}
|
||||
@ -201,16 +202,17 @@ void DataProcessor::SetFileFormat(const fileFormat f) {
|
||||
if (file && file->GetFileType() != f) {
|
||||
//remember the pointer values before they are destroyed
|
||||
int nd[MAX_DIMENSIONS];nd[0] = 0; nd[1] = 0;
|
||||
uint32_t* maxf = 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);
|
||||
file->GetMemberPointerValues(nd, maxf, fname, fpath, findex, owenable, dindex, nunits, nf, dr, port);
|
||||
//create file writer with same pointers
|
||||
SetupFileWriter(fileWriteEnable, nd, fname, fpath, findex, owenable, dindex, nunits, nf, dr, port);
|
||||
SetupFileWriter(fileWriteEnable, nd, maxf, fname, fpath, findex, owenable, dindex, nunits, nf, dr, port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataProcessor::SetupFileWriter(bool fwe, int* nd, char* fname, char* fpath, uint64_t* findex,
|
||||
void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf, char* fname, char* fpath, uint64_t* findex,
|
||||
bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
GeneralData* g)
|
||||
{
|
||||
@ -229,14 +231,14 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, char* fname, char* fpath,
|
||||
switch(*fileFormatType){
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
file = new HDF5File(index, generalData->maxFramesPerFile,
|
||||
file = new HDF5File(index, maxf,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno,
|
||||
generalData->nPixelsX, generalData->nPixelsY, &silentMode);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
file = new BinaryFile(index, generalData->maxFramesPerFile,
|
||||
file = new BinaryFile(index, maxf,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno, &silentMode);
|
||||
break;
|
||||
|
@ -10,7 +10,7 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
File::File(int ind, uint32_t maxf,
|
||||
File::File(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
bool* smode):
|
||||
@ -42,7 +42,7 @@ string File::GetCurrentFileName() {
|
||||
void File::PrintMembers() {
|
||||
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl
|
||||
<< "Index: " << index << endl
|
||||
<< "Max Frames Per File: " << maxFramesPerFile << endl
|
||||
<< "Max Frames Per File: " << *maxFramesPerFile << endl
|
||||
<< "Number of Detectors in x dir: " << numDetX << endl
|
||||
<< "Number of Detectors in y dir: " << numDetY << endl
|
||||
<< "File Name Prefix: " << fileNamePrefix << endl
|
||||
@ -61,11 +61,12 @@ void File::PrintMembers() {
|
||||
}
|
||||
|
||||
|
||||
void File::GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*& findex, bool*& owenable,
|
||||
void File::GetMemberPointerValues(int* nd, uint32_t*& maxf, char*& fname, char*& fpath, uint64_t*& findex, bool*& owenable,
|
||||
int*& dindex, int*& nunits, uint64_t*& nf, uint32_t*& dr, uint32_t*& portno)
|
||||
{
|
||||
nd[0] = numDetX;
|
||||
nd[1] = numDetY;
|
||||
maxf = maxFramesPerFile;
|
||||
fname = fileNamePrefix;
|
||||
fpath = filePath;
|
||||
findex = fileIndex;
|
||||
@ -77,7 +78,4 @@ void File::GetMemberPointerValues(int* nd, char*& fname, char*& fpath, uint64_t*
|
||||
portno = udpPortNumber;
|
||||
}
|
||||
|
||||
void File::SetMaxFramesPerFile(uint32_t maxf) {
|
||||
maxFramesPerFile = maxf;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ hid_t HDF5File::virtualfd = 0;
|
||||
|
||||
|
||||
|
||||
HDF5File::HDF5File(int ind, uint32_t maxf,
|
||||
HDF5File::HDF5File(int ind, uint32_t* maxf,
|
||||
int* nd, char* fname, char* fpath, uint64_t* findex, bool* owenable,
|
||||
int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t* portno,
|
||||
uint32_t nx, uint32_t ny,
|
||||
@ -95,8 +95,7 @@ int HDF5File::CreateFile(uint64_t fnum) {
|
||||
|
||||
//first time
|
||||
if(!fnum) UpdateDataType();
|
||||
|
||||
uint64_t framestosave = ((*numImages - fnum) > maxFramesPerFile) ? maxFramesPerFile : (*numImages-fnum);
|
||||
uint64_t framestosave = ((*numImages - fnum) > (*maxFramesPerFile)) ? (*maxFramesPerFile) : (*numImages-fnum);
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
|
||||
fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
@ -137,7 +136,7 @@ void HDF5File::CloseAllFiles() {
|
||||
|
||||
|
||||
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
if (numFramesInFile >= maxFramesPerFile) {
|
||||
if (numFramesInFile >= (*maxFramesPerFile)) {
|
||||
CloseCurrentFile();
|
||||
CreateFile(fnum);
|
||||
}
|
||||
@ -145,12 +144,12 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
numActualPacketsInFile += nump;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
|
||||
fnum%maxFramesPerFile, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
fnum%(*maxFramesPerFile), nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
dataspace, dataset, datatype) == OK) {
|
||||
sls_detector_header* header = (sls_detector_header*) (buffer);
|
||||
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
|
||||
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
fnum%maxFramesPerFile,
|
||||
fnum%(*maxFramesPerFile),
|
||||
dataset_para, header) == OK) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return OK;
|
||||
@ -220,7 +219,7 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
virtualfd, masterFileName,
|
||||
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
|
||||
*detIndex, *numUnitsPerDetector,
|
||||
maxFramesPerFile, numf+1,
|
||||
*maxFramesPerFile, numf+1,
|
||||
"data", datatype,
|
||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
HDF5_WRITER_VERSION);
|
||||
|
@ -21,7 +21,7 @@ const string Listener::TypeName = "Listener";
|
||||
|
||||
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
uint32_t* portno, char* e, int* act, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* us, uint32_t* as) :
|
||||
uint32_t* us, uint32_t* as, uint32_t* fpf) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
generalData(0),
|
||||
@ -34,6 +34,9 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
activated(act),
|
||||
numImages(nf),
|
||||
dynamicRange(dr),
|
||||
udpSocketBufferSize(us),
|
||||
actualUDPSocketBufferSize(as),
|
||||
framesPerFile(fpf),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -45,9 +48,9 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
carryOverPacket(0),
|
||||
listeningPacket(0),
|
||||
udpSocketAlive(0),
|
||||
silentMode(false),
|
||||
udpSocketBufferSize(us),
|
||||
actualUDPSocketBufferSize(as)
|
||||
numPacketsStatistic(0),
|
||||
numFramesStatistic(0),
|
||||
silentMode(false)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw std::exception();
|
||||
@ -335,7 +338,7 @@ void Listener::ThreadExecution() {
|
||||
//Statistics
|
||||
if(!silentMode) {
|
||||
numFramesStatistic++;
|
||||
if (numFramesStatistic >= generalData->maxFramesPerFile)
|
||||
if (numFramesStatistic >= *framesPerFile)
|
||||
PrintFifoStatistics();
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
strcpy(fileName,"run");
|
||||
strcpy(filePath,"");
|
||||
fileIndex = 0;
|
||||
framesPerFile = 0;
|
||||
scanTag = 0;
|
||||
fileWriteEnable = true;
|
||||
overwriteEnable = true;
|
||||
@ -174,6 +175,11 @@ uint64_t UDPBaseImplementation::getFileIndex() const{
|
||||
return fileIndex;
|
||||
}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFramesPerFile() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return framesPerFile;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::getScanTag() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return scanTag;
|
||||
@ -438,6 +444,13 @@ void UDPBaseImplementation::setFileIndex(const uint64_t i){
|
||||
FILE_LOG(logINFO) << "File Index: " << fileIndex;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFramesPerFile(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
framesPerFile = i;
|
||||
FILE_LOG(logINFO) << "Frames per file: " << framesPerFile;
|
||||
}
|
||||
|
||||
//FIXME: needed?
|
||||
void UDPBaseImplementation::setScanTag(const int i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
@ -112,6 +112,7 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
|
||||
if (gapPixelsEnable != b) {
|
||||
gapPixelsEnable = b;
|
||||
@ -151,12 +152,13 @@ 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,
|
||||
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
|
||||
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet,
|
||||
&framesPerFile, fileName, filePath, &fileIndex, &overwriteEnable,
|
||||
&detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i],
|
||||
generalData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,6 +183,8 @@ int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
||||
generalData = new ShortGotthardData();
|
||||
else
|
||||
generalData = new GotthardData();
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
|
||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
@ -352,6 +356,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
numThreads = generalData->threadsPerReceiver;
|
||||
fifoDepth = generalData->defaultFifoDepth;
|
||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
|
||||
//local network parameters
|
||||
SetLocalNetworkParameters();
|
||||
@ -369,7 +374,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
try {
|
||||
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
||||
&udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange,
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize);
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile);
|
||||
listener.push_back(l);
|
||||
|
||||
DataProcessor* p = new DataProcessor(i, fifo[i], &fileFormatType,
|
||||
@ -409,12 +414,13 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
|
||||
|
||||
void UDPStandardImplementation::setDetectorPositionId(const int i){
|
||||
|
||||
detID = i;
|
||||
FILE_LOG(logINFO) << "Detector Position Id:" << detID;
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, fileName, filePath, &fileIndex,
|
||||
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData);
|
||||
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet,
|
||||
&framesPerFile, fileName, filePath, &fileIndex, &overwriteEnable,
|
||||
&detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i],
|
||||
generalData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,6 +296,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_ADDITIONAL_JSON_HEADER: return "F_ADDITIONAL_JSON_HEADER";
|
||||
case F_RECEIVER_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_UDP_SOCK_BUF_SIZE";
|
||||
case F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE: return "F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE";
|
||||
case F_SET_RECEIVER_FRAMES_PER_FILE:return "F_SET_RECEIVER_FRAMES_PER_FILE";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -348,6 +349,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_ADDITIONAL_JSON_HEADER] = &slsReceiverTCPIPInterface::set_additional_json_header;
|
||||
flist[F_RECEIVER_UDP_SOCK_BUF_SIZE] = &slsReceiverTCPIPInterface::set_udp_socket_buffer_size;
|
||||
flist[F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE]= &slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size;
|
||||
flist[F_SET_RECEIVER_FRAMES_PER_FILE] = &slsReceiverTCPIPInterface::set_frames_per_file;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -2704,3 +2706,55 @@ int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_frames_per_file() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int index = -1;
|
||||
int retval = -1;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
// execute action
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (receiverBase == NULL)
|
||||
invalidReceiverObject();
|
||||
else {
|
||||
// set
|
||||
if(index >= 0) {
|
||||
if (mySock->differentClients && lockStatus)
|
||||
receiverlocked();
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setFramesPerFile(index);
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval=receiverBase->getFramesPerFile();
|
||||
if(index >= 0 && retval != index) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set frames per file\n");
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "frames per file:" << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user