Index: /trunk/FACT++/scripts/Main.js
===================================================================
--- /trunk/FACT++/scripts/Main.js	(revision 14764)
+++ /trunk/FACT++/scripts/Main.js	(revision 14765)
@@ -358,58 +358,28 @@
 // ----------------------------------------------------------------
 
-// All times are in UTC
-// NEW SYNTAX:   "date", "MODE", "SOURCENAME"
-// STARTUP and SHUTDOWN have no sourcename, but need an empty "" 
-var observations =
-[
- [ "2013-01-08 23:05", "STARTUP",  "" ],
- [ "2013-01-08 23:13", "RATESCAN_SOURCENAME", "Dark Patch 3"],
-// [ "2013-01-08 23:32", "DATA", "Dark Patch 3"],
- [ "2013-01-08 23:30", "DATA", "Crab" ],
- [ "2013-01-09 04:45", "DATA",     "Mrk 421" ],
-// [ "2013-01-08 18:58", "RATESCAN_SOURCENAME", "Dark Patch 3"],
-// [ "2013-01-08 06:00", "RATESCAN_COORDINATES", 3.1415, 3.1415 ], -- not yet implemented
- [ "2013-01-09 07:00", "SHUTDOWN", ""],
-];
-
-//observations[-1] = { start:now, source:"END", toString:function(){ return "END ["+this.start+"]" } };
-
-//
-// Convert time given in UTC to correct Date object (be aware
-// the Date object will be in local time!)
-//
-// FIXME: Check transisiton from summer- and winter-time!!
-//
+var observations = [
+    { date:"2013-01-09 21:05 UTC", task:'startup' },
+    { date:"2013-01-09 21:20 UTC", task:'ratescan', source:'Dark Patch 3' },
+    { date:"2013-01-09 21:21 UTC", source:'Crab'},
+    { date:"2013-01-10 04:44 UTC", task:'ratescan', source:'Dark Patch 3'},
+    { date:"2013-01-10 04:45 UTC", task:'data', source:'Mrk 421'},
+    { date:"2013-01-10 04:44 UTC", task:'ratescan', ra:3.1415, dec:3.1415},
+    { date:"2013-01-10 04:44 UTC", task:'shutdown'} ];
+    
+    
+// make Observation objects from user input and check if 'date' is increasing.
 for (var i=0; i<observations.length; i++)
 {
-    var utc = new Date(observations[i][0]+" UTC");
-    if (isNaN(utc.valueOf()))
-        throw new Error("Not a valid date '"+observations[i][0]+"' in row "+i);
-    if (i>0 && utc<=observations[i-1][0])
-        throw new Error("Start time '"+utc.toUTCString()+"' in row "+i+" exceeds start time in row "+(i-1));
-    //observations[i][0] = utc;
-    //observations[i] = { start:utc, source:observations[i][1], toString:function(){ return this.source+" ["+this.start+"]" } };
-    observations[i] = { start:utc, 
-                        source:observations[i][2], 
-                        mode:observations[i][1], 
-                        toString:function(){ return this.source+" ["+this.start+"]" } };
-}
-
-// Get the observation scheduled for 'now' from the table and
-// retunr its index
-function getObservation(now)
-{
-    if (now==undefined)
-        now = new Date();
-
-    if (isNaN(now.valueOf()))
-        throw new Error("Date argument in getObservation invalid.");
-
-    for (var i=0; i<observations.length; i++)
-        if (now<observations[i].start)
-            return i-1;
-
-    return observations.length-1;
-}
+    observations[i] = new Observation(observations[i]);
+    
+    // check if the start date given by the user is increasing.
+    if (i>0 && observations[i].utc <= observations[i-1].utc)
+    {
+        throw new Error("Start time '"+utc.toUTCString()+
+                        "' in row "+i+" exceeds start time in row "+(i-1));
+    }
+}
+
+
 
 // ----------------------------------------------------------------
@@ -448,4 +418,20 @@
 }
 
+// Get the observation scheduled for 'now' from the table and
+// return its index
+function getObservation(now)
+{
+    if (now==undefined)
+        now = new Date();
+    
+    if (isNaN(now.valueOf()))
+        throw new Error("Date argument in getObservation invalid.");
+
+    for (var i=0; i<observations.length; i++)
+        if ( now<observations[i].start )
+            return i-1;
+    
+    return observations.length-1;
+}
 var run = -2;
 var lastObs;
@@ -497,6 +483,6 @@
     }
 
-    // Check (once) if startup of shutdown is scheduled
-    switch (obs.mode)
+    // Check if obs.task is one of the one-time-tasks
+    switch (obs.task)
     {
     case "STARTUP":
@@ -529,5 +515,5 @@
         continue;
 
-    case "RATESCAN_SOURCENAME":
+    case "RATESCAN":
         console.out("  RATESCAN  ");
        
@@ -535,5 +521,9 @@
         dim.wait("DRIVE_CONTROL", "Armed", 3000);
         
-        dim.send("DRIVE_CONTROL/TRACK_SOURCE", 0, 0, obs.source);
+        if (obs.source != undefined)
+            dim.send("DRIVE_CONTROL/TRACK_ON", obs.source);
+        else
+            dim.send("DRIVE_CONTROL/TRACK", obs.ra, obs.dec);
+            
         dim.wait("DRIVE_CONTROL", "OnTrack", 300000);
 
@@ -554,6 +544,7 @@
         dim.wait("RATE_SCAN", "InProgress", 10000);
         dim.wait("RATE_SCAN", "Connected", 2700000);
-        console.out("Ratescan done.")        
-
+
+        console.out("Ratescan done.");
+        run = -1;
         continue;
     }
Index: /trunk/FACT++/scripts/Observation_class.js
===================================================================
--- /trunk/FACT++/scripts/Observation_class.js	(revision 14765)
+++ /trunk/FACT++/scripts/Observation_class.js	(revision 14765)
@@ -0,0 +1,85 @@
+'use strict';
+
+/* **************
+ * this file contains just the implementation of the 
+ * Observation class (I know there are no classes in javascript...)
+ */
+
+// Constructor
+function Observation ( oArg ) {
+    
+    if (oArg['date'])
+    {
+        // FIXME: Check transisiton from summer- and winter-time!!
+        var utc = new Date(oArg.date);
+        if (isNaN(utc.valueOf()))
+        {
+            throw new Error(startDateString+' is not a valid Date String.'+
+                        ' Try something like "2013-01-08 23:05 UTC" .');
+        }
+        this.utc = utc
+    }
+    else
+    {
+        throw new Error("Observation object must have a 'date' parameter");
+    }
+    
+    if (oArg['task'])
+        this.task = oArg.task.toUpperCase()
+    else
+        this.task = 'DATA'
+        
+    if (oArg['source'])
+        this.source = oArg.source
+    else
+        this.source = undefined
+        
+    if (oArg['ra'])
+        this.ra = oArg.ra
+    else
+        this.ra = undefined
+        
+    if (oArg['dec'])
+        this.dec = oArg.dec
+    else
+        this.dec = undefined
+    
+    
+    
+    switch( this.task)
+    {
+        case 'DATA':
+            if (this.source == undefined)
+                throw new Error(
+                    "Observation must have either 'source' or 'task' " +
+                    "if 'task' == 'data' it must have also have 'source' ");
+            break;
+        case 'STARTUP':
+            if ( this.source != undefined)
+            {
+                console.out("warning. Observation with task='startup' also has source defined");
+            }
+            break;
+        case 'SHUTDOWN':
+            if ( this.source != undefined)
+            {
+                console.out("warning. Observation with task='shutdown' also has source defined");
+            }
+            break;
+        case 'RATESCAN':
+            if ( this.source == undefined && (this.ra == undefined || this.dec == undefined) )
+            {
+                throw new Error(
+                    "Observation must have either 'source' or 'ra' & 'dec' " +
+                    "if 'task' == 'ratescan'");
+            }
+    }
+    
+    
+}
+
+// method toString()
+Observation.prototype.toString = function() 
+{ 
+    return this.source+" ["+this.utc+"]" ;
+}
