Changeset 14765


Ignore:
Timestamp:
01/09/13 15:53:11 (12 years ago)
Author:
neise
Message:
introduced new class to generate the schedule - called Observation. Now the list of observations can be filled with Ratescans loocking on source-names as well as ratescans looking at specific ra-dec-coordinates.
Location:
trunk/FACT++/scripts
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/Main.js

    r14764 r14765  
    358358// ----------------------------------------------------------------
    359359
    360 // All times are in UTC
    361 // NEW SYNTAX:   "date", "MODE", "SOURCENAME"
    362 // STARTUP and SHUTDOWN have no sourcename, but need an empty ""
    363 var observations =
    364 [
    365  [ "2013-01-08 23:05", "STARTUP",  "" ],
    366  [ "2013-01-08 23:13", "RATESCAN_SOURCENAME", "Dark Patch 3"],
    367 // [ "2013-01-08 23:32", "DATA", "Dark Patch 3"],
    368  [ "2013-01-08 23:30", "DATA", "Crab" ],
    369  [ "2013-01-09 04:45", "DATA",     "Mrk 421" ],
    370 // [ "2013-01-08 18:58", "RATESCAN_SOURCENAME", "Dark Patch 3"],
    371 // [ "2013-01-08 06:00", "RATESCAN_COORDINATES", 3.1415, 3.1415 ], -- not yet implemented
    372  [ "2013-01-09 07:00", "SHUTDOWN", ""],
    373 ];
    374 
    375 //observations[-1] = { start:now, source:"END", toString:function(){ return "END ["+this.start+"]" } };
    376 
    377 //
    378 // Convert time given in UTC to correct Date object (be aware
    379 // the Date object will be in local time!)
    380 //
    381 // FIXME: Check transisiton from summer- and winter-time!!
    382 //
     360var observations = [
     361    { date:"2013-01-09 21:05 UTC", task:'startup' },
     362    { date:"2013-01-09 21:20 UTC", task:'ratescan', source:'Dark Patch 3' },
     363    { date:"2013-01-09 21:21 UTC", source:'Crab'},
     364    { date:"2013-01-10 04:44 UTC", task:'ratescan', source:'Dark Patch 3'},
     365    { date:"2013-01-10 04:45 UTC", task:'data', source:'Mrk 421'},
     366    { date:"2013-01-10 04:44 UTC", task:'ratescan', ra:3.1415, dec:3.1415},
     367    { date:"2013-01-10 04:44 UTC", task:'shutdown'} ];
     368   
     369   
     370// make Observation objects from user input and check if 'date' is increasing.
    383371for (var i=0; i<observations.length; i++)
    384372{
    385     var utc = new Date(observations[i][0]+" UTC");
    386     if (isNaN(utc.valueOf()))
    387         throw new Error("Not a valid date '"+observations[i][0]+"' in row "+i);
    388     if (i>0 && utc<=observations[i-1][0])
    389         throw new Error("Start time '"+utc.toUTCString()+"' in row "+i+" exceeds start time in row "+(i-1));
    390     //observations[i][0] = utc;
    391     //observations[i] = { start:utc, source:observations[i][1], toString:function(){ return this.source+" ["+this.start+"]" } };
    392     observations[i] = { start:utc,
    393                         source:observations[i][2],
    394                         mode:observations[i][1],
    395                         toString:function(){ return this.source+" ["+this.start+"]" } };
    396 }
    397 
    398 // Get the observation scheduled for 'now' from the table and
    399 // retunr its index
    400 function getObservation(now)
    401 {
    402     if (now==undefined)
    403         now = new Date();
    404 
    405     if (isNaN(now.valueOf()))
    406         throw new Error("Date argument in getObservation invalid.");
    407 
    408     for (var i=0; i<observations.length; i++)
    409         if (now<observations[i].start)
    410             return i-1;
    411 
    412     return observations.length-1;
    413 }
     373    observations[i] = new Observation(observations[i]);
     374   
     375    // check if the start date given by the user is increasing.
     376    if (i>0 && observations[i].utc <= observations[i-1].utc)
     377    {
     378        throw new Error("Start time '"+utc.toUTCString()+
     379                        "' in row "+i+" exceeds start time in row "+(i-1));
     380    }
     381}
     382
     383
    414384
    415385// ----------------------------------------------------------------
     
    448418}
    449419
     420// Get the observation scheduled for 'now' from the table and
     421// return its index
     422function getObservation(now)
     423{
     424    if (now==undefined)
     425        now = new Date();
     426   
     427    if (isNaN(now.valueOf()))
     428        throw new Error("Date argument in getObservation invalid.");
     429
     430    for (var i=0; i<observations.length; i++)
     431        if ( now<observations[i].start )
     432            return i-1;
     433   
     434    return observations.length-1;
     435}
    450436var run = -2;
    451437var lastObs;
     
    497483    }
    498484
    499     // Check (once) if startup of shutdown is scheduled
    500     switch (obs.mode)
     485    // Check if obs.task is one of the one-time-tasks
     486    switch (obs.task)
    501487    {
    502488    case "STARTUP":
     
    529515        continue;
    530516
    531     case "RATESCAN_SOURCENAME":
     517    case "RATESCAN":
    532518        console.out("  RATESCAN  ");
    533519       
     
    535521        dim.wait("DRIVE_CONTROL", "Armed", 3000);
    536522       
    537         dim.send("DRIVE_CONTROL/TRACK_SOURCE", 0, 0, obs.source);
     523        if (obs.source != undefined)
     524            dim.send("DRIVE_CONTROL/TRACK_ON", obs.source);
     525        else
     526            dim.send("DRIVE_CONTROL/TRACK", obs.ra, obs.dec);
     527           
    538528        dim.wait("DRIVE_CONTROL", "OnTrack", 300000);
    539529
     
    554544        dim.wait("RATE_SCAN", "InProgress", 10000);
    555545        dim.wait("RATE_SCAN", "Connected", 2700000);
    556         console.out("Ratescan done.")       
    557 
     546
     547        console.out("Ratescan done.");
     548        run = -1;
    558549        continue;
    559550    }
Note: See TracChangeset for help on using the changeset viewer.