Changeset 15146


Ignore:
Timestamp:
03/25/13 09:32:47 (12 years ago)
Author:
tbretz
Message:
Catch the timeout when a run is started and check for FAD loss; removed the need stop the ratecontrol over and over when not necessary; added DRSCALIB and SINGLEPE task; make use of v8.timeout; adapted timeout when starting a run to the use of the current based threshold calibration; implemented timout for the run duration
File:
1 edited

Legend:

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

    r15137 r15146  
    2929// ----------------------------------------------------------------
    3030
    31 dimctrl.defineState(37, "TimeOutBeforeTakingData", "MCP took more than 5minutes to start TakingData");
     31//dimctrl.defineState(37, "TimeOutBeforeTakingData", "MCP took more than 5minutes to start TakingData");
    3232
    3333
     
    185185    dim.send("MCP/START", time?time:-1, count?count:-1, type);
    186186
    187     // What could be a reasonable timeout here?
    188187    // FIXME: Replace by callback?
    189188    //
     
    216215    // 
    217216
    218     if (!dim.wait("MCP", "TakingData", -300000) )
    219     {
    220         console.out("MCP took longer than 5 minutes to start TakingData");
    221         console.out("maybe this idicates a problem with one of the FADs?");
    222         dimctrl.setState(37);
    223         dim.wait("MCP", "TakingData", 500);
    224     }
    225     dim.wait("MCP", "Idle");
     217    // Use this if you use the rate control to calibrate by rates
     218    //if (!dim.wait("MCP", "TakingData", -300000) )
     219    //{
     220    //    throw new Error("MCP took longer than 5 minutes to start TakingData"+
     221    //                    "maybe this idicates a problem with one of the FADs?");
     222    //}
     223
     224    // Here we could check and handle fad losses
     225    try
     226    {
     227        dim.wait("MCP", "TakingData", 15000);
     228    }
     229    catch (e)
     230    {
     231        if (dim.state("MCP").name=="Configuring3" &&
     232            dim.state("FAD_CONTROL").name=="Configuring2")
     233        {
     234            conssole.out("");
     235            conssole.out("Waiting for fadctrl to get configured timed out... checking for FAD loss.");
     236            conssole.out("");
     237
     238            var con  = service_con.get();
     239            var stat = con.obj['status'];
     240
     241            var reset = [ ];
     242
     243            for (var i=0; i<40; i++)
     244                if (stat[i]!=0x43)
     245                {
     246                    console.out("  FAD %2d".$(i)+" not in Configured state.");
     247                    reset.push(i/10);
     248                }
     249
     250            reset = reset.filter(function(elem,pos){return reset.indexOf(elem)==pos;});
     251
     252            if (reset.length>0)
     253            {
     254                console.out("");
     255                console.out("  FADs belong to crates "+reset);
     256            }
     257        }
     258
     259        dim.send("MCP/RESET");
     260
     261        // If it works, we can decide here what to do...
     262
     263        throw e;
     264    }
     265
     266    if (time>0)
     267        dim.wait("MCP", "Idle", time*1250); // run time plus 25%
     268    else
     269        dim.wait("MCP", "Idle");
    226270
    227271    //console.out("  Take run: end");
     
    271315    }
    272316
    273     dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
    274     dim.wait("RATE_CONTROL", "Connected", 3000);
     317    //dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
     318    //dim.wait("RATE_CONTROL", "Connected", 3000);
    275319
    276320    //console.out("  DRS cal: end");
     
    470514    console.out("  Feedback wait: start");
    471515
     516    function func(service)
     517    {
     518        if ((service.cnt!=undefined && service.get().counter>service.cnt+10) ||
     519            (service.voltageStep && service.voltageStep<0.02))
     520            return true;
     521    }
     522
    472523    var now = new Date();
    473     //v8.timeout(90000, function() { if (!(this.cnt==undefined || this.get().counter<=this.cnt+2)) return true; });
     524    //v8.timeout(5*60000, func, this);
    474525    while ((this.cnt==undefined || this.get().counter<=this.cnt+10) && (!this.voltageStep || this.voltageStep>0.02))
    475526        v8.sleep();
     
    601652    }
    602653
     654    var now = new Date();
    603655    v8.timeout(150000, func);
    604656
    605     // FIXME: Add a check for the position here!
    606 
    607     console.out("Shutdown: end");
     657    var report = sub.get();
     658
     659    console.out("");
     660    console.out("Shutdown procedure seems to be finished...");
     661    console.out("  Telescope at Zd="+report.obj['Zd']+"deg Az="+report.obj['Az']+"deg");
     662    console.out("  Please make sure the park position was reached");
     663    console.out("  and the telescope is not moving anymore.");
     664    console.out("  Please check that the lid is closed and the voltage switched off.");
     665    console.out("");
     666    console.out("Shutdown: end ["+(new Date()-now)/1000+"s]");
    608667}
    609668
     
    708767        continue;
    709768    }
    710 // add time
     769
    711770    console.out("\n"+(new Date()).toUTCString()+": Current measurement: "+obs[sub]);
    712771
     
    732791        service_feedback.voltageOff();
    733792
    734         dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
    735         dim.wait("RATE_CONTROL", "Connected", 3000);
     793        //dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
     794        //dim.wait("RATE_CONTROL", "Connected", 3000);
    736795
    737796        console.out("  Waiting for first scheduled observation.","");
     
    751810        continue;
    752811
     812    case "DRSCALIB":
     813        console.out("  DRSCALIB", "");
     814
     815        console.out("  Take DRS calibration [drscalib]");
     816        doDrsCalibration();  // -> VoltageOff
     817        console.out("  DRS calibration done.");
     818
     819        //dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
     820        //dim.wait("RATE_CONTROL", "Connected", 3000);
     821
     822        sub++;
     823        continue;
     824
     825    case "SINGLEPE":
     826
     827        // FIXME: Check whether a DRS calib is necessary.
     828
     829        service_feedback.voltageOn();
     830        service_feedback.waitForVoltageOn();
     831
     832        // Before we can switch to 3000 we have to make the right DRS calibration
     833        console.out("  Take single p.e. run.");
     834        while (!takeRun("pedestal", 5000));
     835
     836        service_feedback.voltageOff();
     837
     838        //dim.send("RATE_CONTROL/STOP"); // get out of GlobalThresholdSet
     839        //dim.wait("RATE_CONTROL", "Connected", 3000);
     840
     841        sub++;
     842        continue;
     843
    753844    case "RATESCAN":
    754845        console.out("  RATESCAN  ");
    755 
     846        /*
    756847        if (dim.state("FTM_CONTROL").name=="TriggerOn")
    757848        {
    758849            dim.send("FTM_CONTROL/STOP_TRIGGER");
    759850            dim.wait("FTM_CONTROL", "Idle", 3000);
    760         }
    761 
     851        }*/
     852
     853        // This is a workaround to make sure that we really catch
     854        // the new state and not the old one
    762855        dim.send("DRIVE_CONTROL/STOP");
    763856        dim.wait("DRIVE_CONTROL", "Armed", 5000);
     
    794887             [ "FEEDBACK",        [ "CurrentControl"           ] ],
    795888             [ "RATE_SCAN",       [ "Connected"                ] ],
    796              [ "RATE_CONTROL",    [ "Connected", "InProgress"  ] ],
     889             [ "RATE_CONTROL",    [ "Connected", "GlobalThresholdSet", "InProgress"  ] ],
    797890             [ "LID_CONTROL",     [ "Open"                     ] ],
    798891             [ "DRIVE_CONTROL",   [ "Tracking", "OnTrack"      ] ],
    799              [ "FTM_CONTROL",     [ "Idle",                    ] ],
     892             [ "FTM_CONTROL",     [ "Idle", "TriggerOn"        ] ],
    800893             [ "FAD_CONTROL",     [ "Connected", "WritingData" ] ],
    801894            ];
     
    811904        dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 50, 1000, -10);
    812905
    813         // lets wait if the Ratescan really starts .. it should be started after 10sec max.       
     906        // Lets wait if the ratescan really starts... this might take a few
     907        // seconds because RATE_SCAN configures the ftm and is waiting for
     908        // it to be configured.
    814909        dim.wait("RATE_SCAN", "InProgress", 10000);
    815910        dim.wait("RATE_SCAN", "Connected", 2700000);
     
    818913        // after the Ratescan, no data is written to disk. I don't know why, but it happens all the time
    819914        // So I decided to put this line here as a kind of patchwork....
    820         dim.send("FAD_CONTROL/SET_FILE_FORMAT", 2);
     915        //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 2);
    821916
    822917        console.out("Ratescan done.");
     
    860955         [ "FEEDBACK",        [ "CurrentCtrlIdle", "CurrentControl"        ] ],
    861956         [ "RATE_SCAN",       [ "Connected"                                ] ],
    862          [ "RATE_CONTROL",    [ "Connected", "InProgress"                  ] ],
     957         [ "RATE_CONTROL",    [ "Connected", "GlobalThresholdSet", "InProgress" ] ],
    863958         [ "LID_CONTROL",     [ "Open", "Closed"                           ] ],
    864959         [ "DRIVE_CONTROL",   [ "Armed", "Tracking", "OnTrack"             ] ],
Note: See TracChangeset for help on using the changeset viewer.