Index: /trunk/FACT++/Makefile.am
===================================================================
--- /trunk/FACT++/Makefile.am	(revision 12159)
+++ /trunk/FACT++/Makefile.am	(revision 12160)
@@ -70,5 +70,13 @@
 if HAS_HELP2MAN
 dist_man1_MANS = \
-	dimctrl.man ftmctrl.man datalogger.man triggerschedule.man fitsdump.man
+	dimctrl.man \ 
+	ftmctrl.man \
+	fadctrl.man \
+	fscctrl.man \
+	mcp.man \
+	feedback.man \
+	biasctrl.man \
+	datalogger.man \
+	fitsdump.man
 endif
 
@@ -377,5 +385,6 @@
 fact_SOURCES = $(fact_SRCADD) $(fact_QT_SOURCES) \
 	gui/CheckBoxDelegate.cc gui/HtmlDelegate.cc \
-	gui/fact.cc gui/FactGui.cc src/HeadersFTM.cc
+	gui/fact.cc gui/FactGui.cc src/HeadersFTM.cc \
+	src/PixelMap.cc
 
 viewer_LDADD = $(QT4_LIB) $(QT4_LDFLAGS) -L. -lQtOpenGL -lGLU libConfiguration.la libTools.la
Index: /trunk/FACT++/Makefile.in
===================================================================
--- /trunk/FACT++/Makefile.in	(revision 12159)
+++ /trunk/FACT++/Makefile.in	(revision 12160)
@@ -229,5 +229,5 @@
 	gui/BasicGlCamera.cc gui/CheckBoxDelegate.cc \
 	gui/HtmlDelegate.cc gui/fact.cc gui/FactGui.cc \
-	src/HeadersFTM.cc
+	src/HeadersFTM.cc src/PixelMap.cc
 am__objects_2 =
 @HAS_GUI_TRUE@am__objects_3 = gui/design.$(OBJEXT)
@@ -245,5 +245,5 @@
 	gui/CheckBoxDelegate.$(OBJEXT) gui/HtmlDelegate.$(OBJEXT) \
 	gui/fact.$(OBJEXT) gui/FactGui.$(OBJEXT) \
-	src/HeadersFTM.$(OBJEXT)
+	src/HeadersFTM.$(OBJEXT) src/PixelMap.$(OBJEXT)
 fact_OBJECTS = $(am_fact_OBJECTS)
 am__DEPENDENCIES_1 =
@@ -690,5 +690,13 @@
 # 	libAstro.la
 @HAS_HELP2MAN_TRUE@dist_man1_MANS = \
-@HAS_HELP2MAN_TRUE@	dimctrl.man ftmctrl.man datalogger.man triggerschedule.man fitsdump.man
+@HAS_HELP2MAN_TRUE@	dimctrl.man \
+@HAS_HELP2MAN_TRUE@	ftmctrl.man \
+@HAS_HELP2MAN_TRUE@	fadctrl.man \
+@HAS_HELP2MAN_TRUE@	fscctrl.man \
+@HAS_HELP2MAN_TRUE@	mcp.man \
+@HAS_HELP2MAN_TRUE@	feedback.man \
+@HAS_HELP2MAN_TRUE@	biasctrl.man \
+@HAS_HELP2MAN_TRUE@	datalogger.man \
+@HAS_HELP2MAN_TRUE@	fitsdump.man
 
 
@@ -881,4 +889,8 @@
 test_SOURCES = src/test.cc
 test_LDADD = libTools.la libStateMachine.la libTime.la libDim.la libDim++.la libConfiguration.la
+
+#test_SOURCES = src/test.cc  src/DataCalib.cc src/DataProcessorImp.cc src/DimWriteStatistics.cc src/FitsFile.cc src/MessageImp.cc src/DimDescriptionService.cc src/WindowLog.cc
+#test_LDADD = libTime.la  libDim.la libDim++.la
+#libTools.la libStateMachine.la libTime.la libDim.la libDim++.la libConfiguration.la
 datalogger_SOURCES = src/datalogger.cc src/LocalControl.h \
 	$(am__append_6)
@@ -935,5 +947,6 @@
 fact_SOURCES = $(fact_SRCADD) $(fact_QT_SOURCES) \
 	gui/CheckBoxDelegate.cc gui/HtmlDelegate.cc \
-	gui/fact.cc gui/FactGui.cc src/HeadersFTM.cc
+	gui/fact.cc gui/FactGui.cc src/HeadersFTM.cc \
+	src/PixelMap.cc
 
 viewer_LDADD = $(QT4_LIB) $(QT4_LDFLAGS) -L. -lQtOpenGL -lGLU libConfiguration.la libTools.la
@@ -1279,4 +1292,6 @@
 gui/FactGui.$(OBJEXT): gui/$(am__dirstamp) \
 	gui/$(DEPDIR)/$(am__dirstamp)
+src/PixelMap.$(OBJEXT): src/$(am__dirstamp) \
+	src/$(DEPDIR)/$(am__dirstamp)
 fact$(EXEEXT): $(fact_OBJECTS) $(fact_DEPENDENCIES) 
 	@rm -f fact$(EXEEXT)
@@ -1494,4 +1509,5 @@
 	-rm -f src/MessageImp.$(OBJEXT)
 	-rm -f src/MessageImp.lo
+	-rm -f src/PixelMap.$(OBJEXT)
 	-rm -f src/Readline.$(OBJEXT)
 	-rm -f src/Readline.lo
@@ -1615,4 +1631,5 @@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/MessageDim.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/MessageImp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/PixelMap.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/Readline.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ReadlineColor.Plo@am__quote@
Index: /trunk/FACT++/gui/FactGui.h
===================================================================
--- /trunk/FACT++/gui/FactGui.h	(revision 12159)
+++ /trunk/FACT++/gui/FactGui.h	(revision 12160)
@@ -3690,5 +3690,5 @@
         fDimFadRuns            ("FAD_CONTROL/RUNS",               (void*)NULL, 0, this),
         fDimFadEvents          ("FAD_CONTROL/EVENTS",             (void*)NULL, 0, this),
-        fDimFadRawData         ("FAD_CONTROL/RAW_DATA",           (void*)NULL, 0, this),
+        fDimFadRawData         ("FAD_CONTROL/RAWX_DATA",           (void*)NULL, 0, this),
         fDimFadEventData       ("FAD_CONTROL/EVENT_DATA",         (void*)NULL, 0, this),
         fDimFadConnections     ("FAD_CONTROL/CONNECTIONS",        (void*)NULL, 0, this),
@@ -3701,5 +3701,5 @@
         fDimFadRoi             ("FAD_CONTROL/REGION_OF_INTEREST", (void*)NULL, 0, this),
         fDimFadDac             ("FAD_CONTROL/DAC",                (void*)NULL, 0, this),
-        fDimFadDrsCalibration  ("FAD_CONTROL/DRS_CALIBRATION",    (void*)NULL, 0, this),
+        fDimFadDrsCalibration  ("FAD_CONTROL/DRSX_CALIBRATION",    (void*)NULL, 0, this),
         fDimFadStatus          ("FAD_CONTROL/STATUS",             (void*)NULL, 0, this),
         fDimFadStatistics1     ("FAD_CONTROL/STATISTICS1",        (void*)NULL, 0, this),
Index: /trunk/FACT++/src/DataWriteFits.cc
===================================================================
--- /trunk/FACT++/src/DataWriteFits.cc	(revision 12159)
+++ /trunk/FACT++/src/DataWriteFits.cc	(revision 12160)
@@ -44,5 +44,5 @@
     fFile.AddColumn('C', "Errors",              4);
     fFile.AddColumn('I', "SoftTrig");
-    fFile.AddColumn('I', "PCTime",              2);
+    fFile.AddColumn('I', "UnixTimeUTC",         2);
     fFile.AddColumn('I', "BoardTime",           NBOARDS);
     fFile.AddColumn('S', "StartCellData",       NPIX);
Index: /trunk/FACT++/src/PixelMap.h
===================================================================
--- /trunk/FACT++/src/PixelMap.h	(revision 12159)
+++ /trunk/FACT++/src/PixelMap.h	(revision 12160)
@@ -31,4 +31,6 @@
     int group() const { return pixel()>4; }
     int hv() const    { return hv_channel+hv_board*32; }
+
+    operator bool() const { return index>=0; }
 };
 
@@ -181,5 +183,3 @@
 };
 
-//const PixelMapEntry PixelMap::empty = { 0, 0, 0, 0, 0, 0 };
-
 #endif
Index: /trunk/FACT++/src/feedback.cc
===================================================================
--- /trunk/FACT++/src/feedback.cc	(revision 12159)
+++ /trunk/FACT++/src/feedback.cc	(revision 12160)
@@ -301,18 +301,22 @@
                             // Kd = 0;
 
-                            //                    -110 / -110 (-23 DAC / -0.51V)
-                            // Reference voltage: -238 / -203
-                            //                    -360 / -343 ( 23 DAC /  0.51V)
-
-                            // 0.005 A/V
-                            // 220 Amplitude / 1V
-
-                            // Gain = 1V / 200 = 0.005
-
                             // => Kp = 0.01 * gain     = 0.00005
                             // => Ki = 0.8  * gain/20s = 0.00025
                             // => Kd = 0.1  * gain/20s = 0.00003
 
-                            //valarray<double> correction = - Kp*(PV[2] - PV[1]) + Ki * dT * (SP-PV[2]) - Kd/dT * (PV[2] - 2*PV[1] + PV[0]);
+                            //valarray<double> correction =
+                            // -      Kp * (PV[2] - PV[1])
+                            // + dT * Ki * (SP    - PV[2])
+                            // - Kd / dT * (PV[2] - 2*PV[1] + PV[0]);
+                            //
+                            // - (Kp+Kd/dT1) * (PV[2] - PV[1])
+                            // + dT2 * Ki * (SP    - PV[2])
+                            // + Kd / dT1 * (PV[1] - PV[0]);
+                            //
+                            // - Kp * (PV[2] - PV[1])
+                            // + Ki * (SP    - PV[2])*dT
+                            // - Kd * (PV[2] - PV[1])/dT
+                            // + Kd * (PV[1] - PV[0])/dT;
+                            //
                             //valarray<double> correction =
                             //    - Kp*(PV[2] - PV[1]) + Ki * T21 * (SP-PV[2]) - Kd*(PV[2]-PV[1])/T21 - Kd*(PV[0]-PV[1])/T01;
@@ -324,4 +328,16 @@
                                 );
 
+                            /*
+                             integral = 0
+                             start:
+                                 integral += (fSP - fPV[2])*dt
+
+                                 output = Kp*(fSP - fPV[2]) + Ki*integral - Kd*(fPV[2] - fPV[1])/dt
+
+                                 wait(dt)
+
+                                 goto start
+                             */
+
                             vector<float> vec(2*BIAS::kNumChannels);
                             for (int i=0; i<BIAS::kNumChannels; i++)
@@ -337,6 +353,6 @@
                                 Info("Sending correction to feedback.");
 
-                                dic_cmnd_service((char*)"BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
-                                                 (void*)(vec.data()+416), 416*sizeof(float));
+                                DimClient::sendCommandNB("BIAS_CONTROL/ADD_REFERENCE_VOLTAGES",
+                                                         (void*)(vec.data()+416), 416*sizeof(float));
 
                                 /*
@@ -607,4 +623,13 @@
             return 1;
         }
+
+        //                    -110 / -110 (-23 DAC / -0.51V)
+        // Reference voltage: -238 / -203
+        //                    -360 / -343 ( 23 DAC /  0.51V)
+
+        // 0.005 A/V
+        // 220 Amplitude / 1V
+
+        // Gain = 1V / 200 = 0.005
 
         fGain = 5; // (BIAS)V / (DRS)V     ( 1V / 0.22V )
@@ -676,4 +701,6 @@
 void PrintHelp()
 {
+    Main::PrintHelp<StateMachineFeedback>();
+
     /* Additional help text which is printed after the configuration
      options goes here */
Index: /trunk/FACT++/src/tools.cc
===================================================================
--- /trunk/FACT++/src/tools.cc	(revision 12159)
+++ /trunk/FACT++/src/tools.cc	(revision 12160)
@@ -73,2 +73,43 @@
     return str.substr(start, end-start+1);
 }
+
+// --------------------------------------------------------------------------
+//
+//! This is a static helper to remove leading and trailing whitespaces.
+//!
+//! Usage example:
+//!
+//! \code
+//!    string str = "     Dies ist ein test fuer einen ganz     langen Satz "
+//!        "und ob er korrekt umgebrochen und formatiert wird. Alles "
+//!        "nur ein simpler test aber trotzdem ganz wichtig.";
+//!
+//!    cout << setfill('-') << setw(40) << "+" << endl;
+//!    while (1)
+//!    {
+//!        const string rc = Tools::Wrap(str, 40);
+//!        if (rc.empty())
+//!            break;
+//!        cout << rc << endl;
+//!    }
+//! \endcode
+//!
+string Tools::Wrap(string &str, size_t width)
+{
+    const size_t pos = str.length()<width ? string::npos : str.find_last_of(' ', width);
+    if (pos==string::npos)
+    {
+        const string rc = str;
+        str = "";
+        return rc;
+    }
+
+    const size_t indent = str.find_first_not_of(' ');
+
+    const string rc = str.substr(0, pos);
+    const size_t p2 = str.find_first_not_of(' ', pos+1);
+
+    str = str.substr(0, indent) + str.substr(p2==string::npos ? pos+1 : p2);
+
+    return rc;
+}
Index: /trunk/FACT++/src/tools.h
===================================================================
--- /trunk/FACT++/src/tools.h	(revision 12159)
+++ /trunk/FACT++/src/tools.h	(revision 12160)
@@ -1,2 +1,5 @@
+#ifndef FACT_Tools
+#define FACT_Tools
+
 #include <string>
 
@@ -6,3 +9,6 @@
     std::string Form(const char *fmt, ...);
     std::string Trim(const std::string &str);
+    std::string Wrap(std::string &str, size_t width=78);
 }
+
+#endif
