From acb900961ab8a354f34d9c35f64ea573932a0f9b Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 10 Nov 2016 14:37:26 +0100 Subject: [PATCH] fixed time interval in receiveR --- .../include/UDPBaseImplementation.h | 15 +++++++++++++++ slsReceiverSoftware/include/UDPInterface.h | 13 +++++++++++++ slsReceiverSoftware/src/UDPBaseImplementation.cpp | 10 ++++++++++ .../src/UDPStandardImplementation.cpp | 2 +- .../src/slsReceiverTCPIPInterface.cpp | 4 ++-- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 3cb4edbe5..89a601ff6 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -154,6 +154,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ uint32_t getFrameToGuiFrequency() const; + /** + * Gets the timer between frames streamed when frequency is set to 0 + * @return timer between frames streamed + */ + uint32_t getFrameToGuiTimer() const; + /** * Get the data stream enable * @return 1 to send via zmq, else 0 @@ -317,6 +323,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ int setFrameToGuiFrequency(const uint32_t freq); + /** + * Sets the timer between frames streamed when frequency is set to 0 + * @param time_in_ms timer between frames streamed + */ + void setFrameToGuiTimer(const uint32_t time_in_ms); + /** * Set the data stream enable * @param enable 0 to disable, 1 to enable @@ -555,8 +567,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter int shortFrameEnable; /** Frequency of Frames sent to GUI */ uint32_t frameToGuiFrequency; + /** Timer of Frames sent to GUI when frequency is 0 */ + uint32_t frameToGuiTimerinMS; /** Data Stream Enable from Receiver */ int32_t dataStreamEnable; + static const int DEFAULT_STREAMING_TIMER = 500; diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 5065f3ab4..365fc6782 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -214,6 +214,13 @@ class UDPInterface { */ virtual uint32_t getFrameToGuiFrequency() const = 0; + /** + * Gets the timer between frames streamed when frequency is set to 0 + * @return timer between frames streamed + */ + virtual uint32_t getFrameToGuiTimer() const = 0; + + /** * Get the data stream enable * @return 1 to send via zmq, else 0 @@ -372,6 +379,12 @@ class UDPInterface { */ virtual int setFrameToGuiFrequency(const uint32_t freq) = 0; + /** + * Sets the timer between frames streamed when frequency is set to 0 + * @param time_in_ms timer between frames streamed + */ + virtual void setFrameToGuiTimer(const uint32_t time_in_ms) = 0; + /** * Set the data stream enable * @param enable 0 to disable, 1 to enable diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 22c24e05d..3a73b7422 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -77,6 +77,7 @@ void UDPBaseImplementation::initializeMembers(){ //***acquisition parameters*** shortFrameEnable = -1; frameToGuiFrequency = 0; + frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER; dataStreamEnable = false; } @@ -176,6 +177,8 @@ int UDPBaseImplementation::getShortFrameEnable() const{ FILE_LOG(logDEBUG) << __ uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiFrequency;} +uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiTimerinMS;} + uint32_t UDPBaseImplementation::getDataStreamEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dataStreamEnable;} uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionPeriod;} @@ -328,6 +331,13 @@ int UDPBaseImplementation::setFrameToGuiFrequency(const uint32_t freq){ return OK; } +void UDPBaseImplementation::setFrameToGuiTimer(const uint32_t time_in_ms){ + FILE_LOG(logDEBUG) << __AT__ << " starting"; + + frameToGuiTimerinMS = time_in_ms; + FILE_LOG(logINFO) << "Frame To Gui Timer:" << frameToGuiTimerinMS; +} + uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){ FILE_LOG(logDEBUG) << __AT__ << " starting"; diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 1e56872b3..76edf0ced 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -1814,7 +1814,7 @@ void UDPStandardImplementation::startDataCallback(){ cprintf(BLUE,"%d Elapsed time:%f seconds\n",ithread,( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0); #endif //still less than 250 ms, keep waiting - if((( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) < 0.5)/**fixed 250 ms*/ + if((( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) < (frameToGuiTimerinMS/1000)) continue; //done with timer, look into data randomSendNow = true; diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 3024331bf..c608143e3 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -2177,9 +2177,9 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){ } else{ if(index >= 0 ){ - receiverBase->setDataStreamTimer(index); + receiverBase->setFrameToGuiTimer(index); } - retval=receiverBase->getDataStreamTimer(); + retval=receiverBase->getFrameToGuiTimer(); if(index>=0 && retval!=index){ strcpy(mess,"Could not set datastream timer"); cprintf(RED,"%s\n",mess);