Package wpn.hdri.ss.data

Examples of wpn.hdri.ss.data.Timestamp


    public void testGetValue_LastNearest() throws Exception {
        Attribute<Long> attr = new NumericAttribute<Long>(deviceName, name, Interpolation.LAST);

        attr.addValue(timestamp, Value.<Long>getInstance(10000L), timestamp);

        attr.addValue(timestamp.add(new Timestamp(10)), Value.<Long>getInstance(10001L), timestamp);

        long result = attr.getAttributeValue(timestamp.add(new Timestamp(15))).getValue().get();

        assertEquals(10001L, result);
    }
View Full Code Here


    public void testGetValue_Linear() throws Exception {
        Attribute<Double> attr = new NumericAttribute<Double>(deviceName, name, Interpolation.LINEAR);

        attr.addValue(timestamp, Value.<Double>getInstance(12.), timestamp);

        attr.addValue(timestamp.add(new Timestamp(10)), Value.<Double>getInstance(24.), timestamp.add(new Timestamp(10)));

        double result = attr.getAttributeValue(timestamp.add(new Timestamp(5))).getValue().get();

        assertEquals(18., result);
    }
View Full Code Here

    @Test
    public void testGetValue_Linear_missedRightValue() {
        Attribute<Long> attribute = new NumericAttribute<Long>(deviceName, name, Interpolation.LINEAR);

        attribute.addValue(timestamp, Value.getInstance(1000L), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance(1000L), timestamp);

        long result = attribute.getAttributeValue(timestamp.add(new Timestamp(20))).getValue().get();

        assertEquals(1000L, result);
    }
View Full Code Here

    public void testPrecision_SameValue() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, "double", Interpolation.LINEAR, BigDecimal.ONE);

        Value<Double> value = Value.getInstance(20.3);
        attribute.addValue(timestamp, value, timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance(20.1), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(20)), Value.getInstance(20.5), timestamp);

        assertSame(value, attribute.getAttributeValue().getValue());
        double result = attribute.getAttributeValue().getValue().get();

        assertEquals(20.3, result);
View Full Code Here

    @Test
    public void testPrecision_SameValue_morePrecision() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, "double", Interpolation.LINEAR, new BigDecimal("0.001"));

        attribute.addValue(timestamp, Value.getInstance(0.2441406), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance(0.2453613), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(15)), Value.getInstance(0.2454613), timestamp);

        double result = attribute.getAttributeValue().getValue().get();

        assertEquals(0.2453613, result);
        int attributeSize = Iterables.toArray(attribute.getAttributeValues(), AttributeValue.class).length;
View Full Code Here

    @Test
    public void testSameValue_Numeric() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, "double", Interpolation.LINEAR, BigDecimal.ONE);

        attribute.addValue(timestamp, Value.getInstance(20.3), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance(20.3), timestamp);

        double result = attribute.getAttributeValue().getValue().get();

        assertEquals(20.3, result);
        int attributeSize = Iterables.toArray(attribute.getAttributeValues(), AttributeValue.class).length;
View Full Code Here

    @Test
    public void testPrecision_SameValueDifferentTime() {
        Attribute<String> attribute = new NonNumericAttribute<String>(deviceName, name, "string", Interpolation.LAST);

        attribute.addValue(timestamp, Value.getInstance("Rabbit"), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance("Rabbit"), timestamp);

        String result = attribute.getAttributeValue().getValue().get();

        assertEquals("Rabbit", result);
        assertEquals(timestamp, attribute.getAttributeValue().getWriteTimestamp());
View Full Code Here

    @Test
    public void testPrecision_DifferentValue() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, "double", Interpolation.LINEAR, BigDecimal.ONE);

        attribute.addValue(timestamp, Value.getInstance(20.3), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.getInstance(20.7), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(20)), Value.getInstance(21.4), timestamp);

        double result = attribute.getAttributeValue().getValue().get();

        assertEquals(21.4, result);
    }
View Full Code Here

    @Test
    public void testAddNull_Numeric_first() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, Interpolation.LAST);

        attribute.addValue(timestamp.add(new Timestamp(10)), Value.NULL, timestamp);

        Double result = attribute.getAttributeValue().getValue().get();
//        assertNull(result);
        assertNull(result);
    }
View Full Code Here

    @Test
    public void testAddNull_Numeric() {
        Attribute<Double> attribute = new NumericAttribute<Double>(deviceName, name, Interpolation.LAST);

        attribute.addValue(timestamp, Value.getInstance(12.), timestamp);
        attribute.addValue(timestamp.add(new Timestamp(10)), Value.NULL, timestamp);

        Double result = attribute.getAttributeValue().getValue().get();
        assertNull(result);
//        assertEquals(12., result);
    }
View Full Code Here

TOP

Related Classes of wpn.hdri.ss.data.Timestamp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.