Index: /trunk/FACT++/src/EventBuilderWrapper.h
===================================================================
--- /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11285)
+++ /trunk/FACT++/src/EventBuilderWrapper.h	(revision 11286)
@@ -2,5 +2,6 @@
 #define FACT_EventBuilderWrapper
 
-/*
+#include <sstream>
+
 #if BOOST_VERSION < 104400
 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))
@@ -9,8 +10,4 @@
 #endif
 #include <boost/thread.hpp>
-
-using namespace std;
-*/
-
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 
@@ -28,4 +25,6 @@
 
 using ba::ip::tcp;
+
+using namespace std;
 
 class DataFileImp
@@ -494,5 +493,5 @@
                      "Version number");
 
-            WriteKey("PLLLCK",  i, hh.PLLLCK,
+            WriteKey("STATUS",  i, hh.PLLLCK,
                      "");
 /*
@@ -508,8 +507,8 @@
             WriteKey("EVTCNTR", i, hh.fad_evt_counter,
                      "FAD Event Counter");
-*/
+
             WriteKey("REFCLK",  i, hh.REFCLK_frequency,
                      "Reference Clock Frequency");
-
+*/
             WriteKey("BOARDID", i, hh.board_id,
                      "Board ID");
@@ -518,6 +517,6 @@
                      "ADC clock phase shift");
 
-            //WriteKey("TRGGEN",  i, hh.number_of_triggers_to_generate,
-            //         "Number of triggers to generate");
+            WriteKey("TRGGEN",  i, hh.number_of_triggers_to_generate,
+                     "Number of triggers to generate");
 
             WriteKey("PRESC",   i, hh.trigger_generator_prescaler,
@@ -690,13 +689,15 @@
     enum CommandStates_t // g_runStat
     {
-        kAbort      = -2,  // quit as soon as possible ('abort')
-        kExit       = -1,  // stop reading, quit when buffered events done ('exit')
-        kInitialize =  0,  // 'initialize' (e.g. dim not yet started)
-        kHybernate  =  1,  // do nothing for long time ('hybernate') [wakeup within ~1sec]
-        kSleep      =  2,  // do nothing ('sleep')                   [wakeup within ~10msec]
-        kModeFlush  = 10,  // read data from camera, but skip them ('flush')
-        kModeTest   = 20,  // read data and process them, but do not write to disk ('test')
-        kModeFlag   = 30,  // read data, process and write all to disk ('flag')
-        kModeRun    = 40,  // read data, process and write selected to disk ('run')
+        kAbort      = -40,  // quit as soon as possible ('abort')
+        kExit       = -30,  // stop reading, quit when buffered events done ('exit')
+        kReset      = -20,  // Like EXIT but without closing files and sockets
+        kStop       = -10,  // Like ABORT but without closing files and sockets
+        kInitialize =  0,   // 'initialize' (e.g. dim not yet started)
+        kHybernate  =  1,   // do nothing for long time ('hybernate') [wakeup within ~1sec]
+        kSleep      =  2,   // do nothing ('sleep')                   [wakeup within ~10msec]
+        kModeFlush  = 10,   // read data from camera, but skip them ('flush')
+        kModeTest   = 20,   // read data and process them, but do not write to disk ('test')
+        kModeFlag   = 30,   // read data, process and write all to disk ('flag')
+        kModeRun    = 40,   // read data, process and write selected to disk ('run')
     };
 
@@ -734,5 +735,6 @@
     DimDescribedService fDimTemperature;
     DimDescribedService fDimRefClock;
-    DimDescribedService fDimStatistics;
+    DimDescribedService fDimStatistics1;
+    DimDescribedService fDimStatistics2;
 
     bool fDebugStream;
@@ -782,5 +784,6 @@
         fDimTemperature ("FAD_CONTROL/TEMPERATURE",      "F:82", ""),
         fDimRefClock    ("FAD_CONTROL/REFERENCE_CLOCK",  "I:42", ""),
-        fDimStatistics  ("FAD_CONTROL/STATISTICS",       "X:8",  ""),
+        fDimStatistics1 ("FAD_CONTROL/STATISTICS1",      "I:3;I:5;I:1;X:3", ""),
+        fDimStatistics2 ("FAD_CONTROL/STATISTICS2",      "I:1;I:280;X:40;I:40;I:4;I:4;I:2;I:2;I:3;C:40",  ""),
         fDebugStream(false), fDebugRead(false)
    {
@@ -819,9 +822,10 @@
     void SetMaxMemory(unsigned int mb) const
     {
+        /*
         if (mb*1000000<GetUsedMemory())
         {
             // ffMsg.Warn("...");
             return;
-        }
+        }*/
 
         g_maxMem = size_t(mb)*1000000;
@@ -888,4 +892,10 @@
         fMsg.Message("Signal abort to EventBuilder thread...");
         g_runStat = kAbort;
+    }
+
+    void ResetThread()
+    {
+        fMsg.Message("Signal reset to EventBuilder thread...");
+        g_runStat = kReset;
     }
 
@@ -952,5 +962,5 @@
     }
 
-    size_t GetUsedMemory() const { return gi_usedMem; }
+//    size_t GetUsedMemory() const { return gi_usedMem; }
 
     virtual int CloseOpenFiles() { CloseRunFile(0, 0); return 0; }
@@ -1288,5 +1298,5 @@
         fMsg.Update(str, severity);
     }
-
+/*
     void factStat(int64_t *stat, int len)
     {
@@ -1323,4 +1333,66 @@
         fMsg.Info(str);
     }
+    */
+
+    void factStat(const EVT_STAT &stat)
+    {
+        fDimStatistics2.Update(stat);
+        /*
+         //some info about what happened since start of program (or last 'reset')
+         uint32_t reset ;             //#if increased, reset all counters
+         uint32_t numRead[MAX_SOCK] ; //how often succesfull read from N sockets per loop
+
+         uint64_t gotByte[NBOARDS] ;  //#Bytes read per Board
+         uint32_t gotErr[NBOARDS] ;   //#Communication Errors per Board
+         uint32_t evtGet;             //#new Start of Events read
+         uint32_t evtTot;             //#complete Events read
+         uint32_t evtErr;             //#Events with Errors
+         uint32_t evtSkp;             //#Events incomplete (timeout)
+
+         uint32_t procTot;            //#Events processed
+         uint32_t procErr;            //#Events showed problem in processing
+         uint32_t procTrg;            //#Events accepted by SW trigger
+         uint32_t procSkp;            //#Events rejected by SW trigger
+
+         uint32_t feedTot;            //#Events used for feedBack system
+         uint32_t feedErr;            //#Events rejected by feedBack
+
+         uint32_t wrtTot;             //#Events written to disk
+         uint32_t wrtErr;             //#Events with write-error
+
+         uint32_t runOpen;            //#Runs opened
+         uint32_t runClose;           //#Runs closed
+         uint32_t runErr;             //#Runs with open/close errors
+
+
+         //info about current connection status
+         uint8_t  numConn[NBOARDS] ;  //#Sockets succesfully open per board
+         */
+    }
+
+    void factStat(const GUI_STAT &stat)
+    {
+        fDimStatistics1.Update(stat);
+        /*
+         //info about status of the main threads
+         int32_t  readStat ;          //read thread
+         int32_t  procStat ;          //processing thread(s)
+         int32_t  writStat ;          //write thread
+
+         //info about some rates
+         int32_t  deltaT ;            //time in milli-seconds for rates
+         int32_t  readEvt ;           //#events read
+         int32_t  procEvt ;           //#events processed
+         int32_t  writEvt ;           //#events written
+         int32_t  skipEvt ;           //#events skipped
+
+         //some info about current state of event buffer (snapspot)
+         int32_t evtBuf;             //#Events currently waiting in Buffer
+         uint64_t totMem;             //#Bytes available in Buffer
+         uint64_t usdMem;             //#Bytes currently used
+         uint64_t maxMem;             //max #Bytes used during past Second
+         */
+    }
+
 
     boost::array<FAD::EventHeader, 40> fVecHeader;
@@ -1443,7 +1515,7 @@
 	    fNumConnected.resize(40);
 
-	vector<uint> con(gi_NumConnect, gi_NumConnect+40);
-
-	bool changed = con!=fNumConnected || !IsThreadRunning();
+	const vector<uint> con(gi_NumConnect, gi_NumConnect+40);
+
+	const bool changed = con!=fNumConnected || !IsThreadRunning();
 
         fNumConnected = con;
@@ -1585,10 +1657,15 @@
     }
 
-    void factStat(int64_t *array, int len)
-    {
-        EventBuilderWrapper::This->factStat(array, len);
-    }
-
-    void debugHead(int socket, void *buf)
+    void factStat(GUI_STAT stat)
+    {
+        EventBuilderWrapper::This->factStat(stat);
+    }
+
+    void factStatNew(EVT_STAT stat)
+    {
+        EventBuilderWrapper::This->factStat(stat);
+    }
+
+    void debugHead(int socket, int/*board*/, void *buf)
     {
         const uint16_t *ptr = reinterpret_cast<uint16_t*>(buf);
