fixed effects of scan

This commit is contained in:
2019-10-29 14:43:51 +01:00
parent 4b2cb7ecc1
commit eb2040f0a7
11 changed files with 107 additions and 277 deletions

View File

@ -54,11 +54,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
ctbDbitList(cdl),
ctbDbitOffset(cdo),
ctbAnalogDataBytes(cad),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
numTotalFramesCaught(0),
startedFlag(false),
firstIndex(0),
numFramesCaught(0),
currentFrameIndex(0),
rawDataReadyCallBack(nullptr),
@ -89,32 +86,20 @@ bool DataProcessor::IsRunning() {
return runningFlag;
}
bool DataProcessor::GetAcquisitionStartedFlag(){
return acquisitionStartedFlag;
}
bool DataProcessor::GetMeasurementStartedFlag(){
return measurementStartedFlag;
}
uint64_t DataProcessor::GetNumTotalFramesCaught() {
return numTotalFramesCaught;
bool DataProcessor::GetStartedFlag(){
return startedFlag;
}
uint64_t DataProcessor::GetNumFramesCaught() {
return numFramesCaught;
}
uint64_t DataProcessor::GetActualProcessedAcquisitionIndex() {
uint64_t DataProcessor::GetCurrentFrameIndex() {
return currentFrameIndex;
}
uint64_t DataProcessor::GetProcessedAcquisitionIndex() {
return currentFrameIndex - firstAcquisitionIndex;
}
uint64_t DataProcessor::GetProcessedMeasurementIndex() {
return currentFrameIndex - firstMeasurementIndex;
uint64_t DataProcessor::GetProcessedIndex() {
return currentFrameIndex - firstIndex;
}
@ -133,18 +118,12 @@ void DataProcessor::SetFifo(Fifo* f) {
fifo = f;
}
void DataProcessor::ResetParametersforNewAcquisition() {
numTotalFramesCaught = 0;
firstAcquisitionIndex = 0;
currentFrameIndex = 0;
acquisitionStartedFlag = false;
}
void DataProcessor::ResetParametersforNewMeasurement(){
void DataProcessor::ResetParametersforNewAcquisition(){
runningFlag = false;
startedFlag = false;
numFramesCaught = 0;
firstMeasurementIndex = 0;
measurementStartedFlag = false;
firstIndex = 0;
currentFrameIndex = 0;
if (tempBuffer != nullptr) {
delete [] tempBuffer;
@ -157,21 +136,14 @@ void DataProcessor::ResetParametersforNewMeasurement(){
}
void DataProcessor::RecordFirstIndices(uint64_t fnum) {
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
//listen to this fnum, later +1
currentFrameIndex = fnum;
measurementStartedFlag = true;
firstMeasurementIndex = fnum;
startedFlag = true;
firstIndex = fnum;
//start of entire acquisition
if (!acquisitionStartedFlag) {
acquisitionStartedFlag = true;
firstAcquisitionIndex = fnum;
}
FILE_LOG(logDEBUG1) << index << " First Acquisition Index:" << firstAcquisitionIndex <<
"\tFirst Measurement Index:" << firstMeasurementIndex;
FILE_LOG(logDEBUG1) << index << " First Index:" << firstIndex;
}
@ -322,13 +294,12 @@ void DataProcessor::ProcessAnImage(char* buf) {
uint32_t nump = header.packetNumber;
if (nump == generalData->packetsPerFrame) {
numFramesCaught++;
numTotalFramesCaught++;
}
FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
if (!measurementStartedFlag) {
RecordFirstIndices(fnum);
if (!startedFlag) {
RecordFirstIndex(fnum);
if (*dataStreamEnable) {
//restart timer
@ -384,7 +355,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
if (file != nullptr)
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
fnum-firstMeasurementIndex, nump);
fnum-firstIndex, nump);
}

View File

@ -29,10 +29,8 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
fileIndex(fi),
flippedDataX(fd),
additionJsonHeader(ajh),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
startedFlag(false),
firstIndex(0),
completeBuffer(nullptr),
gapPixelsEnable(gpEnable),
quadEnable(qe)
@ -79,15 +77,11 @@ void DataStreamer::SetFifo(Fifo* f) {
fifo = f;
}
void DataStreamer::ResetParametersforNewAcquisition() {
firstAcquisitionIndex = 0;
acquisitionStartedFlag = false;
}
void DataStreamer::ResetParametersforNewMeasurement(const std::string& fname){
void DataStreamer::ResetParametersforNewAcquisition(const std::string& fname){
runningFlag = false;
firstMeasurementIndex = 0;
measurementStartedFlag = false;
startedFlag = false;
firstIndex = 0;
// strcpy(fileNametoStream, fname);
fileNametoStream = fname;
if (completeBuffer) {
@ -103,18 +97,11 @@ void DataStreamer::ResetParametersforNewMeasurement(const std::string& fname){
}
}
void DataStreamer::RecordFirstIndices(uint64_t fnum) {
measurementStartedFlag = true;
firstMeasurementIndex = fnum;
void DataStreamer::RecordFirstIndex(uint64_t fnum) {
startedFlag = true;
firstIndex = fnum;
//start of entire acquisition
if (!acquisitionStartedFlag) {
acquisitionStartedFlag = true;
firstAcquisitionIndex = fnum;
}
FILE_LOG(logDEBUG1) << index << " First Acquisition Index: " << firstAcquisitionIndex <<
"\tFirst Measurement Index: " << firstMeasurementIndex;
FILE_LOG(logDEBUG1) << index << " First Index: " << firstIndex;
}
void DataStreamer::SetGeneralData(GeneralData* g) {
@ -206,8 +193,8 @@ void DataStreamer::ProcessAnImage(char* buf) {
uint64_t fnum = header->detHeader.frameNumber;
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
if (!measurementStartedFlag) {
RecordFirstIndices(fnum);
if (!startedFlag) {
RecordFirstIndex(fnum);
}
//shortframe gotthard
@ -254,8 +241,8 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
sls_detector_header header = rheader->detHeader;
uint64_t frameIndex = header.frameNumber - firstMeasurementIndex;
uint64_t acquisitionIndex = header.frameNumber - firstAcquisitionIndex;
uint64_t frameIndex = header.frameNumber - firstIndex;
uint64_t acquisitionIndex = header.frameNumber;
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex,
numDet[0], numDet[1], nx, ny, size,

View File

@ -44,10 +44,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, std::atomic<runStatus>*
silentMode(sm),
row(0),
column(0),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
startedFlag(false),
firstIndex(0),
numPacketsCaught(0),
lastCaughtFrameIndex(0),
currentFrameIndex(0),
@ -82,14 +80,6 @@ bool Listener::IsRunning() {
return runningFlag;
}
bool Listener::GetAcquisitionStartedFlag(){
return acquisitionStartedFlag;
}
bool Listener::GetMeasurementStartedFlag(){
return measurementStartedFlag;
}
uint64_t Listener::GetPacketsCaught() {
return numPacketsCaught;
}
@ -115,18 +105,12 @@ void Listener::SetFifo(Fifo* f) {
void Listener::ResetParametersforNewAcquisition() {
acquisitionStartedFlag = false;
firstAcquisitionIndex = 0;
runningFlag = false;
startedFlag = false;
numPacketsCaught = 0;
firstIndex = 0;
currentFrameIndex = 0;
lastCaughtFrameIndex = 0;
}
void Listener::ResetParametersforNewMeasurement() {
runningFlag = false;
measurementStartedFlag = false;
numPacketsCaught = 0;
firstMeasurementIndex = 0;
carryOverFlag = false;
carryOverPacket = sls::make_unique<char[]>(generalData->packetSize);
memset(carryOverPacket.get(),0,generalData->packetSize);
@ -142,24 +126,17 @@ void Listener::ResetParametersforNewMeasurement() {
void Listener::RecordFirstIndices(uint64_t fnum) {
void Listener::RecordFirstIndex(uint64_t fnum) {
//listen to this fnum, later +1
currentFrameIndex = fnum;
measurementStartedFlag = true;
firstMeasurementIndex = fnum;
//start of entire acquisition
if (!acquisitionStartedFlag) {
acquisitionStartedFlag = true;
firstAcquisitionIndex = fnum;
}
startedFlag = true;
firstIndex = fnum;
if(!(*silentMode)) {
if (!index) {
FILE_LOG(logINFOBLUE) << index <<
" First Acquisition Index: " << firstAcquisitionIndex;
FILE_LOG(logDEBUG1) << index << " First Measurement Index: " << firstMeasurementIndex;
" First Index: " << firstIndex;
}
}
}
@ -519,7 +496,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
// -------------------old header -----------------------------------------------------------------------------
else {
// set first packet to be odd or even (check required when switching from roi to no roi)
if (myDetectorType == GOTTHARD && !measurementStartedFlag) {
if (myDetectorType == GOTTHARD && !startedFlag) {
oddStartingPacket = generalData->SetOddStartingPacket(index, &listeningPacket[0]);
}
@ -540,8 +517,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
FILE_LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex <<
", fnum:" << fnum << ", pnum:" << pnum << ", numpackets:" << numpackets;
if (!measurementStartedFlag)
RecordFirstIndices(fnum);
if (!startedFlag)
RecordFirstIndex(fnum);
if (pnum >= pperFrame ) {
FILE_LOG(logERROR) << "Bad packet " << pnum <<

View File

@ -228,49 +228,36 @@ bool slsReceiverImplementation::getOverwriteEnable() const {
}
/***acquisition count parameters***/
uint64_t slsReceiverImplementation::getTotalFramesCaught() const {
uint64_t sum = 0;
uint32_t flagsum = 0;
for (const auto &it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag();
sum += it->GetNumTotalFramesCaught();
}
// no data processed
if (flagsum != dataProcessor.size())
return 0;
return (sum / dataProcessor.size());
}
uint64_t slsReceiverImplementation::getFramesCaught() const {
uint64_t sum = 0;
uint64_t min = -1;
uint32_t flagsum = 0;
for (const auto &it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag();
sum += it->GetNumFramesCaught();
flagsum += it->GetStartedFlag();
uint64_t curr = it->GetNumFramesCaught();
min = curr < min ? curr : min;
}
// no data processed
if (flagsum != dataProcessor.size())
return 0;
return (sum / dataProcessor.size());
return min;
}
uint64_t slsReceiverImplementation::getAcquisitionIndex() const {
uint64_t sum = 0;
uint64_t min = -1;
uint32_t flagsum = 0;
for (const auto &it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag();
sum += it->GetActualProcessedAcquisitionIndex();
flagsum += it->GetStartedFlag();
uint64_t curr = it->GetCurrentFrameIndex();
min = curr < min ? curr : min;
}
// no data processed
if (flagsum != dataProcessor.size())
return 0;
return (sum / dataProcessor.size());
return min;
}
/***connection parameters***/
@ -1221,24 +1208,11 @@ void slsReceiverImplementation::setDetectorPositionId(const int id) {
}
}
/***acquisition functions***/
void slsReceiverImplementation::resetAcquisitionCount() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
for (const auto &it : listener)
it->ResetParametersforNewAcquisition();
for (const auto &it : dataProcessor)
it->ResetParametersforNewAcquisition();
for (const auto &it : dataStreamer)
it->ResetParametersforNewAcquisition();
FILE_LOG(logINFO) << "Acquisition Count has been reset";
}
int slsReceiverImplementation::startReceiver(char *c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
FILE_LOG(logINFO) << "Starting Receiver";
resetAcquisitionCount();
ResetParametersforNewMeasurement();
ResetParametersforNewAcquisition();
// listener
if (CreateUDPSockets() == FAIL) {
@ -1308,8 +1282,8 @@ void slsReceiverImplementation::stopReceiver() {
bool anycaught = false;
for (const auto &it : dataProcessor) {
maxIndexCaught =
std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
if (it->GetMeasurementStartedFlag())
std::max(maxIndexCaught, it->GetProcessedIndex());
if (it->GetStartedFlag())
anycaught = true;
}
// to create virtual file & set files/acquisition to 0 (only hdf5 at the
@ -1422,8 +1396,8 @@ void slsReceiverImplementation::closeFiles() {
for (const auto &it : dataProcessor) {
it->CloseFiles();
maxIndexCaught =
std::max(maxIndexCaught, it->GetProcessedMeasurementIndex());
if (it->GetMeasurementStartedFlag())
std::max(maxIndexCaught, it->GetProcessedIndex());
if (it->GetStartedFlag())
anycaught = true;
}
// to create virtual file & set files/acquisition to 0 (only hdf5 at the
@ -1554,20 +1528,20 @@ int slsReceiverImplementation::SetupFifoStructure() {
return OK;
}
void slsReceiverImplementation::ResetParametersforNewMeasurement() {
void slsReceiverImplementation::ResetParametersforNewAcquisition() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
for (const auto &it : listener)
it->ResetParametersforNewMeasurement();
it->ResetParametersforNewAcquisition();
for (const auto &it : dataProcessor)
it->ResetParametersforNewMeasurement();
it->ResetParametersforNewAcquisition();
if (dataStreamEnable) {
char fnametostream[MAX_STR_LENGTH * 2];
snprintf(fnametostream, MAX_STR_LENGTH * 2, "%s/%s", filePath,
fileName);
for (const auto &it : dataStreamer)
it->ResetParametersforNewMeasurement(fnametostream);
it->ResetParametersforNewAcquisition(fnametostream);
}
}

View File

@ -757,7 +757,7 @@ int slsReceiverTCPIPInterface::get_frame_index(Interface &socket) {
}
int slsReceiverTCPIPInterface::get_frames_caught(Interface &socket) {
int retval = impl()->getTotalFramesCaught();
int retval = impl()->getFramesCaught();
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
return socket.sendResult(retval);
}