Index: trunk/FACT++/scripts/Main.js
===================================================================
--- trunk/FACT++/scripts/Main.js	(revision 18714)
+++ trunk/FACT++/scripts/Main.js	(revision 18715)
@@ -39,10 +39,55 @@
 
     observations = getSchedule();
+    if (observations.length==0)
+        return -1;
+
+    var suspended = -1;
+
+    var rc = observations.length-1;
 
     for (var i=0; i<observations.length; i++)
-        if (now<observations[i].start)
-            return i-1;
-
-    return observations.length-1;
+    {
+        // Find the first observation which is in the future
+        if (observations[i].start>now)
+        {
+            rc = i-1;
+            break;
+        }
+
+        // If the loop just passed a suspend, i.e. it is in the past, set the suspend flag
+        if (observations[i][0].task=="SUSPEND")
+            suspended = i;
+
+        // If the loop just passed a resume, i.e. it is in the past, remove the suspend flag
+        if (observations[i][0].task=="RESUME")
+            suspended = -1;
+    }
+
+    // Now rc contains the index of the first observation in the past
+
+    // If the system is in suspend mode, the suspend observation is
+    // returned as recent measurement. For convenience (to avoid that
+    // the next observation is announced), all furture observations
+    // are removed.
+    if (suspended>=0)
+    {
+        observations.splice(suspended+1);
+        return suspended;
+    }
+
+    // Observations have already been resumed and the last scheduled
+    // observation is the resume itself: remove the resume and
+    // all leading suspend/resume pairs until the last observation
+    // is found
+    while (rc>=0 && observations[rc][0].task=="RESUME")
+    {
+        observations.splice(rc--, 1);
+
+        // Find previous suspend
+        if (rc>=0 && observations[rc][0].task=="SUSPEND")
+            observations.splice(rc--, 1);
+    }
+
+    return rc;
 }
 
@@ -918,5 +963,8 @@
     if (!nextObs && nextId)
     {
-        dim.log("No further observation scheduled.");
+        if (obs[sub].task=="SUSPEND")
+            dim.log("Further observation suspended.");
+        else
+            dim.log("No further observation scheduled.");
         console.out("");
         nextId = undefined;
@@ -1002,8 +1050,8 @@
     }
 
-    datalogger_subscriptions.check();                                         
-                                                                                
+    datalogger_subscriptions.check();
+
     // If this is an observation which needs the voltage to be swicthed on
-    // skip that if the voltage is not stable                                    
+    // skip that if the voltage is not stable
     /*
     if (obs[sub].task=="DATA" || obs[sub].task=="RATESCAN")
