Index: trunk/FACT++/scripts/Main.js
===================================================================
--- trunk/FACT++/scripts/Main.js	(revision 14997)
+++ trunk/FACT++/scripts/Main.js	(revision 14998)
@@ -89,4 +89,8 @@
 service_con.onchange = function(evt)
 {
+    // This happens, but why?
+    if (!evt.obj['status'])
+        return;
+
     this.reset = [ ];
 
@@ -247,4 +251,5 @@
 
     dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
+    dim.wait("RATE_CONTROL", "Connected", 3000);
 
     console.out("  DRS cal: end");
@@ -425,9 +430,8 @@
 if (!checkStates(table, 10000))
 {
-    console.out("Something unexpected has happened. Although the startup-",
+    throw new Error"Something unexpected has happened. Although the startup-",
             "procedure has finished, not all servers are in the state",
             "in which they ought to be. Please, try to find out what",
             "happened...");
-    exit();
 }
 
@@ -620,8 +624,8 @@
     case "RATESCAN":
         console.out("  RATESCAN  ");
-       
+
         dim.send("DRIVE_CONTROL/STOP");
-        dim.wait("DRIVE_CONTROL", "Armed", 3000);
-        
+        dim.wait("DRIVE_CONTROL", "Armed", 5000);
+
         if (obs.source != undefined)
             dim.send("DRIVE_CONTROL/TRACK_ON", obs.source);
@@ -637,5 +641,11 @@
         // this part might be simply wrong here, since I should be able to expect
         // the system to be able for data taking. And if not, then it is not here,
-        // to bring the system into a better state, correct?  
+        // to bring the system into a better state, correct?
+
+        // [TB] Either here the system have to be brought to the correct state, or
+        //      it has to be ensured that the previous code brought the system to a correct
+        //      state. In this case checkStates could be used (but is a bit of obsolete)
+        //      Doing non-throwing checks without checking the return value does not make
+        //      sense at all.
         dim.wait("FEEDBACK", "CurrentControl", -100);
         dim.wait("BIAS_CONTROL", "VoltageOn", -100);
@@ -672,4 +682,8 @@
     // ------------------------------------------------------------
 
+    // Checking for 'Ramping' in the BIAS_CONTROL is not ideal, but at the moment
+    // it is not possible to distinguish between a real ramping and the short
+    // ramping which takes place whenever the feedback updated the voltages.
+
     console.out("  Checking states [mainloop]");
     var table =
@@ -680,23 +694,25 @@
          [ "SMART_FACT"    ],
          [ "DATA_LOGGER",     [ "NightlyFileOpen", "WaitForRun", "Logging" ] ],
-         [ "FSC_CONTROL",     [ "Connected"                    ] ],
-         [ "MCP",             [ "Idle"                         ] ],
-         [ "TIME_CHECK",      [ "Valid"                        ] ],
-         [ "PWR_CONTROL",     [ "SystemOn"                     ] ],
-         [ "AGILENT_CONTROL", [ "VoltageOn"                    ] ],
-         [ "BIAS_CONTROL",    [ "VoltageOff", "VoltageOn"                   ] ],
-         [ "FEEDBACK",        [ "CurrentCtrlIdle", "CurrentControl" ] ],
-         [ "RATE_SCAN",       [ "Connected"                    ] ],
-         [ "RATE_CONTROL",    [ "Connected", "InProgress"                    ] ],
-         [ "LID_CONTROL",     [ "Open", "Closed"               ] ],
-         [ "DRIVE_CONTROL",   [ "Armed", "Tracking", "OnTrack" ] ],
-         [ "FTM_CONTROL",     [ "Idle", "TriggerOn"            ] ],
-         [ "FAD_CONTROL",     [ "Connected", "WritingData"     ] ],
+         [ "FSC_CONTROL",     [ "Connected"                                ] ],
+         [ "MCP",             [ "Idle"                                     ] ],
+         [ "TIME_CHECK",      [ "Valid"                                    ] ],
+         [ "PWR_CONTROL",     [ "SystemOn"                                 ] ],
+         [ "AGILENT_CONTROL", [ "VoltageOn"                                ] ],
+         [ "BIAS_CONTROL",    [ "VoltageOff", "VoltageOn", "Ramping"       ] ],
+         [ "FEEDBACK",        [ "CurrentCtrlIdle", "CurrentControl"        ] ],
+         [ "RATE_SCAN",       [ "Connected"                                ] ],
+         [ "RATE_CONTROL",    [ "Connected", "InProgress"                  ] ],
+         [ "LID_CONTROL",     [ "Open", "Closed"                           ] ],
+         [ "DRIVE_CONTROL",   [ "Armed", "Tracking", "OnTrack"             ] ],
+         [ "FTM_CONTROL",     [ "Idle", "TriggerOn"                        ] ],
+         [ "FAD_CONTROL",     [ "Connected", "WritingData"                 ] ],
         ];
 
     if (!checkStates(table))
     {
-        throw new Error("Something unexpected has happened. One of the servers"+
-                        "is in a state in which it should not be. Please,"+
+        //dim.alarm("System inconsistent");
+        //dim.alarm();
+        throw new Error("Something unexpected has happened. One of the servers "+
+                        "is in a state in which it should not be. Please, "+
                         "try to find out what happened...");
     }
