Index: trunk/FACT++/src/EventBuilderWrapper.h
===================================================================
--- trunk/FACT++/src/EventBuilderWrapper.h	(revision 11012)
+++ trunk/FACT++/src/EventBuilderWrapper.h	(revision 11013)
@@ -79,7 +79,50 @@
         return result.str();
     }
-
 };
 
+class DataFileNone : public DataFileImp
+{
+public:
+    DataFileNone(uint32_t id) : DataFileImp(id) { }
+
+    bool OpenFile(RUN_HEAD* h)
+    {
+        cout << "OPEN_FILE #" << GetRunId() << " (" << this << ")" <<  endl;
+        cout << " Ver= " << h->Version << endl;
+        cout << " Typ= " << h->RunType << endl;
+        cout << " Nb = " << h->NBoard << endl;
+        cout << " Np = " << h->NPix << endl;
+        cout << " NTm= " << h->NTm << endl;
+        cout << " roi= " << h->Nroi << endl;
+
+        return true;
+    }
+    bool Write(EVENT *)
+    {
+        return true;
+    }
+    bool Close(RUN_TAIL * = 0)
+    {
+        cout << "CLOSE FILE #" << GetRunId() << " (" << this << ")" << endl;
+        return true;
+    }
+};
+
+class DataFileDebug : public DataFileNone
+{
+public:
+    DataFileDebug(uint32_t id) : DataFileNone(id) { }
+
+    bool Write(EVENT *e)
+    {
+        cout << "WRITE_EVENT #" << GetRunId() << " (" << e->EventNum << ")" << endl;
+        cout << " Typ=" << e->TriggerType << endl;
+        cout << " roi=" << e->Roi << endl;
+        cout << " trg=" << e->SoftTrig << endl;
+        cout << " tim=" << e->PCTime << endl;
+
+        return true;
+    }
+};
 
 #include "FAD.h"
@@ -265,5 +308,5 @@
 };
 
-
+#ifdef HAS_FITS
 class DataFileFits : public DataFileImp
 {
@@ -624,4 +667,7 @@
 
 };
+#else
+#define DataFileFits DataFileRaw
+#endif
 
 class EventBuilderWrapper
@@ -630,4 +676,6 @@
     // FIXME
     static EventBuilderWrapper *This;
+
+    MessageImp &fMsg;
 
 private:
@@ -647,6 +695,4 @@
     };
 
-    MessageImp &fMsg;
-
     enum
     {
@@ -655,5 +701,14 @@
     };
 
-    bool fFitsFormat;
+    enum FileFormat_t
+    {
+        kNone,
+        kDebug,
+        kFits,
+        kRaw
+    };
+
+    FileFormat_t fFileFormat;
+
 
     uint32_t fMaxRun;
@@ -665,7 +720,12 @@
     DimDescribedService fDimCurrentEvent;
 
+    int Write(const Time &time, const std::string &txt, int qos)
+    {
+        return fMsg.Write(time, txt, qos);
+    }
+
 public:
-    EventBuilderWrapper(MessageImp &msg) : fMsg(msg), 
-        fFitsFormat(false), fMaxRun(0),
+    EventBuilderWrapper(MessageImp &imp) : fMsg(imp),
+        fFileFormat(kRaw), fMaxRun(0),
         fDimFiles ("FAD_CONTROL/FILES",         "X:1", ""),
         fDimRuns  ("FAD_CONTROL/RUNS",          "I:1", ""),
@@ -687,8 +747,9 @@
     {
         Abort();
+
         // FIXME: Used timed_join and abort afterwards
         //        What's the maximum time the eb need to abort?
         fThread.join();
-        //fMsg.Info("EventBuilder stopped.");
+        //ffMsg.Info("EventBuilder stopped.");
 
         for (vector<DataFileImp*>::iterator it=fFiles.begin(); it!=fFiles.end(); it++)
@@ -696,9 +757,4 @@
     }
 
-    void Update(ostringstream &msg, int severity)
-    {
-        fMsg.Update(msg, severity);
-    }
-
     bool IsThreadRunning()
     {
@@ -710,5 +766,5 @@
         if (mb*1000000<GetUsedMemory())
         {
-            // fMsg.Warn("...");
+            // ffMsg.Warn("...");
             return;
         }
@@ -771,5 +827,5 @@
     {
         fThread.join();
-        fMsg.Message("EventBuilder stopped.");
+        ffMsg.Message("EventBuilder stopped.");
     }*/
 
@@ -828,7 +884,12 @@
     {
         // Check if file already exists...
-        DataFileImp *file = fFitsFormat ?
-            static_cast<DataFileImp*>(new DataFileFits(runid)) :
-            static_cast<DataFileImp*>(new DataFileRaw(runid));
+        DataFileImp *file = 0;
+        switch (fFileFormat)
+        {
+        case kNone:  file = new DataFileNone(runid);  break;
+        case kDebug: file = new DataFileDebug(runid); break;
+        case kFits:  file = new DataFileFits(runid);  break;
+        case kRaw:   file = new DataFileRaw(runid);   break;
+        }
 
         try
@@ -841,12 +902,4 @@
             return 0;
         }
-
-        cout << "OPEN_FILE #" << runid << " (" << file << ")" <<  endl;
-        cout << " Ver= " << h->Version << endl;
-        cout << " Typ= " << h->RunType << endl;
-        cout << " Nb = " << h->NBoard << endl;
-        cout << " Np = " << h->NPix << endl;
-        cout << " NTm= " << h->NTm << endl;
-        cout << " roi= " << h->Nroi << endl;
 
         fFiles.push_back(file);
@@ -864,7 +917,4 @@
         Update(fDimFiles, fFiles.size());
 
-//        fDimFiles.setData(fFiles.size());
-//        fDimFiles.update();
-
         return reinterpret_cast<FileHandle_t>(file);
     }
@@ -873,12 +923,4 @@
     {
         DataFileImp *file = reinterpret_cast<DataFileImp*>(handler);
-
-        cout << "WRITE_EVENT " << file->GetRunId() << endl;
-
-        cout << " Evt=" << e->EventNum << endl;
-        cout << " Typ=" << e->TriggerType << endl;
-        cout << " roi=" << e->Roi << endl;
-        cout << " trg=" << e->SoftTrig << endl;
-        cout << " tim=" << e->PCTime << endl;
 
         if (!file->Write(e))
@@ -908,5 +950,5 @@
         DataFileImp *file = reinterpret_cast<DataFileImp*>(handler);
 
-         const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file);
+        const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file);
         if (it==fFiles.end())
         {
@@ -918,13 +960,10 @@
 
         ostringstream str;
-        str << "CLOSE_RUN requested for " << file->GetRunId() << " (" << file << ")" <<endl;
-        fMsg.Debug(str);
+        str << "Closing file for run " << file->GetRunId() << " (" << file << ")" << endl;
+        fMsg.Info(str);
 
         fFiles.erase(it);
 
         Update(fDimFiles, fFiles.size());
-
-        //fDimFiles.setData(fFiles.size());
-        //fDimFiles.update();
 
         const bool rc = file->Close(tail);
@@ -974,5 +1013,5 @@
             str << err;
         str << "): " << message;
-        EventBuilderWrapper::This->Update(str, severity);
+        EventBuilderWrapper::This->fMsg.Update(str, severity);
     }
 
@@ -994,5 +1033,5 @@
         str << message;
 
-        EventBuilderWrapper::This->Update(str, severity);
+        EventBuilderWrapper::This->fMsg.Update(str, severity);
     }
 
