/** {@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); } } }
/** * 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); } }
/** 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)); } }
/** @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(); }
/** 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; }
/** @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)); }
/** * 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(); }
/** @return Maximum number of live samples in ring buffer */ public int getLiveCapacity() { return samples.getLiveCapacity(); }