Index: /trunk/FACT++/src/fadctrl.cc
===================================================================
--- /trunk/FACT++/src/fadctrl.cc	(revision 11078)
+++ /trunk/FACT++/src/fadctrl.cc	(revision 11079)
@@ -51,14 +51,6 @@
 
 protected:
-    virtual void UpdateFirstHeader()
-    {
-    }
-
-    virtual void UpdateEventHeader()
-    {
-        // emit service with trigger counter from header
-        if (!fIsVerbose)
-            return;
-
+    void PrintEventHeader()
+    {
         Out() << endl << kBold << "Header received (N=" << dec << fCounter << "):" << endl;
         Out() << fEventHeader;
@@ -67,29 +59,11 @@
     }
 
-    /*
-    virtual void UpdateChannelHeader(int i)
-    {
-        // emit service with trigger counter from header
-        if (!fIsVerbose)
-            return;
-
-        Out() << fChannelHeader[i];
-        if (fIsHexOutput)
-            Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl;
-    }
-    */
-
-    virtual void UpdateChannelHeaders()
-    {
-        // emit service with trigger counter from header
-        if (!fIsVerbose)
-            return;
-
+    void PrintChannelHeaders()
+    {
         Out() << dec << endl;
 
-        Out() << kBold << "ID: Crate=" << fEventHeader.Crate() << " Board=" << fEventHeader.Board() << endl;
         for (unsigned int c=0; c<FAD::kNumChips; c++)
         {
-            Out() << "ReadoutWin #" << c << ":";
+            Out() << "ROI" << fEventHeader.Crate() << ":" << fEventHeader.Board() << ":" << c << ":";
             for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++)
                 Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fRegionOfInterest;
@@ -97,14 +71,50 @@
         }
 
+        Out() << "CEL" << fEventHeader.Crate() << ":" << fEventHeader.Board() << ":";
         for (unsigned int c=0; c<FAD::kNumChips; c++)
         {
-            Out() << "StartCells #" << c << ":";
-            for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++)
-                Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell;
-            Out() << endl;
-        }
+            if (0)//fIsFullChannelHeader)
+            {
+                for (unsigned int ch=0; ch<FAD::kNumChannelsPerChip; ch++)
+                    Out() << " " << setw(4) << fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell;
+                Out() << endl;
+            }
+            else
+            {
+                Out() << " ";
+                const uint16_t cel = fChannelHeader[c*FAD::kNumChannelsPerChip].fStartCell;
+                for (unsigned int ch=1; ch<FAD::kNumChannelsPerChip; ch++)
+                    if (cel!=fChannelHeader[c*FAD::kNumChannelsPerChip+ch].fStartCell)
+                    {
+                        Out() << "!";
+                        break;
+                    }
+                Out() << cel;
+            }
+        }
+        Out() << endl;
 
         if (fIsHexOutput)
             Out() << Converter::GetHex<uint16_t>(fChannelHeader, 16) << endl;
+
+    }
+
+    virtual void UpdateFirstHeader()
+    {
+    }
+
+    virtual void UpdateEventHeader()
+    {
+        // emit service with trigger counter from header
+        if (fIsVerbose)
+            PrintEventHeader();
+    }
+
+    virtual void UpdateChannelHeaders()
+    {
+        // emit service with trigger counter from header
+        if (fIsVerbose)
+            PrintChannelHeaders();
+
     }
 
@@ -173,6 +183,4 @@
             UpdateEventHeader();
 
-            fCounter++;
-
             fBuffer.resize(fEventHeader.fPackageLength-sizeof(FAD::EventHeader)/2);
             AsyncRead(ba::buffer(fBuffer), kReadData);
@@ -246,5 +254,8 @@
         }
 
-        UpdateChannelHeaders();
+        if (fIsVerbose)
+            UpdateChannelHeaders();
+
+        fCounter++;
 
         fBuffer.resize(sizeof(FAD::EventHeader)/2);
@@ -532,4 +543,15 @@
     }
 
+    void PrintEvent()
+    {
+        if (fCounter>0)
+        {
+            PrintEventHeader();
+            PrintChannelHeaders();
+        }
+        else
+            Out() << "No event received yet." << endl;
+    }
+
 };
 
@@ -824,10 +846,39 @@
     }
 
+    int PrintEvent(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "PrintEvent", 2))
+            return T::kSM_FatalError;
+
+        const int16_t slot = evt.Get<int16_t>();
+
+        if (slot<0)
+        {
+            for (BoardList::iterator i=fBoards.begin(); i!=fBoards.end(); i++)
+                i->second.second->PrintEvent();
+        }
+        else
+        {
+            const BoardList::iterator it=fBoards.find(slot);
+            if (it!=fBoards.end())
+            {
+                it->second.second->PrintEvent();
+                return T::GetCurrentState();
+            }
+
+            ostringstream str;
+            str << "Slot " << slot << " not found.";
+            T::Warn(str);
+        }
+
+        return T::GetCurrentState();
+    }
+
     int SetBlockTransmission(const EventImp &evt)
     {
-        if (!CheckEventSize(evt.GetSize(), "SetBlockTransmission", 5))
-            return T::kSM_FatalError;
-
-        const int32_t slot = evt.Get<int32_t>();
+        if (!CheckEventSize(evt.GetSize(), "SetBlockTransmission", 3))
+            return T::kSM_FatalError;
+
+        const int16_t slot = evt.Get<int32_t>();
 
         const BoardList::iterator it=fBoards.find(slot);
@@ -841,4 +892,28 @@
 
         it->second.second->SetBlockTransmission(evt.Get<uint8_t>(4));
+
+        return T::GetCurrentState();
+    }
+
+    int SetBlockTransmissionRange(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetBlockTransmissionRange", 5))
+            return T::kSM_FatalError;
+
+        const int16_t *slot  = evt.Ptr<int16_t>();
+        const bool     block = evt.Get<uint8_t>(8);
+
+        for (int i=slot[0]; i<=slot[1]; i++)
+        {
+            const BoardList::iterator it=fBoards.find(i);
+            if (it==fBoards.end())
+            {
+                ostringstream str;
+                str << "Slot " << i << " not found.";
+                T::Warn(str);
+                continue;
+            }
+            it->second.second->SetBlockTransmission(block);
+        }
 
         return T::GetCurrentState();
@@ -1239,8 +1314,20 @@
             ("");
 
-        T::AddEvent("BLOCK_TRANSMISSION", "I:1;B:1")
+        T::AddEvent("PRINT_EVENT", "I")
+            (boost::bind(&StateMachineFAD::PrintEvent, this, _1))
+            ("Print (last) event"
+             "|board[int]:slot from which the event should be printed (-1 for all)");
+
+        T::AddEvent("BLOCK_TRANSMISSION", "S:1;B:1")
             (boost::bind(&StateMachineFAD::SetBlockTransmission, this, _1))
             ("Blocks the transmission of commands to the given slot. Use with care! For debugging pupose only!"
-             "|slot[int]:Slot to which the command transmission should be blocked (0-39)"
+             "|slot[short]:Slot to which the command transmission should be blocked (0-39)"
+             "|enable[bool]:Whether the command transmission should be blockes (yes) or allowed (no)");
+
+        T::AddEvent("BLOCK_TRANSMISSION_RANGE", "S:2;B:1")
+            (boost::bind(&StateMachineFAD::SetBlockTransmissionRange, this, _1))
+            ("Blocks the transmission of commands to the given range of slots. Use with care! For debugging pupose only!"
+             "|first[short]:First slot to which the command transmission should be blocked (0-39)"
+             "|last[short]:Last slot to which the command transmission should be blocked (0-39)"
              "|enable[bool]:Whether the command transmission should be blockes (yes) or allowed (no)");
 
@@ -1278,5 +1365,5 @@
             (boost::bind(&StateMachineFAD::RemoveSlot, this, _1))
             ("Remove the Iaddress in slot n. For a list see LIST"
-             "|slot[int]:Remove the address in slot n from the list");
+             "|slot[short]:Remove the address in slot n from the list");
         T::AddEvent("LIST_SLOTS")
             (boost::bind(&StateMachineFAD::ListSlots, this))
