Index: trunk/FACT++/src/pwrctrl.cc
===================================================================
--- trunk/FACT++/src/pwrctrl.cc	(revision 14451)
+++ trunk/FACT++/src/pwrctrl.cc	(revision 14514)
@@ -26,90 +26,83 @@
 using namespace std;
 
-class ConnectionLid : public Connection
+class ConnectionInterlock : public Connection
 {
 protected:
 
-    struct Lid
-    {
-        bool fc_ok;
-        bool bp_on;
-        bool il_on;
-        bool fl_ok;
-        bool fp_en;
-        bool x_on;
-        bool y_on;
-        bool z_on;
-
-        Lid() { }
+    struct Status
+    {
+        bool fWaterFlowOk;
+        bool fWaterLevelOk;
+
+        bool fPwrBiasOn;
+        bool fPwr24VOn;
+        bool fPwrPumpOn;
+        bool fPwrDriveOn;
+
+        bool fDriveMainSwitchOn;
+        bool fDriveFeedbackOn;
+
+        Status() { }
+
+        bool Set(bool &rc, const QString &value)
+        {
+            rc = value.toInt();
+            return true;
+        }
 
         bool Set(const QDomNamedNodeMap &map)
         {
-            if (!map.contains("id") || !map.contains("value"))
+            if (!map.contains("id") || !map.contains("title"))
                 return false;
 
             QString item  = map.namedItem("id").nodeValue();
-            QString value = map.namedItem("value").nodeValue();
-
-            if (item==(QString("FC_OK")))
-            {
-                fc_ok = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("BP_ON")))
-            {
-                bp_on = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("IL_ON")))
-            {
-                il_on = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("FL_OK")))
-            {
-                fl_ok = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("FP_EN")))
-            {
-                fp_en = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("X_ON")))
-            {
-                x_on = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("Y_ON")))
-            {
-                y_on = value.toInt();
-                return true;
-            }
-
-            if (item==(QString("Z_ON")))
-            {
-                z_on = value.toInt();
-                return true;
-            }
+            QString value = map.namedItem("title").nodeValue();
+
+            if (item==(QString("flow_meter")))
+                return Set(fWaterFlowOk, value);
+
+            if (item==(QString("level")))
+                return Set(fWaterLevelOk, value);
+
+            if (item==(QString("bias_power")))
+                return Set(fPwrBiasOn, value);
+
+            if (item==(QString("power_24v")))
+                return Set(fPwr24VOn, value);
+
+            if (item==(QString("pump")))
+                return Set(fPwrPumpOn, value);
+
+            if (item==(QString("drive_power")))
+                return Set(fPwrDriveOn, value);
+
+            if (item==(QString("drive_on")))
+                return Set(fDriveMainSwitchOn, value);
+
+            if (item==(QString("drive_enable")))
+                return Set(fDriveFeedbackOn, value);
 
             return false;
         }
 
+        void Print(ostream &out, const string &title, const bool &val, const string &t="enabled", const string &f="disabled")
+        {
+            out << setw(15) << (title+":");
+            if (val)
+                out << kGreen << t << endl;
+            else
+                out << kRed   << f << endl;
+        }
+
         void Print(ostream &out)
         {
-            out << "FC_OK=" << fc_ok << endl;
-            out << "BP_ON=" << bp_on << endl;
-            out << "IL_ON=" << il_on << endl;
-            out << "FL_OK=" << fl_ok << endl;
-            out << "FP_EN=" << fp_en << endl;
-            out << "X_ON =" << x_on  << endl;
-            out << "Y_ON =" << y_on  << endl;
-            out << "Z_ON =" << z_on  << endl;
+            Print(out, "Water flow",     fWaterFlowOk,  "ok", "low");
+            Print(out, "Water level",    fWaterLevelOk, "ok", "low");
+            Print(out, "Power bias",     fPwrBiasOn);
+            Print(out, "Power 24V",      fPwr24VOn);
+            Print(out, "Power pump",     fPwrPumpOn);
+            Print(out, "Power drive",    fPwrDriveOn);
+            Print(out, "Drive main",     fDriveMainSwitchOn, "on", "off");
+            Print(out, "Drive feedback", fDriveFeedbackOn,   "on", "off");
         }
 
@@ -130,7 +123,7 @@
     Time fLastReport;
 
-    Lid fLid1;
-
-    virtual void Update(const Lid &)
+    Status fStatus;
+
+    virtual void Update(const Status &)
     {
     }
@@ -224,14 +217,14 @@
             const QDomNamedNodeMap att = e.attributes();
 
-            fLid1.Set(att);
+            fStatus.Set(att);
         }
 
         if (fIsVerbose)
         {
-            fLid1.Print(Out());
+            fStatus.Print(Out());
             Out() << "------------------------------------------------------" << endl;
         }
 
-        Update(fLid1);
+        Update(fStatus);
 
         fRdfData = "";
@@ -302,5 +295,5 @@
     {
         async_read_some(ba::buffer(fArray),
-                        boost::bind(&ConnectionLid::HandleRead, this,
+                        boost::bind(&ConnectionInterlock::HandleRead, this,
                                     dummy::error, dummy::bytes_transferred));
     }
@@ -374,5 +367,5 @@
 
 public:
-    ConnectionLid(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
+    ConnectionInterlock(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
         fIsVerbose(true), fLastReport(Time::none), fKeepAlive(ioservice)
     {
@@ -411,5 +404,5 @@
 
         fKeepAlive.expires_from_now(boost::posix_time::seconds(fInterval));
-        fKeepAlive.async_wait(boost::bind(&ConnectionLid::HandleRequest,
+        fKeepAlive.async_wait(boost::bind(&ConnectionInterlock::HandleRequest,
                                           this, dummy::error));
     }
@@ -449,5 +442,5 @@
 };
 
-const uint16_t ConnectionLid::kMaxAddr = 0xfff;
+const uint16_t ConnectionInterlock::kMaxAddr = 0xfff;
 
 // ------------------------------------------------------------------------
@@ -455,5 +448,5 @@
 #include "DimDescriptionService.h"
 
-class ConnectionDimWeather : public ConnectionLid
+class ConnectionDimWeather : public ConnectionInterlock
 {
 private:
@@ -462,5 +455,5 @@
 public:
     ConnectionDimWeather(ba::io_service& ioservice, MessageImp &imp) :
-        ConnectionLid(ioservice, imp)/*,
+        ConnectionInterlock(ioservice, imp)/*,
         fDim("PWR_CONTROL/DATA", "S:2;F:2;F:2",
              "|status[bool]:Lid1/2 open or closed"
@@ -470,6 +463,6 @@
     }
 
-    void Update(const Lid &l1)
-        {
+    void Update(const Status &status)
+    {
             /*
         struct DimData
@@ -508,5 +501,5 @@
 
 template <class T, class S>
-class StateMachineLidControl : public T, public ba::io_service, public ba::io_service::work
+class StateMachinePowerControl : public T, public ba::io_service, public ba::io_service::work
 {
 private:
@@ -594,5 +587,5 @@
 
 public:
-    StateMachineLidControl(ostream &out=cout) :
+    StateMachinePowerControl(ostream &out=cout) :
         T(out, "LID_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
         fLid(*this, *this)
@@ -627,16 +620,16 @@
         // Verbosity commands
         T::AddEvent("SET_VERBOSE", "B")
-            (bind(&StateMachineLidControl::SetVerbosity, this, placeholders::_1))
+            (bind(&StateMachinePowerControl::SetVerbosity, this, placeholders::_1))
             ("set verbosity state"
              "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
 
         T::AddEvent("OPEN", Lid::State::kInconsistent, Lid::State::kClosed)
-            (bind(&StateMachineLidControl::Open, this));
+            (bind(&StateMachinePowerControl::Open, this));
 
         T::AddEvent("CLOSE", Lid::State::kInconsistent, Lid::State::kOpen)
-            (bind(&StateMachineLidControl::Close, this));
+            (bind(&StateMachinePowerControl::Close, this));
 
         T::AddEvent("POST", "C")
-            (bind(&StateMachineLidControl::Post, this, placeholders::_1))
+            (bind(&StateMachinePowerControl::Post, this, placeholders::_1))
             ("set verbosity state"
              "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
@@ -664,5 +657,5 @@
 int RunShell(Configuration &conf)
 {
-    return Main::execute<T, StateMachineLidControl<S, R>>(conf);
+    return Main::execute<T, StateMachinePowerControl<S, R>>(conf);
 }
 
@@ -742,5 +735,5 @@
     {
         if (conf.Get<bool>("no-dim"))
-            return RunShell<LocalStream, StateMachine, ConnectionLid>(conf);
+            return RunShell<LocalStream, StateMachine, ConnectionInterlock>(conf);
         else
             return RunShell<LocalStream, StateMachineDim, ConnectionDimWeather>(conf);
@@ -750,7 +743,7 @@
     {
         if (conf.Get<int>("console")==0)
-            return RunShell<LocalShell, StateMachine, ConnectionLid>(conf);
+            return RunShell<LocalShell, StateMachine, ConnectionInterlock>(conf);
         else
-            return RunShell<LocalConsole, StateMachine, ConnectionLid>(conf);
+            return RunShell<LocalConsole, StateMachine, ConnectionInterlock>(conf);
     }
     else
