From 63fdc318ac726f74a706e8a1bb12f57c0363786e Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 24 Feb 2003 16:04:29 +0000 Subject: [PATCH] fixed beacon time stamp initialization for beacons associated with active circuits --- src/ca/bhe.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ca/bhe.cpp b/src/ca/bhe.cpp index 0846f4ed6..9ea662fde 100644 --- a/src/ca/bhe.cpp +++ b/src/ca/bhe.cpp @@ -98,6 +98,14 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, */ this->timeStamp = currentTime; +#ifdef DEBUG + { + char name[64]; + this->name ( name, sizeof ( name ) ); + ::printf ( "fb %s\n", name ); + } +#endif + return false; } @@ -130,6 +138,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, // compute the beacon period (if we have seen at least two beacons) bool netChange = false; double currentPeriod = currentTime - this->timeStamp; + if ( this->averagePeriod < 0.0 ) { double totalRunningTime; @@ -142,6 +151,15 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, */ this->averagePeriod = currentPeriod; +#ifdef DEBUG + { + char name[64]; + this->name ( name, sizeof ( name ) ); + ::printf ( "fp=%g %s\n", + this->averagePeriod, name ); + } +#endif + /* * ignore beacons seen for the first time shortly after * init, but do not ignore beacons arriving with a short @@ -201,7 +219,17 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, // if the beacon looks ok this->pIIU->beaconArrivalNotify ( currentTime ); } - + +#ifdef DEBUG + { + char name[64]; + this->name ( name, sizeof ( name ) ); + ::printf ( "cp=%g ap=%g %s\n", + currentPeriod, this->averagePeriod, + name ); + } +#endif + // update a running average period this->averagePeriod = currentPeriod * 0.125 + this->averagePeriod * 0.875; @@ -228,11 +256,9 @@ epicsTime bhe::updateTime () const return this->timeStamp; } -void bhe::registerIIU ( tcpiiu & iiu, const epicsTime & currentTime ) +void bhe::registerIIU ( tcpiiu & iiu ) { this->pIIU = & iiu; - this->timeStamp = currentTime; - this->averagePeriod = - DBL_MAX; } void bhe::unregisterIIU ( tcpiiu & iiu )