Package org.yamcs.studio.data
Class VTypeHelper
java.lang.Object
org.yamcs.studio.data.VTypeHelper
A center place for VType related operations.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatValue
(FormatEnum formatEnum, VType vValue, int precision) Format a VType value to string.static String
getAlarmName
(VType obj) Extract the alarm name from the VType obj.static AlarmSeverity
getAlarmSeverity
(VType obj) Extract theAlarmSeverity
from the VType obj.static BasicDataType
getBasicDataType
(VType obj) Get the basic data type of a single VType value.static Display
getDisplayInfo
(VType obj) Extract the display information from the VType obj.static double
Get double value from aVType
object.static double
Get double value from aVType
object at index.static double[]
getDoubleArray
(VType obj) Get double array from a VType object.static String
getLoHiSuffix
(VType obj) static Number
Get the original number value of the VType object without casting.static Number
Get the original number value of the VType object at a index without casting.static int
Get size of a VType object value.static String
Get String from a VType value.static Instant
getTimestamp
(VType obj) Extract the Timestamp from the VType obj.static Object
getWrappedArray
(VType obj) Get wrapped array in the VNumberArray object.static boolean
isPrimaryNumberArray
(Object array) Is an object primary array
-
Field Details
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION- See Also:
-
UNSET_PRECISION
public static final int UNSET_PRECISION- See Also:
-
HEX_PREFIX
- See Also:
-
MAX_FORMAT_VALUE_COUNT
public static final int MAX_FORMAT_VALUE_COUNTThe max count of values to be formatted into string. The value beyond this count will be omitted.- See Also:
-
ARRAY_ELEMENT_SEPARATOR
- See Also:
-
-
Constructor Details
-
VTypeHelper
public VTypeHelper()
-
-
Method Details
-
formatValue
Format a VType value to string.- Parameters:
formatEnum
- the formatvValue
- PVManager value, such as VDouble, VEnum, V....precision
- decimal precision. If it is -1, it will use the precision from PV.- Returns:
- the formated string
-
getAlarmName
Extract the alarm name from the VType obj.- Parameters:
obj
- the VType object.- Returns:
- the alarm name or empty if there is no alarm info from the object.
-
getLoHiSuffix
-
getAlarmSeverity
Extract theAlarmSeverity
from the VType obj.- Parameters:
obj
- the VType object.- Returns:
- the alarm severity or null if there is no alarm info from the object.
-
getBasicDataType
Get the basic data type of a single VType value. If it is not a basic data type, it will return BasicDataType.UNKNOWN.- Parameters:
obj
- The PV Manager VType value.- Returns:
- the data type.
-
getDisplayInfo
Extract the display information from the VType obj.- Parameters:
obj
- the VType object.- Returns:
- the display information or null if there is no display info from the object.
-
getDouble
Get double value from aVType
object. It might be casted from other numeric type.- Parameters:
obj
- the VType object.- Returns:
- double or NaN if no double value is available in the object.
-
getDouble
Get double value from aVType
object at index. It might be casted from other numeric type.- Parameters:
obj
- the VType object.index
- index of the double value- Returns:
- double or NaN if no double value is available in the object at the index.
-
getDoubleArray
Get double array from a VType object.- Parameters:
obj
- an object implementing a standard type- Returns:
- the double array from the VType object or empty double array if no double array can be extracted from the input.
-
getNumber
Get the original number value of the VType object without casting. If it is an array, return the first element.- Parameters:
obj
- the VType object value.- Returns:
- the number or null if it is not a Number.
-
getNumber
Get the original number value of the VType object at a index without casting.- Parameters:
obj
- the VType object value.- Returns:
- the number or null if it is not a Number.
-
getSize
Get size of a VType object value.- Parameters:
obj
-- Returns:
- 1 for scalar. Otherwise return size of the array.
-
getString
Get String from a VType value.- Parameters:
obj
- the value- Returns:
- the String from the VType value.
-
getTimestamp
Extract the Timestamp from the VType obj.- Parameters:
obj
- the VType object.- Returns:
- the time or null if there is no time info in the object.
-
getWrappedArray
Get wrapped array in the VNumberArray object. The wrapped array could be double[], float[], int[], long[], short[], byte[] etc.- Parameters:
obj
- theVType
object.- Returns:
- the wrapped array or null if no array is wrapped in the object.
-
isPrimaryNumberArray
Is an object primary array- Parameters:
array
- the object- Returns:
- true if it is a primary type array, such as byte[], int[], double[] etc.
-