From 62b8f02fefa8ea43a8b21f20eae4de431a814171 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 9 Aug 2002 16:52:39 +0000 Subject: [PATCH] initialize the beacon sequence number --- src/ca/bhe.cpp | 41 +++++++++++++++++++---------------------- src/ca/cac.cpp | 4 ++-- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/ca/bhe.cpp b/src/ca/bhe.cpp index 62eb65f5a..094444ff7 100644 --- a/src/ca/bhe.cpp +++ b/src/ca/bhe.cpp @@ -56,9 +56,10 @@ void bhe::operator delete ( void *pCadaver, size_t size ) * zero (so we can correctly compute the period * between the 1st and 2nd beacons) */ -bhe::bhe ( const epicsTime & initialTimeStamp, const inetAddrID & addr ) : +bhe::bhe ( const epicsTime & initialTimeStamp, + unsigned initialBeaconNumber, const inetAddrID & addr ) : inetAddrID ( addr ), timeStamp ( initialTimeStamp ), averagePeriod ( - DBL_MAX ), - lastBeaconNumber ( UINT_MAX ) + lastBeaconNumber ( initialBeaconNumber ) { # ifdef DEBUG { @@ -91,8 +92,12 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, const epicsTime & currentTime, unsigned beaconNumber, unsigned protocolRevision ) { + // + // this block is enetered if the beacon was created as a side effect of + // creating a connection and so we dont yet know the first beacon time + // and sequence number + // if ( this->timeStamp == epicsTime () ) { - if ( CA_V410 ( protocolRevision ) ) { this->lastBeaconNumber = beaconNumber; } @@ -119,9 +124,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, } } - /* - * compute the beacon period (if we have seen at least two beacons) - */ + // 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 ) { @@ -191,10 +194,8 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, netChange = true; } else { - /* - * update state of health for active virtual circuits - * if the beacon looks ok - */ + // update state of health for active virtual circuits + // if the beacon looks ok tsDLIter < tcpiiu > iter = this->iiuList.firstIter (); while ( iter.valid() ) { iter->beaconArrivalNotify (); @@ -202,20 +203,11 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime, } } - /* - * update a running average period - */ - this->averagePeriod = currentPeriod * 0.125 + this->averagePeriod * 0.875; + // update a running average period + this->averagePeriod = currentPeriod * 0.125 + + this->averagePeriod * 0.875; } - //{ - // char name[64]; - // this->name ( name, sizeof ( name ) ); - // - // printf ( "new beacon period %f for %s\n", - // this->averagePeriod, name ); - //} - this->timeStamp = currentTime; return netChange; @@ -237,6 +229,11 @@ double bhe::period () const return this->averagePeriod; } +epicsTime bhe::updateTime () const +{ + return this->timeStamp; +} + void bhe::registerIIU ( tcpiiu & iiu ) { this->iiuList.add ( iiu ); diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index bd6828e44..46972c997 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -399,7 +399,7 @@ void cac::beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime, * time that we have seen a server's beacon * shortly after the program started up) */ - pBHE = new bhe ( currentTime, addr ); + pBHE = new bhe ( currentTime, beaconNumber, addr ); if ( pBHE ) { if ( this->beaconTable.add ( *pBHE ) < 0 ) { pBHE->destroy (); @@ -552,7 +552,7 @@ bool cac::lookupChannelAndTransferToTCP ( } bhe * pBHE = this->beaconTable.lookup ( addr.ia ); if ( ! pBHE ) { - epics_auto_ptr < bhe > pNewBHE ( new bhe ( epicsTime (), addr.ia ) ); + epics_auto_ptr < bhe > pNewBHE ( new bhe ( epicsTime (), 0u, addr.ia ) ); if ( pNewBHE.get () ) { if ( this->beaconTable.add ( *pNewBHE ) >= 0 ) { pBHE = pNewBHE.release ();