Changeset 16798 for trunk/FACT++


Ignore:
Timestamp:
06/10/13 12:04:19 (11 years ago)
Author:
tbretz
Message:
Reoragnized the logging output, to get closer to a final version sending everything to the log stream; ftmctrl now in Valid not in Idle; added check for the clock conditioner.
File:
1 edited

Legend:

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

    r16533 r16798  
    9292function doDrsCalibration(where)
    9393{
    94     console.out("  Take DRS calibration ["+where+"]");
     94    console.out("  "+new Date().toUTCString()+": Starting DRS calibration ["+where+"]");
    9595
    9696    service_feedback.voltageOff();
     
    132132        //                                       4'40 / 2'00
    133133
    134     console.out("  DRS calibration done [%.1f]".$((new Date()-tm)/1000));
     134    console.out("  "+new Date().toUTCString()+": DRS calibration done [%.1f]".$((new Date()-tm)/1000));
    135135}
    136136
     
    157157    if (isClosed)
    158158    {
    159         console.out("  Open lid: start");
     159        console.out("  "+new Date().toUTCString()+": Opening lid");
    160160        dim.send("LID_CONTROL/OPEN");
    161161    }
     
    163163
    164164    if (isClosed)
    165         console.out("  Open lid: done [%.1fs]".$((new Date()-tm)/1000));
     165        console.out("  "+new Date().toUTCString()+": Lid open [%.1fs]".$((new Date()-tm)/1000));
    166166}
    167167
     
    175175    if (isOpen)
    176176    {
    177         console.out("  Close lid: start");
     177        console.out("  "+new Date().toUTCString()+": Closing lid.");
    178178        dim.send("LID_CONTROL/CLOSE");
    179179    }
     
    181181
    182182    if (isOpen)
    183         console.out("  Close lid: end [%.1fs]".$((new Date()-tm)/1000));
     183        console.out("  "+new Date().toUTCString()+": Lid closed [%.1fs]".$((new Date()-tm)/1000));
    184184}
    185185
     
    238238    if (isOn)
    239239    {
    240         console.out("  Voltage off: start");
     240        console.out("  "+new Date().toUTCString()+": Switching voltage off.");
    241241
    242242        // Supress the possibility that the bias control is
     
    246246        if (isControl)
    247247        {
    248             console.out("  Suspending feedback.");
     248            //console.out("  Suspending feedback.");
    249249            dim.send("FEEDBACK/ENABLE_OUTPUT", false);
    250250            dim.wait("FEEDBACK", "CurrentCtrlIdle", 3000);
     
    252252
    253253        // Switch voltage off
    254         console.out("  "+new Date().toUTCString()+": Voltage off: switch off");
     254        //console.out("  "+new Date().toUTCString()+": Voltage off: switch off");
    255255        dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");
    256256
     
    258258        if (isControl)
    259259        {
    260             console.out("  Resuming feedback.");
     260            //console.out("  Resuming feedback.");
    261261            dim.send("FEEDBACK/ENABLE_OUTPUT", true);
    262262            dim.wait("FEEDBACK", "CurrentControl", 3000);
     
    270270
    271271    if (isOn)
    272         console.out("  Voltage off: end");
     272        console.out("  "+new Date().toUTCString()+": Voltage off.");
    273273}
    274274
     
    302302    if (isOff)
    303303    {
    304         console.out("  "+new Date().toUTCString()+": Voltage on: switch on");
     304        console.out("  "+new Date().toUTCString()+": Switching voltage on.");
    305305        //console.out(JSON.stringify(dim.state("BIAS_CONTROL")));
    306306
     
    317317    if (isOff)
    318318    {
    319         console.out("  Voltage on: cnt="+this.cnt);
     319        console.out("  "+new Date().toUTCString()+": Voltage on [cnt="+this.cnt+"]");
    320320
    321321        this.previous = undefined;
     
    344344
    345345    // FIXME: timeout missing
    346     console.out("  Feedback wait: start");
     346    console.out("  "+new Date().toUTCString()+": Waiting for voltage to be stable.");
    347347
    348348    function func()
     
    357357    v8.timeout(4*60000, func, this);
    358358
    359     console.out("  Feedback wait: end [dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));
     359    console.out("  "+new Date().toUTCString()+": Voltage stable within limits [dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));
    360360}
    361361
     
    366366function Shutdown()
    367367{
    368     console.out("Shutdown: start");
     368    console.out("  "+new Date().toUTCString()+": Starting shutdown.");
    369369
    370370    service_feedback.voltageOff();
     
    372372    dim.send("DRIVE_CONTROL/PARK");
    373373
    374     console.out("Waiting for telescope to park. This may take a while.");
     374    console.out("","Waiting for telescope to park. This may take a while.");
    375375
    376376    // FIXME: This might not work is the drive is already close to park position
     
    401401    dim.send("BIAS_CONTROL/DISCONNECT");
    402402
    403     dim.wait("FTM_CONTROL",  "Idle",         3000);
     403    dim.wait("FTM_CONTROL",  "Valid",        3000);
    404404    dim.wait("BIAS_CONTROL", "Disconnected", 3000);
    405405    dim.wait("FEEDBACK",     "Connected",    3000);
     
    463463         "FAD_CONTROL/START_RUN",
    464464         "FAD_CONTROL/STATISTICS1",
    465  //        "FAD_CONTROL/STATISTICS2",
    466465         "FAD_CONTROL/STATS",
    467466         "FAD_CONTROL/STATUS",
     
    531530
    532531// ================================================================
     532//  Code to monitor clock conditioner
     533// ================================================================
     534
     535var sub_counter = new Subscription("FTM_CONTROL/COUNTER");
     536sub_counter.onchange = function(evt)
     537{
     538    if (evt.qos>0 && evt.qos!=2 && evt.qos&0x100==0)
     539        throw new Error("FTM reports: clock conditioner not locked.");
     540}
     541
     542// ================================================================
    533543//  Code related to monitoring the fad system
    534544// ================================================================
     
    547557// (FIXME: Should that go to the general CheckState?)
    548558// ----------------------------------------------------------------
    549 console.out("Checking send.");
     559//console.out("Checking send.");
    550560checkSend(["MCP", "DRIVE_CONTROL", "LID_CONTROL", "FAD_CONTROL", "FEEDBACK"]);
    551 console.out("Checking send: done");
     561//console.out("Checking send: done");
    552562
    553563// ----------------------------------------------------------------
    554564// Bring feedback into the correct operational state
    555565// ----------------------------------------------------------------
    556 console.out("Feedback init: start.");
     566//console.out("Feedback init: start.");
    557567service_feedback.get(5000);
    558568
     
    565575// Connect to the DRS_RUNS service
    566576// ----------------------------------------------------------------
    567 console.out("Drs runs init: start.");
     577//console.out("Drs runs init: start.");
    568578
    569579var sub_drsruns = new Subscription("FAD_CONTROL/DRS_RUNS");
     
    582592
    583593    if (valid)
    584         console.out("  Last DRS calib: %.1fmin ago".$(diff));
     594        console.out("  "+new Date().toUTCString()+": Last DRS calib: %.1fmin ago".$(diff));
    585595    else
    586         console.out("  No valid drs calibration available");
     596        console.out("  "+new Date().toUTCString()+": No valid drs calibration available.");
    587597
    588598    return valid ? diff : null;
     
    615625// Start main loop
    616626// ----------------------------------------------------------------
    617 console.out("Start main loop.");
     627console.out("  "+new Date().toUTCString()+": Entering main loop.");
    618628
    619629var run = -2; // getObservation never called
     
    645655    if (!was_up && sun.isUp)
    646656    {
    647         console.out("", "Sun rise detected.... automatic shutdown initiated!");
     657        console.out("", "  "+new Date().toUTCString()+": Sun rise detected.... automatic shutdown initiated!");
    648658        // FIXME: State check?
    649659        Shutdown();
     
    743753         [ "LID_CONTROL",     [ "Open", "Closed"           ] ],
    744754         [ "DRIVE_CONTROL",   drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ],
    745          [ "FTM_CONTROL",     [ "Idle", "TriggerOn"        ] ],
     755         [ "FTM_CONTROL",     [ "Valid", "TriggerOn"       ] ],
    746756         [ "FAD_CONTROL",     [ "Connected", "RunInProgress" ] ],
    747757         [ "RATE_SCAN",       [ "Connected"                ] ],
     
    763773    {
    764774    case "STARTUP":
    765         console.out("  STARTUP", "");
     775        console.out("  "+new Date().toUTCString()+": New task [STARTUP]", "");
    766776        CloseLid();
    767777
     
    772782
    773783        // Before we can switch to 3000 we have to make the right DRS calibration
    774         console.out("  Take single p.e. run.");
     784        console.out("  "+new Date().toUTCString()+": Taking single p.e. run.");
    775785        while (!takeRun("pedestal", 5000));
    776786
     
    778788        service_feedback.voltageOff();
    779789        system_on = true;
     790        console.out("  "+new Date().toUTCString()+": Task finished [STARTUP]", "");
    780791        break;
    781792
    782793    case "SHUTDOWN":
    783         console.out("  SHUTDOWN", "");
     794        console.out("  "+new Date().toUTCString()+": New task [SHUTDOWN]", "");
    784795        Shutdown();
    785796        system_on = false;
     
    789800        console.out("  Waiting for next startup.", "");
    790801        sub++;
     802        console.out("  "+new Date().toUTCString()+": Task finished [SHUTDOWN]", "");
    791803        continue;
    792804
     
    796808
    797809    case "DRSCALIB":
    798         console.out("  DRSCALIB", "");
     810        console.out("  "+new Date().toUTCString()+": New task [DRSCALIB]", "");
    799811        doDrsCalibration("drscalib");  // will switch the voltage off
     812       console.out("  "+new Date().toUTCString()+": Task finished [DRSCALIB]", "");
    800813        break;
    801814
    802815    case "SINGLEPE":
    803         console.out("  SINGLE-PE", "");
     816        console.out("  "+new Date().toUTCString()+": New task [SINGLE-PE]", "");
    804817
    805818        // The lid must be closes
     
    816829
    817830        // Before we can switch to 3000 we have to make the right DRS calibration
    818         console.out("  Take single p.e. run.");
     831        console.out("  "+new Date().toUTCString()+": Taking single p.e. run.");
    819832        while (!takeRun("pedestal", 5000));
    820833
    821834        // It is unclear what comes next, so we better switch off the voltage
    822835        service_feedback.voltageOff();
     836       console.out("  "+new Date().toUTCString()+": Task finished [SINGLE-PE]", "");
    823837        break;
    824838
    825839    case "RATESCAN":
    826         console.out("  RATESCAN", "");
     840        console.out("  "+new Date().toUTCString()+": New task [RATESCAN]", "");
    827841
    828842        var tm1 = new Date();
     
    840854
    841855        if (obs.source != undefined)
     856        {
     857            console.out("  "+new Date().toUTCString()+": Moving drive to '"+obs[cub].source+"'.");
    842858            dim.send("DRIVE_CONTROL/TRACK_ON", obs[sub].source);
     859        }
    843860        else
     861        {
     862            console.out("  "+new Date().toUTCString()+": Moving drive to: ra="+obs[sub].ra+" dec="+obs[sub].dec);
    844863            dim.send("DRIVE_CONTROL/TRACK", obs[sub].ra, obs[sub].dec);
     864        }
    845865
    846866        dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing
     
    849869
    850870        var tm2 = new Date();
     871
     872        console.out("  "+new Date().toUTCString()+": Starting ratescan.");
    851873
    852874        // Start rate scan
     
    864886        //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 2);
    865887
    866         console.out("  Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000));
     888        console.out("  "+new Date().toUTCString()+": Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000));
     889        console.out("  "+new Date().toUTCString()+": Task finished [RATESCAN]", "");
    867890        break; // case "RATESCAN"
    868891
     
    884907        // ------------------------------------------------------------
    885908
    886         console.out("  Run #"+run+"  (remaining "+parseInt(remaining)+"min)");
     909        console.out("  "+new Date().toUTCString()+": Run #"+run+"  (remaining "+parseInt(remaining)+"min)");
    887910
    888911        // ----- Time since last DRS Calibration [min] ------
     
    910933
    911934            //console.out("  Move telescope to '"+source+"' "+offset+" "+wobble);
    912             console.out("  Move telescope to '"+obs[sub].source+"' ["+wobble+"]");
     935            console.out("  "+new Date().toUTCString()+": Moving telescope to '"+obs[sub].source+"' [wobble="+wobble+"]");
    913936
    914937            //var offset = observations[obs][2];
     
    943966        if (point)
    944967        {
    945             console.out("  Calibration.");
     968            console.out("  "+new Date().toUTCString()+": Starting calibration.");
    946969
    947970            // Calibration (2% of 20')
     
    956979        }
    957980
    958         console.out("  Taking data: start [5min]");
     981        //console.out("  Taking data: start [5min]");
     982
     983        // FIXME: What do we do if during calibration something has happened
     984        // e.g. drive went to ERROR? Maybe we have to check all states again?
    959985
    960986        var len = 300;
     
    968994        }
    969995
    970         console.out("  Taking data: done");
     996        //console.out("  Taking data: done");
    971997        run++;
    972998
     
    9751001
    9761002    if (nextObs!=undefined && sub==obs.length-1)
    977         console.out("  Waiting for next observation scheduled for "+nextObs.start.toUTCString(),"");
     1003        console.out("  "+new Date().toUTCString()+": Waiting for next observation scheduled at "+nextObs.start.toUTCString(),"");
    9781004
    9791005    sub++;
Note: See TracChangeset for help on using the changeset viewer.