Changeset 15137 for trunk/FACT++/scripts


Ignore:
Timestamp:
03/22/13 17:14:55 (12 years ago)
Author:
tbretz
Message:
Reoragnized and improved the output; instead of just waiting for the voltage to get up, we now wait until the steps between two ratecontrol induced updates are reasonably small. The pure waiting was too short (espacially during bright moon light) and might have effected a lot of pedestal and light-pulser runs. The waiting was typically 30s, but it can take up to two minutes.
File:
1 edited

Legend:

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

    r15117 r15137  
    170170}
    171171
     172var startrun = new Subscription("FAD_CONTROL/START_RUN");
     173startrun.get(5000);
     174
    172175function takeRun(type, count, time)
    173176{
     
    177180        time = -1;
    178181
    179     console.out("  Take run: N="+count+" T="+time+"s ["+type+"]");
     182    var nextrun = startrun.get().obj['next'];
     183    console.out("  Take run %3d".$(nextrun)+": N="+count+" T="+time+"s ["+type+"]");
    180184
    181185    dim.send("MCP/START", time?time:-1, count?count:-1, type);
     
    221225    dim.wait("MCP", "Idle");
    222226
    223     console.out("  Take run: end");
     227    //console.out("  Take run: end");
    224228
    225229    // DN: currently reconnect() never returns false
     
    235239function doDrsCalibration()
    236240{
    237     console.out("  DRS cal: start");
     241    //console.out("  DRS cal: start");
    238242    service_feedback.voltageOff();
    239243
     
    270274    dim.wait("RATE_CONTROL", "Connected", 3000);
    271275
    272     console.out("  DRS cal: end");
     276    //console.out("  DRS cal: end");
    273277}
    274278
     
    319323
    320324var service_feedback = new Subscription("FEEDBACK/DEVIATION");
     325
     326service_feedback.onchange = function(evt)
     327{
     328    if (this.cnt && evt.counter>this.cnt+12)
     329        return;
     330
     331    this.voltageStep = null;
     332    if (!evt.obj)
     333        return;
     334
     335    var delta = evt.obj['DeltaBias'];
     336
     337    var avg = 0;
     338    for (var i=0; i<320; i++)
     339        avg += delta[i];
     340    avg /= 320;
     341
     342    if (this.previous)
     343        this.voltageStep = Math.abs(avg-this.previous);
     344
     345    this.previous = avg;
     346
     347    console.out("  DeltaV="+this.voltageStep);
     348}
    321349
    322350// DN:  Why is voltageOff() implemented as
     
    413441    if (isOff)
    414442    {
     443        console.out("  Voltage on: cnt="+this.cnt);
     444
     445        this.previous = undefined;
    415446        this.cnt = this.get().counter;
    416         console.out("  Voltage on: cnt="+this.cnt);
     447        this.voltageStep = undefined;
    417448    }
    418449}
     
    433464
    434465    // Avoid output if condition is already fulfilled
    435     if (this.cnt && this.get().counter>this.cnt+2)
     466    if (this.cnt && this.get().counter>this.cnt+10)
    436467        return;
    437468
     
    440471
    441472    var now = new Date();
    442     while (this.cnt==undefined || this.get().counter<=this.cnt+2)
     473    //v8.timeout(90000, function() { if (!(this.cnt==undefined || this.get().counter<=this.cnt+2)) return true; });
     474    while ((this.cnt==undefined || this.get().counter<=this.cnt+10) && (!this.voltageStep || this.voltageStep>0.02))
    443475        v8.sleep();
    444476
    445     console.out("  Feedback wait: end [cnt=%d, %.2fs]".$(this.get().counter, (new Date()-now)/1000));
     477    console.out("  Feedback wait: end [dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));
    446478}
    447479
     
    547579
    548580    // FIXME: This might not work is the drive is already close to park position
    549     dim.wait("DRIVE_CONTROL", "Moving", 3000);
    550     dim.wait("DRIVE_CONTROL", "Armed", 120000);
     581    dim.wait("DRIVE_CONTROL", "Locked", 3000);
     582    //dim.wait("DRIVE_CONTROL", "Moving", 3000);
     583    //dim.wait("DRIVE_CONTROL", "Armed", 120000);
    551584
    552585    // dim.wait("DRIVE_CONTROL", "Locked", 3000);
     
    620653    if (idxObs===undefined)
    621654        exit();
     655
     656    // FIXME: Check missing whether a shutdown is needed...
    622657
    623658    // we are still waiting for the first observation in the schedule
     
    684719        CloseLid();
    685720
    686         console.out("  Take DRS calibration.");
     721        console.out("  Take DRS calibration [startup]");
    687722        doDrsCalibration();  // -> VoltageOff
     723        console.out("  DRS calibration done.");
    688724
    689725        service_feedback.voltageOn();
     
    712748
    713749    case "IDLE":
    714         // FIXME: Checks missing whether a shutdown is needed...
    715750        v8.sleep(1000);
    716751        continue;
     
    876911        // Change wobble position every four runs,
    877912        // start with alternating wobble positions each day
    878         var wobble = (parseInt(run/4) + parseInt(new Date()/1000/3600/24-0.5))%2;
     913        var wobble = (parseInt(run/4) + parseInt(new Date()/1000/3600/24-0.5))%2+1;
    879914
    880915        //console.out("  Move telescope to '"+source+"' "+offset+" "+wobble);
     
    886921        //dim.send("DRIVE_CONTROL/TRACK_SOURCE", offset, wobble, source);
    887922
    888         dim.send("DRIVE_CONTROL/TRACK_WOBBLE", wobble+1, obs[sub].source);
     923        dim.send("DRIVE_CONTROL/TRACK_WOBBLE", wobble, obs[sub].source);
    889924
    890925        // Do we have to check if the telescope is really moving?
     
    894929    if (drscal)
    895930    {
    896         console.out("  Take DRS calibration.");
     931        console.out("  Take DRS calibration [interleaved]");
    897932        doDrsCalibration();  // -> VoltageOff
     933        console.out("  DRS calibration done.");
    898934    }
    899935
Note: See TracChangeset for help on using the changeset viewer.