예제 #1
0
 @Override
 public AbstractProcess getDataSourceDescriptionAtTime(double time) {
   Iterator<AbstractProcess> it =
       descriptionTimeIndex.iterator(KEY_SML_START_ALL_TIME, new Key(time), Index.DESCENT_ORDER);
   if (it.hasNext()) return it.next();
   return null;
 }
예제 #2
0
 @Override
 public AbstractProcess getLatestDataSourceDescription() {
   Iterator<AbstractProcess> it =
       descriptionTimeIndex.iterator(
           KEY_SML_START_ALL_TIME, KEY_SML_END_ALL_TIME, Index.DESCENT_ORDER);
   if (it.hasNext()) return it.next();
   return null;
 }
예제 #3
0
 @Override
 public void removeDataSourceDescription(double time) {
   Iterator<AbstractProcess> it =
       descriptionTimeIndex.iterator(KEY_SML_START_ALL_TIME, new Key(time), Index.DESCENT_ORDER);
   if (it.hasNext()) {
     AbstractProcess sml = it.next();
     it.remove();
     getStorage().deallocate(sml);
   }
 }
예제 #4
0
  @Override
  public void storeDataSourceDescription(AbstractProcess process) {
    if (process.getNumValidTimes() > 0) {
      // we add the description in index for each validity period/instant
      for (AbstractTimeGeometricPrimitive validTime : process.getValidTimeList()) {
        double time = Double.NaN;

        if (validTime instanceof TimeInstant)
          time = ((TimeInstant) validTime).getTimePosition().getDecimalValue();
        else if (validTime instanceof TimePeriod)
          time = ((TimePeriod) validTime).getBeginPosition().getDecimalValue();

        if (!Double.isNaN(time)) {
          AbstractProcess oldProcess = descriptionTimeIndex.set(new Key(time), process);
          if (oldProcess != null) getStorage().deallocate(oldProcess);
        }
      }
    } else {
      // if no validity period is specified, we just add with current time
      double time = System.currentTimeMillis() / 1000.;
      descriptionTimeIndex.put(new Key(time), process);
    }
  }
예제 #5
0
  @Override
  public void removeDataSourceDescriptionHistory(double startTime, double endTime) {
    Storage db = getStorage();

    Iterator<AbstractProcess> it =
        descriptionTimeIndex.iterator(new Key(startTime), new Key(endTime), Index.ASCENT_ORDER);
    while (it.hasNext()) {
      AbstractProcess sml = it.next();

      // get end of validity of process description
      double endValidity = Double.NaN;
      AbstractTimeGeometricPrimitive validTime = sml.getValidTimeList().get(0);
      if (validTime instanceof TimePeriod)
        endValidity = ((TimePeriod) validTime).getEndPosition().getDecimalValue();

      // check that end of validity is also within time range
      // if end of validity is now, endValidity will be NaN
      // if this is the last description returned, don't remove it if end of validity is now
      if (endValidity <= endTime || (Double.isNaN(endValidity) && it.hasNext())) {
        it.remove();
        db.deallocate(sml);
      }
    }
  }
예제 #6
0
 @Override
 public List<AbstractProcess> getDataSourceDescriptionHistory(double startTime, double endTime) {
   List<AbstractProcess> processList =
       descriptionTimeIndex.getList(new Key(startTime), new Key(endTime));
   return Collections.unmodifiableList(processList);
 }