Changeset 18715 for trunk/FACT++


Ignore:
Timestamp:
01/06/17 12:01:00 (8 years ago)
Author:
tbretz
Message:
Implemented the suspend/resume feature. Everything after a suspend is ignored. If a successive resume is found suspend/resume are ignored.
File:
1 edited

Legend:

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

    r18651 r18715  
    3939
    4040    observations = getSchedule();
     41    if (observations.length==0)
     42        return -1;
     43
     44    var suspended = -1;
     45
     46    var rc = observations.length-1;
    4147
    4248    for (var i=0; i<observations.length; i++)
    43         if (now<observations[i].start)
    44             return i-1;
    45 
    46     return observations.length-1;
     49    {
     50        // Find the first observation which is in the future
     51        if (observations[i].start>now)
     52        {
     53            rc = i-1;
     54            break;
     55        }
     56
     57        // If the loop just passed a suspend, i.e. it is in the past, set the suspend flag
     58        if (observations[i][0].task=="SUSPEND")
     59            suspended = i;
     60
     61        // If the loop just passed a resume, i.e. it is in the past, remove the suspend flag
     62        if (observations[i][0].task=="RESUME")
     63            suspended = -1;
     64    }
     65
     66    // Now rc contains the index of the first observation in the past
     67
     68    // If the system is in suspend mode, the suspend observation is
     69    // returned as recent measurement. For convenience (to avoid that
     70    // the next observation is announced), all furture observations
     71    // are removed.
     72    if (suspended>=0)
     73    {
     74        observations.splice(suspended+1);
     75        return suspended;
     76    }
     77
     78    // Observations have already been resumed and the last scheduled
     79    // observation is the resume itself: remove the resume and
     80    // all leading suspend/resume pairs until the last observation
     81    // is found
     82    while (rc>=0 && observations[rc][0].task=="RESUME")
     83    {
     84        observations.splice(rc--, 1);
     85
     86        // Find previous suspend
     87        if (rc>=0 && observations[rc][0].task=="SUSPEND")
     88            observations.splice(rc--, 1);
     89    }
     90
     91    return rc;
    4792}
    4893
     
    918963    if (!nextObs && nextId)
    919964    {
    920         dim.log("No further observation scheduled.");
     965        if (obs[sub].task=="SUSPEND")
     966            dim.log("Further observation suspended.");
     967        else
     968            dim.log("No further observation scheduled.");
    921969        console.out("");
    922970        nextId = undefined;
     
    10021050    }
    10031051
    1004     datalogger_subscriptions.check();                                         
    1005                                                                                
     1052    datalogger_subscriptions.check();
     1053
    10061054    // If this is an observation which needs the voltage to be swicthed on
    1007     // skip that if the voltage is not stable                                   
     1055    // skip that if the voltage is not stable
    10081056    /*
    10091057    if (obs[sub].task=="DATA" || obs[sub].task=="RATESCAN")
Note: See TracChangeset for help on using the changeset viewer.