Index: trunk/FACT++/src/lidctrl.cc
===================================================================
--- trunk/FACT++/src/lidctrl.cc	(revision 14978)
+++ trunk/FACT++/src/lidctrl.cc	(revision 15103)
@@ -166,11 +166,7 @@
         fRdfData = "";
 
-        if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Unknown") ||
-            (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Unknown"))
-        {
-            Warn("Lid status unknown ("+fLid1.status+"/"+fLid2.status+")");
-            PostClose(false);
-            return;
-        }
+        if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown") ||
+            (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown"))
+            Warn("Lid reported status unknown by lidctrl ("+fLid1.status+"/"+fLid2.status+")");
 
         fLastReport = Time();
@@ -358,4 +354,19 @@
             return State::kDisconnected;
 
+        // Unidentified state detected
+        if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown") ||
+            (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown"))
+            return State::kUnidentified;
+
+        // This is an assumption, but the best we have...
+        if (fLid1.status=="Closed" && fLid2.status=="Power Problem")
+            return State::kClosed;
+        if (fLid2.status=="Closed" && fLid1.status=="Power Problem")
+            return State::kClosed;
+        if (fLid1.status=="Open" && fLid2.status=="Power Problem")
+            return State::kOpen;
+        if (fLid2.status=="Open" && fLid1.status=="Power Problem")
+            return State::kOpen;
+
         // Inconsistency
         if (fLid1.status!=fLid2.status)
@@ -365,4 +376,8 @@
         if (fLid1.status=="Unknown")
             return State::kUnknown;
+
+        // Power Problem
+        if (fLid1.status=="Power Problem")
+            return State::kPowerProblem;
 
         // Closed
@@ -413,4 +428,8 @@
         DimData data;
 
+        if (l1.status=="Unknown")
+            data.status[0] = 3;
+        if (l1.status=="Power Problem")
+            data.status[0] = 2;
         if (l1.status=="Open")
             data.status[0] = 1;
@@ -418,4 +437,8 @@
             data.status[0] = 0;
 
+        if (l2.status=="Unknown")
+            data.status[1] = 3;
+        if (l2.status=="Power Problem")
+            data.status[1] = 2;
         if (l2.status=="Open")
             data.status[1] = 1;
@@ -429,4 +452,5 @@
         data.position[1] = l2.position;
 
+        fDim.setQuality(GetState());
         fDim.Update(data);
     }
@@ -544,4 +568,7 @@
                      "Connection established, but status still not known");
 
+        T::AddStateName(Lid::State::kUnidentified, "Unidentified",
+                     "At least one lid reported a state which could not be identified by lidctrl");
+
         T::AddStateName(Lid::State::kInconsistent, "Inconsistent",
                      "Both lids show different states");
@@ -549,4 +576,7 @@
         T::AddStateName(Lid::State::kUnknown, "Unknown",
                      "Arduino reports at least one lids in an unknown status");
+
+        T::AddStateName(Lid::State::kPowerProblem, "PowerProblem",
+                     "Arduino reports both lids to have a power problem (might also be that both are at the end switches)");
 
         T::AddStateName(Lid::State::kClosed, "Closed",
@@ -566,9 +596,9 @@
              "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
 
-        T::AddEvent("OPEN", Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kClosed)
+        T::AddEvent("OPEN", Lid::State::kUnidentified, Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kPowerProblem, Lid::State::kClosed)
             (bind(&StateMachineLidControl::Open, this))
             ("Open the lids");
 
-        T::AddEvent("CLOSE", Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kOpen)
+        T::AddEvent("CLOSE", Lid::State::kUnidentified, Lid::State::kInconsistent, Lid::State::kUnknown, Lid::State::kPowerProblem, Lid::State::kOpen)
             (bind(&StateMachineLidControl::Close, this))
             ("Close the lids");
