]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Total errbit statistics added. Sergey.
authorhadaq <hadaq>
Tue, 31 May 2011 15:10:33 +0000 (15:10 +0000)
committerhadaq <hadaq>
Tue, 31 May 2011 15:10:33 +0000 (15:10 +0000)
ebctrl/ioc/ebctrlApp/src/Makefile
ebctrl/ioc/ebctrlApp/src/errbitstat.c

index a9641853cbca46aa2f5fa8740b3d9c82265915a9..0791a3a908311afa7144cf7f2ae0b2b5f09f3b97 100644 (file)
@@ -58,6 +58,7 @@ ebctrl_DBD += totalbytewrit.dbd
 ebctrl_DBD += totalevtdataerr.dbd
 ebctrl_DBD += totalevtdrate.dbd
 ebctrl_DBD += totalevttagerr.dbd
+ebctrl_DBD += totalerrbitstat.dbd
 
 # <name>_registerRecordDeviceDriver.cpp will be created from <name>.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
index 5b11f7436ca63882b73b6fdfd2d9d383e213fa74..785eb8d6cbb52c5e9ede2118e0aa193fbd012d4a 100644 (file)
@@ -63,7 +63,7 @@ static int env2int(char *envName)
     }
     else{
       if(errbitstatDebug)
-       printf("<E> errbitstat.c: env var %s is not known!");
+       printf("<E> 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<MAXERRS; i++ ){
-      if( errbit & (0x00000001 << errMsgs[i].bit) ){
-       sprintf(msg, "EB%s <E> subsys: %i errbit: %d msg: %s", getenv("EBNUM"), subsys, errMsgs[i].bit, errMsgs[i].msg);
+  for( i=0; i<MAXERRS; i++ ){
+    if( errbit & (0x00000001 << errMsgs[i].bit) ){
+      
+      retVal = retVal + errbitstat;
 
+      if(errbitstat != statOld[nrOfErrWord][subsys] && ((int)dT > env2int("ERRBITWAIT")) ){
+       sprintf(msg, "EB%s <E> 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("<E> 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;
        }