Package org.yamcs.studio.data.vtype
Class ValueFactory
java.lang.Object
org.yamcs.studio.data.vtype.ValueFactory
Factory class for all concrete implementation of the types.
The factory methods do not do anything in terms of defensive copy and immutability to the objects, which they are passed as they are. It's the client responsibility to prepare them appropriately, which is automatically done anyway for all objects except collections.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Alarm
No alarm.static Display
Returns a display from 0 to 1, suitable for booleans.static Display
Empty display information.static VNumberArray
ndArray
(VNumberArray data, ArrayDimensionDisplay... dimensions) Constructs and nd array with the data, time and alarm in the first array and the given dimension information.static Alarm
Alarm based on the value and the display ranges.static Alarm
newAlarm
(AlarmSeverity alarmSeverity, String alarmName) New alarm with the given severity and status.static ArrayDimensionDisplay
newDisplay
(int nCells) Returns an array display where the index is used to calculate the cell boundaries.static ArrayDimensionDisplay
newDisplay
(int size, ListNumberProvider boundaryProvider) static ArrayDimensionDisplay
newDisplay
(int size, ListNumberProvider boundaryProvider, boolean invert) static Display
newDisplay
(Double lowerDisplayLimit, Double lowerAlarmLimit, double lowerWarningLimit, String units, NumberFormat numberFormat, Double upperWarningLimit, double upperAlarmLimit, Double upperDisplayLimit, double lowerCtrlLimit, Double upperCtrlLimit) Creates a new displaystatic ArrayDimensionDisplay
newDisplay
(ListNumber boundaries, boolean reversed, String unit) static ArrayDimensionDisplay
newDisplay
(ListNumber boundaries, String unit) static Time
New time, with no user tag and valid data.static Time
Creates a new time.static VBoolean
newVBoolean
(boolean value, Alarm alarm, Time time) Creates a new VBoolean.static VBooleanArray
newVBooleanArray
(ListBoolean data, Alarm alarm, Time time) Creates a new VBooleanArray.static VByte
Creates a new VByte.static VByteArray
newVByteArray
(ListByte values, Alarm alarm, Time time, Display display) Creates a new VByteArray.static VDouble
newVDouble
(Double value) Creates a new VDouble, no alarm, time now, no display.static VDouble
newVDouble
(Double value, Alarm alarm, Time time, Display display) Creates a new VDouble.static VDouble
newVDouble
(Double value, Display display) Creates new immutable VDouble by using metadata from the old value, now as timestamp and computing alarm from the metadata range.static VDouble
newVDouble
(Double value, Time time) Creates a new VDouble, no alarm, no display.static VDouble
newVDouble
(Double value, Time time, Display display) Creates a new VDouble using the given value, time, display and generating the alarm from the value and display information.static VDoubleArray
newVDoubleArray
(ListDouble data, Alarm alarm, Time time, Display display) Creates a new VDoubleArray.static VEnum
Create a new VEnum.static VEnumArray
Create a new VEnumArray.static VFloat
Creates a new VFloat.static VFloatArray
newVFloatArray
(ListFloat data, Alarm alarm, Time time, Display display) Creates a new VFloatArray.static VImage
newVImage
(int height, int width, byte[] data) Creates a new VImage given the data and the size.static VImage
Creates a new VImage given the data and the size.static VImage
newVImage
(int height, int width, ListNumber data, VImageDataType imageDataType, Alarm alarm, Time time) Creates a new VImage of type TYPE_3BYTE_BGR given the data and the size.static VInt
Creates a new VInt.static VIntArray
newVIntArray
(ListInt values, Alarm alarm, Time time, Display display) Creates a new VIntArray.static VLong
Creates a new VLong.static VLongArray
newVLongArray
(ListLong values, Alarm alarm, Time time, Display display) Creates a new VLongArray.static VMultiDouble
Creates a new VMultiDouble.static VNumber
newVNumber
(Number value, Alarm alarm, Time time, Display display) Creates a new VNumber based on the type of the datastatic VNumberArray
newVNumberArray
(ListNumber data, Alarm alarm, Time time, Display display) Creates a new VNumberArray based on the type of the data.static VNumberArray
newVNumberArray
(ListNumber data, ListInt sizes, List<ArrayDimensionDisplay> dimensionDisplay, Alarm alarm, Time time, Display display) Creates a new VNumberArray based on the type of the data.static VShort
Creates a new VShort.static VShortArray
newVShortArray
(ListShort values, Alarm alarm, Time time, Display display) Creates a new VShortArray.static VStatistics
newVStatistics
(double average, double stdDev, double min, double max, int nSamples, Alarm alarm, Time time, Display display) Creates a new VStatistics.static VString
newVString
(String value, Alarm alarm, Time time) Creates a new VString.static VStringArray
newVStringArray
(List<String> data, Alarm alarm, Time time) Creates a new VStringArray.static VTable
Creates a new VTable - this method is provisional and will change in the future.static Time
timeNow()
New time with the current timestamp, no user tag and valid data.static VType
Converts a standard java type to VTypes.static VType
Converts a standard java type to VTypes.static VType
toVTypeChecked
(Object javaObject) AstoVType(java.lang.Object)
but throws an exception if conversion not possible.static VType
toVTypeChecked
(Object javaObject, Alarm alarm, Time time, Display display) AstoVType(java.lang.Object, org.yamcs.studio.data.vtype.Alarm, org.yamcs.studio.data.vtype.Time, org.yamcs.studio.data.vtype.Display)
but throws an exception if conversion not possible.static VType
Deprecated.static VType
-
Constructor Details
-
ValueFactory
public ValueFactory()
-
-
Method Details
-
newVString
Creates a new VString. -
newVBoolean
Creates a new VBoolean. -
newVMultiDouble
public static VMultiDouble newVMultiDouble(List<VDouble> values, Alarm alarm, Time time, Display display) Creates a new VMultiDouble. -
newVLong
Creates a new VLong. -
newVInt
Creates a new VInt. -
newVShort
Creates a new VShort. -
newVByte
Creates a new VByte. -
newAlarm
New alarm with the given severity and status. -
alarmNone
No alarm.- Returns:
- severity and status NONE
-
newAlarm
Alarm based on the value and the display ranges. -
newTime
Creates a new time. -
newTime
New time, with no user tag and valid data. -
timeNow
New time with the current timestamp, no user tag and valid data.- Returns:
- the new time
-
newDisplay
public static Display newDisplay(Double lowerDisplayLimit, Double lowerAlarmLimit, double lowerWarningLimit, String units, NumberFormat numberFormat, Double upperWarningLimit, double upperAlarmLimit, Double upperDisplayLimit, double lowerCtrlLimit, Double upperCtrlLimit) Creates a new display -
newDisplay
-
newDisplay
public static ArrayDimensionDisplay newDisplay(ListNumber boundaries, boolean reversed, String unit) -
newDisplay
public static ArrayDimensionDisplay newDisplay(int size, ListNumberProvider boundaryProvider, boolean invert) -
newDisplay
-
newDisplay
Returns an array display where the index is used to calculate the cell boundaries.- Parameters:
nCells
- the number of cells along the direction- Returns:
- a new array display
-
displayNone
Empty display information.- Returns:
- no display
-
displayBoolean
Returns a display from 0 to 1, suitable for booleans.- Returns:
- a display for boolean
-
newVNumber
Creates a new VNumber based on the type of the data -
newVDouble
Creates a new VDouble. -
newVDouble
Creates a new VDouble using the given value, time, display and generating the alarm from the value and display information. -
newVDouble
Creates new immutable VDouble by using metadata from the old value, now as timestamp and computing alarm from the metadata range. -
newVDouble
Creates a new VDouble, no alarm, time now, no display. -
newVDouble
Creates a new VDouble, no alarm, no display. -
newVFloat
Creates a new VFloat. -
newVEnum
Create a new VEnum.- Parameters:
index
- the index in the label arraylabels
- the labelsalarm
- the alarmtime
- the time- Returns:
- the new value
-
newVStatistics
public static VStatistics newVStatistics(double average, double stdDev, double min, double max, int nSamples, Alarm alarm, Time time, Display display) Creates a new VStatistics. -
newVNumberArray
public static VNumberArray newVNumberArray(ListNumber data, Alarm alarm, Time time, Display display) Creates a new VNumberArray based on the type of the data. -
newVNumberArray
public static VNumberArray newVNumberArray(ListNumber data, ListInt sizes, List<ArrayDimensionDisplay> dimensionDisplay, Alarm alarm, Time time, Display display) Creates a new VNumberArray based on the type of the data.- Parameters:
data
- the array datasizes
- the array shapedimensionDisplay
- the array axis display informationalarm
- the alarmtime
- the timedisplay
- the display- Returns:
- a new value
-
ndArray
Constructs and nd array with the data, time and alarm in the first array and the given dimension information.- Parameters:
data
- the array with the datadimensions
- the dimension information- Returns:
- a new array
-
newVDoubleArray
public static VDoubleArray newVDoubleArray(ListDouble data, Alarm alarm, Time time, Display display) Creates a new VDoubleArray. -
newVFloatArray
Creates a new VFloatArray. -
newVImage
Creates a new VImage given the data and the size. -
newVImage
Creates a new VImage given the data and the size. -
newVImage
public static VImage newVImage(int height, int width, ListNumber data, VImageDataType imageDataType, Alarm alarm, Time time) Creates a new VImage of type TYPE_3BYTE_BGR given the data and the size. -
newVLongArray
Creates a new VLongArray. -
newVIntArray
Creates a new VIntArray. -
newVShortArray
Creates a new VShortArray. -
newVByteArray
Creates a new VByteArray. -
newVEnumArray
public static VEnumArray newVEnumArray(ListInt indexes, List<String> labels, Alarm alarm, Time time) Create a new VEnumArray.- Parameters:
indexes
- the indexes in the label arraylabels
- the labelsalarm
- the alarmtime
- the time- Returns:
- the new value
-
newVBooleanArray
Creates a new VBooleanArray. -
newVStringArray
Creates a new VStringArray. -
newVTable
Creates a new VTable - this method is provisional and will change in the future.- Parameters:
types
- the types for each columnnames
- the names for each columnvalues
- the values for each column- Returns:
- the new value
-
wrapValue
Deprecated.Takes a java objects and wraps it into a vType. All numbers are wrapped as VDouble. String is wrapped as VString. double[] and ListDouble are wrapped as VDoubleArray. A List of String is wrapped to a VStringArray. Alarms are alarmNone(), time are timeNow() and display are displayNone();- Parameters:
value
- the value to wrap- Returns:
- the wrapped value
-
wrapValue
Deprecated.Takes a java objects and wraps it into a vType. All numbers are wrapped as VDouble. String is wrapped as VString. double[] and ListDouble are wrapped as VDoubleArray. A List of String is wrapped to a VStringArray. Alarms are alarm, time are timeNow() and display are displayNone();- Parameters:
value
- the value to wrapalarm
- the alarm for the value- Returns:
- the wrapped value
-
toVType
Converts a standard java type to VTypes. Returns null if no conversion is possible. CallstoVType(java.lang.Object, org.yamcs.studio.data.vtype.Alarm, org.yamcs.studio.data.vtype.Time, org.yamcs.studio.data.vtype.Display)
with no alarm, time now and no display.- Parameters:
javaObject
- the value to wrap- Returns:
- the new VType value
-
toVType
Converts a standard java type to VTypes. Returns null if no conversion is possible.Types are converted as follow:
- Boolean -> VBoolean
- Number -> corresponding VNumber
- String -> VString
- number array -> corresponding VNumberArray
- ListNumber -> corresponding VNumberArray
- List -> if all elements are String, VStringArray
- Parameters:
javaObject
- the value to wrapalarm
- the alarmtime
- the timedisplay
- the display- Returns:
- the new VType value
-
toVTypeChecked
AstoVType(java.lang.Object)
but throws an exception if conversion not possible.- Parameters:
javaObject
- the value to wrap- Returns:
- the new VType value
-
toVTypeChecked
AstoVType(java.lang.Object, org.yamcs.studio.data.vtype.Alarm, org.yamcs.studio.data.vtype.Time, org.yamcs.studio.data.vtype.Display)
but throws an exception if conversion not possible.- Parameters:
javaObject
- the value to wrapalarm
- the alarmtime
- the timedisplay
- the display- Returns:
- the new VType value
-
toVType(java.lang.Object)