Package trclib.dataprocessor
Class TrcWrapValueConverter
java.lang.Object
trclib.dataprocessor.TrcWrapValueConverter
- Direct Known Subclasses:
TrcAbsoluteEncoder
This class is typically used to monitor a sensor value that wraps around and convert it to a continuous value.
For example, absolute encoder usually returns a value range between 0.0 and 1.0. When the value crosses over the
zero crossing, it jumps to the other extreme end. This doesn't work well for controllers such as PID control.
This class will monitors the crossovers and will increment or decrement the crossover count depending on which
direction the value is crossing over. It provides a getContinuousValue method to return a continuous value
incorporating the crossover count as part of the value. For example, instead of returning a value between 0.0 and
1.0, it will return a value such as 3.56 where 3 is the number of crossovers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcWrapValueConverter
(String instanceName, DoubleSupplier valueSupplier, double rangeLow, double rangeHigh) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
This method returns the current continuous value.boolean
This method returns the state of the converter task.void
This method resets the converter state.void
setTaskEnabled
(boolean enabled) This method enables/disables the converter task.toString()
This method returns the instance name.
-
Field Details
-
instanceName
-
valueSupplier
-
-
Constructor Details
-
TrcWrapValueConverter
public TrcWrapValueConverter(String instanceName, DoubleSupplier valueSupplier, double rangeLow, double rangeHigh) Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.valueSupplier
- specifies the method to call to get the value.rangeLow
- specifies the low range of the value.rangeHigh
- specifies the high range of the value.
-
-
Method Details
-
toString
This method returns the instance name. -
isTaskEnabled
public boolean isTaskEnabled()This method returns the state of the converter task.- Returns:
- true if converter task is enabled, false otherwise.
-
setTaskEnabled
public void setTaskEnabled(boolean enabled) This method enables/disables the converter task. It is not automatically enabled when created. You must explicitly call this method to enable the converter.- Parameters:
enabled
- specifies true for enabling the converter, disabling it otherwise.
-
resetConverter
public void resetConverter()This method resets the converter state. -
getContinuousValue
public double getContinuousValue()This method returns the current continuous value.- Returns:
- current continuous value.
-