Changeset 15289 for trunk/FACT++


Ignore:
Timestamp:
04/10/13 10:17:48 (12 years ago)
Author:
tbretz
Message:
Improved the code to handle the INCOMPLETE message, added some code to suppress double shutdown and allow simple tests during day-time.
File:
1 edited

Legend:

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

    r15284 r15289  
    101101sub_incomplete.onchange = function(evt)
    102102{
    103     if (!evt)
     103    if (!evt.data)
     104    {
     105        this.last_inc = 0;
    104106        return;
    105 
    106     var inc = evt.data[0];//obj['incomplete'];
     107    }
     108
     109    var inc = evt.obj['incomplete'];
    107110    if (!inc)
     111    {
     112        this.last_inc = 0;
    108113        return;
    109 
    110     if ((evt.time - this.last_time)<5000 && this.last_inc==inc)
     114    }
     115
     116    if (this.last_inc==inc)
    111117        return;
    112118
     
    136142    }
    137143
    138     this.last_time = evt.time;
    139144    this.last_inc  = inc;
    140145}
     
    322327            if (stat[i]!=0x43)
    323328            {
    324                 console.out("   ...disconnect ", i);
     329                console.out("   ...disconnect "+i);
    325330                dim.send("FAD_CONTROL/DISCONNECT", i);
    326331            }
     
    332337            if (stat[i]!=0x43)
    333338            {
    334                 console.out("   ...reconnect ", i);
     339                console.out("   ...reconnect "+i);
    335340                dim.send("FAD_CONTROL/CONNECT", i);
    336341            }
     
    353358            if (incomplete&(1<<i))
    354359            {
    355                 console.out("   ...disconnect ", i);
     360                console.out("   ...disconnect "+i);
    356361                dim.send("FAD_CONTROL/DISCONNECT", i);
    357362            }
     
    363368            if (incomplete&(1<<i))
    364369            {
    365                 console.out("   ...reconnect ", i);
     370                console.out("   ...reconnect "+i);
    366371                dim.send("FAD_CONTROL/CONNECT", i);
    367372            }
     
    650655function Shutdown()
    651656{
    652     /**** dummy ****/
    653     //console.out("  => [SHUTDOWN] called.");
    654657    console.out("Shutdown: start");
    655658
    656     dim.send("FEEDBACK/STOP");
    657     dim.send("FEEDBACK/ENABLE_OUTPUT", false);
    658     dim.send("FTM_CONTROL/STOP_TRIGGER");
    659659    service_feedback.voltageOff();
    660660    CloseLid();
     
    665665    // FIXME: This might not work is the drive is already close to park position
    666666    dim.wait("DRIVE_CONTROL", "Locked", 3000);
    667     //dim.wait("DRIVE_CONTROL", "Moving", 3000);
    668     //dim.wait("DRIVE_CONTROL", "Armed", 120000);
    669 
    670     // dim.wait("DRIVE_CONTROL", "Locked", 3000);
    671667
    672668    var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION");
     
    688684    var now = new Date();
    689685    v8.timeout(150000, func);
     686
     687    //dim.send("FEEDBACK/STOP");
     688    dim.send("FEEDBACK/ENABLE_OUTPUT", false);
     689    dim.send("FTM_CONTROL/STOP_TRIGGER");
     690
     691    dim.wait("FEEDBACK", "CurrentCtrlIdle", 3000);
     692    dim.wait("FTM_CONTROL", "Idle", 3000);
    690693
    691694    var report = sub.get();
     
    789792var lastObs;
    790793var sun = Sun.horizon(-13);
     794var system_on;  // undefined
    791795
    792796while (1)
     
    815819        // FIXME: State check?
    816820        Shutdown();
     821        system_on = false;
    817822        continue;
    818823    }
     
    863868    }
    864869
     870    var task = obs[sub].task;
     871
    865872    // Check if sun is still up... only DATA and RATESCAN must be suppressed
    866     if ((obs[sub].task=="DATA" || obs[sub].task=="RATESCAN") && sun.isUp)
     873    if ((task=="DATA" || task=="RATESCAN") && sun.isUp)
    867874    {
    868875        var now = new Date();
     
    872879        continue;
    873880    }
     881
     882    if (system_on===false && task!="STARTUP")
     883    {
     884        v8.sleep(1000);
     885        continue;
     886    }
     887
     888    var power_states = sun.isUp || system_on===false ? [ "DriveOff" ] : [ "SystemOn" ];
     889
     890    var drive_states = sun.isUp || system_on===false ? [ ] : [ "Armed", "Tracking", "OnTrack" ];
    874891
    875892    // A scheduled task was found, lets check if all servers are
     
    887904         [ "MCP",             [ "Idle"                     ] ],
    888905         [ "TIME_CHECK",      [ "Valid"                    ] ],
    889          [ "PWR_CONTROL",     [ "SystemOn"                 ] ],
     906         [ "PWR_CONTROL",     power_states/*[ "SystemOn"                 ]*/ ],
    890907         [ "AGILENT_CONTROL", [ "VoltageOn"                ] ],
    891908         [ "BIAS_CONTROL",    [ "VoltageOff", "VoltageOn", "Ramping" ] ],
    892909         [ "FEEDBACK",        [ "CurrentControl", "CurrentCtrlIdle" ] ],
    893910         [ "LID_CONTROL",     [ "Open", "Closed"           ] ],
    894          [ "DRIVE_CONTROL",   [ "Armed", "Tracking", "OnTrack" ] ],
     911         [ "DRIVE_CONTROL",   drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ],
    895912         [ "FTM_CONTROL",     [ "Idle", "TriggerOn"        ] ],
    896913         [ "FAD_CONTROL",     [ "Connected", "WritingData" ] ],
     
    926943        // It is unclear what comes next, so we better switch off the voltage
    927944        service_feedback.voltageOff();
     945        system_on = true;
    928946        break;
    929947
     
    931949        console.out("  SHUTDOWN", "");
    932950        Shutdown();
     951        system_on = false;
    933952
    934953        // FIXME: Avoid new observations after a shutdown until
Note: See TracChangeset for help on using the changeset viewer.