added beacon anomaly count diagnostic

This commit is contained in:
Jeff Hill
2003-02-05 22:08:54 +00:00
parent 0b8f25214f
commit 168c9c5503
7 changed files with 54 additions and 53 deletions
+14 -3
View File
@@ -1079,15 +1079,26 @@ double epicsShareAPI ca_beacon_period ( chid pChan )
// extern "C"
unsigned epicsShareAPI ca_get_ioc_connection_count ()
{
ca_client_context *pcac;
int caStatus = fetchClientContext ( &pcac );
ca_client_context * pcac;
int caStatus = fetchClientContext ( & pcac );
if ( caStatus != ECA_NORMAL ) {
return caStatus;
return 0u;
}
return pcac->connectionCount ();
}
unsigned epicsShareAPI ca_beacon_anomaly_count ()
{
ca_client_context * pcac;
int caStatus = fetchClientContext ( & pcac );
if ( caStatus != ECA_NORMAL ) {
return 0u;
}
return pcac->beaconAnomaliesSinceProgramStart ();
}
// extern "C"
int epicsShareAPI ca_channel_status ( epicsThreadId /* tid */ )
{
+17 -45
View File
@@ -1978,21 +1978,16 @@ void pend_event_delay_test ( dbr_double_t request )
assert ( fabs(accuracy) < 10.0 );
}
void caTaskExistTest ()
void caTaskExistTest ( unsigned interestLevel )
{
int status;
epicsTimeStamp end_time;
epicsTimeStamp start_time;
dbr_double_t delay;
showProgressBegin ( "caTaskExistTest", interestLevel );
epicsTimeGetCurrent ( &start_time );
printf ( "entering ca_task_exit()\n" );
status = ca_task_exit ();
SEVCHK ( status, NULL );
epicsTimeGetCurrent ( &end_time );
delay = epicsTimeDiffInSeconds ( &end_time, &start_time );
printf ( "in ca_task_exit() for %f sec\n", delay );
showProgressEnd ( interestLevel );
}
void verifyDataTypeMacros ()
@@ -2221,43 +2216,20 @@ void monitorUpdateTest ( chid chan, unsigned interestLevel )
void verifyReasonableBeaconPeriod ( chid chan )
{
if ( ca_get_ioc_connection_count () > 0 ) {
double beaconPeriod, expectedBeaconPeriod, error, percentError;
unsigned attempts = 0u;
double beaconPeriod;
unsigned attempts = 0u;
int status;
int status;
if ( envGetConfigParamPtr ( & EPICS_CAS_BEACON_PERIOD ) ) {
status = envGetDoubleConfigParam ( & EPICS_CAS_BEACON_PERIOD,
& expectedBeaconPeriod );
}
else {
status = envGetDoubleConfigParam ( & EPICS_CA_BEACON_PERIOD,
& expectedBeaconPeriod );
}
assert ( status >=0 );
while ( 1 ) {
static const unsigned maxAttempts = 10u;
const double delay = ( expectedBeaconPeriod * 4 ) / maxAttempts;
assert ( ca_get_ioc_connection_count () > 0 );
beaconPeriod = ca_beacon_period ( chan );
if ( beaconPeriod >= 0.0 ) {
error = beaconPeriod - expectedBeaconPeriod;
percentError = fabs ( error ) / expectedBeaconPeriod;
if ( percentError < 0.1 ) {
break;
}
printf ( "Beacon period error estimate = %f sec.\n", error );
}
else {
printf ( "Beacon period unavailable\n" );
}
assert ( attempts++ < maxAttempts );
printf ( "Waiting for a better beacon period estimate result (%f sec).\n",
attempts * delay );
ca_pend_event ( delay );
}
}
printf ( "Beacon anomalies detected since program start %u\n",
ca_beacon_anomaly_count () );
beaconPeriod = ca_beacon_period ( chan );
assert ( beaconPeriod >= 0.0 );
printf ( "Estimated beacon period for channel %s = %f sec.\n",
ca_name ( chan ), beaconPeriod );
}
void verifyOldPend ( unsigned interestLevel)
@@ -2538,7 +2510,7 @@ int acctst ( char *pName, unsigned interestLevel, unsigned channelCount,
/* status = ca_clear_channel ( chan ); */
/* SEVCHK ( status, NULL ); */
caTaskExistTest ();
caTaskExistTest ( interestLevel );
free ( pChans );
+3 -3
View File
@@ -230,8 +230,9 @@ void ca_client_context::fdWasDestroyed ( int fd )
void ca_client_context::show ( unsigned level ) const
{
::printf ( "ca_client_context at %p\n",
static_cast <const void *> ( this ) );
::printf ( "ca_client_context at %p pndRecvCnt=%u ioSeqNo=%u\n",
static_cast <const void *> ( this ),
this->pndRecvCnt, this->ioSeqNo );
if ( level > 0u ) {
this->mutex.show ( level - 1u );
this->clientCtx.show ( level - 1u );
@@ -243,7 +244,6 @@ void ca_client_context::show ( unsigned level ) const
this->ioSeqNo );
::printf ( "IO done event:\n");
this->ioDone.show ( level - 1u );
}
}
+4
View File
@@ -149,6 +149,8 @@ cac::cac ( cacNotify & notifyIn, bool enablePreemptiveCallbackIn ) :
initializingThreadsId ( epicsThreadGetIdSelf() ),
initializingThreadsPriority ( epicsThreadGetPrioritySelf() ),
maxRecvBytesTCP ( MAX_TCP ),
nRecvThreadsPending ( 0u ),
beaconAnomalyCount ( 0u ),
preemptiveCallbackEnabled ( enablePreemptiveCallbackIn )
{
if ( ! osiSockAttach () ) {
@@ -427,6 +429,8 @@ void cac::beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime,
return;
}
this->beaconAnomalyCount++;
this->pudpiiu->beaconAnomalyNotify ();
# if DEBUG
+7
View File
@@ -118,6 +118,7 @@ public:
void beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime,
ca_uint32_t beaconNumber, unsigned protocolRevision );
void repeaterSubscribeConfirmNotify ();
unsigned beaconAnomaliesSinceProgramStart () const;
// IO management
void flushRequest ();
@@ -254,6 +255,7 @@ private:
unsigned initializingThreadsPriority;
unsigned maxRecvBytesTCP;
unsigned nRecvThreadsPending;
unsigned beaconAnomalyCount;
bool preemptiveCallbackEnabled;
void privateUninstallIIU ( epicsGuard < callbackMutex > &, tcpiiu &iiu );
@@ -404,6 +406,11 @@ inline bool cac::preemptiveCallbakIsEnabled () const
return this->preemptiveCallbackEnabled;
}
inline unsigned cac::beaconAnomaliesSinceProgramStart () const
{
return this->beaconAnomalyCount;
}
inline epicsGuard < callbackMutex > cac::callbackGuardFactory ()
{
// facilitate the return value optimization
+3 -2
View File
@@ -930,9 +930,11 @@ epicsShareFunc int epicsShareAPI ca_replace_printf_handler (
* (for testing purposes only)
*/
epicsShareFunc unsigned epicsShareAPI ca_get_ioc_connection_count (void);
epicsShareFunc int epicsShareAPI ca_preemtive_callback_is_enabled (void);
epicsShareFunc void epicsShareAPI ca_self_test (void);
epicsShareFunc unsigned epicsShareAPI ca_beacon_anomaly_count (void);
epicsShareFunc unsigned epicsShareAPI ca_search_attempts (chid chan);
epicsShareFunc double epicsShareAPI ca_beacon_period (chid chan);
epicsShareFunc int epicsShareAPI ca_preemtive_callback_is_enabled ();
/*
* used when an auxillary thread needs to join a CA client context started
@@ -945,7 +947,6 @@ epicsShareFunc int epicsShareAPI ca_attach_context ( struct ca_client_context *
epicsShareFunc int epicsShareAPI ca_client_status ( unsigned level );
epicsShareFunc int epicsShareAPI ca_context_status ( struct ca_client_context *, unsigned level );
epicsShareFunc void epicsShareAPI ca_self_test ();
/*
* deprecated
+6
View File
@@ -242,6 +242,7 @@ public:
void show ( unsigned level ) const;
unsigned connectionCount () const;
unsigned sequenceNumberOfOutstandingIO () const;
unsigned beaconAnomaliesSinceProgramStart () const;
void incrementOutstandingIO ( unsigned ioSeqNo );
void decrementOutstandingIO ( unsigned ioSeqNo );
void exception ( int status, const char *pContext,
@@ -536,6 +537,11 @@ inline unsigned ca_client_context::connectionCount () const
return this->clientCtx.connectionCount ();
}
inline unsigned ca_client_context::beaconAnomaliesSinceProgramStart () const
{
return this->clientCtx.beaconAnomaliesSinceProgramStart ();
}
inline CASG * ca_client_context::lookupCASG ( unsigned id )
{
return this->clientCtx.lookupCASG ( id );