Package edu.wpi.first.wpilibj.simulation
Class AnalogTriggerSim
- java.lang.Object
-
- edu.wpi.first.wpilibj.simulation.AnalogTriggerSim
-
public class AnalogTriggerSim extends Object
Class to control a simulated analog trigger.
-
-
Constructor Summary
Constructors Constructor Description AnalogTriggerSim(AnalogTrigger analogTrigger)
Constructs from an AnalogTrigger object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AnalogTriggerSim
createForChannel(int channel)
Creates an AnalogTriggerSim for an analog input channel.static AnalogTriggerSim
createForIndex(int index)
Creates an AnalogTriggerSim for a simulated index.boolean
getInitialized()
Check if this analog trigger has been initialized.double
getTriggerLowerBound()
Get the lower bound.double
getTriggerUpperBound()
Get the upper bound.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the analog trigger is initialized.CallbackStore
registerTriggerLowerBoundCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the lower bound.CallbackStore
registerTriggerUpperBoundCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the upper bound.void
resetData()
Reset all simulation data for this object.void
setInitialized(boolean initialized)
Change whether this analog trigger has been initialized.void
setTriggerLowerBound(double triggerLowerBound)
Change the lower bound.void
setTriggerUpperBound(double triggerUpperBound)
Change the upper bound.
-
-
-
Constructor Detail
-
AnalogTriggerSim
public AnalogTriggerSim(AnalogTrigger analogTrigger)
Constructs from an AnalogTrigger object.- Parameters:
analogTrigger
- AnalogTrigger to simulate
-
-
Method Detail
-
createForChannel
public static AnalogTriggerSim createForChannel(int channel)
Creates an AnalogTriggerSim for an analog input channel.- Parameters:
channel
- analog input channel- Returns:
- Simulated object
- Throws:
NoSuchElementException
- if no AnalogTrigger is configured for that channel
-
createForIndex
public static AnalogTriggerSim createForIndex(int index)
Creates an AnalogTriggerSim for a simulated index. The index is incremented for each simulated AnalogTrigger.- Parameters:
index
- simulator index- Returns:
- Simulated object
-
registerInitializedCallback
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the analog trigger is initialized.- Parameters:
callback
- the callback that will be called whenever the analog trigger is initializedinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
public boolean getInitialized()
Check if this analog trigger has been initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized)
Change whether this analog trigger has been initialized.- Parameters:
initialized
- the new value
-
registerTriggerLowerBoundCallback
public CallbackStore registerTriggerLowerBoundCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the lower bound.- Parameters:
callback
- the callback that will be called whenever the lower bound is changedinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getTriggerLowerBound
public double getTriggerLowerBound()
Get the lower bound.- Returns:
- the lower bound
-
setTriggerLowerBound
public void setTriggerLowerBound(double triggerLowerBound)
Change the lower bound.- Parameters:
triggerLowerBound
- the new lower bound
-
registerTriggerUpperBoundCallback
public CallbackStore registerTriggerUpperBoundCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the upper bound.- Parameters:
callback
- the callback that will be called whenever the upper bound is changedinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getTriggerUpperBound
public double getTriggerUpperBound()
Get the upper bound.- Returns:
- the upper bound
-
setTriggerUpperBound
public void setTriggerUpperBound(double triggerUpperBound)
Change the upper bound.- Parameters:
triggerUpperBound
- the new upper bound
-
resetData
public void resetData()
Reset all simulation data for this object.
-
-