Changeset 14765 for trunk/FACT++/scripts
- Timestamp:
- 01/09/13 15:53:11 (12 years ago)
- Location:
- trunk/FACT++/scripts
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r14764 r14765 358 358 // ---------------------------------------------------------------- 359 359 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 // 360 var 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. 383 371 for (var i=0; i<observations.length; i++) 384 372 { 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 414 384 415 385 // ---------------------------------------------------------------- … … 448 418 } 449 419 420 // Get the observation scheduled for 'now' from the table and 421 // return its index 422 function 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 } 450 436 var run = -2; 451 437 var lastObs; … … 497 483 } 498 484 499 // Check (once) if startup of shutdown is scheduled500 switch (obs. mode)485 // Check if obs.task is one of the one-time-tasks 486 switch (obs.task) 501 487 { 502 488 case "STARTUP": … … 529 515 continue; 530 516 531 case "RATESCAN _SOURCENAME":517 case "RATESCAN": 532 518 console.out(" RATESCAN "); 533 519 … … 535 521 dim.wait("DRIVE_CONTROL", "Armed", 3000); 536 522 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 538 528 dim.wait("DRIVE_CONTROL", "OnTrack", 300000); 539 529 … … 554 544 dim.wait("RATE_SCAN", "InProgress", 10000); 555 545 dim.wait("RATE_SCAN", "Connected", 2700000); 556 console.out("Ratescan done.") 557 546 547 console.out("Ratescan done."); 548 run = -1; 558 549 continue; 559 550 }
Note:
See TracChangeset
for help on using the changeset viewer.