Search in sources :

Example 66 with VType

use of org.diirt.vtype.VType in project org.csstudio.display.builder by kasemir.

the class CSVSampleImporterUnitTest method testCSVImport.

@Test
public void testCSVImport() throws Exception {
    final InputStream input = getClass().getResourceAsStream("Lakeshore_A_9_2011.xml");
    final SampleImporter importer = new CSVSampleImporter();
    final List<VType> values = importer.importValues(input);
    assertTrue(values.size() > 0);
    for (VType value : values) System.out.println(VTypeHelper.toString(value));
    final String text = VTypeHelper.toString(values.get(values.size() - 1));
    assertThat(text, containsString("2011-09-13"));
    assertThat(text, containsString("08:57:44.968"));
    assertThat(text, containsString("84.912"));
}
Also used : VType(org.diirt.vtype.VType) InputStream(java.io.InputStream) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 67 with VType

use of org.diirt.vtype.VType in project org.csstudio.display.builder by kasemir.

the class PVSamplesUnitTest method testUndefinedLiveData.

/**
 * When 'monitoring' a PV, IOCs will send data with zero time stamps
 *  for records that have never been processed.
 *  Check that time stamps are patched to host time.
 */
@Test
public void testUndefinedLiveData() {
    final AtomicInteger waveform_index = new AtomicInteger(0);
    // Start w/ empty samples
    final PVSamples samples = new PVSamples(waveform_index);
    assertEquals(0, samples.size());
    // Add sample w/ null time stamp, INVALID/UDF
    final Instant null_time = Instant.ofEpochMilli(0);
    VType value = new ArchiveVNumber(null_time, AlarmSeverity.NONE, "", null, 0.0);
    assertThat(ValueUtil.timeOf(value).isTimeValid(), equalTo(false));
    samples.addLiveSample(value);
    System.out.println("Original: " + value);
    // Should have that sample, plus copy that's extrapolated to 'now'
    assertEquals(2, samples.size());
    value = samples.get(0).getVType();
    System.out.println("Sampled : " + value);
    assertThat(ValueUtil.timeOf(value).isTimeValid(), equalTo(true));
}
Also used : VType(org.diirt.vtype.VType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArchiveVNumber(org.csstudio.archive.vtype.ArchiveVNumber) Instant(java.time.Instant) Test(org.junit.Test)

Example 68 with VType

use of org.diirt.vtype.VType in project org.csstudio.display.builder by kasemir.

the class BaseLEDRepresentation method contentChanged.

private void contentChanged(final WidgetProperty<VType> property, final VType old_value, final VType new_value) {
    final VType value = model_widget.runtimePropValue().getValue();
    if (value == null) {
        value_color = alarm_colors[AlarmSeverity.UNDEFINED.ordinal()];
        value_label = "";
    } else {
        int value_index = computeColorIndex(new_value);
        final Color[] save_colors = colors;
        if (value_index < 0)
            value_index = 0;
        if (value_index >= save_colors.length)
            value_index = save_colors.length - 1;
        value_color = save_colors[value_index];
        value_label = computeLabel(value_index);
    }
    dirty_content.mark();
    toolkit.scheduleUpdate(this);
}
Also used : VType(org.diirt.vtype.VType) Color(javafx.scene.paint.Color)

Example 69 with VType

use of org.diirt.vtype.VType in project org.csstudio.display.builder by kasemir.

the class ComboRepresentation method contentChanged.

private void contentChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    VType value = model_widget.runtimePropValue().getValue();
    boolean fromPV = model_widget.propItemsFromPV().getValue() && value instanceof VEnum;
    // also sets index
    items = computeItems(value, fromPV);
    dirty_content.mark();
    toolkit.scheduleUpdate(this);
}
Also used : VType(org.diirt.vtype.VType) VEnum(org.diirt.vtype.VEnum)

Aggregations

VType (org.diirt.vtype.VType)69 Test (org.junit.Test)17 IPV (org.csstudio.simplepv.IPV)8 ArrayList (java.util.ArrayList)7 Display (org.diirt.vtype.Display)7 VEnum (org.diirt.vtype.VEnum)7 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)6 ListNumber (org.diirt.util.array.ListNumber)6 IFigure (org.eclipse.draw2d.IFigure)6 Instant (java.time.Instant)5 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)5 VNumberArray (org.diirt.vtype.VNumberArray)5 VString (org.diirt.vtype.VString)5 List (java.util.List)4 RuntimePV (org.csstudio.display.builder.runtime.pv.RuntimePV)4 RuntimePVListener (org.csstudio.display.builder.runtime.pv.RuntimePVListener)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ValueIterator (org.csstudio.archive.reader.ValueIterator)3 ArchiveVNumber (org.csstudio.archive.vtype.ArchiveVNumber)3 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)3