From: hadaq <hadaq>
Date: Thu, 28 Oct 2010 17:02:07 +0000 (+0000)
Subject: errBitStat added. Sergey.
X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=8d2e9536d8e699e985afbd4bb7d1852151219880;p=daqdata.git

errBitStat added. Sergey.
---

diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c
index 71e281b..0f0afbb 100644
--- a/hadaq/evtbuild.c
+++ b/hadaq/evtbuild.c
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.139 2010-10-11 15:42:32 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.140 2010-10-28 17:02:07 hadaq Exp $";
 
 #define _POSIX_C_SOURCE 199309L
 #define SYSLOG_NAMES
@@ -982,6 +982,7 @@ int main(int argc, char *argv[])
 		sprintf(buf, "evtId%d", i);
 		theStats->evtId[i] = Worker_addStatistic(worker, buf);
 	}
+
 	for (i = 0; i < theArgs->nrOfMsgs; i++) {
 		char buf[WORKER_MAX_NAME_LEN];
 
@@ -1011,6 +1012,30 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	/* 
+	 * Statistics of ErrorBits: Maximally five different errorBit
+	 * patterns can be monitored.
+	 */
+	for (i = 0; i < 5; i++) {
+		char buf[WORKER_MAX_NAME_LEN];
+		sprintf(buf, "errBitPtrn%d", i);
+		theStats->errBitPtrn[i] = Worker_addStatistic(worker, buf);
+	}
+
+	for (i = 0; i < theArgs->nrOfMsgs; i++) {
+		char buf[WORKER_MAX_NAME_LEN];
+		sprintf(buf, "errBitStat1_%d", i);
+		theStats->errBitStat0[i] = Worker_addStatistic(worker, buf);
+		sprintf(buf, "errBitStat2_%d", i);
+		theStats->errBitStat1[i] = Worker_addStatistic(worker, buf);
+		sprintf(buf, "errBitStat3_%d", i);
+		theStats->errBitStat2[i] = Worker_addStatistic(worker, buf);
+		sprintf(buf, "errBitStat4_%d", i);
+		theStats->errBitStat3[i] = Worker_addStatistic(worker, buf);
+		sprintf(buf, "errBitStat5_%d", i);
+		theStats->errBitStat4[i] = Worker_addStatistic(worker, buf);
+	}
+
 	/* Add statistic for fill levels of buffers. */
 	for (i = 0; i < theArgs->nrOfMsgs; i++) {
 		char buf[WORKER_MAX_NAME_LEN];
@@ -1132,6 +1157,39 @@ int main(int argc, char *argv[])
 
 			(*theStats->trigNr[i]) = SubEvt_trigNr(subEvt);
 			(*theStats->errBit[i]) = SubEvt_errBit(subEvt);
+
+			int ptrn;
+			for (ptrn = 0; ptrn < ERRBITPTRNMAX; ptrn++) {
+				if ((*theStats->errBitPtrn[ptrn]) == 0) {
+					(*theStats->errBitPtrn[ptrn]) = SubEvt_errBit(subEvt);
+					if (ptrn == 0)
+						(*theStats->errBitStat0[i])++;
+					else if (ptrn == 1)
+						(*theStats->errBitStat1[i])++;
+					else if (ptrn == 2)
+						(*theStats->errBitStat2[i])++;
+					else if (ptrn == 3)
+						(*theStats->errBitStat3[i])++;
+					else if (ptrn == 4)
+						(*theStats->errBitStat4[i])++;
+
+					break;
+				} else if ((*theStats->errBitPtrn[ptrn]) == SubEvt_errBit(subEvt)) {
+					if (ptrn == 0)
+						(*theStats->errBitStat0[i])++;
+					else if (ptrn == 1)
+						(*theStats->errBitStat1[i])++;
+					else if (ptrn == 2)
+						(*theStats->errBitStat2[i])++;
+					else if (ptrn == 3)
+						(*theStats->errBitStat3[i])++;
+					else if (ptrn == 4)
+						(*theStats->errBitStat4[i])++;
+
+					break;
+				}
+			}
+
 			if (theArgs->debugOptsCnt) {
 				(*theStats->debugWord[i]) = SubEvt_debugWord(subEvt);
 				(*theStats->debugSize[i]) = SubEvt_size(subEvt);