Class Value

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.math.BigInteger UNSIGNED_LONG_MASK
      A bit mask to convert to unsigned 64-bit integers, which are not natively supported by Java.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Value()
      Constructs a new instance.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void absValue()
      Sets the instance's value to its absolute value, if possible.
      abstract Value[] asArray()
      Gets the value as array.
      Int64Value enumToOrdinalValue​(com.smartgridready.ns.v0.EnumMapProduct enumMapProduct)
      Gets the ordinal value of an enumeration.
      static Value fromDiscreteInput​(com.smartgridready.ns.v0.ModbusDataType modbusDataType, boolean[] bitregister)
      Gets a value from a Modbus discrete input.
      static Value fromModbusRegister​(com.smartgridready.ns.v0.ModbusDataType modbusDataType, int[] registers)
      Converts a list of Modbus registers to a given value.
      static Value fromString​(com.smartgridready.ns.v0.DataTypeProduct dataType, java.lang.String value)
      Converts a string to a different to a Value.
      abstract java.util.Map<java.lang.String,​java.lang.Boolean> getBitmap()
      Gets the value as SGr bitmap.
      abstract boolean getBoolean()
      Gets the value as boolean.
      abstract java.time.Instant getDateTime()
      Gets the value as time stamp.
      abstract EnumRecord getEnum()
      Gets the value as SGr enumeration record.
      abstract float getFloat32()
      Gets the value as 32-bit floating-point.
      abstract double getFloat64()
      Gets the value as 64-bit floating-point.
      abstract short getInt16()
      Gets the value as 16-bit integer.
      abstract int getInt16U()
      Gets the value as unsigned 16-bit integer.
      abstract int getInt32()
      Gets the value as 32-bit integer.
      abstract long getInt32U()
      Gets the value as unsigned 32-bit integer.
      abstract long getInt64()
      Gets the value as 64-bit integer.
      abstract java.math.BigInteger getInt64U()
      Gets the value as unsigned 64-bit integer.
      abstract byte getInt8()
      Gets the value as 8-bit integer.
      abstract short getInt8U()
      Gets the value as unsigned 8-bit integer.
      abstract com.fasterxml.jackson.databind.JsonNode getJson()
      Gets the value as JSON.
      <T> T getJson​(java.lang.Class<T> aClass)
      Gets the value as JSON and converts to an instance of a given class.
      abstract java.lang.String getString()
      Gets the value as string.
      abstract void roundToInt()
      Rounds the instance's value to the nearest integer, if possible.
      byte[] toModbusDiscreteVal​(com.smartgridready.ns.v0.ModbusDataType modbusDataType)
      Converts the value to a list of Modbus discrete inputs.
      int[] toModbusRegister​(com.smartgridready.ns.v0.ModbusDataType modbusDataType)
      Converts the value to a list of Modbus registers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UNSIGNED_LONG_MASK

        public static final java.math.BigInteger UNSIGNED_LONG_MASK
        A bit mask to convert to unsigned 64-bit integers, which are not natively supported by Java.
    • Constructor Detail

      • Value

        protected Value()
        Constructs a new instance.
    • Method Detail

      • getInt8

        public abstract byte getInt8()
        Gets the value as 8-bit integer.
        Returns:
        a byte
      • getInt8U

        public abstract short getInt8U()
        Gets the value as unsigned 8-bit integer.
        Returns:
        a short
      • getInt16

        public abstract short getInt16()
        Gets the value as 16-bit integer.
        Returns:
        a short
      • getInt16U

        public abstract int getInt16U()
        Gets the value as unsigned 16-bit integer.
        Returns:
        an int
      • getInt32

        public abstract int getInt32()
        Gets the value as 32-bit integer.
        Returns:
        an int
      • getInt32U

        public abstract long getInt32U()
        Gets the value as unsigned 32-bit integer.
        Returns:
        a long
      • getInt64

        public abstract long getInt64()
        Gets the value as 64-bit integer.
        Returns:
        a long
      • getInt64U

        public abstract java.math.BigInteger getInt64U()
        Gets the value as unsigned 64-bit integer.
        Returns:
        a BigInteger
      • getFloat32

        public abstract float getFloat32()
        Gets the value as 32-bit floating-point.
        Returns:
        a float
      • getFloat64

        public abstract double getFloat64()
        Gets the value as 64-bit floating-point.
        Returns:
        a double
      • getString

        public abstract java.lang.String getString()
        Gets the value as string.
        Returns:
        a string
      • getBoolean

        public abstract boolean getBoolean()
        Gets the value as boolean.
        Returns:
        a boolean
      • getEnum

        public abstract EnumRecord getEnum()
        Gets the value as SGr enumeration record.
        Returns:
        an EnumRecord
      • getBitmap

        public abstract java.util.Map<java.lang.String,​java.lang.Boolean> getBitmap()
        Gets the value as SGr bitmap.
        Returns:
        a map of strings to boolean values
      • getDateTime

        public abstract java.time.Instant getDateTime()
        Gets the value as time stamp.
        Returns:
        an Instant
      • getJson

        public abstract com.fasterxml.jackson.databind.JsonNode getJson()
        Gets the value as JSON.
        Returns:
        a JsonNode
      • absValue

        public abstract void absValue()
        Sets the instance's value to its absolute value, if possible.
      • roundToInt

        public abstract void roundToInt()
        Rounds the instance's value to the nearest integer, if possible.
      • asArray

        public abstract Value[] asArray()
        Gets the value as array.
        Returns:
        an array of Value
      • getJson

        public <T> T getJson​(java.lang.Class<T> aClass)
        Gets the value as JSON and converts to an instance of a given class.
        Type Parameters:
        T - the generic type
        Parameters:
        aClass - the class to convert to
        Returns:
        an instance of the given class
      • toModbusRegister

        public int[] toModbusRegister​(com.smartgridready.ns.v0.ModbusDataType modbusDataType)
        Converts the value to a list of Modbus registers.
        Parameters:
        modbusDataType - the Modbus data type to convert to
        Returns:
        an array of integer
      • toModbusDiscreteVal

        public byte[] toModbusDiscreteVal​(com.smartgridready.ns.v0.ModbusDataType modbusDataType)
        Converts the value to a list of Modbus discrete inputs.
        Parameters:
        modbusDataType - the Modbus data type to convert to
        Returns:
        an array of byte
      • fromModbusRegister

        public static Value fromModbusRegister​(com.smartgridready.ns.v0.ModbusDataType modbusDataType,
                                               int[] registers)
        Converts a list of Modbus registers to a given value.
        Parameters:
        modbusDataType - the Modbus data type to convert to
        registers - the Modbus registers
        Returns:
        an instance of Value
      • fromString

        public static Value fromString​(com.smartgridready.ns.v0.DataTypeProduct dataType,
                                       java.lang.String value)
        Converts a string to a different to a Value.
        Parameters:
        dataType - the data type to convert to
        value - the string value to convert
        Returns:
        an instance of Value
      • enumToOrdinalValue

        public Int64Value enumToOrdinalValue​(com.smartgridready.ns.v0.EnumMapProduct enumMapProduct)
        Gets the ordinal value of an enumeration.
        Parameters:
        enumMapProduct - the enumeration definition
        Returns:
        a 64-bit integer value
      • fromDiscreteInput

        public static Value fromDiscreteInput​(com.smartgridready.ns.v0.ModbusDataType modbusDataType,
                                              boolean[] bitregister)
        Gets a value from a Modbus discrete input.
        Parameters:
        modbusDataType - the Modbus data type
        bitregister - the discrete input valueü
        Returns:
        an instance of Value