Class Value
- java.lang.Object
-
- com.smartgridready.communicator.common.api.values.Value
-
- Direct Known Subclasses:
ArrayValue,BitmapValue,BooleanValue,DateTimeValue,EnumValue,Int64UValue,JsonValue,NumberValue,StringValue
public abstract class Value extends java.lang.ObjectThe base class for all SGr value types.
-
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigIntegerUNSIGNED_LONG_MASKA bit mask to convert to unsigned 64-bit integers, which are not natively supported by Java.
-
Constructor Summary
Constructors Modifier Constructor Description protectedValue()Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidabsValue()Sets the instance's value to its absolute value, if possible.abstract Value[]asArray()Gets the value as array.Int64ValueenumToOrdinalValue(com.smartgridready.ns.v0.EnumMapProduct enumMapProduct)Gets the ordinal value of an enumeration.static ValuefromDiscreteInput(com.smartgridready.ns.v0.ModbusDataType modbusDataType, boolean[] bitregister)Gets a value from a Modbus discrete input.static ValuefromModbusRegister(com.smartgridready.ns.v0.ModbusDataType modbusDataType, int[] registers)Converts a list of Modbus registers to a given value.static ValuefromString(com.smartgridready.ns.v0.DataTypeProduct dataType, java.lang.String value)Converts a string to a different to aValue.abstract java.util.Map<java.lang.String,java.lang.Boolean>getBitmap()Gets the value as SGr bitmap.abstract booleangetBoolean()Gets the value as boolean.abstract java.time.InstantgetDateTime()Gets the value as time stamp.abstract EnumRecordgetEnum()Gets the value as SGr enumeration record.abstract floatgetFloat32()Gets the value as 32-bit floating-point.abstract doublegetFloat64()Gets the value as 64-bit floating-point.abstract shortgetInt16()Gets the value as 16-bit integer.abstract intgetInt16U()Gets the value as unsigned 16-bit integer.abstract intgetInt32()Gets the value as 32-bit integer.abstract longgetInt32U()Gets the value as unsigned 32-bit integer.abstract longgetInt64()Gets the value as 64-bit integer.abstract java.math.BigIntegergetInt64U()Gets the value as unsigned 64-bit integer.abstract bytegetInt8()Gets the value as 8-bit integer.abstract shortgetInt8U()Gets the value as unsigned 8-bit integer.abstract com.fasterxml.jackson.databind.JsonNodegetJson()Gets the value as JSON.<T> TgetJson(java.lang.Class<T> aClass)Gets the value as JSON and converts to an instance of a given class.abstract java.lang.StringgetString()Gets the value as string.abstract voidroundToInt()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.
-
-
-
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.
-
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 toregisters- 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 aValue.- Parameters:
dataType- the data type to convert tovalue- 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
-
-