print only one message for each beacon if every beacon is printed

This commit is contained in:
Jeff Hill
2004-03-31 22:01:04 +00:00
parent 7e606dafac
commit 1d6a7f59f4
+28 -26
View File
@@ -206,6 +206,8 @@ int main ( int argc, char ** argv )
}
if ( epicsNTOH16 ( pCurMsg->m_cmmd ) == CA_PROTO_RSRV_IS_UP ) {
bool anomaly = false;
epicsTime previousTime;
struct sockaddr_in ina;
/*
@@ -241,39 +243,15 @@ int main ( int argc, char ** argv )
epicsTime currentTime = epicsTime::getCurrent();
if ( interest > 1) {
char date[64];
currentTime.strftime ( date, sizeof ( date ),
"%Y-%m-%d %H:%M:%S.%09f");
char host[64];
ipAddrToA ( &ina, host, sizeof ( host ) );
printf ( "beacon %-40s %s\n", host, date );
}
/*
* look for it in the hash table
*/
bhe *pBHE = beaconTable.lookup ( ina );
if ( pBHE ) {
epicsTime previousTime = pBHE->updateTime ( guard );
bool anomaly = pBHE->updatePeriod (
previousTime = pBHE->updateTime ( guard );
anomaly = pBHE->updatePeriod (
guard, programBeginTime,
currentTime, beaconNumber, protocolRevision );
if ( anomaly ) {
char date[64];
currentTime.strftime ( date, sizeof ( date ),
"%Y-%m-%d %H:%M:%S.%09f");
char host[64];
ipAddrToA ( &ina, host, sizeof ( host ) );
printf ( "anomaly %-40s %s\n",
host, date );
if ( interest > 0 ) {
printf ( "\testimate=%f current=%f\n",
pBHE->period ( guard ),
currentTime - previousTime );
}
fflush(stdout);
}
}
else {
/*
@@ -292,6 +270,30 @@ int main ( int argc, char ** argv )
}
}
}
if ( anomaly || interest > 1 ) {
char date[64];
currentTime.strftime ( date, sizeof ( date ),
"%Y-%m-%d %H:%M:%S.%09f");
char host[64];
ipAddrToA ( &ina, host, sizeof ( host ) );
const char * pPrefix = "";
if ( interest > 1 ) {
if ( anomaly ) {
pPrefix = "* ";
}
else {
pPrefix = " ";
}
}
printf ( "%s%-40s %s\n",
pPrefix, host, date );
if ( anomaly && interest > 0 ) {
printf ( "\testimate=%f current=%f\n",
pBHE->period ( guard ),
currentTime - previousTime );
}
fflush(stdout);
}
}
pCurBuf += msgSize;
pCurMsg = reinterpret_cast < const caHdr * > ( pCurBuf );