sending and writing subexptime in the receiver files, adding 0x in front of all numbers printed in command line which is hexa

This commit is contained in:
Dhanya Maliakal 2017-08-10 17:25:28 +02:00
parent 11943c4b5c
commit ad3e3ce255
12 changed files with 76 additions and 168 deletions

View File

@ -66,11 +66,12 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
* @param nx number of pixels in x direction * @param nx number of pixels in x direction
* @param ny number of pixels in y direction * @param ny number of pixels in y direction
* @param at acquisition time * @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period * @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int CreateMasterFile(bool en, uint32_t size, int CreateMasterFile(bool en, uint32_t size,
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap); uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap);
/** /**
* Close Current File * Close Current File

View File

@ -108,12 +108,13 @@ class BinaryFileStatic {
* @param nf number of images * @param nf number of images
* @param acquisitionTime acquisition time * @param acquisitionTime acquisition time
* @param acquisitionPeriod acquisition period * @param acquisitionPeriod acquisition period
* @param subexposuretime sub exposure time
* @param version version of software for binary writing * @param version version of software for binary writing
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateMasterDataFile(FILE*& fd, string fname, bool owenable, static int CreateMasterDataFile(FILE*& fd, string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size, uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf, uint32_t dr, bool tenE, uint32_t size, uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
uint64_t acquisitionTime, uint64_t acquisitionPeriod, double version) uint64_t acquisitionTime, uint64_t subexposuretime, uint64_t acquisitionPeriod, double version)
{ {
if(!owenable){ if(!owenable){
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
@ -137,6 +138,7 @@ class BinaryFileStatic {
"y : %d pixels\n" "y : %d pixels\n"
"Total Frames : %lld\n" "Total Frames : %lld\n"
"Exptime (ns) : %lld\n" "Exptime (ns) : %lld\n"
"SubExptime (ns) : %lld\n"
"Period (ns) : %lld\n" "Period (ns) : %lld\n"
"Timestamp : %s\n\n" "Timestamp : %s\n\n"
@ -163,6 +165,7 @@ class BinaryFileStatic {
nPixelsY, nPixelsY,
(long long int)nf, (long long int)nf,
(long long int)acquisitionTime, (long long int)acquisitionTime,
(long long int)subexposuretime,
(long long int)acquisitionPeriod, (long long int)acquisitionPeriod,
ctime(&t)); ctime(&t));
if (strlen(message) > MAX_STR_LENGTH) { if (strlen(message) > MAX_STR_LENGTH) {

View File

@ -175,10 +175,11 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param en ten giga enable * @param en ten giga enable
* @param nf number of frames * @param nf number of frames
* @param at acquisition time * @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period * @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t ap); int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, uint64_t ap);
/** /**
* Closes files * Closes files

View File

@ -144,11 +144,12 @@ class File : private virtual slsReceiverDefs {
* @param nx number of pixels in x direction * @param nx number of pixels in x direction
* @param ny number of pixels in y direction * @param ny number of pixels in y direction
* @param at acquisition time * @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period * @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
virtual int CreateMasterFile(bool en, uint32_t size, virtual int CreateMasterFile(bool en, uint32_t size,
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) { uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap) {
bprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n"); bprintf(RED,"This is a generic function CreateMasterFile that should be overloaded by a derived class\n");
return OK; return OK;
} }

View File

@ -200,6 +200,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/ */
uint64_t getAcquisitionTime() const; uint64_t getAcquisitionTime() const;
/**
* Get Sub Exposure Time
* @return Sub Exposure Time
*/
uint64_t getSubExpTime() const;
/* /*
* Get Number of Frames expected by receiver from detector * Get Number of Frames expected by receiver from detector
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)
@ -396,6 +402,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/ */
int setAcquisitionTime(const uint64_t i); int setAcquisitionTime(const uint64_t i);
/**
* Set Sub Exposure Time
* @param i Sub Exposure Time
* @return OK or FAIL
*/
void setSubExpTime(const uint64_t i);
/** /**
* Set Number of Frames expected by receiver from detector * Set Number of Frames expected by receiver from detector
* The data receiver status will change from running to idle when it gets this number of frames * The data receiver status will change from running to idle when it gets this number of frames
@ -581,6 +594,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
uint64_t acquisitionPeriod; uint64_t acquisitionPeriod;
/** Acquisition Time */ /** Acquisition Time */
uint64_t acquisitionTime; uint64_t acquisitionTime;
/** Sub Exposure Time */
uint64_t subExpTime;
/** Frame Number */ /** Frame Number */
uint64_t numberOfFrames; uint64_t numberOfFrames;
/** Dynamic Range */ /** Dynamic Range */

View File

@ -43,6 +43,7 @@ class UDPInterface {
* -setAcquisitionPeriod * -setAcquisitionPeriod
* -setNumberOfFrames * -setNumberOfFrames
* -setAcquisitionTime * -setAcquisitionTime
* -setSubExpTime
* -setDynamicRange * -setDynamicRange
* -setFlippedData * -setFlippedData
* -setActivate * -setActivate
@ -284,6 +285,12 @@ class UDPInterface {
*/ */
virtual uint64_t getAcquisitionTime() const = 0; virtual uint64_t getAcquisitionTime() const = 0;
/**
* Get Sub Exposure Time
* @return Sub Exposure Time
*/
virtual uint64_t getSubExpTime() const = 0;
/* /*
* Get Number of Frames expected by receiver from detector * Get Number of Frames expected by receiver from detector
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)
@ -476,6 +483,13 @@ class UDPInterface {
*/ */
virtual int setAcquisitionTime(const uint64_t i) = 0; virtual int setAcquisitionTime(const uint64_t i) = 0;
/**
* Set Sub Exposure Time
* @param i Sub Exposure Time
* @return OK or FAIL
*/
virtual void setSubExpTime(const uint64_t i) = 0;
/** /**
* Set Number of Frames expected by receiver from detector * Set Number of Frames expected by receiver from detector
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented) * The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)

View File

@ -80,28 +80,6 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
*/ */
int setDataStreamEnable(const bool enable); int setDataStreamEnable(const bool enable);
/**
* Set Acquisition Period
* @param i acquisition period
* @return OK or FAIL
*/
int setAcquisitionPeriod(const uint64_t i);
/**
* Set Acquisition Time
* @param i acquisition time
* @return OK or FAIL
*/
int setAcquisitionTime(const uint64_t i);
/**
* Set Number of Frames expected by receiver from detector
* The data receiver status will change from running to idle when it gets this number of frames
* @param i number of frames expected
* @return OK or FAIL
*/
int setNumberOfFrames(const uint64_t i);
/** /**
* Set Dynamic Range or Number of Bits Per Pixel * Set Dynamic Range or Number of Bits Per Pixel
* @param i dynamic range that is 4, 8, 16 or 32 * @param i dynamic range that is 4, 8, 16 or 32

View File

@ -101,7 +101,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
int BinaryFile::CreateMasterFile(bool en, uint32_t size, int BinaryFile::CreateMasterFile(bool en, uint32_t size,
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) { uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap) {
//beginning of every acquisition //beginning of every acquisition
numFramesInFile = 0; numFramesInFile = 0;
numActualPacketsInFile = 0; numActualPacketsInFile = 0;
@ -111,7 +111,7 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
FILE_LOG(logINFO) << "Master File: " << masterFileName; FILE_LOG(logINFO) << "Master File: " << masterFileName;
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, *overWriteEnable, return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, *overWriteEnable,
*dynamicRange, en, size, nx, ny, *numImages, *dynamicRange, en, size, nx, ny, *numImages,
at, ap, BINARY_WRITER_VERSION); at, st, ap, BINARY_WRITER_VERSION);
} }
return OK; return OK;
} }

View File

@ -247,10 +247,10 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
} }
// only the first file // only the first file
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t ap) { int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, uint64_t ap) {
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, ap) == FAIL) at, st, ap) == FAIL)
return FAIL; return FAIL;
if (file->CreateFile(currentFrameIndex) == FAIL) if (file->CreateFile(currentFrameIndex) == FAIL)
return FAIL; return FAIL;

View File

@ -45,6 +45,7 @@ void UDPBaseImplementation::initializeMembers(){
strcpy(detHostname,""); strcpy(detHostname,"");
acquisitionPeriod = 0; acquisitionPeriod = 0;
acquisitionTime = 0; acquisitionTime = 0;
subExpTime = 0;
numberOfFrames = 0; numberOfFrames = 0;
dynamicRange = 16; dynamicRange = 16;
tengigaEnable = false; tengigaEnable = false;
@ -192,6 +193,8 @@ uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ FILE_LOG(logDEBUG)
uint64_t UDPBaseImplementation::getAcquisitionTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionTime;} uint64_t UDPBaseImplementation::getAcquisitionTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionTime;}
uint64_t UDPBaseImplementation::getSubExpTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return subExpTime;}
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;} uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;}
uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dynamicRange;} uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dynamicRange;}
@ -415,6 +418,13 @@ int UDPBaseImplementation::setAcquisitionTime(const uint64_t i){
return OK; return OK;
} }
void UDPBaseImplementation::setSubExpTime(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
subExpTime = i;
FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subExpTime/(1E9) << "s";
}
int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){ int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";

View File

@ -223,66 +223,6 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {\
} }
int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
if (acquisitionPeriod != i) {
acquisitionPeriod = i;
/*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) {
case GOTTHARD:
case PROPIX:
if (SetupFifoStructure() == FAIL)
return FAIL;
break;
default:
break;
}*/
}
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s";
return OK;
}
int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
if (acquisitionTime != i) {
acquisitionTime = i;
/*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) {
case GOTTHARD:
case PROPIX:
if (SetupFifoStructure() == FAIL)
return FAIL;
break;
default:
break;
}*/
}
FILE_LOG (logINFO) << "Acquisition Period: " << (double)acquisitionTime/(1E9) << "s";
return OK;
}
int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
if (numberOfFrames != i) {
numberOfFrames = i;
/*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
switch (myDetectorType) {
case GOTTHARD:
case PROPIX:
if (SetupFifoStructure() == FAIL)
return FAIL;
break;
default:
break;
}*/
}
FILE_LOG (logINFO) << "Number of Frames:" << numberOfFrames;
return OK;
}
int UDPStandardImplementation::setDynamicRange(const uint32_t i) { int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
if (dynamicRange != i) { if (dynamicRange != i) {
dynamicRange = i; dynamicRange = i;
@ -645,35 +585,6 @@ void UDPStandardImplementation::SetThreadPriorities() {
return; return;
} }
} }
/*
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
if ((*it)->SetThreadPriority(PROCESSOR_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "No root privileges to prioritize writer threads";
return;
}
}
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
if ((*it)->SetThreadPriority(STREAMER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "No root privileges to prioritize streamer threads";
return;
}
}
struct sched_param tcp_param;
tcp_param.sched_priority = TCP_PRIORITY;
if (pthread_setschedparam(pthread_self(),5 , &tcp_param) != EPERM) {
FILE_LOG(logWARNING) << "No root privileges to prioritize tcp threads";
return;
}
ostringstream osfn;
osfn << "Priorities set - "
"TCP:"<< TCP_PRIORITY <<
", Listener:" << LISTENER_PRIORITY <<
", Processor:" << PROCESSOR_PRIORITY;
if (dataStreamEnable)
osfn << ", Streamer:" << STREAMER_PRIORITY;
*/
ostringstream osfn; ostringstream osfn;
osfn << "Priorities set - " osfn << "Priorities set - "
"Listener:" << LISTENER_PRIORITY; "Listener:" << LISTENER_PRIORITY;
@ -683,38 +594,6 @@ void UDPStandardImplementation::SetThreadPriorities() {
int UDPStandardImplementation::SetupFifoStructure() { int UDPStandardImplementation::SetupFifoStructure() {
//recalculate number of jobs & fifodepth, return if no change
/* if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) {
int oldnumberofjobs = numberofJobs;
//listen to only n jobs at a time
if (frameToGuiFrequency)
numberofJobs = frameToGuiFrequency;
else { NOT YET
//random freq depends on acquisition period/time (calculate upto 100ms/period)
int i = ((acquisitionPeriod > 0) ?
(SAMPLE_TIME_IN_NS/acquisitionPeriod):
((acquisitionTime > 0) ? (SAMPLE_TIME_IN_NS/acquisitionTime) : SAMPLE_TIME_IN_NS));
//must be > 0 and < max jobs
numberofJobs = ((i < 1) ? 1 : ((i > MAX_JOBS_PER_THREAD) ? MAX_JOBS_PER_THREAD : i));
}
FILE_LOG (logINFO) << "Number of Jobs Per Thread:" << numberofJobs;
uint32_t oldfifodepth = fifoDepth;
//reduce fifo depth if numberofJobsPerBuffer > 1 (to save memory)
if (numberofJobs > 1) {
fifoDepth = ((fifoDepth % numberofJobs) ?
((fifoDepth/numberofJobs)+1) : //if not directly divisible
(fifoDepth/numberofJobs));
}
FILE_LOG (logINFO) << "Total Fifo Depth Recalculated:" << fifoDepth;
//no change, return
if ((oldnumberofjobs == numberofJobs) && (oldfifodepth == fifoDepth))
return OK;
}else*/
numberofJobs = 1; numberofJobs = 1;
@ -787,7 +666,7 @@ int UDPStandardImplementation::SetupWriter() {
bool error = false; bool error = false;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) for (unsigned int i = 0; i < dataProcessor.size(); ++i)
if (dataProcessor[i]->CreateNewFile(tengigaEnable, if (dataProcessor[i]->CreateNewFile(tengigaEnable,
numberOfFrames, acquisitionTime, acquisitionPeriod) == FAIL) { numberOfFrames, acquisitionTime, subExpTime, acquisitionPeriod) == FAIL) {
error = true; error = true;
break; break;
} }

View File

@ -999,6 +999,9 @@ int slsReceiverTCPIPInterface::set_timer() {
case CYCLES_NUMBER: case CYCLES_NUMBER:
receiverBase->setNumberOfFrames(index[1]); receiverBase->setNumberOfFrames(index[1]);
break; break;
case SUBFRAME_ACQUISITION_TIME:
receiverBase->setSubExpTime(index[1]);
break;
default: default:
ret = FAIL; ret = FAIL;
sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]);
@ -1018,7 +1021,15 @@ int slsReceiverTCPIPInterface::set_timer() {
case CYCLES_NUMBER: case CYCLES_NUMBER:
retval=receiverBase->getNumberOfFrames(); retval=receiverBase->getNumberOfFrames();
break; break;
case SUBFRAME_ACQUISITION_TIME:
retval=receiverBase->getSubExpTime();
break;
default:
ret = FAIL;
sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]);
FILE_LOG(logERROR) << "Warning: " << mess;
} }
// check // check
if (ret == OK && index[1] >= 0 && retval != index[1]) { if (ret == OK && index[1] >= 0 && retval != index[1]) {
ret = FAIL; ret = FAIL;
@ -1028,12 +1039,7 @@ int slsReceiverTCPIPInterface::set_timer() {
} }
#endif #endif
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
if (index[0] == ACQUISITION_TIME) FILE_LOG(logDEBUG1) << getTimerType(index[0]) << ":" << retval;
FILE_LOG(logDEBUG1) << "acquisition time:" << retval;
else if(index[0] == FRAME_PERIOD)
FILE_LOG(logDEBUG1) << "acquisition period:" << retval
else
FILE_LOG(logDEBUG1) << "frame number:" << retval;
#endif #endif
if (ret == OK && mySock->differentClients) if (ret == OK && mySock->differentClients)