Index: trunk/FACT++/scripts/Main.js
===================================================================
--- trunk/FACT++/scripts/Main.js	(revision 15446)
+++ trunk/FACT++/scripts/Main.js	(revision 15454)
@@ -137,32 +137,13 @@
 }
 
+
+// ================================================================
+//  Code related to taking data
+// ================================================================
+
 var sub_connections = new Subscription("FAD_CONTROL/CONNECTIONS");
 
-/**
- * call-back function of FAD_CONTROL/CONNECTIONS
- * store IDs of problematic FADs 
- *
- */
-/*
-sub_connections.onchange = function(evt)
-{
-    // This happens, but why?
-    if (!evt.obj['status'])
-        return;
-
-    this.reset = [ ];
-
-    for (var x=0; x<40; x++)
-        if (evt.obj['status'][x]!=66 && evt.obj['status'][x]!=67)
-            this.reset.push(x);
-
-    if (this.reset.length==0)
-        return;
-
-    //m.alarm("FAD board loss detected...");
-    dim.send("MCP/RESET");
-    dim.send("FAD_CONTROL/CLOSE_OPEN_FILES");
-}
-*/
+var startrun = new Subscription("FAD_CONTROL/START_RUN");
+startrun.get(5000);
 
 /**
@@ -184,36 +165,4 @@
  *          exit();
  */
-sub_connections.reconnect = function()
-{
-    // this.reset is a list containing the IDs of FADs, 
-    // which have neither CONNECTION==66 nor ==67, whatever this means :-)
-    if (this.reset.length==0)
-        return true;
-
-    console.out("  Reconnect: start ["+this.reset.length+"]");
-
-    for (var i=0; i<this.reset.length; i++)
-        dim.send("FAD_CONTROL/DISCONNECT", this.reset[i]);
-
-    v8.sleep(3000);
-
-    while (this.reset.length)
-        dim.send("FAD_CONTROL/CONNECT", this.reset.pop());
-
-    v8.sleep(1000);
-    dim.wait("FAD_CONTROL", "Connected", 3000);
-
-    console.out("  Reconnect: end");
-
-    return true;
-}
-
-// ================================================================
-//  Code related to taking data
-// ================================================================
-
-var startrun = new Subscription("FAD_CONTROL/START_RUN");
-startrun.get(5000);
-
 function reconnect(list, txt)
 { /*
@@ -264,8 +213,4 @@
     var nextrun = startrun.get().obj['next'];
     console.out("  Take run %3d".$(nextrun)+": N="+count+" T="+time+"s ["+type+"]");
-
-    incomplete = 0;
-
-    dim.send("MCP/START", time?time:-1, count?count:-1, type);
 
     // FIXME: Replace by callback?
@@ -308,9 +253,13 @@
     // Here we could check and handle fad losses
 
+    incomplete = 0;
+
     for (var n=0; n<3; n++)
     {
+        dim.send("MCP/START", time?time:-1, count?count:-1, type);
         try
         {
             dim.wait("MCP", "TakingData", 15000);
+break;
         }
         catch (e)
@@ -346,8 +295,12 @@
             reconnect(list, "configuration");
 
-            if (n<2)
+            /*if (n<2)
                 return false;
 
-            throw e;
+                throw e;
+                */
+
+            if (n==2)
+                throw e;
         }
     }
@@ -879,10 +832,12 @@
 {
     var n = new Date();
-    if (test==-1)
+    if (observations.length>0 && test==-1)
         console.out(n.toUTCString()+": First observation scheduled for "+observations[0].start.toUTCString());
     if (test>=0 && test<observations.length)
         console.out(n.toUTCString()+": First observation should start immediately.");
-    if (observations[0].start>n+12*3600*1000)
+    if (observations.length>0 && observations[0].start>n+12*3600*1000)
         console.out(n.toUTCString()+": No observations scheduled for the next 12 hours!");
+    if (observations.length==0)
+        console.out(n.toUTCString()+": No observations scheduled!");
 }
 
