Esempio n. 1
0
 public void setDate(Instant date) {
   if (date == null) {
     this.date = null;
   } else {
     this.date = date.toString(DATE_FORMAT);
   }
 }
 // reduce duration by one on each tick of the clock
 void tick() {
   duration -= 1;
   if (duration < 0) {
     log.error(
         getName() + "SE start at " + start.toString() + " ticked past duration " + duration);
   }
   usageIndex += 1;
 }
 // Returns the ShiftEnergy instance for the current time
 // Note that for this to work, the ShiftEnergy.tick() method
 // must be called once/timeslot.
 ShiftEnergy getCurrentNeed(Instant when) {
   if (null == needs) return null;
   for (int i = 0; i < needs.length; i++) {
     // if it's the last one, return it.
     if ((i == needs.length - 1) || (needs[i + 1].getStart().isAfter(when))) {
       return needs[i];
     }
   }
   // should never get here
   log.error(
       getName()
           + " at "
           + when.toString()
           + " ran off end of plan length "
           + size
           + " starting "
           + start.toString());
   return null;
 }