Class VTypeHelper

java.lang.Object
org.yamcs.studio.data.VTypeHelper

public class VTypeHelper extends Object
A center place for VType related operations.
  • Field Details

  • Constructor Details

    • VTypeHelper

      public VTypeHelper()
  • Method Details

    • formatValue

      public static String formatValue(FormatEnum formatEnum, VType vValue, int precision)
      Format a VType value to string.
      Parameters:
      formatEnum - the format
      vValue - 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

      public static String getAlarmName(VType obj)
      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

      public static String getLoHiSuffix(VType obj)
    • getAlarmSeverity

      public static AlarmSeverity getAlarmSeverity(VType obj)
      Extract the AlarmSeverity 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

      public static BasicDataType getBasicDataType(VType obj)
      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

      public static Display getDisplayInfo(VType obj)
      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

      public static double getDouble(VType obj)
      Get double value from a VType 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

      public static double getDouble(VType obj, int index)
      Get double value from a VType 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

      public static double[] getDoubleArray(VType obj)
      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

      public static Number getNumber(VType obj)
      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

      public static Number getNumber(VType obj, int index)
      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

      public static int getSize(VType obj)
      Get size of a VType object value.
      Parameters:
      obj -
      Returns:
      1 for scalar. Otherwise return size of the array.
    • getString

      public static String getString(VType obj)
      Get String from a VType value.
      Parameters:
      obj - the value
      Returns:
      the String from the VType value.
    • getTimestamp

      public static Instant getTimestamp(VType obj)
      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

      public static Object getWrappedArray(VType obj)
      Get wrapped array in the VNumberArray object. The wrapped array could be double[], float[], int[], long[], short[], byte[] etc.
      Parameters:
      obj - the VType object.
      Returns:
      the wrapped array or null if no array is wrapped in the object.
    • isPrimaryNumberArray

      public static boolean isPrimaryNumberArray(Object array)
      Is an object primary array
      Parameters:
      array - the object
      Returns:
      true if it is a primary type array, such as byte[], int[], double[] etc.