From c24964b3f207e85bfdf892f0e23191ed44ecba3c Mon Sep 17 00:00:00 2001 From: hadaq Date: Tue, 31 May 2011 15:10:33 +0000 Subject: [PATCH] Total errbit statistics added. Sergey. --- ebctrl/ioc/ebctrlApp/src/Makefile | 2 ++ ebctrl/ioc/ebctrlApp/src/errbitstat.c | 42 +++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ebctrl/ioc/ebctrlApp/src/Makefile b/ebctrl/ioc/ebctrlApp/src/Makefile index a964185..0791a3a 100644 --- a/ebctrl/ioc/ebctrlApp/src/Makefile +++ b/ebctrl/ioc/ebctrlApp/src/Makefile @@ -58,6 +58,7 @@ ebctrl_DBD += totalbytewrit.dbd ebctrl_DBD += totalevtdataerr.dbd ebctrl_DBD += totalevtdrate.dbd ebctrl_DBD += totalevttagerr.dbd +ebctrl_DBD += totalerrbitstat.dbd # _registerRecordDeviceDriver.cpp will be created from .dbd ebctrl_SRCS += ebctrl_registerRecordDeviceDriver.cpp @@ -87,6 +88,7 @@ ebctrl_SRCS += totalevtdisc.c ebctrl_SRCS += totalevtdrate.c ebctrl_SRCS += totalevtscomp.c ebctrl_SRCS += totalevttagerr.c +ebctrl_SRCS += totalerrbitstat.c # The following adds support from base/src/vxWorks ebctrl_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary diff --git a/ebctrl/ioc/ebctrlApp/src/errbitstat.c b/ebctrl/ioc/ebctrlApp/src/errbitstat.c index 5b11f74..785eb8d 100644 --- a/ebctrl/ioc/ebctrlApp/src/errbitstat.c +++ b/ebctrl/ioc/ebctrlApp/src/errbitstat.c @@ -63,7 +63,7 @@ static int env2int(char *envName) } else{ if(errbitstatDebug) - printf(" errbitstat.c: env var %s is not known!"); + printf(" errbitstat.c: env var %s is not known!", envName); } if(errbitstatDebug) @@ -73,8 +73,10 @@ static int env2int(char *envName) return retVal; } -static void errbit2logger( const uint32_t errbit, const uint32_t errbitstat, int nrOfErrWord, const int subsys ) +static uint32_t errbit2logger( const uint32_t errbit, const uint32_t errbitstat, + int nrOfErrWord, const int subsys, const time_t dT) { + uint32_t retVal = 0; int i, j; char msg[250]; static uint32_t statOld[5][100]; /* 5 error words, 100 data sources */ @@ -93,19 +95,24 @@ static void errbit2logger( const uint32_t errbit, const uint32_t errbitstat, int /* * If errBitStatistics increased... */ - if(errbitstat != statOld[nrOfErrWord][subsys]){ - for( i=0; i subsys: %i errbit: %d msg: %s", getenv("EBNUM"), subsys, errMsgs[i].bit, errMsgs[i].msg); + for( i=0; i env2int("ERRBITWAIT")) ){ + sprintf(msg, "EB%s subsys: %i errbit: %d msg: %s", getenv("EBNUM"), subsys, errMsgs[i].bit, errMsgs[i].msg); + openlog("DAQ", LOG_ODELAY, LOG_LOCAL1); syslog(LOG_INFO, msg); closelog(); - } - } - statOld[nrOfErrWord][subsys] = errbitstat; + statOld[nrOfErrWord][subsys] = errbitstat; + } + } } + + return retVal; /* Zero if no error */ } long errbitstat_init( struct genSubRecord *pgsub ) @@ -115,7 +122,7 @@ long errbitstat_init( struct genSubRecord *pgsub ) long errbitstat_proc( struct genSubRecord *pgsub ) { - uint32_t *out[10]; + uint32_t *out[11]; unsigned long tmp; int i; @@ -129,7 +136,9 @@ long errbitstat_proc( struct genSubRecord *pgsub ) out[7] = (uint32_t *)pgsub->valh; /* errbit statistics 2 */ out[8] = (uint32_t *)pgsub->vali; /* errbit statistics 3 */ out[9] = (uint32_t *)pgsub->valj; /* errbit statistics 4 */ + out[10] = (uint32_t *)pgsub->valk; /* total statistics of errors */ + /* out[10] must not be initialized to zero here */ for( i=0; i<10; i++ ) *out[i] = 0; @@ -173,9 +182,14 @@ long errbitstat_proc( struct genSubRecord *pgsub ) * *************** error bit statictics *************** */ int j; + uint32_t totalErrBitStat = 0; static time_t t0 = 0; time_t t, dT; + if( (int)t0 == 0 ){ + *out[10] = 0; /* initialize total errorbit statistics */ + } + t = time(NULL); dT = t - t0; /* delta Time for logging error statistics */ @@ -187,6 +201,8 @@ long errbitstat_proc( struct genSubRecord *pgsub ) if( Worker_getStatistic( buf, name, &tmp ) == -1) { *out[i+5] = 0; + *out[10] = 0; /* total errorbit statistics */ + if(errbitstatDebug) printf(" errbitstat.c: Worker_getStatistic failed for %s!\n", name); } @@ -197,8 +213,10 @@ long errbitstat_proc( struct genSubRecord *pgsub ) * ERRBITLOG = 0/1 (log via syslog (off/on)) * ERRBITWAIT = wait time in seconds */ - if(env2int("ERRBITLOG") && ((int)dT > env2int("ERRBITWAIT"))){ - errbit2logger(*out[i], *out[i+5], i, j); + if(env2int("ERRBITLOG")){ + totalErrBitStat = totalErrBitStat + errbit2logger(*out[i], *out[i+5], i, j, dT); + *out[10] = totalErrBitStat; + t0 = t; } -- 2.43.0