示例#1
0
  /** {@inheritDoc} */
  @SuppressWarnings("nls")
  @Override
  public void pvChanged(final PVReaderEvent<List<VType>> event) {
    final PVReader<List<VType>> pv = event.getPvReader();
    // Check for error
    final Exception error = pv.lastException();
    if (error != null)
      Activator.getLogger().log(Level.FINE, "PV " + pv.getName() + " error", error);

    final List<VType> values = pv.getValue();
    if (values == null) { // No current value
      current_value = null;
      // In 'monitor' mode, mark in live sample buffer
      if (period <= 0) logDisconnected();
      return;
    } else {
      boolean added = false;
      for (VType value : values) {
        // Cache most recent for 'scanned' operation
        current_value = value;
        // In 'monitor' mode, add to live sample buffer
        if (period <= 0) {
          Activator.getLogger()
              .log(Level.FINE, "PV {0} received {1}", new Object[] {getName(), value});
          samples.addLiveSample(value);
          added = true;
        }
      }
      if (automaticRefresh
          && added
          && samples.isHistoryRefreshNeeded(model.getStartTime(), model.getEndTime())) {
        model.fireItemRefreshRequested(this);
      }
    }
  }
示例#2
0
 /**
  * Add data retrieved from an archive to the 'historic' section
  *
  * @param server_name Archive server that provided these samples
  * @param new_samples Historic data
  */
 public synchronized void mergeArchivedSamples(
     final String server_name, final List<VType> new_samples) {
   samples.mergeArchivedData(server_name, new_samples);
   if (automaticRefresh
       && samples.isHistoryRefreshNeeded(model.getStartTime(), model.getEndTime())) {
     model.fireItemRefreshRequested(this);
   }
 }
示例#3
0
 /** Add one(!) 'disconnected' sample */
 private void logDisconnected() {
   synchronized (samples) {
     final int size = samples.getSize();
     if (size > 0) {
       final String last = VTypeHelper.getMessage(samples.getSample(size - 1).getValue());
       // Does last sample already have 'disconnected' status?
       if (Messages.Model_Disconnected.equals(last)) return;
     }
     samples.addLiveSample(new PlotSample(Messages.LiveData, Messages.Model_Disconnected));
   }
 }
示例#4
0
  /** @param index New waveform index */
  @Override
  public void setWaveformIndex(int index) {
    if (index < 0) index = 0;
    if (index == waveform_index) return;
    waveform_index = index;

    // change all the index of samples in this instance
    samples.setWaveformIndex(waveform_index);

    //        fireItemLookChanged();
  }
示例#5
0
 /** Set new item name, which changes the underlying PV name {@inheritDoc} */
 @Override
 public boolean setName(final String new_name) throws Exception {
   if (!super.setName(new_name)) return false;
   // Stop PV, clear samples
   final boolean running = (pv != null);
   if (running) stop();
   samples.clear();
   // Create new PV, maybe start it
   if (running) start(scan_timer);
   return true;
 }
示例#6
0
 /** @param value Value to log with 'now' as time stamp */
 private void logValueAsNow(final VType value) {
   if (value == null) logDisconnected();
   else
     // Transform value to have 'now' as time stamp
     samples.addLiveSample(VTypeHelper.transformTimestampToNow(value));
 }
示例#7
0
 /**
  * Set new capacity for live sample ring buffer
  *
  * <p>
  *
  * @param new_capacity New sample count capacity
  * @throws Exception on out-of-memory error
  */
 public void setLiveCapacity(final int new_capacity) throws Exception {
   samples.setLiveCapacity(new_capacity);
   //        fireItemLookChanged();
 }
示例#8
0
 /** @return Maximum number of live samples in ring buffer */
 public int getLiveCapacity() {
   return samples.getLiveCapacity();
 }