All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stepfunc.dnp3.Timestamp Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
// This library is provided under the terms of a non-commercial license.
// 
// Please refer to the source repository for details:
// 
// https://github.com/stepfunc/dnp3/blob/master/LICENSE.txt
// 
// Please contact Step Function I/O if you are interested in commercial license:
// 
// [email protected]
package io.stepfunc.dnp3;

import org.joou.*;

/**
 * Timestamp associated with particular measurement from the outstation. The validity of the value depends on the quality.
 */
public final class Timestamp
{
    /**
     * Count of milliseconds since UNIX epoch
     * 
     * 

Warning: Only the lower 48-bits are used in DNP3 timestamps and time synchronization

*/ public ULong value; /** * Enumeration that indicates the timestamp's validity */ public TimeQuality quality; /** * @param value New value for the 'value' field * @return Reference to this instance of the class with the modified value */ public Timestamp withValue(ULong value) { this.value = value; return this; } /** * @param value New value for the 'quality' field * @return Reference to this instance of the class with the modified value */ public Timestamp withQuality(TimeQuality value) { this.quality = value; return this; } /** * Creates an invalid timestamp struct * *

Values are initialized to: *

    *
  • {@link Timestamp#value} : 0
  • *
  • {@link Timestamp#quality} : {@link TimeQuality#INVALID_TIME}
  • *
* * @return Initialized {@link Timestamp} instance */ public static Timestamp invalidTimestamp() { return new Timestamp(ULong.valueOf(0L), TimeQuality.INVALID_TIME); } /** * Creates a synchronized timestamp struct * *

Values are initialized to: *

    *
  • {@link Timestamp#quality} : {@link TimeQuality#SYNCHRONIZED_TIME}
  • *
* * @param value Count of milliseconds since UNIX epoch * @return Initialized {@link Timestamp} instance */ public static Timestamp synchronizedTimestamp(ULong value) { return new Timestamp(value, TimeQuality.SYNCHRONIZED_TIME); } /** * Creates an unsynchronized timestamp struct * *

Values are initialized to: *

    *
  • {@link Timestamp#quality} : {@link TimeQuality#UNSYNCHRONIZED_TIME}
  • *
* * @param value Count of milliseconds since UNIX epoch * @return Initialized {@link Timestamp} instance */ public static Timestamp unsynchronizedTimestamp(ULong value) { return new Timestamp(value, TimeQuality.UNSYNCHRONIZED_TIME); } private Timestamp(ULong value, TimeQuality quality) { this.value = value; this.quality = quality; } void _assertFieldsNotNull() { java.util.Objects.requireNonNull(value, "value cannot be null"); java.util.Objects.requireNonNull(quality, "quality cannot be null"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy