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
ConstructorDescriptionSmartNumber
(String id, double value) Creates a SmartNumber with the element name and a default value. -
Method Summary
Modifier and TypeMethodDescriptiondouble
float
double
get()
double
int
intValue()
long
void
reset()
Resets the value onSmartDashboard
to the default valuevoid
static Number
This function checks to see ifoldNumber
is aSmartNumber
, if it is, then it sets theoldNumber
tonewNumber
and 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 onSmartDashboard
will 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 onSmartDashboard
will be set to
-
reset
public void reset()Resets the value onSmartDashboard
to the default value -
doubleValue
public double doubleValue()- Specified by:
doubleValue
in classNumber
- Returns:
- the value of the number from
SmartDashboard
(casted to a double)
-
floatValue
public float floatValue()- Specified by:
floatValue
in 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 ifoldNumber
is aSmartNumber
, if it is, then it sets theoldNumber
tonewNumber
and returns theoldNumber
. Otherwise, it just returnsnewNumber
.- Parameters:
oldNumber
- number that is being replacednewNumber
- number representing the value of the new number- Returns:
- if
oldNumber
is not aSmartNumber
, then this function will returnnewNumber
. IfoldNumber
is aSmartNumber
, then this function will returnoldNumber
with its value set tonewNumber
-