Package edu.wpi.first.wpilibj.simulation
Class SimDeviceSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.SimDeviceSim
public class SimDeviceSim extends Object
Class to control the simulation side of a SimDevice.
-
Constructor Summary
Constructors Constructor Description SimDeviceSim(String name)Constructs a SimDeviceSim.SimDeviceSim(String name, int index)Constructs a SimDeviceSim.SimDeviceSim(String name, int index, int channel)Constructs a SimDeviceSim. -
Method Summary
Modifier and Type Method Description static SimDeviceDataJNI.SimDeviceInfo[]enumerateDevices(String prefix)Get all sim devices with the given prefix.SimDeviceDataJNI.SimValueInfo[]enumerateValues()Get all data of this object.SimBooleangetBoolean(String name)Get the property object with the given name.SimDoublegetDouble(String name)Get the property object with the given name.SimEnumgetEnum(String name)Get the property object with the given name.static String[]getEnumOptions(SimEnum val)Get all options for the given enum.SimIntgetInt(String name)Get the property object with the given name.SimLonggetLong(String name)Get the property object with the given name.intgetNativeHandle()Get the native handle of this object.SimValuegetValue(String name)Get the property object with the given name.static CallbackStoreregisterDeviceCreatedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify)Register a callback to be run every time a newSimDeviceis created.static CallbackStoreregisterDeviceFreedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify)Register a callback to be run every time aSimDeviceis freed/destroyed.CallbackStoreregisterValueChangedCallback(SimValue value, SimValueCallback callback, boolean initialNotify)Register a callback to be run every time a value is changed on this device.CallbackStoreregisterValueCreatedCallback(SimValueCallback callback, boolean initialNotify)Register a callback to be run every time a new value is added to this device.CallbackStoreregisterValueResetCallback(SimValue value, SimValueCallback callback, boolean initialNotify)Register a callback for SimDouble.reset() and similar functions.static voidresetData()Reset all SimDevice data.
-
Constructor Details
-
SimDeviceSim
Constructs a SimDeviceSim.- Parameters:
name- name of the SimDevice
-
SimDeviceSim
Constructs a SimDeviceSim.- Parameters:
name- name of the SimDeviceindex- device index number to append to name
-
SimDeviceSim
Constructs a SimDeviceSim.- Parameters:
name- name of the SimDeviceindex- device index number to append to namechannel- device channel number to append to name
-
-
Method Details
-
getValue
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getInt
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getLong
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getDouble
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getEnum
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getBoolean
Get the property object with the given name.- Parameters:
name- the property name- Returns:
- the property object
-
getEnumOptions
Get all options for the given enum.- Parameters:
val- the enum- Returns:
- names of the different values for that enum
-
enumerateValues
Get all data of this object.- Returns:
- all data and fields of this object
-
getNativeHandle
Get the native handle of this object.- Returns:
- the handle used to refer to this object through JNI
-
registerValueCreatedCallback
public CallbackStore registerValueCreatedCallback(SimValueCallback callback, boolean initialNotify)Register a callback to be run every time a new value is added to this device.- Parameters:
callback- the callbackinitialNotify- should the callback be run with the initial state- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
registerValueChangedCallback
public CallbackStore registerValueChangedCallback(SimValue value, SimValueCallback callback, boolean initialNotify)Register a callback to be run every time a value is changed on this device.- Parameters:
value- simulated valuecallback- the callbackinitialNotify- should the callback be run with the initial state- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
registerValueResetCallback
public CallbackStore registerValueResetCallback(SimValue value, SimValueCallback callback, boolean initialNotify)Register a callback for SimDouble.reset() and similar functions. The callback is called with the old value.- Parameters:
value- simulated valuecallback- callbackinitialNotify- ignored (present for consistency)- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
enumerateDevices
Get all sim devices with the given prefix.- Parameters:
prefix- the prefix to filter sim devices- Returns:
- all sim devices
-
registerDeviceCreatedCallback
public static CallbackStore registerDeviceCreatedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify)Register a callback to be run every time a newSimDeviceis created.- Parameters:
prefix- the prefix to filter sim devicescallback- the callbackinitialNotify- should the callback be run with the initial state- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
registerDeviceFreedCallback
public static CallbackStore registerDeviceFreedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify)Register a callback to be run every time aSimDeviceis freed/destroyed.- Parameters:
prefix- the prefix to filter sim devicescallback- the callbackinitialNotify- should the callback be run with the initial state- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
resetData
Reset all SimDevice data.
-