/** * Check a received value for basic problems before passing it on to the sample mechanism * * @param value Value as received from network layer * @return Value to be used for archive */ private VType checkReceivedValue(VType value) { if (value instanceof Time) { try { final Time time = (Time) value; // Invoke time.getTimestamp() to detect RuntimeError in VType 2013/11/01 if (time.isTimeValid() && time.getTimestamp() != null) return value; else { trouble_sample_log.log("'" + getName() + "': Invalid time stamp "); value = VTypeHelper.transformTimestamp(value, Timestamp.now()); } } catch (RuntimeException ex) { Logger.getLogger(getClass().getName()) .log(Level.WARNING, "'" + getName() + "': Exception getting time stamp", ex); value = VTypeHelper.transformTimestamp(value, Timestamp.now()); } } else trouble_sample_log.log("'" + getName() + "': Received no time information for " + value); return value; }
/** * Add given info value to buffer, tweaking its time stamp if necessary * * @param value Value to archive * @return Value that was actually added, which may have adjusted time stamp */ protected final VType addInfoToBuffer(VType value) { synchronized (this) { if (last_archived_value != null) { final Timestamp last = VTypeHelper.getTimestamp(last_archived_value); if (last.compareTo(VTypeHelper.getTimestamp(value)) >= 0) { // Patch the time stamp final Timestamp next = last.plus(TimeDuration.ofMillis(100)); value = VTypeHelper.transformTimestamp(value, next); } // else: value is OK as is } } addValueToBuffer(value); return value; }