Package wpn.hdri.ss.data

Examples of wpn.hdri.ss.data.Timestamp


    }

    @Override
    @Command
    public String[] getSnapshot(long value) throws Exception {
        Timestamp timestamp = new Timestamp(value);
        RequestContext ctx = getContext();
        Multimap<AttributeName, AttributeValue<?>> values = engine.getValues(timestamp, ctx.attributesGroup);

        AttributeValuesView view = new AttributeValuesView(values, isUseAliases());
View Full Code Here


            if (++tries < MAX_TRIES) {
                logger.warn("An attempt to read attribute " + attribute.getFullName() + " has failed. Tries left: " + (MAX_TRIES - tries), e);
            } else {
                logger.warn("All attempts to read attribute " + attribute.getFullName() + " failed. Writing null.", e);

                Timestamp now = Timestamp.now();
                attribute.addValue(now, Value.NULL, now);
                tries = 0;
            }
        }
    }
View Full Code Here

     *
     * @param eventData new value
     */
    public final void onEvent(EventData<Object> eventData) {
        if (append)
            attribute.addValue(Timestamp.now(), Value.getInstance(eventData.getData()), new Timestamp(eventData.getTimestamp()));
        else
            attribute.replaceValue(Timestamp.now(), Value.getInstance(eventData.getData()), new Timestamp(eventData.getTimestamp()));
    }
View Full Code Here

     * For tests only
     *
     * @return
     */
    Iterable<AttributeValue<T>> getAttributeValues() {
        return getAttributeValues(new Timestamp(0L));
    }
View Full Code Here

        long timestamp = System.currentTimeMillis();
        final NumericAttribute<Double> doubleAttribute = new NumericAttribute<Double>("fake", "double", Interpolation.LAST, 0.);
        for (int i = 0; i < _1M; ++i) {
            long currentTimestamp = timestamp + i * 1000;
            Timestamp writeTimestamp = new Timestamp(currentTimestamp);
            doubleAttribute.addValue(writeTimestamp, Value.getInstance(Math.random()), writeTimestamp);
        }


        AttributesManager attributesManager = new AttributesManager(new AttributeFactory() {
View Full Code Here

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

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

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

        AttributeValue<Double>[] result = Iterables.toArray(attr.getAttributeValues(timestamp.subtract(new Timestamp(10))), AttributeValue.class);

        assertEquals(0.1D, result[0].getValue().get(), 0.07D);
        assertEquals(0.2D, result[1].getValue().get(), 0.07D);
    }
View Full Code Here

    public void testGetValue() 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(5))).getValue().get();

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

    public void testGetValue_Last() 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().getValue().get();

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

    public void testGetValues() 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);

        AttributeValue[] result = Iterables.toArray(attr.getAttributeValues(), AttributeValue.class);
        int attributeSize = result.length;

        assertEquals(10000L, result[0].getValue().get());
View Full Code Here

    public void testGetValues_Bounded() 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);

        AttributeValue[] result = Iterables.toArray(attr.getAttributeValues(timestamp.add(new Timestamp(5))), AttributeValue.class);
        int attributeSize = result.length;

        assertEquals(10001L, result[0].getValue().get());
        assertTrue(attributeSize == 1);
    }
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.