diff --git a/MAC/GCF/TM/src/Port/GCF_RawPort.cc b/MAC/GCF/TM/src/Port/GCF_RawPort.cc index f540e13a8760997fcfc164be9f2fc9590f3b6fa2..77ed9ca4f47ca67d33a0217bcfcc317cab4841de 100644 --- a/MAC/GCF/TM/src/Port/GCF_RawPort.cc +++ b/MAC/GCF/TM/src/Port/GCF_RawPort.cc @@ -184,8 +184,8 @@ long GCFRawPort::setTimer(long delay_sec, long delay_usec, { ASSERT(_pTimerHandler); return _pTimerHandler->setTimer(*this, - (unsigned long) (delay_sec * 1000000 + delay_usec), - (unsigned long) (interval_sec * 1000000 + interval_usec), + (uint64) (delay_sec * 1000000 + delay_usec), + (uint64) (interval_sec * 1000000 + interval_usec), arg); } @@ -195,8 +195,8 @@ long GCFRawPort::setTimer(double delay_seconds, { ASSERT(_pTimerHandler); return _pTimerHandler->setTimer(*this, - (unsigned long) (delay_seconds * 1000000.0), - (unsigned long) (interval_seconds * 1000000.0), + (uint64) (delay_seconds * 1000000.0), + (uint64) (interval_seconds * 1000000.0), arg); } diff --git a/MAC/GCF/TM/src/Timer/GTM_Timer.cc b/MAC/GCF/TM/src/Timer/GTM_Timer.cc index 780d8b11778e90348002df4ec62c2f7309b51e09..49f6f10e293c94cafd1b0bf5e9b2ab7b73db3e83 100644 --- a/MAC/GCF/TM/src/Timer/GTM_Timer.cc +++ b/MAC/GCF/TM/src/Timer/GTM_Timer.cc @@ -39,8 +39,8 @@ namespace LOFAR GTMTimer::GTMTimer(GCFRawPort& port, unsigned long id, - unsigned long timeVal, - unsigned long intervalTime, + uint64 timeVal, + uint64 intervalTime, void* arg) : _port(port), _id(id), _time(timeVal), _timeLeft(timeVal), @@ -52,9 +52,9 @@ GTMTimer::GTMTimer(GCFRawPort& port, void GTMTimer::decreaseTime() { - long uSec = getElapsedTime(); + int64 uSec = getElapsedTime(); - if ((long)_timeLeft > uSec) + if (uSec < 0 || _timeLeft > (uint64) uSec) { _timeLeft -= uSec; } @@ -72,12 +72,12 @@ void GTMTimer::decreaseTime() _port.dispatch(te); if (_intervalTime > 0) { - unsigned long timeoverflow = uSec - _timeLeft; + uint64 timeoverflow = uSec - _timeLeft; if (_intervalTime < timeoverflow) { LOG_ERROR(formatString( - "Timerinterval %fsec of timer %d is to small for performance reasons (tdelta: %ld, tleft: %lu).", + "Timerinterval %fsec of timer %d is to small for performance reasons (tdelta: %lld, tleft: %llu).", ((double) _intervalTime) / 1000000.0, _id, uSec, @@ -102,17 +102,17 @@ void GTMTimer::saveTime() gettimeofday(&_savedTime, &timeZone); } -long GTMTimer::getElapsedTime() +int64 GTMTimer::getElapsedTime() { timeval oldTime(_savedTime); - long uSecDiff(0); + int64 uSecDiff(0); saveTime(); - uSecDiff = ((unsigned long long) (_savedTime.tv_usec) + - (unsigned long long) (_savedTime.tv_sec) * 1000000) - - ((unsigned long long) (oldTime.tv_usec) + - (unsigned long long) (oldTime.tv_sec) * 1000000); + uSecDiff = ((uint64) (_savedTime.tv_usec) + + (uint64) (_savedTime.tv_sec) * 1000000) - + ((uint64) (oldTime.tv_usec) + + (uint64) (oldTime.tv_sec) * 1000000); return uSecDiff; } diff --git a/MAC/GCF/TM/src/Timer/GTM_Timer.h b/MAC/GCF/TM/src/Timer/GTM_Timer.h index 0b6726e487d8e3f73161a706149e7c8052d87eaf..200e6dd4aedc1d38cdf2e2a4c2025d0bfd1d3dd7 100644 --- a/MAC/GCF/TM/src/Timer/GTM_Timer.h +++ b/MAC/GCF/TM/src/Timer/GTM_Timer.h @@ -25,6 +25,7 @@ #include <sys/time.h> #include <time.h> +#include <Common/LofarTypes.h> namespace LOFAR { @@ -46,8 +47,8 @@ class GTMTimer public: GTMTimer (GCFRawPort& port, unsigned long id, - unsigned long timeVal, - unsigned long intervalTime = 0, + uint64 timeVal, + uint64 intervalTime = 0, void* arg = 0); virtual ~GTMTimer () {}; @@ -67,19 +68,20 @@ class GTMTimer private: // helper methods void saveTime (); - long getElapsedTime(); + int64 getElapsedTime(); private: // attributes GCFRawPort& _port; unsigned long _id; - unsigned long _time; - unsigned long _timeLeft; - unsigned long _intervalTime; - void* _arg; // this pointer should NEVER be modified by the GTMTimer class!! - bool _elapsed; - bool _canceled; + uint64 _time; + uint64 _timeLeft; + uint64 _intervalTime; + void* _arg; // this pointer should NEVER be modified by the GTMTimer class!! - timeval _savedTime; + private: // helper attribs. + bool _elapsed; + bool _canceled; + timeval _savedTime; }; } // namespace TM } // namespace GCF diff --git a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc index da0005b25c4c45b4ddeff314b20eda3c0ed9764d..c1682cc283405261abee13efec17a539d2fc7e6d 100644 --- a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc +++ b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.cc @@ -109,8 +109,8 @@ void GTMTimerHandler::workProc() } unsigned long GTMTimerHandler::setTimer(GCFRawPort& port, - unsigned long delaySeconds, - unsigned long intervalSeconds, + uint64 delaySeconds, + uint64 intervalSeconds, void* arg) { unsigned long timerid(1); diff --git a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h index 5dbcbd36d12949ae8f42baed37441769932b903f..ae9e9d7930dd904c241f17c81b992bc3d320c0b6 100644 --- a/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h +++ b/MAC/GCF/TM/src/Timer/GTM_TimerHandler.h @@ -51,8 +51,8 @@ class GTMTimerHandler : GCFHandler void stop (); unsigned long setTimer (GCFRawPort& port, - unsigned long delaySeconds, - unsigned long intervalSeconds = 0, + uint64 delaySeconds, + uint64 intervalSeconds = 0, void* arg = 0); int cancelTimer (unsigned long timerid, void** arg = 0); int cancelAllTimers (GCFRawPort& port);