Search in sources :

Example 6 with PlotSamples

use of org.csstudio.trends.databrowser3.model.PlotSamples in project org.csstudio.display.builder by kasemir.

the class WaveformView method showSelectedSample.

/**
 * Show the current sample of the current model item.
 */
private void showSelectedSample() {
    // Get selected sample (= one waveform)
    final PlotSamples samples = model_item.getSamples();
    final int idx = sample_index.getSelection();
    final PlotSample sample;
    samples.getLock().lock();
    try {
        sample_index.setMaximum(samples.size());
        sample = samples.get(idx);
    } finally {
        samples.getLock().unlock();
    }
    // Setting the value can be delayed while the plot is being updated
    final VType value = sample.getVType();
    Activator.getThreadPool().execute(() -> waveform.setValue(value));
    if (value == null)
        clearInfo();
    else {
        updateAnnotation(sample.getPosition(), sample.getValue());
        int size = value instanceof VNumberArray ? ((VNumberArray) value).getData().size() : 1;
        plot.getXAxis().setValueRange(0.0, (double) size);
        timestamp.setText(TimestampHelper.format(VTypeHelper.getTimestamp(value)));
        status.setText(NLS.bind(Messages.SeverityStatusFmt, VTypeHelper.getSeverity(value).toString(), VTypeHelper.getMessage(value)));
    }
    plot.requestUpdate();
}
Also used : VNumberArray(org.diirt.vtype.VNumberArray) VType(org.diirt.vtype.VType) PlotSample(org.csstudio.trends.databrowser3.model.PlotSample) PlotSamples(org.csstudio.trends.databrowser3.model.PlotSamples)

Aggregations

PlotSamples (org.csstudio.trends.databrowser3.model.PlotSamples)5 PlotSample (org.csstudio.trends.databrowser3.model.PlotSample)3 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)2 VType (org.diirt.vtype.VType)2 PrintWriter (java.io.PrintWriter)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 TimeoutException (java.util.concurrent.TimeoutException)1 FXCanvas (javafx.embed.swt.FXCanvas)1 Scene (javafx.scene.Scene)1 ProcessVariable (org.csstudio.csdata.ProcessVariable)1 TimeDataSearch (org.csstudio.javafx.rtplot.data.TimeDataSearch)1 AnnotationInfo (org.csstudio.trends.databrowser3.model.AnnotationInfo)1 PVItem (org.csstudio.trends.databrowser3.model.PVItem)1 PlotSampleArray (org.csstudio.trends.databrowser3.model.PlotSampleArray)1 XMLPersistence (org.csstudio.trends.databrowser3.persistence.XMLPersistence)1 VNumberArray (org.diirt.vtype.VNumberArray)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1