Changeset 17926 for trunk


Ignore:
Timestamp:
07/22/14 13:46:23 (10 years ago)
Author:
tbretz
Message:
Added handling for Critical and OnStandby status of feedback.
File:
1 edited

Legend:

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

    r17923 r17926  
    173173    //}
    174174
     175    // ================================================================
     176    //  Function for Critical voltage
     177    // ================================================================
     178
     179    // INSTALL a watchdog... send FAD_CONTROL/CLOSE_OPEN_FILES
     180    // could send MCP/RESET as well but would result in a timeout
     181    var callback = dim.onchange['FEEDBACK'];
     182    dim.onchange['FEEDBACK'] = function(state)
     183    {
     184        if (callback)
     185            callback.call(this, state);
     186
     187        if ((state.name=="Critical" || state.name=="OnStandby") &&
     188            (this.last!="Critical"  && this.last!="OnStandby"))
     189        {
     190            console.out("Feedback state changed from "+this.last+" to "+state.name+" [takeRun.js]");
     191
     192            // Includes FAD_CONTROL/CLOSE_ALL_OPEN_FILES
     193            dim.send("MCP/STOP");
     194        }
     195
     196        this.last=state.name;
     197    }
     198
    175199    // Here we could check and handle fad losses
    176200
     
    241265    }
    242266
     267    // This is to check if we have missed the event. This can happen as
     268    // a race condition when the MCP/STOP is sent by the event handler
     269    // but the run was not yet fully configured.
     270    var statefb = dim.state("FEEDBACK").name;
     271    if (statefb=="Critical" || statefb=="OnStandby")
     272    {
     273        console.out("Run started by FEEDBACK in state "+statefb);
     274        dim.send("MCP/STOP"); // Includes FAD_CONTROL/CLOSE_ALL_OPEN_FILES
     275
     276        dim.onchange['FEEDBACK'] = callback;
     277
     278        return true;
     279    }
     280
    243281    dim.wait("MCP", "Idle", time>0 ? time*1250 : undefined); // run time plus 25%
     282
     283    // REMOVE watchdog
     284    dim.onchange['FEEDBACK'] = callback;
    244285
    245286    if (incomplete)
Note: See TracChangeset for help on using the changeset viewer.