Changeset 17924 for trunk/FACT++/scripts


Ignore:
Timestamp:
07/22/14 13:45:43 (10 years ago)
Author:
tbretz
Message:
Reverting to last revision.
File:
1 edited

Legend:

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

    r17922 r17924  
    195195
    196196// ================================================================
    197 //  Interrupt data taking in case of high currents
    198 // ================================================================
    199 dim.onchange['FEEDBACK'] = function(state)
    200 {
    201     if ((state.name=="Critical" || state.name=="OnStandby") &&
    202         (this.prev!="Critical"  && this.prev!="OnStandby"))
    203     {
    204         console.out("Feedback state changed from "+this.prev+" to "+state.name+" [Main.js]");
    205         irq = "RESCHEDULE";
    206     }
    207     this.prev=state.name;
    208 }
    209 
    210 // ================================================================
    211197//  Code related to switching bias voltage on and off
    212198// ================================================================
     
    217203{
    218204    if (!evt.data)
    219         return;
    220 
    221     if (this.ok==undefined)
    222205        return;
    223206
     
    240223    }
    241224    avg /= 320;
     225
     226    if (this.ok==undefined)
     227        return;
     228
    242229
    243230    this.ok = cnt<3;// || (this.last!=undefined && Math.abs(this.last-avg)<0.002);
     
    319306        ov = 1.1;
    320307
    321     if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") // FIXME: Warning, OnStandby, Critical if (ov<this.ov)
     308    if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress")
    322309    {
    323310        dim.log("Stoping feedback.");
     
    341328
    342329        dim.send("FEEDBACK/START", ov);
    343 
    344         // FIXME: We could miss "InProgress" if it immediately changes to "Warning"
    345         //        Maybe a dim.timeout state>8 ?
    346330        dim.wait("FEEDBACK", "InProgress", 45000);
    347331
     
    381365// ================================================================
    382366
    383 function Shutdown(singlepe)
     367function Shutdown()
    384368{
    385369    dim.log("Starting shutdown.");
     
    435419    }*/
    436420
    437     if (singlepe)
    438     {
    439         dim.log("Taking single-pe run.");
    440 
    441         // The voltage must be on
    442         service_feedback.voltageOn();
    443         service_feedback.waitForVoltageOn();
    444 
    445         // Before we can switch to 3000 we have to make the right DRS calibration
    446         dim.log("Taking single p.e. run.");
    447         while (!irq && !takeRun("single-pe", 10000));
    448     }
     421    dim.log("Taking single-pe run.");
     422
     423    // The voltage must be on
     424    service_feedback.voltageOn();
     425    service_feedback.waitForVoltageOn();
     426
     427    // Before we can switch to 3000 we have to make the right DRS calibration
     428    dim.log("Taking single p.e. run.");
     429    while (!irq && !takeRun("single-pe", 10000));
    449430
    450431    // It is unclear what comes next, so we better switch off the voltage
     
    547528         "FTM_CONTROL/TRIGGER_RATES",
    548529         "GPS_CONTROL/NEMA",
    549          "SQM_CONTROL/DATA",
    550530         "LID_CONTROL/DATA",
    551531         "MAGIC_LIDAR/DATA",
     
    574554
    575555    var list = obj.data.split('\n').map(map);
    576 //     [A
     556
    577557    function check(name)
    578558    {
     
    633613//console.out("Feedback init: start.");
    634614service_feedback.get(5000);
     615
     616//v8.timeout(3000, function() { var n = dim.state("FEEDBACK").name; if (n=="CurrentCtrlIdle" || n=="CurrentControl") return true; });
    635617
    636618// ----------------------------------------------------------------
     
    726708
    727709    if (irq.toUpperCase()=="RESCHEDULE")
    728     {
    729         irq = undefined;
    730         return false;
    731     }
     710        return true;
    732711
    733712    if (irq.toUpperCase()=="OFF")
     
    737716        return true;
    738717    }
    739 
    740     /*
    741     if (irq.toUpperCase()=="STOP")
    742     {
    743         dim.send("FAD_CONTROL/CLOSE_OPEN_FILES");
    744         dim.send("MCP/STOP");
    745         return true;
    746     }*/
    747718
    748719    if (irq.toUpperCase()=="SHUTDOWN")
     
    846817    }
    847818
    848     // Check if sun is still up... only DATA and */
     819    // Check if sun is still up... only DATA and RATESCAN must be suppressed
    849820    if ((obs[sub].task=="DATA" || obs[sub].task=="RATESCAN") && sun.isUp)
    850821    {
     
    865836    // otherwise it is difficult to allow e.g. the STARTUP at the beginning of the night
    866837    var power_states = sun.isUp || !system_on ? [ "DriveOff", "SystemOn" ] : [ "SystemOn" ];
    867     var drive_states = sun.isUp || !system_on ? undefined : [ "Armed", "Tracking", "OnTrack" ];
     838    var drive_states = sun.isUp || !system_on ?   undefined    : [ "Armed", "Tracking", "OnTrack" ];
    868839
    869840    // A scheduled task was found, lets check if all servers are
     
    887858         [ "AGILENT_CONTROL_80V", [ "VoltageOn"                ] ],
    888859         [ "BIAS_CONTROL",        [ "VoltageOff", "VoltageOn", "Ramping" ] ],
    889          [ "FEEDBACK",            [ "Calibrated", "InProgress", "OnStandby", "Warning", "Critical" ] ],
     860         [ "FEEDBACK",            [ "Calibrated", "InProgress" ] ],
    890861         [ "LID_CONTROL",         [ "Open", "Closed"           ] ],
    891862         [ "DRIVE_CONTROL",       drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ],
     
    895866         [ "RATE_CONTROL",        [ "Connected", "GlobalThresholdSet", "InProgress"  ] ],
    896867         [ "GPS_CONTROL",         [ "Locked"  ] ],
    897          [ "SQM_CONTROL",         [ "Valid"  ] ],
    898868        ];
    899869
     
    902872    {
    903873        throw new Error("Something unexpected has happened. One of the servers "+
    904                         "is in a state in which it should not be. Please,"+ 
     874                        "is in a state in which it should not be. Please,"+
    905875                        "try to find out what happened...");
    906876    }
    907877
    908     datalogger_subscriptions.check();                                         
    909                                                                                
    910     // If this is an observation which needs the voltage to be swicthed on
    911     // skip that if the voltage is not stable                                   
    912     /*
    913     if (obs[sub].task=="DATA" || obs[sub].task=="RATESCAN")
    914     {
    915         var state = dim.state("FEEDBACK").name;
    916         if (state=="Warning" || state=="Critical" || state=="OnStandby")
    917         {
    918             v8.sleep(1000);
    919             continue;
    920         }
    921     }*/
    922 
     878    datalogger_subscriptions.check();
    923879
    924880    // Check if obs.task is one of the one-time-tasks
     
    953909
    954910    case "SHUTDOWN":
    955         Shutdown(true);
     911        Shutdown();
    956912        system_on = false;
    957913
     
    10811037        service_feedback.waitForVoltageOn();
    10821038
    1083         if (!irq)
    1084         {
    1085             var tm2 = new Date();
    1086 
    1087             dim.log("Starting ratescan.");
    1088 
    1089             // Start rate scan
    1090             dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 50, 1000, -10);
    1091 
    1092             // Lets wait if the ratescan really starts... this might take a few
    1093             // seconds because RATE_SCAN configures the ftm and is waiting for
    1094             // it to be configured.
    1095             dim.wait("RATE_SCAN", "InProgress", 10000);
    1096             dim.wait("RATE_SCAN", "Connected", 2700000);
    1097 
    1098             // Here one could implement a watchdog for the feedback as well, but what is the difference
    1099             // whether finally one has to find out if the feedback was in the correct state
    1100             // or the ratescan was interrupted?
    1101 
    1102             // this line is actually some kind of hack.
    1103             // after the Ratescan, no data is written to disk. I don't know why, but it happens all the time
    1104             // So I decided to put this line here as a kind of patchwork....
    1105             //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 6);
    1106 
    1107             dim.log("Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000));
    1108         }
    1109 
     1039        var tm2 = new Date();
     1040
     1041        dim.log("Starting ratescan.");
     1042
     1043        // Start rate scan
     1044        dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 50, 1000, -10);
     1045
     1046        // Lets wait if the ratescan really starts... this might take a few
     1047        // seconds because RATE_SCAN configures the ftm and is waiting for
     1048        // it to be configured.
     1049        dim.wait("RATE_SCAN", "InProgress", 10000);
     1050        dim.wait("RATE_SCAN", "Connected", 2700000);
     1051
     1052        // this line is actually some kind of hack.
     1053        // after the Ratescan, no data is written to disk. I don't know why, but it happens all the time
     1054        // So I decided to put this line here as a kind of patchwork....
     1055        //dim.send("FAD_CONTROL/SET_FILE_FORMAT", 6);
     1056
     1057        dim.log("Ratescan done [%.1fs, %.1fs]".$((tm2-tm1)/1000, (new Date()-tm2)/1000));
    11101058        dim.log("Task finished [RATESCAN]");
    11111059        console.out("");
     
    11241072        }
    11251073    */
    1126 
    11271074        // Calculate remaining time for this observation in minutes
    11281075        var remaining = nextObs==undefined ? 0 : (nextObs.start-new Date())/60000;
     
    11871134
    11881135        if (irq)
    1189             continue;
     1136            break;
    11901137
    11911138        OpenLid();
     
    11931140        // This is now th right time to wait for th drive to be stable
    11941141        dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing
    1195 
    1196         // Now check the voltage... (do not start a lot of stuff just to do nothing)
    1197         var state = dim.state("FEEDBACK").name;
    1198         if (state=="Warning" || state=="Critical" || state=="OnStandby")
    1199         {
    1200             v8.sleep(60000);
    1201             continue;
    1202         }
    12031142
    12041143        // Now we are 'OnTrack', so we can ramp to nominal voltage
     
    12081147
    12091148        // If pointing had changed, do calibration
    1210         if (!irq && point)
     1149        if (point)
    12111150        {
    12121151            dim.log("Starting calibration.");
     
    12381177        {
    12391178            var len = 300;
    1240             while (!irq && len>15)
     1179            while (len>15)
    12411180            {
    12421181                var time = new Date();
Note: See TracChangeset for help on using the changeset viewer.