mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
removed unnecessary functions in listener and dataprocessor and ensure processedin measurement is not same saas processed frames in acqustion
This commit is contained in:
parent
001d6415bf
commit
cb008bb700
@ -93,6 +93,11 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
uint64_t GetProcessedAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Get Current Frame Index thats been processed for each real time acquisition (eg. for each scan)
|
||||
* @return -1 if no frames have been caught, else current frame index
|
||||
*/
|
||||
uint64_t GetProcessedMeasurementIndex();
|
||||
|
||||
//*** setters ***
|
||||
/**
|
||||
@ -250,33 +255,14 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Fifo structure */
|
||||
Fifo* fifo;
|
||||
|
||||
/** Data Stream Enable */
|
||||
bool* dataStreamEnable;
|
||||
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
/** Measurement Started flag */
|
||||
bool measurementStartedFlag;
|
||||
|
||||
/**Number of complete frames caught for an entire acquisition (including all scans) */
|
||||
uint64_t numTotalFramesCaught;
|
||||
|
||||
/** Number of complete frames caught for each real time acquisition (eg. for each scan) */
|
||||
uint64_t numFramesCaught;
|
||||
|
||||
/** Frame Number of First Frame of an entire Acquisition (including all scans) */
|
||||
uint64_t firstAcquisitionIndex;
|
||||
|
||||
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
|
||||
uint64_t firstMeasurementIndex;
|
||||
|
||||
/** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
//individual members
|
||||
/** File writer implemented as binary or hdf5 File */
|
||||
File* file;
|
||||
|
||||
/** Data Stream Enable */
|
||||
bool* dataStreamEnable;
|
||||
|
||||
/** File Format Type */
|
||||
fileFormat* fileFormatType;
|
||||
|
||||
@ -284,6 +270,35 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
bool* fileWriteEnable;
|
||||
|
||||
|
||||
//acquisition start
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
/** Measurement Started flag */
|
||||
bool measurementStartedFlag;
|
||||
|
||||
/** Frame Number of First Frame of an entire Acquisition (including all scans) */
|
||||
uint64_t firstAcquisitionIndex;
|
||||
|
||||
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
|
||||
uint64_t firstMeasurementIndex;
|
||||
|
||||
|
||||
//for statistics
|
||||
/**Number of complete frames caught for an entire acquisition (including all scans) */
|
||||
uint64_t numTotalFramesCaught;
|
||||
|
||||
/** Number of complete frames caught for each real time acquisition (eg. for each scan) */
|
||||
uint64_t numFramesCaught;
|
||||
|
||||
/** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//call back
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
|
@ -73,10 +73,10 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
bool GetMeasurementStartedFlag();
|
||||
|
||||
/**
|
||||
* Get Total Packets caught in an acquisition
|
||||
* @return Total Packets caught in an acquisition
|
||||
* Get Packets caught in a real time acquisition (start and stop of receiver)
|
||||
* @return Packets caught in a real time acquisition
|
||||
*/
|
||||
uint64_t GetTotalPacketsCaught();
|
||||
uint64_t GetPacketsCaught();
|
||||
|
||||
/**
|
||||
* Get Last Frame index caught
|
||||
@ -217,12 +217,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Detector Type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
/** Measurement Started flag */
|
||||
bool measurementStartedFlag;
|
||||
|
||||
/** Receiver Status */
|
||||
runStatus* status;
|
||||
|
||||
@ -244,11 +238,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Dynamic Range */
|
||||
uint32_t* dynamicRange;
|
||||
|
||||
/**Number of complete Packets caught for an entire acquisition (including all scans) */
|
||||
volatile uint64_t numTotalPacketsCaught;
|
||||
|
||||
/** Number of complete Packets caught for each real time acquisition (eg. for each scan) */
|
||||
volatile uint64_t numPacketsCaught;
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
/** Measurement Started flag */
|
||||
bool measurementStartedFlag;
|
||||
|
||||
/** Frame Number of First Frame of an entire Acquisition (including all scans) */
|
||||
uint64_t firstAcquisitionIndex;
|
||||
@ -256,14 +252,21 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
|
||||
uint64_t firstMeasurementIndex;
|
||||
|
||||
|
||||
// for statistics
|
||||
/** Number of complete Packets caught for each real time acquisition (eg. for each scan (start& stop of receiver)) */
|
||||
volatile uint64_t numPacketsCaught;
|
||||
|
||||
/** Last Frame Index caught from udp network */
|
||||
uint64_t lastCaughtFrameIndex;
|
||||
|
||||
|
||||
// parameters to acquire image
|
||||
/** Current Frame Index, default value is 0
|
||||
* ( always check acquisitionStartedFlag for validity first)
|
||||
*/
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
/** Last Frame Index caught from udp network */
|
||||
uint64_t lastCaughtFrameIndex;
|
||||
|
||||
/** True if there is a packet carry over from previous Image */
|
||||
bool carryOverFlag;
|
||||
|
||||
|
@ -39,17 +39,17 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool*
|
||||
ThreadObject(NumberofDataProcessors),
|
||||
generalData(0),
|
||||
fifo(f),
|
||||
dataStreamEnable(dsEnable),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
numTotalFramesCaught(0),
|
||||
numFramesCaught(0),
|
||||
firstAcquisitionIndex(0),
|
||||
firstMeasurementIndex(0),
|
||||
currentFrameIndex(0),
|
||||
file(0),
|
||||
dataStreamEnable(dsEnable),
|
||||
fileFormatType(ftype),
|
||||
fileWriteEnable(fwenable),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
firstMeasurementIndex(0),
|
||||
numTotalFramesCaught(0),
|
||||
numFramesCaught(0),
|
||||
currentFrameIndex(0),
|
||||
rawDataReadyCallBack(dataReadycb),
|
||||
pRawDataReady(pDataReadycb)
|
||||
{
|
||||
@ -114,6 +114,9 @@ uint64_t DataProcessor::GetProcessedAcquisitionIndex() {
|
||||
return currentFrameIndex - firstAcquisitionIndex;
|
||||
}
|
||||
|
||||
uint64_t DataProcessor::GetProcessedMeasurementIndex() {
|
||||
return currentFrameIndex - firstMeasurementIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -32,8 +32,6 @@ Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno,
|
||||
generalData(0),
|
||||
fifo(f),
|
||||
myDetectorType(dtype),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
status(s),
|
||||
udpSocket(0),
|
||||
udpPortNumber(portno),
|
||||
@ -41,12 +39,13 @@ Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno,
|
||||
activated(act),
|
||||
numImages(nf),
|
||||
dynamicRange(dr),
|
||||
numTotalPacketsCaught(0),
|
||||
numPacketsCaught(0),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
firstMeasurementIndex(0),
|
||||
currentFrameIndex(0),
|
||||
numPacketsCaught(0),
|
||||
lastCaughtFrameIndex(0),
|
||||
currentFrameIndex(0),
|
||||
carryOverFlag(0),
|
||||
carryOverPacket(0),
|
||||
listeningPacket(0)
|
||||
@ -103,8 +102,8 @@ bool Listener::GetMeasurementStartedFlag(){
|
||||
return measurementStartedFlag;
|
||||
}
|
||||
|
||||
uint64_t Listener::GetTotalPacketsCaught() {
|
||||
return numTotalPacketsCaught;
|
||||
uint64_t Listener::GetPacketsCaught() {
|
||||
return numPacketsCaught;
|
||||
}
|
||||
|
||||
uint64_t Listener::GetLastFrameIndexCaught() {
|
||||
@ -133,7 +132,6 @@ void Listener::SetFifo(Fifo*& f) {
|
||||
|
||||
void Listener::ResetParametersforNewAcquisition() {
|
||||
acquisitionStartedFlag = false;
|
||||
numTotalPacketsCaught = 0;
|
||||
firstAcquisitionIndex = 0;
|
||||
currentFrameIndex = 0;
|
||||
lastCaughtFrameIndex = 0;
|
||||
@ -387,7 +385,6 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
//update parameters
|
||||
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
||||
numTotalPacketsCaught++;
|
||||
|
||||
// -------------------------- new header ----------------------------------------------------------------------
|
||||
if (myDetectorType == JUNGFRAU) {
|
||||
@ -463,7 +460,6 @@ uint32_t Listener::CreateAnImage(char* buf) {
|
||||
|
||||
//update parameters
|
||||
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
||||
numTotalPacketsCaught++;
|
||||
|
||||
//reset data to -1
|
||||
memset(buf, 0xFF, generalData->dataSize);
|
||||
|
@ -492,12 +492,12 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
|
||||
//create virtual file
|
||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
||||
uint64_t maxFramescaught = 0;
|
||||
uint64_t maxIndexCaught = 0;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
maxFramescaught = max(maxFramescaught, (*it)->GetNumFramesCaught());
|
||||
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
}
|
||||
if (maxFramescaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxFramescaught);
|
||||
if (maxIndexCaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxIndexCaught); //to create virtual file
|
||||
}
|
||||
|
||||
while(DataStreamer::GetRunningMask()){
|
||||
@ -515,7 +515,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
for (int i = 0; i < numThreads; i++) {
|
||||
tot += dataProcessor[i]->GetNumFramesCaught();
|
||||
|
||||
uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetTotalPacketsCaught();
|
||||
uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught();
|
||||
if (missingpackets) {
|
||||
cprintf(RED, "\n[Port %d]\n",udpPortNum[i]);
|
||||
cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets);
|
||||
@ -555,7 +555,7 @@ void UDPStandardImplementation::startReadout(){
|
||||
//current packets caught
|
||||
volatile int totalP = 0,prev=-1;
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetTotalPacketsCaught();
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
|
||||
//wait for all packets
|
||||
if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){
|
||||
@ -574,7 +574,7 @@ void UDPStandardImplementation::startReadout(){
|
||||
totalP = 0;
|
||||
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetTotalPacketsCaught();
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
#ifdef VERY_VERBOSE
|
||||
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
|
||||
#endif
|
||||
@ -602,13 +602,13 @@ void UDPStandardImplementation::shutDownUDPSockets() {
|
||||
|
||||
|
||||
void UDPStandardImplementation::closeFiles() {
|
||||
uint64_t maxFramescaught = 0;
|
||||
uint64_t maxIndexCaught = 0;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
(*it)->CloseFiles();
|
||||
maxFramescaught = max(maxFramescaught, (*it)->GetNumFramesCaught());
|
||||
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
}
|
||||
if (maxFramescaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxFramescaught);
|
||||
if (maxIndexCaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxIndexCaught);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user