Changeset 18114 for trunk/FACT++


Ignore:
Timestamp:
02/12/15 10:49:20 (10 years ago)
Author:
tbretz
Message:
Added SLEEP task which is a shutdown without locking the drive and disconnecting the bias crate; restructured RATESCAN2 to switch voltage off before closing the lid or switching the voltage to the breakdown voltage in case of voltage on to avoid moving through full moon with full bias voltage as in data taking. Ramping voltage back to nominal after movement.
File:
1 edited

Legend:

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

    r18085 r18114  
    381381// ================================================================
    382382
    383 function Shutdown(singlepe)
    384 {
    385     dim.log("Starting shutdown.");
     383function Shutdown(type)
     384{
     385    if (!type)
     386        type = "default";
     387
     388    dim.log("Starting shutdown ["+type+"].");
    386389
    387390    var now1 = new Date();
     
    395398    var now2 = new Date();
    396399
    397     dim.send("DRIVE_CONTROL/PARK");
     400    if (type=="sleep")
     401        dim.send("DRIVE_CONTROL/MOVE_TO", 101, 0);
     402    else
     403        dim.send("DRIVE_CONTROL/PARK");
    398404
    399405    console.out("","Waiting for telescope to park. This may take a while.");
    400406
    401407    // FIXME: This might not work is the drive is already close to park position
    402     dim.wait("DRIVE_CONTROL", "Locked", 3000);
     408    if (type!="sleep")
     409        dim.wait("DRIVE_CONTROL", "Locked", 3000);
    403410
    404411    var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION");
     
    424431        dim.log('Park position not reached? Telescope at Zd='+p.obj['Zd']+' Az='+p.obj['Az']);
    425432    }
    426 
    427433    /*
    428434    // Check if DRS calibration is necessary
     
    435441    }*/
    436442
    437     if (singlepe)
     443    if (type=="singlepe")
    438444    {
    439445        dim.log("Taking single-pe run.");
     
    455461    var now3 = new Date();
    456462
    457     //dim.send("FEEDBACK/STOP");
    458463    dim.send("FTM_CONTROL/STOP_TRIGGER");
    459 
    460464    dim.wait("FTM_CONTROL",  "Valid",        3000);
    461     dim.wait("FEEDBACK",     "Calibrated",   3000);
    462 
    463     dim.send("BIAS_CONTROL/DISCONNECT");
    464     dim.wait("BIAS_CONTROL", "Disconnected", 3000);
     465
     466    if (bias!="Disconnected")
     467        dim.wait("FEEDBACK", "Calibrated",   3000);
     468
     469    if (type!="sleep")
     470    {
     471        dim.send("BIAS_CONTROL/DISCONNECT");
     472        dim.wait("BIAS_CONTROL", "Disconnected", 3000);
     473
     474    }
    465475
    466476    var report = sub.get();
    467477
    468478    console.out("");
    469     console.out("Shutdown procedure seems to be finished...");
     479    console.out("Shutdown procedure ["+type+"] seems to be finished...");
    470480    console.out("  "+new Date().toUTCString());
    471481    console.out("  Telescope at Zd=%.1fdeg Az=%.1fdeg".$(report.obj['Zd'], report.obj['Az']));
     
    484494    sub.close();
    485495}
     496
     497
     498// ================================================================
     499//  Function to set the system to sleep-mode
     500// ================================================================
     501// FIXME: do not repeat code from shutdown-function
     502/*
     503function GoToSleep()
     504{
     505    CloseLid();
     506
     507    var isArmed = dim.state("DRIVE_CONTROL").name=="Armed";
     508    if (!isArmed)
     509    {
     510        dim.log("Drive not ready to move. -> send STOP");
     511        dim.send("DRIVE_CONTROL/STOP");
     512        dim.wait("DRIVE_CONTROL", "Armed", 5000);
     513    }
     514
     515    dim.send("DRIVE_CONTROL/MOVE_TO 101 0");//park position
     516    var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION");
     517    sub.get(5000);  // FIXME: Proper error message in case of failure
     518
     519    function func()
     520    {
     521        var report = sub.get();
     522
     523        var zd = report.obj['Zd'];
     524        var az = report.obj['Az'];
     525
     526        if (zd>100 && Math.abs(az)<1)
     527            return true;
     528
     529        return undefined;
     530    }
     531
     532    try { v8.timeout(150000, func); }
     533    catch (e)
     534    {
     535        var p = sub.get();
     536        dim.log('Park position not reached? Telescope at Zd='+p.obj['Zd']+' Az='+p.obj['Az']);
     537    }
     538    var p2 = sub.get();
     539    dim.log('Telescope at Zd=%.1fdeg Az=%.1fdeg'.$(p2.obj['Zd'], p2.obj['Az']));
     540    sub.close();
     541}
     542*/
    486543
    487544// ================================================================
     
    574631
    575632    var list = obj.data.split('\n').map(map);
    576 //     [A
    577633    function check(name)
    578634    {
     
    930986        continue;
    931987
     988    case "SLEEP":
     989        Shutdown("sleep"); //GoToSleep();
     990
     991        sub++;
     992        dim.log("Task finished [SLEEP].");
     993        console.out("");
     994        continue;
     995
    932996    case "STARTUP":
    933997        CloseLid();
     
    9541018
    9551019    case "SHUTDOWN":
    956         Shutdown(true);
     1020        Shutdown("singlepe");
    9571021        system_on = false;
    9581022
     
    11211185        dim.wait("DRIVE_CONTROL", "Armed", 15000);
    11221186
     1187        if (obs[sub].rstype=="dark-bias-off")
     1188            service_feedback.voltageOff();
     1189        else
     1190        {
     1191            // Switch the voltage to a reduced level (Ubd)
     1192            var bias = dim.state("BIAS_CONTROL").name;
     1193            if (bias=="VoltageOn" || bias=="Ramping")
     1194                service_feedback.voltageOn(0);
     1195        }
     1196
    11231197        // Open the lid if required
    11241198        if (!obs[sub].lidclosed)
     
    11271201            CloseLid();
    11281202
    1129         // Switch the voltage to a reduced level (Ubd)
    1130         service_feedback.voltageOn(0);
    1131 
    11321203        // track source/position or move to position
    11331204        if (obs[sub].lidclosed)
     
    11351206            dim.log("Moving telescope to zd="+obs[sub].zd+" az="+obs[sub].az);
    11361207            dim.send("DRIVE_CONTROL/MOVE_TO", obs[sub].zd, obs[sub].az);
    1137             v8.sleep(1000);
     1208            v8.sleep(3000);
    11381209            dim.wait("DRIVE_CONTROL", "Armed", 150000); // 110s for turning and 30s for stabilizing
    11391210        }
     
    11561227        // Now tracking stable, switch voltage to nominal level and wait
    11571228        // for stability.
    1158         if (obs[sub].rstype=="dark-bias-off")
    1159             service_feedback.voltageOff();
    1160         else
     1229        if (obs[sub].rstype!="dark-bias-off")
    11611230        {
    11621231            service_feedback.voltageOn();
    11631232            service_feedback.waitForVoltageOn();
    11641233        }
    1165         dim.log("rs-type: "+obs[sub].rstype);
    11661234
    11671235        if (!irq)
     
    11691237            var tm2 = new Date();
    11701238
    1171             dim.log("Starting ratescan 2/1");
     1239            dim.log("Starting ratescan 2/1 ["+obs[sub].rstype+"]");
    11721240
    11731241            // Start rate scan
     
    11781246            // it to be configured.
    11791247            dim.wait("RATE_SCAN", "InProgress", 10000);
    1180             dim.wait("RATE_SCAN", "Connected", 2700000);
     1248            //FIXME: discuss what best value is here
     1249            dim.wait("RATE_SCAN", "Connected", 2700000);//45min
     1250            //dim.wait("RATE_SCAN", "Connected", 1200000);//3.3h
    11811251
    11821252            // Here one could implement a watchdog for the feedback as well, but what is the difference
     
    11961266            var tm2 = new Date();
    11971267
    1198             dim.log("Starting ratescan 2/2");
     1268            dim.log("Starting ratescan 2/2 ["+obs[sub].rstype+"]");
    11991269
    12001270            // Start rate scan
Note: See TracChangeset for help on using the changeset viewer.