Package com.stuypulse.stuylib.network
Class SmartNumber
java.lang.Object
java.lang.Number
com.stuypulse.stuylib.network.SmartNumber
- All Implemented Interfaces:
IStream,Serializable,DoubleSupplier
SmartNumber works as a wrapper for values on
SmartDashboard. The idea for this class was
to make getting values on SmartDashboard easier by making them variables that you know
were initialized.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSmartNumber(String id, double value) Creates a SmartNumber with the element name and a default value. -
Method Summary
Modifier and TypeMethodDescriptiondoublefloatdoubleget()doubleintintValue()longvoidreset()Resets the value onSmartDashboardto the default valuevoidstatic NumberThis function checks to see ifoldNumberis aSmartNumber, if it is, then it sets theoldNumbertonewNumberand returns theoldNumber.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
SmartNumber
Creates a SmartNumber with the element name and a default value. The value onSmartDashboardwill be reset to the default value on initialization.- Parameters:
id- the name of the number on SmartDashboardvalue- the default / initialization value for the value
-
-
Method Details
-
get
public double get() -
getDefault
public double getDefault()- Returns:
- the default value of the number
-
set
- Parameters:
value- what the value onSmartDashboardwill be set to
-
reset
public void reset()Resets the value onSmartDashboardto the default value -
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber- Returns:
- the value of the number from
SmartDashboard(casted to a double)
-
floatValue
public float floatValue()- Specified by:
floatValuein classNumber- Returns:
- the value of the number from
SmartDashboard(casted to a float)
-
intValue
public int intValue() -
longValue
public long longValue() -
setNumber
This function checks to see ifoldNumberis aSmartNumber, if it is, then it sets theoldNumbertonewNumberand returns theoldNumber. Otherwise, it just returnsnewNumber.- Parameters:
oldNumber- number that is being replacednewNumber- number representing the value of the new number- Returns:
- if
oldNumberis not aSmartNumber, then this function will returnnewNumber. IfoldNumberis aSmartNumber, then this function will returnoldNumberwith its value set tonewNumber
-