Index: /trunk/FACT++/src/EventBuilderWrapper.h
===================================================================
--- /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11135)
+++ /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11136)
@@ -720,4 +720,6 @@
     DimDescribedService fDimCurrentEvent;
     DimDescribedService fDimEventData;
+    DimDescribedService fDimFwVersion;
+    DimDescribedService fDimStatistics;
 
     bool fDebugStream;
@@ -737,4 +739,6 @@
         fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", ""),
 	fDimEventData("FAD_CONTROL/EVENT_DATA", "S:1;I:1;S:1;I:2;S:1;S", ""),
+        fDimFwVersion("FAD_CONTROL/FIRMWARE_VERSION", "F:40", ""),
+        fDimStatistics("FAD_CONTROL/STATISTICS", "X:8", ""),
         fDebugStream(false), fDebugRead(false)
    {
@@ -746,7 +750,7 @@
         memset(fNumEvts, 0, sizeof(fNumEvts));
 
-        Update(fDimRuns,         uint32_t(0));
-        Update(fDimCurrentEvent, uint32_t(0));
-        Update(fDimEvents,       fNumEvts);
+        fDimRuns.Update(uint32_t(0));
+        fDimCurrentEvent.Update(uint32_t(0));
+        fDimEvents.Update(fNumEvts);
 
         for (size_t i=0; i<40; i++)
@@ -906,12 +910,4 @@
     vector<DataFileImp*> fFiles;
 
-    template<class T>
-        void Update(DimDescribedService &svc, const T &data) const
-    {
-        cout << "Update: " << svc.getName() << " (" << sizeof(T) << ")" << endl;
-        svc.setData(const_cast<T*>(&data), sizeof(T));
-        svc.updateService();
-    }
-
     FileHandle_t runOpen(uint32_t runid, RUN_HEAD *h, size_t)
     {
@@ -943,10 +939,10 @@
             fNumEvts[kCurrent] = 0;
 
-            Update(fDimRuns,         fMaxRun);
-            Update(fDimEvents,       fNumEvts);
-            Update(fDimCurrentEvent, uint32_t(0));
-        }
-
-        Update(fDimFiles, fFiles.size());
+            fDimRuns.Update(fMaxRun);
+            fDimEvents.Update(fNumEvts);
+            fDimCurrentEvent.Update(uint32_t(0));
+        }
+
+        fDimFiles.Update(fFiles.size());
 
         return reinterpret_cast<FileHandle_t>(file);
@@ -962,10 +958,10 @@
         if (file->GetRunId()==fMaxRun)
         {
-            Update(fDimCurrentEvent, e->EventNum);
+            fDimCurrentEvent.Update(e->EventNum);
             fNumEvts[kCurrent]++;
         }
 
         fNumEvts[kTotal]++;
-        Update(fDimEvents, fNumEvts);
+        fDimEvents.Update(fNumEvts);
 
         // ===> SignalEvtWritten(runid);
@@ -998,5 +994,5 @@
         fFiles.erase(it);
 
-        Update(fDimFiles, fFiles.size());
+        fDimFiles.Update(fFiles.size());
 
         const bool rc = file->Close(tail);
@@ -1102,11 +1098,13 @@
 
         template<typename T>
-        vector<T> Check(const PEVNT_HEADER *fadhd, const T &val, bool &rc)
-        {
-            const size_t offset = reinterpret_cast<const char*>(&val)-reinterpret_cast<const char*>(fadhd);
+        vector<T> CheckVals(const PEVNT_HEADER *fadhd, const T *val, bool &rc)
+        {
+            const size_t offset = reinterpret_cast<const char*>(val)-reinterpret_cast<const char*>(fadhd);
+
+            cout << "OFFSET=" << offset << endl;
 
             vector<T> vec(40);
 
-            vec[0] = val;
+            vec[0] = *val;
 
             rc = true;
@@ -1115,5 +1113,5 @@
 
                 const T &t = *reinterpret_cast<const T*>(reinterpret_cast<const char*>(fadhd+i)+offset);
-                if (t!=val)
+                if (t!=*val)
                     rc = false;
 
@@ -1123,5 +1121,5 @@
             return vec;
         }
-
+       /*
         template<typename T>
         vector<uint8_t> CheckBits(const PEVNT_HEADER *fadhd, const T &val, T &rc)
@@ -1145,5 +1143,5 @@
             rc = ~rc;
             return vec;
-        }
+        }*/
 
 
@@ -1164,9 +1162,24 @@
         bool     ok_verno;
         bool     ok_runno;
-        uint16_t ok_bitmask;
-
-        const vector<uint16_t> verno   = Check(fadhd, fadhd->version_no, ok_verno);
-        const vector<uint32_t> runno   = Check(fadhd, fadhd->runnumber,  ok_runno);
-        const vector<uint8_t>  bitmask = CheckBits(fadhd, fadhd->PLLLCK, ok_bitmask);
+       // uint16_t ok_bitmask;
+
+        const vector<uint16_t> verno = CheckVals(fadhd, &fadhd->version_no, ok_verno);
+        const vector<uint32_t> runno = CheckVals(fadhd, &fadhd->runnumber,  ok_runno);
+       // const vector<uint8_t>  bitmask = CheckBits(fadhd, &fadhd->PLLLCK,     ok_bitmask);
+
+        static vector<uint16_t> fStoreVersion;
+
+        if (verno!=fStoreVersion)
+        {
+            vector<float> data(40);
+            for (int i=0; i<40; i++)
+            {
+                ostringstream ver;
+                ver << (verno[i]&0xff) << '.' << (verno[i]>>8); // WARNING: No byte-swap yet!
+                data[i] = atof(ver.str().c_str());
+            }
+            fDimFwVersion.Update(data);
+            fStoreVersion=verno;
+        }
 
         /*
@@ -1230,26 +1243,4 @@
 
 	return 0;
-    }
-
-};
-
-EventBuilderWrapper *EventBuilderWrapper::This = 0;
-
-// ----------- Event builder callbacks implementation ---------------
-extern "C"
-{
-    FileHandle_t runOpen(uint32_t irun, RUN_HEAD *runhd, size_t len)
-    {
-        return EventBuilderWrapper::This->runOpen(irun, runhd, len);
-    }
-
-    int runWrite(FileHandle_t fileId, EVENT *event, size_t len)
-    {
-        return EventBuilderWrapper::This->runWrite(fileId, event, len);
-    }
-
-    int runClose(FileHandle_t fileId, RUN_TAIL *runth, size_t len)
-    {
-        return EventBuilderWrapper::This->runClose(fileId, runth, len);
     }
 
@@ -1265,25 +1256,86 @@
         str << "): " << message;
 
-        EventBuilderWrapper::This->fMsg.Update(str, severity);
-    }
-
-    void factStat(int severity, int err, const char* message )
-    {
-        if (err!=-1)
-        {
-            factOut(severity, err, message);
+        fMsg.Update(str, severity);
+    }
+
+    void factStat(int64_t *stat, int len)
+    {
+        if (len!=7)
+        {
+            fMsg.Warn("factStat received unknown number of values.");
             return;
         }
 
-        static string last;
-        if (message==last)
+        vector<int64_t> data(1, g_maxMem);
+        data.insert(data.end(), stat, stat+len);
+
+        static vector<int64_t> last(8);
+        if (data==last)
             return;
-
-        last = message;
-
-        ostringstream str("Status: ");
-        str << message;
-
-        EventBuilderWrapper::This->fMsg.Update(str, severity);
+        last = data;
+
+        fDimStatistics.Update(data);
+
+        //   len ist die Laenge des arrays.
+        //   array[4] enthaelt wieviele bytes im Buffer aktuell belegt sind; daran
+        //   kannst Du pruefen, ob die 100MB voll sind ....
+
+        /*
+         stat[0]= qwait;
+         stat[1]= qskip;
+         stat[2]= qdel ;
+         stat[3]= qtot ;
+         stat[4]= gi_usedMem ;
+         stat[5]= qread;
+         stat[6]= qconn;
+         */
+
+        ostringstream str;
+        str
+            << "Wait=" << stat[0] << " "
+            << "Skip=" << stat[1] << " "
+            << "Del="  << stat[2] << " "
+            << "Tot="  << stat[3] << " "
+            << "Mem="  << stat[4] << "/" << g_maxMem << " "
+            << "Read=" << stat[5] << " "
+            << "Conn=" << stat[6];
+
+
+        fMsg.Info(str);
+    }
+};
+
+EventBuilderWrapper *EventBuilderWrapper::This = 0;
+
+// ----------- Event builder callbacks implementation ---------------
+extern "C"
+{
+    FileHandle_t runOpen(uint32_t irun, RUN_HEAD *runhd, size_t len)
+    {
+        return EventBuilderWrapper::This->runOpen(irun, runhd, len);
+    }
+
+    int runWrite(FileHandle_t fileId, EVENT *event, size_t len)
+    {
+        return EventBuilderWrapper::This->runWrite(fileId, event, len);
+    }
+
+    int runClose(FileHandle_t fileId, RUN_TAIL *runth, size_t len)
+    {
+        return EventBuilderWrapper::This->runClose(fileId, runth, len);
+    }
+
+    void factOut(int severity, int err, const char *message)
+    {
+        EventBuilderWrapper::This->factOut(severity, err, message);
+    }
+
+    void factStat(int64_t *array, int len)
+    {
+        EventBuilderWrapper::This->factStat(array, len);
+    }
+
+    void debugHead(int i, void *buf)
+    {
     }
 
