IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8191


Ignore:
Timestamp:
Aug 5, 2006, 5:12:38 AM (20 years ago)
Author:
eugene
Message:

added Nmax option to trange

Location:
trunk/Ohana/src/opihi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/include/pantasks.h

    r8129 r8191  
    5252  char type;
    5353  char keep;
     54  int Nmax;
     55  int Nrun;
    5456} TimeRange;
    5557
  • trunk/Ohana/src/opihi/pantasks/CheckTasks.c

    r6687 r8191  
    3030    SubmitJob (job);
    3131
    32     /* reset timer on task (don't do this if Create/Submit fails)*/
     32    /* reset timer on task (don't do this if Create/Submit fails) (why not??) */
    3333    gettimeofday (&task[0].last, (void *) NULL);
    3434    task[0].Njobs ++;
     35
     36    /* increment Nrun for inclusive ranges with Nmax */
     37    BumpTimeRanges (task[0].ranges, task[0].Nranges);
    3538
    3639    if (TestElapsedCheck()) return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c

    r6687 r8191  
    11# include "pantasks.h"
    22
     3/* test if we meet all time range qualifications */
    34int CheckTimeRanges (TimeRange *ranges, int Nranges) {
    45
    56  int i, intime, valid;
    6   time_t daytime, weektime, abstime;
     7  time_t daytime, weektime, abstime, testtime;
    78  struct timeval now;
    89  struct tm Now;
    910
     11  /* get the current time */
    1012  gettimeofday (&now, NULL);
    1113  gmtime_r (&now.tv_sec, &Now);
    12   daytime = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600;
     14  daytime  = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600;
    1315  weektime = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600 + Now.tm_wday*86400;
    14   abstime = now.tv_sec;
     16  abstime  = now.tv_sec;
    1517
    1618  valid = TRUE;
    1719  for (i = 0; (i < Nranges) && valid; i++) {
    1820    switch (ranges[i].type) {
     21      /* set the testtime */
    1922      case RANGE_ABS:
    20         intime = (abstime >= ranges[i].start) && (abstime <= ranges[i].stop);
    21         valid = ranges[i].keep ? intime : !intime;
     23        testtime = abstime;
    2224        break;
    2325      case RANGE_DAY:
    24         intime = (daytime >= ranges[i].start) && (daytime <= ranges[i].stop);
    25         valid = ranges[i].keep ? intime : !intime;
     26        testtime = daytime;
    2627        break;
    2728      case RANGE_WEEK:
    28         intime = (weektime >= ranges[i].start) && (weektime <= ranges[i].stop);
    29         valid = ranges[i].keep ? intime : !intime;
     29        testtime = weektime;
    3030        break;
     31      default:
     32        abort ();
    3133    }
    32     if (!valid) return (FALSE);
     34    intime = (testtime >= ranges[i].start) && (testtime <= ranges[i].stop);
     35
     36    /* check for more than max runs in time range */
     37    if (ranges[i].keep && intime && ranges[i].Nmax) {
     38      if (ranges[i].Nrun >= ranges[i].Nmax) return (FALSE);
     39    }
     40    /* reset Nrun if we are outside of intime */
     41    if (ranges[i].keep && !intime && ranges[i].Nmax && ranges[i].Nrun) {
     42      ranges[i].Nrun = 0;
     43    }
     44
     45    /* is this a valid time? */
     46    valid = ranges[i].keep ? intime : !intime;
    3347  }
    3448  return (valid);
    3549
     50
     51/* increment the number of runs for all inclusive time ranges with Nmax > 0
     52   (only call when we execute a task -- after CheckTimeRanges) */
     53int BumpTimeRanges (TimeRange *ranges, int Nranges) {
     54
     55  int i;
     56
     57  for (i = 0; i < Nranges; i++) {
     58    if (ranges[i].keep && ranges[i].Nmax) {
     59      ranges[i].Nrun ++;
     60    }
     61  }
     62  return (TRUE);
     63
  • trunk/Ohana/src/opihi/pantasks/task_trange.c

    r7917 r8191  
    1212  } */
    1313
     14  range.Nmax = 0;
     15  range.Nrun = 0;
     16  if (N = get_argument (argc, argv, "-nmax")) {
     17    remove_argument (N, &argc, argv);
     18    range.Nmax = atoi (argv[N]);
     19    remove_argument (N, &argc, argv);
     20  }
    1421
    1522  /* keep = true means the time range defines a valid time range
Note: See TracChangeset for help on using the changeset viewer.