mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[hal] Add SimValue reset() function (#3064)
This enables correct behavior for resetting incremental sensor values like encoder counts or gyro accumulated angle with WebSockets.
This commit is contained in:
@@ -352,4 +352,13 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
public static void setSimValueBoolean(int handle, boolean value) {
|
||||
setSimValueNative(handle, HALValue.kBoolean, value ? 1 : 0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets a simulated double or integral value to 0. Has no effect on other value types. Use this
|
||||
* instead of Set(0) for resetting incremental sensor values like encoder counts or gyro
|
||||
* accumulated angle to ensure correct behavior in a distributed system (e.g. WebSockets).
|
||||
*
|
||||
* @param handle simulated value handle
|
||||
*/
|
||||
public static native void resetSimValue(int handle);
|
||||
}
|
||||
|
||||
@@ -32,4 +32,13 @@ public class SimDouble extends SimValue {
|
||||
public void set(double value) {
|
||||
SimDeviceJNI.setSimValueDouble(m_handle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the simulated value to 0. Use this instead of Set(0) for resetting incremental sensor
|
||||
* values like encoder counts or gyro accumulated angle to ensure correct behavior in a
|
||||
* distributed system (e.g. WebSockets).
|
||||
*/
|
||||
public void reset() {
|
||||
SimDeviceJNI.resetSimValue(m_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,13 @@ public class SimInt extends SimValue {
|
||||
public void set(int value) {
|
||||
SimDeviceJNI.setSimValueInt(m_handle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the simulated value to 0. Use this instead of Set(0) for resetting incremental sensor
|
||||
* values like encoder counts or gyro accumulated angle to ensure correct behavior in a
|
||||
* distributed system (e.g. WebSockets).
|
||||
*/
|
||||
public void reset() {
|
||||
SimDeviceJNI.resetSimValue(m_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,13 @@ public class SimLong extends SimValue {
|
||||
public void set(long value) {
|
||||
SimDeviceJNI.setSimValueLong(m_handle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the simulated value to 0. Use this instead of Set(0) for resetting incremental sensor
|
||||
* values like encoder counts or gyro accumulated angle to ensure correct behavior in a
|
||||
* distributed system (e.g. WebSockets).
|
||||
*/
|
||||
public void reset() {
|
||||
SimDeviceJNI.resetSimValue(m_handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,19 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
|
||||
public static native void cancelSimValueChangedCallback(int uid);
|
||||
|
||||
/**
|
||||
* Register a callback for SimDeviceJNI.resetSimValue(). The callback is called with the old
|
||||
* value.
|
||||
*
|
||||
* @param handle simulated value handle
|
||||
* @param callback callback
|
||||
* @param initialNotify ignored (present for consistency)
|
||||
*/
|
||||
public static native int registerSimValueResetCallback(
|
||||
int handle, SimValueCallback2 callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSimValueResetCallback(int uid);
|
||||
|
||||
public static native int getSimValueHandle(int device, String name);
|
||||
|
||||
public static class SimValueInfo {
|
||||
|
||||
Reference in New Issue
Block a user