Package edu.wpi.first.wpilibj.simulation
Class SPIAccelerometerSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.SPIAccelerometerSim
public class SPIAccelerometerSim extends Object
A class to control a simulated accelerometer over SPI.
- 
Constructor Summary
Constructors Constructor Description SPIAccelerometerSim(int index)Construct a new simulation object. - 
Method Summary
Modifier and Type Method Description booleangetActive()Check whether the accelerometer is active.intgetRange()Check the range of this accelerometer.doublegetX()Measure the X axis value.doublegetY()Measure the Y axis value.doublegetZ()Measure the Z axis value.CallbackStoreregisterActiveCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when this accelerometer activates.CallbackStoreregisterRangeCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the range changes.CallbackStoreregisterXCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the X axis value changes.CallbackStoreregisterYCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the Y axis value changes.CallbackStoreregisterZCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the Z axis value changes.voidresetData()Reset all simulation data of this object.voidsetActive(boolean active)Define whether this accelerometer is active.voidsetRange(int range)Change the range of this accelerometer.voidsetX(double x)Change the X axis value of the accelerometer.voidsetY(double y)Change the Y axis value of the accelerometer.voidsetZ(double z)Change the Z axis value of the accelerometer. 
- 
Constructor Details
- 
SPIAccelerometerSim
Construct a new simulation object.- Parameters:
 index- the HAL index of the accelerometer
 
 - 
 - 
Method Details
- 
registerActiveCallback
Register a callback to be run when this accelerometer activates.- Parameters:
 callback- the callbackinitialNotify- whether to run the callback with the initial state- Returns:
 - the 
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback. 
 - 
getActive
Check whether the accelerometer is active.- Returns:
 - true if active
 
 - 
setActive
Define whether this accelerometer is active.- Parameters:
 active- the new state
 - 
registerRangeCallback
Register a callback to be run whenever the range changes.- Parameters:
 callback- the callbackinitialNotify- whether to call the callback with the initial state- Returns:
 - the 
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback. 
 - 
getRange
Check the range of this accelerometer.- Returns:
 - the accelerometer range
 
 - 
setRange
Change the range of this accelerometer.- Parameters:
 range- the new accelerometer range
 - 
registerXCallback
Register a callback to be run whenever the X axis value changes.- Parameters:
 callback- the callbackinitialNotify- whether to call the callback with the initial state- Returns:
 - the 
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback. 
 - 
getX
Measure the X axis value.- Returns:
 - the X axis measurement
 
 - 
setX
Change the X axis value of the accelerometer.- Parameters:
 x- the new reading of the X axis
 - 
registerYCallback
Register a callback to be run whenever the Y axis value changes.- Parameters:
 callback- the callbackinitialNotify- whether to call the callback with the initial state- Returns:
 - the 
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback. 
 - 
getY
Measure the Y axis value.- Returns:
 - the Y axis measurement
 
 - 
setY
Change the Y axis value of the accelerometer.- Parameters:
 y- the new reading of the Y axis
 - 
registerZCallback
Register a callback to be run whenever the Z axis value changes.- Parameters:
 callback- the callbackinitialNotify- whether to call the callback with the initial state- Returns:
 - the 
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback. 
 - 
getZ
Measure the Z axis value.- Returns:
 - the Z axis measurement
 
 - 
setZ
Change the Z axis value of the accelerometer.- Parameters:
 z- the new reading of the Z axis
 - 
resetData
Reset all simulation data of this object. 
 -