Package trclib.robotcore
Class TrcPresets
java.lang.Object
trclib.robotcore.TrcPresets
This class implements a generic preset table for looking up preset values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private final double[]
private final double
final TrcDbgTrace
-
Constructor Summary
ConstructorsConstructorDescriptionTrcPresets
(String instanceName, double presetTolerance, double... presets) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getPresetValue
(int index) This method returns the preset value at the specified index.int
nextPresetIndexDown
(double currValue) This method determines the next preset index down from the specified current value.int
nextPresetIndexUp
(double currValue) This method determines the next preset index up from the specified current value.toString()
This method returns the instance name.boolean
validatePresetIndex
(int index) This method checks if the preset index is within the preset table.
-
Field Details
-
tracer
-
instanceName
-
presetTolerance
private final double presetTolerance -
presets
private final double[] presets
-
-
Constructor Details
-
TrcPresets
Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the task name.presetTolerance
- specifies the preset tolerance.presets
- specifies the preset value array.
-
-
Method Details
-
toString
This method returns the instance name. -
validatePresetIndex
public boolean validatePresetIndex(int index) This method checks if the preset index is within the preset table.- Parameters:
index
- specifies the preset table index to check.- Returns:
- true if the index is within the table.
-
getPresetValue
public double getPresetValue(int index) This method returns the preset value at the specified index.- Parameters:
index
- specifies the index into the preset table.- Returns:
- preset value.
-
nextPresetIndexUp
public int nextPresetIndexUp(double currValue) This method determines the next preset index up from the specified current value.- Parameters:
currValue
- specifies the current value to check against.- Returns:
- next preset index up.
-
nextPresetIndexDown
public int nextPresetIndexDown(double currValue) This method determines the next preset index down from the specified current value.- Parameters:
currValue
- specifies the current value to check against.- Returns:
- next preset index down.
-