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 ny number of pixels in y direction
* @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period
* @returns OK or FAIL
*/
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

View File

@ -108,12 +108,13 @@ class BinaryFileStatic {
* @param nf number of images
* @param acquisitionTime acquisition time
* @param acquisitionPeriod acquisition period
* @param subexposuretime sub exposure time
* @param version version of software for binary writing
* @returns 0 for success and 1 for fail
*/
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,
uint64_t acquisitionTime, uint64_t acquisitionPeriod, double version)
uint64_t acquisitionTime, uint64_t subexposuretime, uint64_t acquisitionPeriod, double version)
{
if(!owenable){
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
@ -129,16 +130,17 @@ class BinaryFileStatic {
time_t t = time(0);
char message[MAX_STR_LENGTH];
sprintf(message,
"Version : %.1f\n"
"Dynamic Range : %d\n"
"Ten Giga : %d\n"
"Image Size : %d bytes\n"
"x : %d pixels\n"
"y : %d pixels\n"
"Total Frames : %lld\n"
"Exptime (ns) : %lld\n"
"Period (ns) : %lld\n"
"Timestamp : %s\n\n"
"Version : %.1f\n"
"Dynamic Range : %d\n"
"Ten Giga : %d\n"
"Image Size : %d bytes\n"
"x : %d pixels\n"
"y : %d pixels\n"
"Total Frames : %lld\n"
"Exptime (ns) : %lld\n"
"SubExptime (ns) : %lld\n"
"Period (ns) : %lld\n"
"Timestamp : %s\n\n"
"#Frame Header\n"
"Frame Number : 8 bytes\n"
@ -163,6 +165,7 @@ class BinaryFileStatic {
nPixelsY,
(long long int)nf,
(long long int)acquisitionTime,
(long long int)subexposuretime,
(long long int)acquisitionPeriod,
ctime(&t));
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 nf number of frames
* @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period
* @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

View File

@ -144,11 +144,12 @@ class File : private virtual slsReceiverDefs {
* @param nx number of pixels in x direction
* @param ny number of pixels in y direction
* @param at acquisition time
* @param at sub exposure time
* @param ap acquisition period
* @returns OK or FAIL
*/
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");
return OK;
}

View File

@ -200,6 +200,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/
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
* 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);
/**
* 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
* 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;
/** Acquisition Time */
uint64_t acquisitionTime;
/** Sub Exposure Time */
uint64_t subExpTime;
/** Frame Number */
uint64_t numberOfFrames;
/** Dynamic Range */

View File

@ -43,6 +43,7 @@ class UDPInterface {
* -setAcquisitionPeriod
* -setNumberOfFrames
* -setAcquisitionTime
* -setSubExpTime
* -setDynamicRange
* -setFlippedData
* -setActivate
@ -284,6 +285,12 @@ class UDPInterface {
*/
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
* 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;
/**
* 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
* 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);
/**
* 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
* @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,
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
numFramesInFile = 0;
numActualPacketsInFile = 0;
@ -111,7 +111,7 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
FILE_LOG(logINFO) << "Master File: " << masterFileName;
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, *overWriteEnable,
*dynamicRange, en, size, nx, ny, *numImages,
at, ap, BINARY_WRITER_VERSION);
at, st, ap, BINARY_WRITER_VERSION);
}
return OK;
}

View File

@ -247,10 +247,10 @@ void DataProcessor::SetupFileWriter(int* nd, char* fname, char* fpath, uint64_t*
}
// 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();
if (file->CreateMasterFile(en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY,
at, ap) == FAIL)
at, st, ap) == FAIL)
return FAIL;
if (file->CreateFile(currentFrameIndex) == FAIL)
return FAIL;

View File

@ -45,6 +45,7 @@ void UDPBaseImplementation::initializeMembers(){
strcpy(detHostname,"");
acquisitionPeriod = 0;
acquisitionTime = 0;
subExpTime = 0;
numberOfFrames = 0;
dynamicRange = 16;
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::getSubExpTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return subExpTime;}
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;}
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;
}
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){
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) {
if (dynamicRange != i) {
dynamicRange = i;
@ -645,35 +585,6 @@ void UDPStandardImplementation::SetThreadPriorities() {
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;
osfn << "Priorities set - "
"Listener:" << LISTENER_PRIORITY;
@ -683,38 +594,6 @@ void UDPStandardImplementation::SetThreadPriorities() {
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;
@ -787,7 +666,7 @@ int UDPStandardImplementation::SetupWriter() {
bool error = false;
for (unsigned int i = 0; i < dataProcessor.size(); ++i)
if (dataProcessor[i]->CreateNewFile(tengigaEnable,
numberOfFrames, acquisitionTime, acquisitionPeriod) == FAIL) {
numberOfFrames, acquisitionTime, subExpTime, acquisitionPeriod) == FAIL) {
error = true;
break;
}

View File

@ -999,6 +999,9 @@ int slsReceiverTCPIPInterface::set_timer() {
case CYCLES_NUMBER:
receiverBase->setNumberOfFrames(index[1]);
break;
case SUBFRAME_ACQUISITION_TIME:
receiverBase->setSubExpTime(index[1]);
break;
default:
ret = FAIL;
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:
retval=receiverBase->getNumberOfFrames();
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
if (ret == OK && index[1] >= 0 && retval != index[1]) {
ret = FAIL;
@ -1028,12 +1039,7 @@ int slsReceiverTCPIPInterface::set_timer() {
}
#endif
#ifdef VERYVERBOSE
if (index[0] == ACQUISITION_TIME)
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;
FILE_LOG(logDEBUG1) << getTimerType(index[0]) << ":" << retval;
#endif
if (ret == OK && mySock->differentClients)