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
Modifier and Type Method Description static AnalogTriggerSimcreateForChannel(int channel)Creates an AnalogTriggerSim for an analog input channel.static AnalogTriggerSimcreateForIndex(int index)Creates an AnalogTriggerSim for a simulated index.booleangetInitialized()Check if this analog trigger has been initialized.doublegetTriggerLowerBound()Get the lower bound.doublegetTriggerUpperBound()Get the upper bound.CallbackStoreregisterInitializedCallback(NotifyCallback callback, boolean initialNotify)Register a callback on whether the analog trigger is initialized.CallbackStoreregisterTriggerLowerBoundCallback(NotifyCallback callback, boolean initialNotify)Register a callback on the lower bound.CallbackStoreregisterTriggerUpperBoundCallback(NotifyCallback callback, boolean initialNotify)Register a callback on the upper bound.voidresetData()Reset all simulation data for this object.voidsetInitialized(boolean initialized)Change whether this analog trigger has been initialized.voidsetTriggerLowerBound(double triggerLowerBound)Change the lower bound.voidsetTriggerUpperBound(double triggerUpperBound)Change the upper bound.
-
Constructor Details
-
AnalogTriggerSim
Constructs from an AnalogTrigger object.- Parameters:
analogTrigger- AnalogTrigger to simulate
-
-
Method Details
-
createForChannel
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
Creates an AnalogTriggerSim for a simulated index. The index is incremented for each simulated AnalogTrigger.- Parameters:
index- simulator index- Returns:
- Simulated object
-
registerInitializedCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
Check if this analog trigger has been initialized.- Returns:
- true if initialized
-
setInitialized
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getTriggerLowerBound
Get the lower bound.- Returns:
- the lower bound
-
setTriggerLowerBound
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getTriggerUpperBound
Get the upper bound.- Returns:
- the upper bound
-
setTriggerUpperBound
Change the upper bound.- Parameters:
triggerUpperBound- the new upper bound
-
resetData
Reset all simulation data for this object.
-