mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal] Implement stub mockdata on RoboRIO (#2575)
This makes it much more user-friendly to use simulation classes without needing to ifdef for C++ to avoid linker errors or be very careful about construction to avoid runtime errors in Java.
This commit is contained in:
281
hal/src/main/native/cpp/jni/simulation/AccelerometerDataJNI.cpp
Normal file
281
hal/src/main/native/cpp/jni/simulation/AccelerometerDataJNI.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AccelerometerDataJNI.h"
|
||||
#include "hal/simulation/AccelerometerData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerActiveCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelActiveCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getActive
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getActive
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerActive(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setActive
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setActive
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAccelerometerActive(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerRangeCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelRangeCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getRange
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getRange
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerRange(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setRange
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setRange
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAccelerometerRange(index,
|
||||
static_cast<HAL_AccelerometerRange>(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerXCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerXCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelXCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelXCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getX
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getX
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerX(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setX
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setX
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerX(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerYCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerYCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelYCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelYCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getY
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getY
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerY(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setY
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setY
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerY(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: registerZCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_registerZCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: cancelZCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_cancelZCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: getZ
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_getZ
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAccelerometerZ(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: setZ
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_setZ
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAccelerometerZ(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AccelerometerDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AccelerometerDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAccelerometerData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
306
hal/src/main/native/cpp/jni/simulation/AddressableLEDDataJNI.cpp
Normal file
306
hal/src/main/native/cpp/jni/simulation/AddressableLEDDataJNI.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "ConstBufferCallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AddressableLEDDataJNI.h"
|
||||
#include "hal/simulation/AddressableLEDData.h"
|
||||
|
||||
static_assert(sizeof(jbyte) * 4 == sizeof(HAL_AddressableLEDData));
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAddressableLEDInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAddressableLEDInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAddressableLEDInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAddressableLEDInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: registerOutputPortCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_registerOutputPortCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAddressableLEDOutputPortCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: cancelOutputPortCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_cancelOutputPortCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAddressableLEDOutputPortCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: getOutputPort
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getOutputPort
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAddressableLEDOutputPort(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: setOutputPort
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_setOutputPort
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAddressableLEDOutputPort(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: registerLengthCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_registerLengthCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAddressableLEDLengthCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: cancelLengthCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_cancelLengthCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAddressableLEDLengthCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: getLength
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getLength
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAddressableLEDLength(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: setLength
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_setLength
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAddressableLEDLength(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: registerRunningCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_registerRunningCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAddressableLEDRunningCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: cancelRunningCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_cancelRunningCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAddressableLEDRunningCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: getRunning
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getRunning
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAddressableLEDRunning(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: setRunning
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_setRunning
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAddressableLEDRunning(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: registerDataCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_registerDataCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateConstBufferCallback(
|
||||
env, index, callback, &HALSIM_RegisterAddressableLEDDataCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: cancelDataCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_cancelDataCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeConstBufferCallback(env, handle, index,
|
||||
&HALSIM_CancelAddressableLEDDataCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: getData
|
||||
* Signature: (I)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_getData
|
||||
(JNIEnv* env, jclass, jint index)
|
||||
{
|
||||
auto data =
|
||||
std::make_unique<HAL_AddressableLEDData[]>(HAL_kAddressableLEDMaxLength);
|
||||
int32_t length = HALSIM_GetAddressableLEDData(index, data.get());
|
||||
return MakeJByteArray(
|
||||
env, wpi::ArrayRef(reinterpret_cast<jbyte*>(data.get()), length * 4));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: setData
|
||||
* Signature: (I[B)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_setData
|
||||
(JNIEnv* env, jclass, jint index, jbyteArray arr)
|
||||
{
|
||||
JByteArrayRef jArrRef{env, arr};
|
||||
auto arrRef = jArrRef.array();
|
||||
HALSIM_SetAddressableLEDData(
|
||||
index, reinterpret_cast<const HAL_AddressableLEDData*>(arrRef.data()),
|
||||
arrRef.size() / 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAddressableLEDData(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AddressableLEDDataJNI
|
||||
* Method: findForChannel
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AddressableLEDDataJNI_findForChannel
|
||||
(JNIEnv*, jclass, jint channel)
|
||||
{
|
||||
return HALSIM_FindAddressableLEDForChannel(channel);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
180
hal/src/main/native/cpp/jni/simulation/AnalogGyroDataJNI.cpp
Normal file
180
hal/src/main/native/cpp/jni/simulation/AnalogGyroDataJNI.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AnalogGyroDataJNI.h"
|
||||
#include "hal/simulation/AnalogGyroData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: registerAngleCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerAngleCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogGyroAngleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: cancelAngleCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelAngleCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogGyroAngleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: getAngle
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getAngle
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogGyroAngle(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: setAngle
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setAngle
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogGyroAngle(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: registerRateCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerRateCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogGyroRateCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: cancelRateCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelRateCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogGyroRateCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: getRate
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getRate
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogGyroRate(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: setRate
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setRate
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogGyroRate(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogGyroInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogGyroInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogGyroInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogGyroInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAnalogGyroData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
485
hal/src/main/native/cpp/jni/simulation/AnalogInDataJNI.cpp
Normal file
485
hal/src/main/native/cpp/jni/simulation/AnalogInDataJNI.cpp
Normal file
@@ -0,0 +1,485 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AnalogInDataJNI.h"
|
||||
#include "hal/simulation/AnalogInData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogInInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAverageBitsCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAverageBitsCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAverageBitsCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAverageBitsCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAverageBitsCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInAverageBitsCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAverageBits
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAverageBits
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAverageBits(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAverageBits
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAverageBits
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAnalogInAverageBits(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerOversampleBitsCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerOversampleBitsCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInOversampleBitsCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelOversampleBitsCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelOversampleBitsCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInOversampleBitsCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getOversampleBits
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getOversampleBits
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInOversampleBits(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setOversampleBits
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setOversampleBits
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAnalogInOversampleBits(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerVoltageCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelVoltageCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getVoltage
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getVoltage
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInVoltage(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setVoltage
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setVoltage
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogInVoltage(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAccumulatorInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAccumulatorInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAccumulatorInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(
|
||||
env, handle, index, &HALSIM_CancelAnalogInAccumulatorInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAccumulatorInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAccumulatorInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAccumulatorInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogInAccumulatorInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAccumulatorValueCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAccumulatorValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAccumulatorValueCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInAccumulatorValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAccumulatorValue
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorValue
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAccumulatorValue(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAccumulatorValue
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorValue
|
||||
(JNIEnv*, jclass, jint index, jlong value)
|
||||
{
|
||||
HALSIM_SetAnalogInAccumulatorValue(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAccumulatorCountCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorCountCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAccumulatorCountCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAccumulatorCountCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorCountCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInAccumulatorCountCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAccumulatorCount
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorCount
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAccumulatorCount(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAccumulatorCount
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorCount
|
||||
(JNIEnv*, jclass, jint index, jlong value)
|
||||
{
|
||||
HALSIM_SetAnalogInAccumulatorCount(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAccumulatorCenterCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorCenterCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAccumulatorCenterCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAccumulatorCenterCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorCenterCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInAccumulatorCenterCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAccumulatorCenter
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorCenter
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAccumulatorCenter(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAccumulatorCenter
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorCenter
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAnalogInAccumulatorCenter(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: registerAccumulatorDeadbandCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorDeadbandCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogInAccumulatorDeadbandCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: cancelAccumulatorDeadbandCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorDeadbandCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: getAccumulatorDeadband
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorDeadband
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogInAccumulatorDeadband(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: setAccumulatorDeadband
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorDeadband
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetAnalogInAccumulatorDeadband(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAnalogInData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
130
hal/src/main/native/cpp/jni/simulation/AnalogOutDataJNI.cpp
Normal file
130
hal/src/main/native/cpp/jni/simulation/AnalogOutDataJNI.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AnalogOutDataJNI.h"
|
||||
#include "hal/simulation/AnalogOutData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: registerVoltageCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_registerVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogOutVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: cancelVoltageCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_cancelVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogOutVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: getVoltage
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_getVoltage
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogOutVoltage(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: setVoltage
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_setVoltage
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogOutVoltage(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogOutInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogOutInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogOutInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogOutInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAnalogOutData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
195
hal/src/main/native/cpp/jni/simulation/AnalogTriggerDataJNI.cpp
Normal file
195
hal/src/main/native/cpp/jni/simulation/AnalogTriggerDataJNI.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_AnalogTriggerDataJNI.h"
|
||||
#include "hal/simulation/AnalogTriggerData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogTriggerInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogTriggerInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogTriggerInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogTriggerInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: registerTriggerLowerBoundCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_registerTriggerLowerBoundCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: cancelTriggerLowerBoundCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_cancelTriggerLowerBoundCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(
|
||||
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: getTriggerLowerBound
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_getTriggerLowerBound
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogTriggerTriggerLowerBound(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: setTriggerLowerBound
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_setTriggerLowerBound
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogTriggerTriggerLowerBound(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: registerTriggerUpperBoundCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_registerTriggerUpperBoundCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: cancelTriggerUpperBoundCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_cancelTriggerUpperBoundCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(
|
||||
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: getTriggerUpperBound
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_getTriggerUpperBound
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogTriggerTriggerUpperBound(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: setTriggerUpperBound
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_setTriggerUpperBound
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogTriggerTriggerUpperBound(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAnalogTriggerData(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogTriggerDataJNI
|
||||
* Method: findForChannel
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogTriggerDataJNI_findForChannel
|
||||
(JNIEnv*, jclass, jint channel)
|
||||
{
|
||||
return HALSIM_FindAnalogTriggerForChannel(channel);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
128
hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp
Normal file
128
hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "BufferCallbackStore.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
void InitializeBufferStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
void BufferCallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
}
|
||||
|
||||
void BufferCallbackStore::performCallback(const char* name, uint8_t* buffer,
|
||||
uint32_t length) {
|
||||
JNIEnv* env;
|
||||
JavaVM* vm = sim::GetJVM();
|
||||
bool didAttachThread = false;
|
||||
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (tryGetEnv == JNI_EDETACHED) {
|
||||
// Thread not attached
|
||||
didAttachThread = true;
|
||||
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
|
||||
// Failed to attach, log and return
|
||||
wpi::outs() << "Failed to attach\n";
|
||||
wpi::outs().flush();
|
||||
return;
|
||||
}
|
||||
} else if (tryGetEnv == JNI_EVERSION) {
|
||||
wpi::outs() << "Invalid JVM Version requested\n";
|
||||
wpi::outs().flush();
|
||||
}
|
||||
|
||||
auto toCallbackArr =
|
||||
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
|
||||
static_cast<size_t>(length)});
|
||||
|
||||
env->CallVoidMethod(m_call, sim::GetBufferCallback(), MakeJString(env, name),
|
||||
toCallbackArr, (jint)length);
|
||||
|
||||
jbyte* fromCallbackArr = reinterpret_cast<jbyte*>(
|
||||
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
buffer[i] = fromCallbackArr[i];
|
||||
}
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(toCallbackArr, fromCallbackArr, JNI_ABORT);
|
||||
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (didAttachThread) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
void BufferCallbackStore::free(JNIEnv* env) { m_call.free(env); }
|
||||
|
||||
SIM_JniHandle sim::AllocateBufferCallback(
|
||||
JNIEnv* env, jint index, jobject callback,
|
||||
RegisterBufferCallbackFunc createCallback) {
|
||||
auto callbackStore = std::make_shared<BufferCallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param, uint8_t* buffer,
|
||||
uint32_t length) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
data->performCallback(name, buffer, length);
|
||||
};
|
||||
|
||||
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeBufferCallbackFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(index, callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
47
hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.h
Normal file
47
hal/src/main/native/cpp/jni/simulation/BufferCallbackStore.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
class BufferCallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
void performCallback(const char* name, uint8_t* buffer, uint32_t length);
|
||||
void free(JNIEnv* env);
|
||||
void setCallbackId(int32_t id) { callbackId = id; }
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
void InitializeBufferStore();
|
||||
|
||||
typedef int32_t (*RegisterBufferCallbackFunc)(int32_t index,
|
||||
HAL_BufferCallback callback,
|
||||
void* param);
|
||||
typedef void (*FreeBufferCallbackFunc)(int32_t index, int32_t uid);
|
||||
|
||||
SIM_JniHandle AllocateBufferCallback(JNIEnv* env, jint index, jobject callback,
|
||||
RegisterBufferCallbackFunc createCallback);
|
||||
void FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeBufferCallbackFunc freeCallback);
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
197
hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp
Normal file
197
hal/src/main/native/cpp/jni/simulation/CallbackStore.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CallbackStore.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
void InitializeStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
void CallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
}
|
||||
|
||||
void CallbackStore::performCallback(const char* name, const HAL_Value* value) {
|
||||
JNIEnv* env;
|
||||
JavaVM* vm = sim::GetJVM();
|
||||
bool didAttachThread = false;
|
||||
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (tryGetEnv == JNI_EDETACHED) {
|
||||
// Thread not attached
|
||||
didAttachThread = true;
|
||||
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
|
||||
// Failed to attach, log and return
|
||||
wpi::outs() << "Failed to attach\n";
|
||||
wpi::outs().flush();
|
||||
return;
|
||||
}
|
||||
} else if (tryGetEnv == JNI_EVERSION) {
|
||||
wpi::outs() << "Invalid JVM Version requested\n";
|
||||
wpi::outs().flush();
|
||||
}
|
||||
|
||||
env->CallVoidMethod(m_call, sim::GetNotifyCallback(), MakeJString(env, name),
|
||||
(jint)value->type, (jlong)value->data.v_long,
|
||||
(jdouble)value->data.v_double);
|
||||
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (didAttachThread) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
void CallbackStore::free(JNIEnv* env) { m_call.free(env); }
|
||||
|
||||
SIM_JniHandle sim::AllocateCallback(JNIEnv* env, jint index, jobject callback,
|
||||
jboolean initialNotify,
|
||||
RegisterCallbackFunc createCallback) {
|
||||
auto callbackStore = std::make_shared<CallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param,
|
||||
const HAL_Value* value) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
data->performCallback(name, value);
|
||||
};
|
||||
|
||||
auto id = createCallback(index, callbackFunc, handleAsVoidPtr, initialNotify);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeCallbackFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(index, callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
|
||||
SIM_JniHandle sim::AllocateChannelCallback(
|
||||
JNIEnv* env, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify, RegisterChannelCallbackFunc createCallback) {
|
||||
auto callbackStore = std::make_shared<CallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param,
|
||||
const HAL_Value* value) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
data->performCallback(name, value);
|
||||
};
|
||||
|
||||
auto id = createCallback(index, channel, callbackFunc, handleAsVoidPtr,
|
||||
initialNotify);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
jint channel,
|
||||
FreeChannelCallbackFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(index, channel, callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
|
||||
SIM_JniHandle sim::AllocateCallbackNoIndex(
|
||||
JNIEnv* env, jobject callback, jboolean initialNotify,
|
||||
RegisterCallbackNoIndexFunc createCallback) {
|
||||
auto callbackStore = std::make_shared<CallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param,
|
||||
const HAL_Value* value) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
data->performCallback(name, value);
|
||||
};
|
||||
|
||||
auto id = createCallback(callbackFunc, handleAsVoidPtr, initialNotify);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
|
||||
FreeCallbackNoIndexFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
68
hal/src/main/native/cpp/jni/simulation/CallbackStore.h
Normal file
68
hal/src/main/native/cpp/jni/simulation/CallbackStore.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
class CallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
void performCallback(const char* name, const HAL_Value* value);
|
||||
void free(JNIEnv* env);
|
||||
void setCallbackId(int32_t id) { callbackId = id; }
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
void InitializeStore();
|
||||
|
||||
typedef int32_t (*RegisterCallbackFunc)(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param, HAL_Bool initialNotify);
|
||||
typedef void (*FreeCallbackFunc)(int32_t index, int32_t uid);
|
||||
typedef int32_t (*RegisterChannelCallbackFunc)(int32_t index, int32_t channel,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
typedef void (*FreeChannelCallbackFunc)(int32_t index, int32_t channel,
|
||||
int32_t uid);
|
||||
typedef int32_t (*RegisterCallbackNoIndexFunc)(HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
typedef void (*FreeCallbackNoIndexFunc)(int32_t uid);
|
||||
|
||||
SIM_JniHandle AllocateCallback(JNIEnv* env, jint index, jobject callback,
|
||||
jboolean initialNotify,
|
||||
RegisterCallbackFunc createCallback);
|
||||
SIM_JniHandle AllocateChannelCallback(
|
||||
JNIEnv* env, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify, RegisterChannelCallbackFunc createCallback);
|
||||
SIM_JniHandle AllocateCallbackNoIndex(
|
||||
JNIEnv* env, jobject callback, jboolean initialNotify,
|
||||
RegisterCallbackNoIndexFunc createCallback);
|
||||
void FreeCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeCallbackFunc freeCallback);
|
||||
void FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
jint channel, FreeChannelCallbackFunc freeCallback);
|
||||
void FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
|
||||
FreeCallbackNoIndexFunc freeCallback);
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
@@ -0,0 +1,120 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ConstBufferCallbackStore.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>*
|
||||
callbackHandles;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
void InitializeConstBufferStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
void ConstBufferCallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
}
|
||||
|
||||
void ConstBufferCallbackStore::performCallback(const char* name,
|
||||
const uint8_t* buffer,
|
||||
uint32_t length) {
|
||||
JNIEnv* env;
|
||||
JavaVM* vm = sim::GetJVM();
|
||||
bool didAttachThread = false;
|
||||
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (tryGetEnv == JNI_EDETACHED) {
|
||||
// Thread not attached
|
||||
didAttachThread = true;
|
||||
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
|
||||
// Failed to attach, log and return
|
||||
wpi::outs() << "Failed to attach\n";
|
||||
wpi::outs().flush();
|
||||
return;
|
||||
}
|
||||
} else if (tryGetEnv == JNI_EVERSION) {
|
||||
wpi::outs() << "Invalid JVM Version requested\n";
|
||||
wpi::outs().flush();
|
||||
}
|
||||
|
||||
auto toCallbackArr =
|
||||
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
|
||||
static_cast<size_t>(length)});
|
||||
|
||||
env->CallVoidMethod(m_call, sim::GetConstBufferCallback(),
|
||||
MakeJString(env, name), toCallbackArr, (jint)length);
|
||||
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (didAttachThread) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
void ConstBufferCallbackStore::free(JNIEnv* env) { m_call.free(env); }
|
||||
|
||||
SIM_JniHandle sim::AllocateConstBufferCallback(
|
||||
JNIEnv* env, jint index, jobject callback,
|
||||
RegisterConstBufferCallbackFunc createCallback) {
|
||||
auto callbackStore = std::make_shared<ConstBufferCallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param, const uint8_t* buffer,
|
||||
uint32_t length) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
data->performCallback(name, buffer, length);
|
||||
};
|
||||
|
||||
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeConstBufferCallbackFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(index, callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
class ConstBufferCallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
void performCallback(const char* name, const uint8_t* buffer,
|
||||
uint32_t length);
|
||||
void free(JNIEnv* env);
|
||||
void setCallbackId(int32_t id) { callbackId = id; }
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
void InitializeConstBufferStore();
|
||||
|
||||
typedef int32_t (*RegisterConstBufferCallbackFunc)(
|
||||
int32_t index, HAL_ConstBufferCallback callback, void* param);
|
||||
typedef void (*FreeConstBufferCallbackFunc)(int32_t index, int32_t uid);
|
||||
|
||||
SIM_JniHandle AllocateConstBufferCallback(
|
||||
JNIEnv* env, jint index, jobject callback,
|
||||
RegisterConstBufferCallbackFunc createCallback);
|
||||
void FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeConstBufferCallbackFunc freeCallback);
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
279
hal/src/main/native/cpp/jni/simulation/DIODataJNI.cpp
Normal file
279
hal/src/main/native/cpp/jni/simulation/DIODataJNI.cpp
Normal file
@@ -0,0 +1,279 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_DIODataJNI.h"
|
||||
#include "hal/simulation/DIOData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDIOInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDIOInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDIOInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetDIOInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: registerValueCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_registerValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDIOValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: cancelValueCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_cancelValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index, &HALSIM_CancelDIOValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: getValue
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_getValue
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDIOValue(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: setValue
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_setValue
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetDIOValue(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: registerPulseLengthCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_registerPulseLengthCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDIOPulseLengthCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: cancelPulseLengthCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_cancelPulseLengthCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDIOPulseLengthCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: getPulseLength
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_getPulseLength
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDIOPulseLength(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: setPulseLength
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_setPulseLength
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetDIOPulseLength(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: registerIsInputCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_registerIsInputCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDIOIsInputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: cancelIsInputCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_cancelIsInputCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDIOIsInputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: getIsInput
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_getIsInput
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDIOIsInput(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: setIsInput
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_setIsInput
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetDIOIsInput(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: registerFilterIndexCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_registerFilterIndexCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDIOFilterIndexCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: cancelFilterIndexCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_cancelFilterIndexCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDIOFilterIndexCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: getFilterIndex
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_getFilterIndex
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDIOFilterIndex(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: setFilterIndex
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_setFilterIndex
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetDIOFilterIndex(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DIODataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DIODataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetDIOData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
192
hal/src/main/native/cpp/jni/simulation/DigitalPWMDataJNI.cpp
Normal file
192
hal/src/main/native/cpp/jni/simulation/DigitalPWMDataJNI.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_DigitalPWMDataJNI.h"
|
||||
#include "hal/simulation/DigitalPWMData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDigitalPWMInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDigitalPWMInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDigitalPWMInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetDigitalPWMInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: registerDutyCycleCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_registerDutyCycleCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDigitalPWMDutyCycleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: cancelDutyCycleCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_cancelDutyCycleCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDigitalPWMDutyCycleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: getDutyCycle
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_getDutyCycle
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDigitalPWMDutyCycle(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: setDutyCycle
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_setDutyCycle
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetDigitalPWMDutyCycle(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: registerPinCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_registerPinCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDigitalPWMPinCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: cancelPinCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_cancelPinCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDigitalPWMPinCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: getPin
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_getPin
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDigitalPWMPin(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: setPin
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_setPin
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetDigitalPWMPin(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetDigitalPWMData(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DigitalPWMDataJNI
|
||||
* Method: findForChannel
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DigitalPWMDataJNI_findForChannel
|
||||
(JNIEnv*, jclass, jint channel)
|
||||
{
|
||||
return HALSIM_FindDigitalPWMForChannel(channel);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
498
hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp
Normal file
498
hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp
Normal file
@@ -0,0 +1,498 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_DriverStationDataJNI.h"
|
||||
#include "hal/simulation/DriverStationData.h"
|
||||
#include "hal/simulation/MockHooks.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerEnabledCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerEnabledCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterDriverStationEnabledCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelEnabledCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelEnabledCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelDriverStationEnabledCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getEnabled
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getEnabled
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationEnabled();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setEnabled
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setEnabled
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationEnabled(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerAutonomousCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerAutonomousCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterDriverStationAutonomousCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelAutonomousCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelAutonomousCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(
|
||||
env, handle, &HALSIM_CancelDriverStationAutonomousCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getAutonomous
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getAutonomous
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationAutonomous();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setAutonomous
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setAutonomous
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationAutonomous(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerTestCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerTestCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify, &HALSIM_RegisterDriverStationTestCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelTestCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelTestCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelDriverStationTestCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getTest
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getTest
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationTest();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setTest
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setTest
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationTest(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerEStopCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerEStopCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify, &HALSIM_RegisterDriverStationEStopCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelEStopCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelEStopCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelDriverStationEStopCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getEStop
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getEStop
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationEStop();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setEStop
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setEStop
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationEStop(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerFmsAttachedCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerFmsAttachedCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterDriverStationFmsAttachedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelFmsAttachedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelFmsAttachedCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(
|
||||
env, handle, &HALSIM_CancelDriverStationFmsAttachedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getFmsAttached
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getFmsAttached
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationFmsAttached();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setFmsAttached
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setFmsAttached
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationFmsAttached(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerDsAttachedCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerDsAttachedCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterDriverStationDsAttachedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: cancelDsAttachedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_cancelDsAttachedCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(
|
||||
env, handle, &HALSIM_CancelDriverStationDsAttachedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: getDsAttached
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_getDsAttached
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetDriverStationDsAttached();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setDsAttached
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setDsAttached
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetDriverStationDsAttached(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickAxes
|
||||
* Signature: (B[F)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickAxes
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jfloatArray axesArray)
|
||||
{
|
||||
HAL_JoystickAxes axes;
|
||||
{
|
||||
wpi::java::JFloatArrayRef jArrayRef(env, axesArray);
|
||||
auto arrayRef = jArrayRef.array();
|
||||
auto arraySize = arrayRef.size();
|
||||
int maxCount =
|
||||
arraySize < HAL_kMaxJoystickAxes ? arraySize : HAL_kMaxJoystickAxes;
|
||||
axes.count = maxCount;
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
axes.axes[i] = arrayRef[i];
|
||||
}
|
||||
}
|
||||
HALSIM_SetJoystickAxes(joystickNum, &axes);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickPOVs
|
||||
* Signature: (B[S)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickPOVs
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jshortArray povsArray)
|
||||
{
|
||||
HAL_JoystickPOVs povs;
|
||||
{
|
||||
wpi::java::JShortArrayRef jArrayRef(env, povsArray);
|
||||
auto arrayRef = jArrayRef.array();
|
||||
auto arraySize = arrayRef.size();
|
||||
int maxCount =
|
||||
arraySize < HAL_kMaxJoystickPOVs ? arraySize : HAL_kMaxJoystickPOVs;
|
||||
povs.count = maxCount;
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
povs.povs[i] = arrayRef[i];
|
||||
}
|
||||
}
|
||||
HALSIM_SetJoystickPOVs(joystickNum, &povs);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setJoystickButtons
|
||||
* Signature: (BII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setJoystickButtons
|
||||
(JNIEnv* env, jclass, jbyte joystickNum, jint buttons, jint count)
|
||||
{
|
||||
if (count > 32) {
|
||||
count = 32;
|
||||
}
|
||||
HAL_JoystickButtons joystickButtons;
|
||||
joystickButtons.count = count;
|
||||
joystickButtons.buttons = buttons;
|
||||
HALSIM_SetJoystickButtons(joystickNum, &joystickButtons);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setMatchInfo
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setMatchInfo
|
||||
(JNIEnv* env, jclass, jstring eventName, jstring gameSpecificMessage,
|
||||
jint matchNumber, jint replayNumber, jint matchType)
|
||||
{
|
||||
JStringRef eventNameRef{env, eventName};
|
||||
JStringRef gameSpecificMessageRef{env, gameSpecificMessage};
|
||||
|
||||
HAL_MatchInfo halMatchInfo;
|
||||
std::snprintf(halMatchInfo.eventName, sizeof(halMatchInfo.eventName), "%s",
|
||||
eventNameRef.c_str());
|
||||
std::snprintf(reinterpret_cast<char*>(halMatchInfo.gameSpecificMessage),
|
||||
sizeof(halMatchInfo.gameSpecificMessage), "%s",
|
||||
gameSpecificMessageRef.c_str());
|
||||
halMatchInfo.gameSpecificMessageSize = gameSpecificMessageRef.size();
|
||||
halMatchInfo.matchType = (HAL_MatchType)matchType;
|
||||
halMatchInfo.matchNumber = matchNumber;
|
||||
halMatchInfo.replayNumber = replayNumber;
|
||||
HALSIM_SetMatchInfo(&halMatchInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: registerAllCallbacks
|
||||
* Signature: (Ljava/lang/Object;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_registerAllCallbacks
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
[](HAL_NotifyCallback cb, void* param, HAL_Bool in) {
|
||||
HALSIM_RegisterDriverStationAllCallbacks(cb, param, in);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: notifyNewData
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_notifyNewData
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_NotifyDriverStationNewData();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setSendError
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setSendError
|
||||
(JNIEnv*, jclass, jboolean shouldSend)
|
||||
{
|
||||
if (shouldSend) {
|
||||
HALSIM_SetSendError(nullptr);
|
||||
} else {
|
||||
HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
|
||||
HAL_Bool isLVCode, const char* details,
|
||||
const char* location, const char* callStack,
|
||||
HAL_Bool printMsg) { return 0; });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: setSendConsoleLine
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_setSendConsoleLine
|
||||
(JNIEnv*, jclass, jboolean shouldSend)
|
||||
{
|
||||
if (shouldSend) {
|
||||
HALSIM_SetSendConsoleLine(nullptr);
|
||||
} else {
|
||||
HALSIM_SetSendConsoleLine([](const char* line) { return 0; });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DriverStationDataJNI
|
||||
* Method: resetData
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DriverStationDataJNI_resetData
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_ResetDriverStationData();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
192
hal/src/main/native/cpp/jni/simulation/DutyCycleDataJNI.cpp
Normal file
192
hal/src/main/native/cpp/jni/simulation/DutyCycleDataJNI.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_DutyCycleDataJNI.h"
|
||||
#include "hal/simulation/DutyCycleData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDutyCycleInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDutyCycleInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDutyCycleInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetDutyCycleInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: registerFrequencyCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_registerFrequencyCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDutyCycleFrequencyCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: cancelFrequencyCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_cancelFrequencyCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDutyCycleFrequencyCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: getFrequency
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_getFrequency
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDutyCycleFrequency(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: setFrequency
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_setFrequency
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetDutyCycleFrequency(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: registerOutputCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_registerOutputCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterDutyCycleOutputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: cancelOutputCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_cancelOutputCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelDutyCycleOutputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: getOutput
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_getOutput
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetDutyCycleOutput(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: setOutput
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_setOutput
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetDutyCycleOutput(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetDutyCycleData(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_DutyCycleDataJNI
|
||||
* Method: findForChannel
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_DutyCycleDataJNI_findForChannel
|
||||
(JNIEnv*, jclass, jint channel)
|
||||
{
|
||||
return HALSIM_FindDutyCycleForChannel(channel);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
490
hal/src/main/native/cpp/jni/simulation/EncoderDataJNI.cpp
Normal file
490
hal/src/main/native/cpp/jni/simulation/EncoderDataJNI.cpp
Normal file
@@ -0,0 +1,490 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_EncoderDataJNI.h"
|
||||
#include "hal/simulation/EncoderData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetEncoderInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerCountCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerCountCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderCountCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelCountCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelCountCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderCountCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getCount
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getCount
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderCount(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setCount
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setCount
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetEncoderCount(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerPeriodCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelPeriodCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getPeriod
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getPeriod
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderPeriod(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setPeriod
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setPeriod
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetEncoderPeriod(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerResetCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerResetCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderResetCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelResetCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelResetCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderResetCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getReset
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getReset
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderReset(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setReset
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setReset
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetEncoderReset(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerMaxPeriodCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerMaxPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderMaxPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelMaxPeriodCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelMaxPeriodCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderMaxPeriodCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getMaxPeriod
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getMaxPeriod
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderMaxPeriod(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setMaxPeriod
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setMaxPeriod
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetEncoderMaxPeriod(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerDirectionCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerDirectionCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderDirectionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelDirectionCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelDirectionCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderDirectionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getDirection
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getDirection
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderDirection(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setDirection
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setDirection
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetEncoderDirection(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerReverseDirectionCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerReverseDirectionCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderReverseDirectionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelReverseDirectionCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelReverseDirectionCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderReverseDirectionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getReverseDirection
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getReverseDirection
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderReverseDirection(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setReverseDirection
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setReverseDirection
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetEncoderReverseDirection(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: registerSamplesToAverageCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_registerSamplesToAverageCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterEncoderSamplesToAverageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: cancelSamplesToAverageCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_cancelSamplesToAverageCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelEncoderSamplesToAverageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getSamplesToAverage
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getSamplesToAverage
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderSamplesToAverage(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setSamplesToAverage
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setSamplesToAverage
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetEncoderSamplesToAverage(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setDistance
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setDistance
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetEncoderDistance(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getDistance
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getDistance
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderDistance(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: setRate
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_setRate
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetEncoderRate(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: getRate
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_getRate
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetEncoderRate(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetEncoderData(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_EncoderDataJNI
|
||||
* Method: findForChannel
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_EncoderDataJNI_findForChannel
|
||||
(JNIEnv*, jclass, jint channel)
|
||||
{
|
||||
return HALSIM_FindEncoderForChannel(channel);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
133
hal/src/main/native/cpp/jni/simulation/I2CDataJNI.cpp
Normal file
133
hal/src/main/native/cpp/jni/simulation/I2CDataJNI.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "BufferCallbackStore.h"
|
||||
#include "CallbackStore.h"
|
||||
#include "ConstBufferCallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_I2CDataJNI.h"
|
||||
#include "hal/simulation/I2CData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterI2CInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelI2CInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetI2CInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetI2CInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: registerReadCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_registerReadCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateBufferCallback(env, index, callback,
|
||||
&HALSIM_RegisterI2CReadCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: cancelReadCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_cancelReadCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelI2CReadCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: registerWriteCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_registerWriteCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateConstBufferCallback(env, index, callback,
|
||||
&HALSIM_RegisterI2CWriteCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: cancelWriteCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_cancelWriteCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeConstBufferCallback(env, handle, index,
|
||||
&HALSIM_CancelI2CWriteCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_I2CDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_I2CDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetI2CData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
37
hal/src/main/native/cpp/jni/simulation/NotifierDataJNI.cpp
Normal file
37
hal/src/main/native/cpp/jni/simulation/NotifierDataJNI.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "edu_wpi_first_hal_simulation_NotifierDataJNI.h"
|
||||
#include "hal/simulation/NotifierData.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_NotifierDataJNI
|
||||
* Method: getNextTimeout
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_NotifierDataJNI_getNextTimeout
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetNextNotifierTimeout();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_NotifierDataJNI
|
||||
* Method: getNumNotifiers
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_NotifierDataJNI_getNumNotifiers
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetNumNotifiers();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
421
hal/src/main/native/cpp/jni/simulation/PCMDataJNI.cpp
Normal file
421
hal/src/main/native/cpp/jni/simulation/PCMDataJNI.cpp
Normal file
@@ -0,0 +1,421 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_PCMDataJNI.h"
|
||||
#include "hal/simulation/PCMData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerSolenoidInitializedCallback
|
||||
* Signature: (IILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerSolenoidInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateChannelCallback(
|
||||
env, index, channel, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMSolenoidInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelSolenoidInitializedCallback
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelSolenoidInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jint handle)
|
||||
{
|
||||
return sim::FreeChannelCallback(env, handle, index, channel,
|
||||
&HALSIM_CancelPCMSolenoidInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getSolenoidInitialized
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getSolenoidInitialized
|
||||
(JNIEnv*, jclass, jint index, jint channel)
|
||||
{
|
||||
return HALSIM_GetPCMSolenoidInitialized(index, channel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setSolenoidInitialized
|
||||
* Signature: (IIZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setSolenoidInitialized
|
||||
(JNIEnv*, jclass, jint index, jint channel, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMSolenoidInitialized(index, channel, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerSolenoidOutputCallback
|
||||
* Signature: (IILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerSolenoidOutputCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateChannelCallback(
|
||||
env, index, channel, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMSolenoidOutputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelSolenoidOutputCallback
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelSolenoidOutputCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jint handle)
|
||||
{
|
||||
return sim::FreeChannelCallback(env, handle, index, channel,
|
||||
&HALSIM_CancelPCMSolenoidOutputCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getSolenoidOutput
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getSolenoidOutput
|
||||
(JNIEnv*, jclass, jint index, jint channel)
|
||||
{
|
||||
return HALSIM_GetPCMSolenoidOutput(index, channel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setSolenoidOutput
|
||||
* Signature: (IIZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setSolenoidOutput
|
||||
(JNIEnv*, jclass, jint index, jint channel, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMSolenoidOutput(index, channel, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerCompressorInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerCompressorInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMCompressorInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelCompressorInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelCompressorInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPCMCompressorInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getCompressorInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getCompressorInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPCMCompressorInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setCompressorInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setCompressorInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMCompressorInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerCompressorOnCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerCompressorOnCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMCompressorOnCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelCompressorOnCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelCompressorOnCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPCMCompressorOnCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getCompressorOn
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getCompressorOn
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPCMCompressorOn(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setCompressorOn
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setCompressorOn
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMCompressorOn(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerClosedLoopEnabledCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerClosedLoopEnabledCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMClosedLoopEnabledCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelClosedLoopEnabledCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelClosedLoopEnabledCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPCMClosedLoopEnabledCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getClosedLoopEnabled
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getClosedLoopEnabled
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPCMClosedLoopEnabled(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setClosedLoopEnabled
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setClosedLoopEnabled
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMClosedLoopEnabled(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerPressureSwitchCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerPressureSwitchCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMPressureSwitchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelPressureSwitchCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelPressureSwitchCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPCMPressureSwitchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getPressureSwitch
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getPressureSwitch
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPCMPressureSwitch(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setPressureSwitch
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setPressureSwitch
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPCMPressureSwitch(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerCompressorCurrentCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerCompressorCurrentCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPCMCompressorCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: cancelCompressorCurrentCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_cancelCompressorCurrentCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPCMCompressorCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: getCompressorCurrent
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_getCompressorCurrent
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPCMCompressorCurrent(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: setCompressorCurrent
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_setCompressorCurrent
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPCMCompressorCurrent(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerAllNonSolenoidCallbacks
|
||||
* Signature: (ILjava/lang/Object;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerAllNonSolenoidCallbacks
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
sim::AllocateCallback(
|
||||
env, index, callback, initialNotify,
|
||||
[](int32_t index, HAL_NotifyCallback cb, void* param, HAL_Bool in) {
|
||||
HALSIM_RegisterPCMAllNonSolenoidCallbacks(index, cb, param, in);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: registerAllSolenoidCallbacks
|
||||
* Signature: (IILjava/lang/Object;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_registerAllSolenoidCallbacks
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify)
|
||||
{
|
||||
sim::AllocateChannelCallback(
|
||||
env, index, channel, callback, initialNotify,
|
||||
[](int32_t index, int32_t channel, HAL_NotifyCallback cb, void* param,
|
||||
HAL_Bool in) {
|
||||
HALSIM_RegisterPCMAllSolenoidCallbacks(index, channel, cb, param, in);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PCMDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PCMDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetPCMData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
232
hal/src/main/native/cpp/jni/simulation/PDPDataJNI.cpp
Normal file
232
hal/src/main/native/cpp/jni/simulation/PDPDataJNI.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_PDPDataJNI.h"
|
||||
#include "hal/simulation/PDPData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPDPInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPDPInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPDPInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPDPInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: registerTemperatureCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_registerTemperatureCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPDPTemperatureCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: cancelTemperatureCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_cancelTemperatureCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPDPTemperatureCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: getTemperature
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_getTemperature
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPDPTemperature(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: setTemperature
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_setTemperature
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPDPTemperature(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: registerVoltageCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_registerVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPDPVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: cancelVoltageCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_cancelVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPDPVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: getVoltage
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_getVoltage
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPDPVoltage(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: setVoltage
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_setVoltage
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPDPVoltage(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: registerCurrentCallback
|
||||
* Signature: (IILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_registerCurrentCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
|
||||
jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateChannelCallback(env, index, channel, callback,
|
||||
initialNotify,
|
||||
&HALSIM_RegisterPDPCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: cancelCurrentCallback
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_cancelCurrentCallback
|
||||
(JNIEnv* env, jclass, jint index, jint channel, jint handle)
|
||||
{
|
||||
return sim::FreeChannelCallback(env, handle, index, channel,
|
||||
&HALSIM_CancelPDPCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: getCurrent
|
||||
* Signature: (II)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_getCurrent
|
||||
(JNIEnv*, jclass, jint index, jint channel)
|
||||
{
|
||||
return HALSIM_GetPDPCurrent(index, channel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: setCurrent
|
||||
* Signature: (IID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_setCurrent
|
||||
(JNIEnv*, jclass, jint index, jint channel, jdouble value)
|
||||
{
|
||||
HALSIM_SetPDPCurrent(index, channel, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PDPDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PDPDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetPDPData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
329
hal/src/main/native/cpp/jni/simulation/PWMDataJNI.cpp
Normal file
329
hal/src/main/native/cpp/jni/simulation/PWMDataJNI.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_PWMDataJNI.h"
|
||||
#include "hal/simulation/PWMData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPWMInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerRawValueCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerRawValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMRawValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelRawValueCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelRawValueCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMRawValueCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getRawValue
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getRawValue
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMRawValue(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setRawValue
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setRawValue
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetPWMRawValue(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerSpeedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerSpeedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMSpeedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelSpeedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelSpeedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index, &HALSIM_CancelPWMSpeedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getSpeed
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getSpeed
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMSpeed(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setSpeed
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setSpeed
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPWMSpeed(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerPositionCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerPositionCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMPositionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelPositionCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelPositionCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMPositionCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getPosition
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getPosition
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMPosition(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setPosition
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setPosition
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetPWMPosition(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerPeriodScaleCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerPeriodScaleCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMPeriodScaleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelPeriodScaleCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelPeriodScaleCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMPeriodScaleCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getPeriodScale
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getPeriodScale
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMPeriodScale(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setPeriodScale
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setPeriodScale
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetPWMPeriodScale(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: registerZeroLatchCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_registerZeroLatchCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterPWMZeroLatchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: cancelZeroLatchCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_cancelZeroLatchCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelPWMZeroLatchCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: getZeroLatch
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_getZeroLatch
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetPWMZeroLatch(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: setZeroLatch
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_setZeroLatch
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetPWMZeroLatch(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_PWMDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_PWMDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetPWMData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
230
hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp
Normal file
230
hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_RelayDataJNI.h"
|
||||
#include "hal/simulation/RelayData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerInitializedForwardCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerInitializedForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayInitializedForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelInitializedForwardCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelInitializedForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayInitializedForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getInitializedForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getInitializedForward
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayInitializedForward(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setInitializedForward
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setInitializedForward
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayInitializedForward(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerInitializedReverseCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerInitializedReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayInitializedReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelInitializedReverseCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelInitializedReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayInitializedReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getInitializedReverse
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getInitializedReverse
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayInitializedReverse(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setInitializedReverse
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setInitializedReverse
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayInitializedReverse(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerForwardCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelForwardCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getForward
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayForward(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setForward
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setForward
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayForward(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerReverseCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelReverseCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getReverse
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getReverse
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayReverse(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setReverse
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setReverse
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayReverse(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetRelayData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
792
hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp
Normal file
792
hal/src/main/native/cpp/jni/simulation/RoboRioDataJNI.cpp
Normal file
@@ -0,0 +1,792 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_RoboRioDataJNI.h"
|
||||
#include "hal/simulation/RoboRioData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerFPGAButtonCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerFPGAButtonCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify, &HALSIM_RegisterRoboRioFPGAButtonCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelFPGAButtonCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelFPGAButtonCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioFPGAButtonCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getFPGAButton
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getFPGAButton
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioFPGAButton();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setFPGAButton
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setFPGAButton
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetRoboRioFPGAButton(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerVInVoltageCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerVInVoltageCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify, &HALSIM_RegisterRoboRioVInVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelVInVoltageCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelVInVoltageCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioVInVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getVInVoltage
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getVInVoltage
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioVInVoltage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setVInVoltage
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setVInVoltage
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioVInVoltage(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerVInCurrentCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerVInCurrentCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify, &HALSIM_RegisterRoboRioVInCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelVInCurrentCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelVInCurrentCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioVInCurrentCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getVInCurrent
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getVInCurrent
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioVInCurrent();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setVInCurrent
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setVInCurrent
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioVInCurrent(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserVoltage6VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserVoltage6VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserVoltage6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserVoltage6VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserVoltage6VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserVoltage6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserVoltage6V
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserVoltage6V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserVoltage6V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserVoltage6V
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserVoltage6V
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserVoltage6V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserCurrent6VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserCurrent6VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserCurrent6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserCurrent6VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserCurrent6VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserCurrent6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserCurrent6V
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserCurrent6V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserCurrent6V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserCurrent6V
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserCurrent6V
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserCurrent6V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserActive6VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserActive6VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserActive6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserActive6VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserActive6VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserActive6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserActive6V
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserActive6V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserActive6V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserActive6V
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive6V
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserActive6V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserVoltage5VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserVoltage5VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserVoltage5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserVoltage5VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserVoltage5VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserVoltage5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserVoltage5V
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserVoltage5V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserVoltage5V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserVoltage5V
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserVoltage5V
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserVoltage5V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserCurrent5VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserCurrent5VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserCurrent5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserCurrent5VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserCurrent5VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserCurrent5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserCurrent5V
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserCurrent5V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserCurrent5V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserCurrent5V
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserCurrent5V
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserCurrent5V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserActive5VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserActive5VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserActive5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserActive5VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserActive5VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserActive5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserActive5V
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserActive5V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserActive5V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserActive5V
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive5V
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserActive5V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserVoltage3V3Callback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserVoltage3V3Callback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserVoltage3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserVoltage3V3Callback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserVoltage3V3Callback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserVoltage3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserVoltage3V3
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserVoltage3V3
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserVoltage3V3();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserVoltage3V3
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserVoltage3V3
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserVoltage3V3(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserCurrent3V3Callback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserCurrent3V3Callback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserCurrent3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserCurrent3V3Callback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserCurrent3V3Callback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserCurrent3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserCurrent3V3
|
||||
* Signature: ()D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserCurrent3V3
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserCurrent3V3();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserCurrent3V3
|
||||
* Signature: (D)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserCurrent3V3
|
||||
(JNIEnv*, jclass, jdouble value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserCurrent3V3(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserActive3V3Callback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserActive3V3Callback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserActive3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserActive3V3Callback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserActive3V3Callback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserActive3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserActive3V3
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserActive3V3
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserActive3V3();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserActive3V3
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserActive3V3
|
||||
(JNIEnv*, jclass, jboolean value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserActive3V3(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserFaults6VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserFaults6VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserFaults6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserFaults6VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserFaults6VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserFaults6VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserFaults6V
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserFaults6V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserFaults6V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserFaults6V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults6V
|
||||
(JNIEnv*, jclass, jint value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserFaults6V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserFaults5VCallback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserFaults5VCallback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserFaults5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserFaults5VCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserFaults5VCallback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserFaults5VCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserFaults5V
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserFaults5V
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserFaults5V();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserFaults5V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults5V
|
||||
(JNIEnv*, jclass, jint value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserFaults5V(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: registerUserFaults3V3Callback
|
||||
* Signature: (Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerUserFaults3V3Callback
|
||||
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallbackNoIndex(
|
||||
env, callback, initialNotify,
|
||||
&HALSIM_RegisterRoboRioUserFaults3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: cancelUserFaults3V3Callback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelUserFaults3V3Callback
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
return sim::FreeCallbackNoIndex(env, handle,
|
||||
&HALSIM_CancelRoboRioUserFaults3V3Callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: getUserFaults3V3
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getUserFaults3V3
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetRoboRioUserFaults3V3();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: setUserFaults3V3
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults3V3
|
||||
(JNIEnv*, jclass, jint value)
|
||||
{
|
||||
HALSIM_SetRoboRioUserFaults3V3(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
|
||||
* Method: resetData
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_resetData
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_ResetRoboRioData();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,280 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI.h"
|
||||
#include "hal/simulation/SPIAccelerometerData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: registerActiveCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_registerActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: cancelActiveCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_cancelActiveCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIAccelerometerActiveCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: getActive
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_getActive
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIAccelerometerActive(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: setActive
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_setActive
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetSPIAccelerometerActive(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: registerRangeCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_registerRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: cancelRangeCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_cancelRangeCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIAccelerometerRangeCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: getRange
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_getRange
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIAccelerometerRange(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: setRange
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_setRange
|
||||
(JNIEnv*, jclass, jint index, jint value)
|
||||
{
|
||||
HALSIM_SetSPIAccelerometerRange(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: registerXCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_registerXCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: cancelXCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_cancelXCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIAccelerometerXCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: getX
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_getX
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIAccelerometerX(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: setX
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_setX
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetSPIAccelerometerX(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: registerYCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_registerYCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: cancelYCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_cancelYCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIAccelerometerYCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: getY
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_getY
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIAccelerometerY(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: setY
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_setY
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetSPIAccelerometerY(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: registerZCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_registerZCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: cancelZCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_cancelZCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIAccelerometerZCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: getZ
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_getZ
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIAccelerometerZ(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: setZ
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_setZ
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetSPIAccelerometerZ(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIAccelerometerDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetSPIAccelerometerData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
160
hal/src/main/native/cpp/jni/simulation/SPIDataJNI.cpp
Normal file
160
hal/src/main/native/cpp/jni/simulation/SPIDataJNI.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "BufferCallbackStore.h"
|
||||
#include "CallbackStore.h"
|
||||
#include "ConstBufferCallbackStore.h"
|
||||
#include "SpiReadAutoReceiveBufferCallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_SPIDataJNI.h"
|
||||
#include "hal/simulation/SPIData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterSPIInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetSPIInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetSPIInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: registerReadCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_registerReadCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateBufferCallback(env, index, callback,
|
||||
&HALSIM_RegisterSPIReadCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: cancelReadCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_cancelReadCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelSPIReadCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: registerWriteCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_registerWriteCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateConstBufferCallback(env, index, callback,
|
||||
&HALSIM_RegisterSPIWriteCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: cancelWriteCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_cancelWriteCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeConstBufferCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIWriteCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: registerReadAutoReceiveBufferCallback
|
||||
* Signature: (ILjava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_registerReadAutoReceiveBufferCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback)
|
||||
{
|
||||
return sim::AllocateSpiBufferCallback(
|
||||
env, index, callback, &HALSIM_RegisterSPIReadAutoReceivedDataCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: cancelReadAutoReceiveBufferCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_cancelReadAutoReceiveBufferCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
sim::FreeSpiBufferCallback(env, handle, index,
|
||||
&HALSIM_CancelSPIReadAutoReceivedDataCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SPIDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SPIDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetSPIData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
602
hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp
Normal file
602
hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.cpp
Normal file
@@ -0,0 +1,602 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "SimDeviceDataJNI.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <wpi/UidVector.h>
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "edu_wpi_first_hal_simulation_SimDeviceDataJNI.h"
|
||||
#include "hal/simulation/SimDeviceData.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::java;
|
||||
|
||||
static JClass simDeviceInfoCls;
|
||||
static JClass simValueInfoCls;
|
||||
static JClass simDeviceCallbackCls;
|
||||
static JClass simValueCallbackCls;
|
||||
static jmethodID simDeviceCallbackCallback;
|
||||
static jmethodID simValueCallbackCallback;
|
||||
|
||||
namespace {
|
||||
|
||||
struct DeviceInfo {
|
||||
DeviceInfo(const char* name_, HAL_SimDeviceHandle handle_)
|
||||
: name{name_}, handle{handle_} {}
|
||||
std::string name;
|
||||
HAL_SimValueHandle handle;
|
||||
|
||||
jobject MakeJava(JNIEnv* env) const;
|
||||
void CallJava(JNIEnv* env, jobject callobj) const;
|
||||
};
|
||||
|
||||
struct ValueInfo {
|
||||
ValueInfo(const char* name_, HAL_SimValueHandle handle_, bool readonly_,
|
||||
const HAL_Value& value_)
|
||||
: name{name_}, handle{handle_}, readonly{readonly_}, value{value_} {}
|
||||
std::string name;
|
||||
HAL_SimValueHandle handle;
|
||||
bool readonly;
|
||||
HAL_Value value;
|
||||
|
||||
jobject MakeJava(JNIEnv* env) const;
|
||||
void CallJava(JNIEnv* env, jobject callobj) const;
|
||||
|
||||
private:
|
||||
std::pair<jlong, jdouble> ToValue12() const;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
jobject DeviceInfo::MakeJava(JNIEnv* env) const {
|
||||
static jmethodID func =
|
||||
env->GetMethodID(simDeviceInfoCls, "<init>", "(Ljava/lang/String;I)V");
|
||||
return env->NewObject(simDeviceInfoCls, func, MakeJString(env, name),
|
||||
(jint)handle);
|
||||
}
|
||||
|
||||
void DeviceInfo::CallJava(JNIEnv* env, jobject callobj) const {
|
||||
env->CallVoidMethod(callobj, simDeviceCallbackCallback,
|
||||
MakeJString(env, name), (jint)handle);
|
||||
}
|
||||
|
||||
std::pair<jlong, jdouble> ValueInfo::ToValue12() const {
|
||||
jlong value1 = 0;
|
||||
jdouble value2 = 0.0;
|
||||
switch (value.type) {
|
||||
case HAL_BOOLEAN:
|
||||
value1 = value.data.v_boolean;
|
||||
break;
|
||||
case HAL_DOUBLE:
|
||||
value2 = value.data.v_double;
|
||||
break;
|
||||
case HAL_ENUM:
|
||||
value1 = value.data.v_enum;
|
||||
break;
|
||||
case HAL_INT:
|
||||
value1 = value.data.v_int;
|
||||
break;
|
||||
case HAL_LONG:
|
||||
value1 = value.data.v_long;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return std::pair(value1, value2);
|
||||
}
|
||||
|
||||
jobject ValueInfo::MakeJava(JNIEnv* env) const {
|
||||
static jmethodID func =
|
||||
env->GetMethodID(simValueInfoCls, "<init>", "(Ljava/lang/String;IZIJD)V");
|
||||
auto [value1, value2] = ToValue12();
|
||||
return env->NewObject(simValueInfoCls, func, MakeJString(env, name),
|
||||
(jint)handle, (jboolean)readonly, (jint)value.type,
|
||||
value1, value2);
|
||||
}
|
||||
|
||||
void ValueInfo::CallJava(JNIEnv* env, jobject callobj) const {
|
||||
auto [value1, value2] = ToValue12();
|
||||
env->CallVoidMethod(callobj, simValueCallbackCallback, MakeJString(env, name),
|
||||
(jint)handle, (jboolean)readonly, (jint)value.type,
|
||||
value1, value2);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class CallbackStore {
|
||||
public:
|
||||
explicit CallbackStore(JNIEnv* env, jobject obj) : m_call{env, obj} {}
|
||||
~CallbackStore() {
|
||||
if (m_cancelCallback) m_cancelCallback();
|
||||
}
|
||||
|
||||
void SetCancel(std::function<void()> cancelCallback) {
|
||||
m_cancelCallback = std::move(cancelCallback);
|
||||
}
|
||||
void Free(JNIEnv* env) { m_call.free(env); }
|
||||
jobject Get() const { return m_call; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
std::function<void()> m_cancelCallback;
|
||||
};
|
||||
|
||||
class CallbackThreadJNI : public wpi::SafeThread {
|
||||
public:
|
||||
void Main();
|
||||
|
||||
using DeviceCalls =
|
||||
std::vector<std::pair<std::weak_ptr<CallbackStore>, DeviceInfo>>;
|
||||
DeviceCalls m_deviceCalls;
|
||||
using ValueCalls =
|
||||
std::vector<std::pair<std::weak_ptr<CallbackStore>, ValueInfo>>;
|
||||
ValueCalls m_valueCalls;
|
||||
|
||||
wpi::UidVector<std::shared_ptr<CallbackStore>, 4> m_callbacks;
|
||||
};
|
||||
|
||||
class CallbackJNI {
|
||||
public:
|
||||
static CallbackJNI& GetInstance() {
|
||||
static CallbackJNI inst;
|
||||
return inst;
|
||||
}
|
||||
void SendDevice(int32_t callback, DeviceInfo info);
|
||||
void SendValue(int32_t callback, ValueInfo info);
|
||||
|
||||
std::pair<int32_t, std::shared_ptr<CallbackStore>> AllocateCallback(
|
||||
JNIEnv* env, jobject obj);
|
||||
|
||||
void FreeCallback(JNIEnv* env, int32_t uid);
|
||||
|
||||
private:
|
||||
CallbackJNI() { m_owner.Start(); }
|
||||
|
||||
wpi::SafeThreadOwner<CallbackThreadJNI> m_owner;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void CallbackThreadJNI::Main() {
|
||||
JNIEnv* env;
|
||||
JavaVMAttachArgs args;
|
||||
args.version = JNI_VERSION_1_2;
|
||||
args.name = const_cast<char*>("SimDeviceCallback");
|
||||
args.group = nullptr;
|
||||
jint rs = sim::GetJVM()->AttachCurrentThreadAsDaemon(
|
||||
reinterpret_cast<void**>(&env), &args);
|
||||
if (rs != JNI_OK) return;
|
||||
|
||||
DeviceCalls deviceCalls;
|
||||
ValueCalls valueCalls;
|
||||
|
||||
std::unique_lock lock(m_mutex);
|
||||
while (m_active) {
|
||||
m_cond.wait(lock, [&] { return !m_active; });
|
||||
if (!m_active) break;
|
||||
|
||||
deviceCalls.swap(m_deviceCalls);
|
||||
valueCalls.swap(m_valueCalls);
|
||||
|
||||
lock.unlock(); // don't hold mutex during callback execution
|
||||
|
||||
for (auto&& call : deviceCalls) {
|
||||
if (auto store = call.first.lock()) {
|
||||
if (jobject callobj = store->Get()) {
|
||||
call.second.CallJava(env, callobj);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto&& call : valueCalls) {
|
||||
if (auto store = call.first.lock()) {
|
||||
if (jobject callobj = store->Get()) {
|
||||
call.second.CallJava(env, callobj);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviceCalls.clear();
|
||||
valueCalls.clear();
|
||||
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
// free global references
|
||||
for (auto&& callback : m_callbacks) callback->Free(env);
|
||||
|
||||
sim::GetJVM()->DetachCurrentThread();
|
||||
}
|
||||
|
||||
void CallbackJNI::SendDevice(int32_t callback, DeviceInfo info) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
thr->m_deviceCalls.emplace_back(thr->m_callbacks[callback], std::move(info));
|
||||
thr->m_cond.notify_one();
|
||||
}
|
||||
|
||||
void CallbackJNI::SendValue(int32_t callback, ValueInfo info) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
thr->m_valueCalls.emplace_back(thr->m_callbacks[callback], std::move(info));
|
||||
thr->m_cond.notify_one();
|
||||
}
|
||||
|
||||
std::pair<int32_t, std::shared_ptr<CallbackStore>>
|
||||
CallbackJNI::AllocateCallback(JNIEnv* env, jobject obj) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return std::pair(0, nullptr);
|
||||
auto store = std::make_shared<CallbackStore>(env, obj);
|
||||
return std::pair(thr->m_callbacks.emplace_back(store) + 1, store);
|
||||
}
|
||||
|
||||
void CallbackJNI::FreeCallback(JNIEnv* env, int32_t uid) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
if (uid <= 0 || static_cast<uint32_t>(uid) >= thr->m_callbacks.size()) return;
|
||||
--uid;
|
||||
auto store = std::move(thr->m_callbacks[uid]);
|
||||
thr->m_callbacks.erase(uid);
|
||||
store->Free(env);
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
|
||||
bool InitializeSimDeviceDataJNI(JNIEnv* env) {
|
||||
simDeviceInfoCls = JClass(
|
||||
env, "edu/wpi/first/hal/simulation/SimDeviceDataJNI$SimDeviceInfo");
|
||||
if (!simDeviceInfoCls) return false;
|
||||
|
||||
simValueInfoCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/SimDeviceDataJNI$SimValueInfo");
|
||||
if (!simValueInfoCls) return false;
|
||||
|
||||
simDeviceCallbackCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/SimDeviceCallback");
|
||||
if (!simDeviceCallbackCls) return false;
|
||||
|
||||
simDeviceCallbackCallback = env->GetMethodID(simDeviceCallbackCls, "callback",
|
||||
"(Ljava/lang/String;I)V");
|
||||
if (!simDeviceCallbackCallback) return false;
|
||||
|
||||
simValueCallbackCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/SimValueCallback");
|
||||
if (!simValueCallbackCls) return false;
|
||||
|
||||
simValueCallbackCallback = env->GetMethodID(
|
||||
simValueCallbackCls, "callbackNative", "(Ljava/lang/String;IZIJD)V");
|
||||
if (!simValueCallbackCallback) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreeSimDeviceDataJNI(JNIEnv* env) {
|
||||
simDeviceInfoCls.free(env);
|
||||
simValueInfoCls.free(env);
|
||||
simDeviceCallbackCls.free(env);
|
||||
simValueCallbackCls.free(env);
|
||||
}
|
||||
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: setSimDeviceEnabled
|
||||
* Signature: (Ljava/lang/String;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_setSimDeviceEnabled
|
||||
(JNIEnv* env, jclass, jstring prefix, jboolean enabled)
|
||||
{
|
||||
HALSIM_SetSimDeviceEnabled(JStringRef{env, prefix}.c_str(), enabled);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: isSimDeviceEnabled
|
||||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_isSimDeviceEnabled
|
||||
(JNIEnv* env, jclass, jstring name)
|
||||
{
|
||||
return HALSIM_IsSimDeviceEnabled(JStringRef{env, name}.c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: registerSimDeviceCreatedCallback
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimDeviceCreatedCallback
|
||||
(JNIEnv* env, jclass, jstring prefix, jobject callback,
|
||||
jboolean initialNotify)
|
||||
{
|
||||
auto [uid, store] =
|
||||
CallbackJNI::GetInstance().AllocateCallback(env, callback);
|
||||
int32_t cuid = HALSIM_RegisterSimDeviceCreatedCallback(
|
||||
JStringRef{env, prefix}.c_str(),
|
||||
reinterpret_cast<void*>(static_cast<intptr_t>(uid)),
|
||||
[](const char* name, void* param, HAL_SimDeviceHandle handle) {
|
||||
int32_t uid = reinterpret_cast<intptr_t>(param);
|
||||
CallbackJNI::GetInstance().SendDevice(uid, DeviceInfo{name, handle});
|
||||
},
|
||||
initialNotify);
|
||||
store->SetCancel([cuid] { HALSIM_CancelSimDeviceCreatedCallback(cuid); });
|
||||
return uid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: cancelSimDeviceCreatedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_cancelSimDeviceCreatedCallback
|
||||
(JNIEnv* env, jclass, jint uid)
|
||||
{
|
||||
CallbackJNI::GetInstance().FreeCallback(env, uid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: registerSimDeviceFreedCallback
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimDeviceFreedCallback
|
||||
(JNIEnv* env, jclass, jstring prefix, jobject callback)
|
||||
{
|
||||
auto [uid, store] =
|
||||
CallbackJNI::GetInstance().AllocateCallback(env, callback);
|
||||
int32_t cuid = HALSIM_RegisterSimDeviceFreedCallback(
|
||||
JStringRef{env, prefix}.c_str(),
|
||||
reinterpret_cast<void*>(static_cast<intptr_t>(uid)),
|
||||
[](const char* name, void* param, HAL_SimDeviceHandle handle) {
|
||||
int32_t uid = reinterpret_cast<intptr_t>(param);
|
||||
CallbackJNI::GetInstance().SendDevice(uid, DeviceInfo{name, handle});
|
||||
});
|
||||
store->SetCancel([cuid] { HALSIM_CancelSimDeviceFreedCallback(cuid); });
|
||||
return uid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: cancelSimDeviceFreedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_cancelSimDeviceFreedCallback
|
||||
(JNIEnv* env, jclass, jint uid)
|
||||
{
|
||||
CallbackJNI::GetInstance().FreeCallback(env, uid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: getSimDeviceHandle
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_getSimDeviceHandle
|
||||
(JNIEnv* env, jclass, jstring name)
|
||||
{
|
||||
return HALSIM_GetSimDeviceHandle(JStringRef{env, name}.c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: getSimValueDeviceHandle
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_getSimValueDeviceHandle
|
||||
(JNIEnv*, jclass, jint handle)
|
||||
{
|
||||
return HALSIM_GetSimValueDeviceHandle(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: enumerateSimDevices
|
||||
* Signature: (Ljava/lang/String;)[Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_enumerateSimDevices
|
||||
(JNIEnv* env, jclass, jstring prefix)
|
||||
{
|
||||
// get values
|
||||
std::vector<DeviceInfo> arr;
|
||||
HALSIM_EnumerateSimDevices(
|
||||
JStringRef{env, prefix}.c_str(), &arr,
|
||||
[](const char* name, void* param, HAL_SimDeviceHandle handle) {
|
||||
auto arr = static_cast<std::vector<DeviceInfo>*>(param);
|
||||
arr->emplace_back(name, handle);
|
||||
});
|
||||
|
||||
// convert to java
|
||||
size_t numElems = arr.size();
|
||||
jobjectArray jarr =
|
||||
env->NewObjectArray(arr.size(), simDeviceInfoCls, nullptr);
|
||||
if (!jarr) return nullptr;
|
||||
for (size_t i = 0; i < numElems; ++i) {
|
||||
JLocal<jobject> elem{env, arr[i].MakeJava(env)};
|
||||
env->SetObjectArrayElement(jarr, i, elem.obj());
|
||||
}
|
||||
return jarr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: registerSimValueCreatedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueCreatedCallback
|
||||
(JNIEnv* env, jclass, jint device, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
auto [uid, store] =
|
||||
CallbackJNI::GetInstance().AllocateCallback(env, callback);
|
||||
int32_t cuid = HALSIM_RegisterSimValueCreatedCallback(
|
||||
device, reinterpret_cast<void*>(static_cast<intptr_t>(uid)),
|
||||
[](const char* name, void* param, HAL_SimValueHandle handle,
|
||||
HAL_Bool readonly, const HAL_Value* value) {
|
||||
int32_t uid = reinterpret_cast<intptr_t>(param);
|
||||
CallbackJNI::GetInstance().SendValue(
|
||||
uid, ValueInfo{name, handle, static_cast<bool>(readonly), *value});
|
||||
},
|
||||
initialNotify);
|
||||
store->SetCancel([cuid] { HALSIM_CancelSimValueCreatedCallback(cuid); });
|
||||
return uid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: cancelSimValueCreatedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_cancelSimValueCreatedCallback
|
||||
(JNIEnv* env, jclass, jint uid)
|
||||
{
|
||||
CallbackJNI::GetInstance().FreeCallback(env, uid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: registerSimValueChangedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_registerSimValueChangedCallback
|
||||
(JNIEnv* env, jclass, jint handle, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
auto [uid, store] =
|
||||
CallbackJNI::GetInstance().AllocateCallback(env, callback);
|
||||
int32_t cuid = HALSIM_RegisterSimValueChangedCallback(
|
||||
handle, reinterpret_cast<void*>(static_cast<intptr_t>(uid)),
|
||||
[](const char* name, void* param, HAL_SimValueHandle handle,
|
||||
HAL_Bool readonly, const HAL_Value* value) {
|
||||
int32_t uid = reinterpret_cast<intptr_t>(param);
|
||||
CallbackJNI::GetInstance().SendValue(
|
||||
uid, ValueInfo{name, handle, static_cast<bool>(readonly), *value});
|
||||
},
|
||||
initialNotify);
|
||||
store->SetCancel([cuid] { HALSIM_CancelSimValueChangedCallback(cuid); });
|
||||
return uid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: cancelSimValueChangedCallback
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_cancelSimValueChangedCallback
|
||||
(JNIEnv* env, jclass, jint uid)
|
||||
{
|
||||
CallbackJNI::GetInstance().FreeCallback(env, uid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: getSimValueHandle
|
||||
* Signature: (ILjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_getSimValueHandle
|
||||
(JNIEnv* env, jclass, jint device, jstring name)
|
||||
{
|
||||
return HALSIM_GetSimValueHandle(device, JStringRef{env, name}.c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: enumerateSimValues
|
||||
* Signature: (I)[Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_enumerateSimValues
|
||||
(JNIEnv* env, jclass, jint device)
|
||||
{
|
||||
// get values
|
||||
std::vector<ValueInfo> arr;
|
||||
HALSIM_EnumerateSimValues(
|
||||
device, &arr,
|
||||
[](const char* name, void* param, HAL_SimValueHandle handle,
|
||||
HAL_Bool readonly, const HAL_Value* value) {
|
||||
auto arr = static_cast<std::vector<ValueInfo>*>(param);
|
||||
arr->emplace_back(name, handle, readonly, *value);
|
||||
});
|
||||
|
||||
// convert to java
|
||||
size_t numElems = arr.size();
|
||||
jobjectArray jarr = env->NewObjectArray(arr.size(), simValueInfoCls, nullptr);
|
||||
if (!jarr) return nullptr;
|
||||
for (size_t i = 0; i < numElems; ++i) {
|
||||
JLocal<jobject> elem{env, arr[i].MakeJava(env)};
|
||||
env->SetObjectArrayElement(jarr, i, elem.obj());
|
||||
}
|
||||
return jarr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: getSimValueEnumOptions
|
||||
* Signature: (I)[Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_getSimValueEnumOptions
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
static JClass stringCls{env, "java/lang/String"};
|
||||
if (!stringCls) return nullptr;
|
||||
int32_t numElems = 0;
|
||||
const char** elems = HALSIM_GetSimValueEnumOptions(handle, &numElems);
|
||||
jobjectArray jarr = env->NewObjectArray(numElems, stringCls, nullptr);
|
||||
if (!jarr) return nullptr;
|
||||
for (int32_t i = 0; i < numElems; ++i) {
|
||||
JLocal<jstring> elem{env, MakeJString(env, elems[i])};
|
||||
env->SetObjectArrayElement(jarr, i, elem.obj());
|
||||
}
|
||||
return jarr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimDeviceDataJNI
|
||||
* Method: resetSimDeviceData
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimDeviceDataJNI_resetSimDeviceData
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_ResetSimDeviceData();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
17
hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.h
Normal file
17
hal/src/main/native/cpp/jni/simulation/SimDeviceDataJNI.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
bool InitializeSimDeviceDataJNI(JNIEnv* env);
|
||||
void FreeSimDeviceDataJNI(JNIEnv* env);
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
232
hal/src/main/native/cpp/jni/simulation/SimulatorJNI.cpp
Normal file
232
hal/src/main/native/cpp/jni/simulation/SimulatorJNI.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "BufferCallbackStore.h"
|
||||
#include "CallbackStore.h"
|
||||
#include "ConstBufferCallbackStore.h"
|
||||
#include "SimDeviceDataJNI.h"
|
||||
#include "SpiReadAutoReceiveBufferCallbackStore.h"
|
||||
#include "edu_wpi_first_hal_simulation_SimulatorJNI.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
#include "hal/simulation/MockHooks.h"
|
||||
|
||||
using namespace wpi::java;
|
||||
|
||||
static JavaVM* jvm = nullptr;
|
||||
static JClass notifyCallbackCls;
|
||||
static JClass bufferCallbackCls;
|
||||
static JClass constBufferCallbackCls;
|
||||
static JClass spiReadAutoReceiveBufferCallbackCls;
|
||||
static jmethodID notifyCallbackCallback;
|
||||
static jmethodID bufferCallbackCallback;
|
||||
static jmethodID constBufferCallbackCallback;
|
||||
static jmethodID spiReadAutoReceiveBufferCallbackCallback;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
jint SimOnLoad(JavaVM* vm, void* reserved) {
|
||||
jvm = vm;
|
||||
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
return JNI_ERR;
|
||||
|
||||
notifyCallbackCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/NotifyCallback");
|
||||
if (!notifyCallbackCls) return JNI_ERR;
|
||||
|
||||
notifyCallbackCallback = env->GetMethodID(notifyCallbackCls, "callbackNative",
|
||||
"(Ljava/lang/String;IJD)V");
|
||||
if (!notifyCallbackCallback) return JNI_ERR;
|
||||
|
||||
bufferCallbackCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/BufferCallback");
|
||||
if (!bufferCallbackCls) return JNI_ERR;
|
||||
|
||||
bufferCallbackCallback = env->GetMethodID(bufferCallbackCls, "callback",
|
||||
"(Ljava/lang/String;[BI)V");
|
||||
if (!bufferCallbackCallback) return JNI_ERR;
|
||||
|
||||
constBufferCallbackCls =
|
||||
JClass(env, "edu/wpi/first/hal/simulation/ConstBufferCallback");
|
||||
if (!constBufferCallbackCls) return JNI_ERR;
|
||||
|
||||
constBufferCallbackCallback = env->GetMethodID(
|
||||
constBufferCallbackCls, "callback", "(Ljava/lang/String;[BI)V");
|
||||
if (!constBufferCallbackCallback) return JNI_ERR;
|
||||
|
||||
spiReadAutoReceiveBufferCallbackCls = JClass(
|
||||
env, "edu/wpi/first/hal/simulation/SpiReadAutoReceiveBufferCallback");
|
||||
if (!spiReadAutoReceiveBufferCallbackCls) return JNI_ERR;
|
||||
|
||||
spiReadAutoReceiveBufferCallbackCallback =
|
||||
env->GetMethodID(spiReadAutoReceiveBufferCallbackCls, "callback",
|
||||
"(Ljava/lang/String;[II)I");
|
||||
if (!spiReadAutoReceiveBufferCallbackCallback) return JNI_ERR;
|
||||
|
||||
InitializeStore();
|
||||
InitializeBufferStore();
|
||||
InitializeConstBufferStore();
|
||||
InitializeSpiBufferStore();
|
||||
if (!InitializeSimDeviceDataJNI(env)) return JNI_ERR;
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
void SimOnUnload(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
return;
|
||||
|
||||
notifyCallbackCls.free(env);
|
||||
bufferCallbackCls.free(env);
|
||||
constBufferCallbackCls.free(env);
|
||||
spiReadAutoReceiveBufferCallbackCls.free(env);
|
||||
FreeSimDeviceDataJNI(env);
|
||||
jvm = nullptr;
|
||||
}
|
||||
|
||||
JavaVM* GetJVM() { return jvm; }
|
||||
|
||||
jmethodID GetNotifyCallback() { return notifyCallbackCallback; }
|
||||
|
||||
jmethodID GetBufferCallback() { return bufferCallbackCallback; }
|
||||
|
||||
jmethodID GetConstBufferCallback() { return constBufferCallbackCallback; }
|
||||
|
||||
jmethodID GetSpiReadAutoReceiveBufferCallback() {
|
||||
return spiReadAutoReceiveBufferCallbackCallback;
|
||||
}
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: setRuntimeType
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_setRuntimeType
|
||||
(JNIEnv*, jclass, jint type)
|
||||
{
|
||||
HALSIM_SetRuntimeType(static_cast<HAL_RuntimeType>(type));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: waitForProgramStart
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_waitForProgramStart
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_WaitForProgramStart();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: setProgramStarted
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_setProgramStarted
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_SetProgramStarted();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: getProgramStarted
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_getProgramStarted
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_GetProgramStarted();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: restartTiming
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_restartTiming
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_RestartTiming();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: pauseTiming
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_pauseTiming
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_PauseTiming();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: resumeTiming
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_resumeTiming
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
HALSIM_ResumeTiming();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: isTimingPaused
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_isTimingPaused
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return HALSIM_IsTimingPaused();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: stepTiming
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_stepTiming
|
||||
(JNIEnv*, jclass, jlong delta)
|
||||
{
|
||||
HALSIM_StepTiming(delta);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_SimulatorJNI
|
||||
* Method: resetHandles
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_SimulatorJNI_resetHandles
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
hal::HandleBase::ResetGlobalHandles();
|
||||
}
|
||||
} // extern "C"
|
||||
24
hal/src/main/native/cpp/jni/simulation/SimulatorJNI.h
Normal file
24
hal/src/main/native/cpp/jni/simulation/SimulatorJNI.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/Types.h"
|
||||
#include "jni.h"
|
||||
|
||||
typedef HAL_Handle SIM_JniHandle;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
JavaVM* GetJVM();
|
||||
|
||||
jmethodID GetNotifyCallback();
|
||||
jmethodID GetBufferCallback();
|
||||
jmethodID GetConstBufferCallback();
|
||||
jmethodID GetSpiReadAutoReceiveBufferCallback();
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
@@ -0,0 +1,133 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "SpiReadAutoReceiveBufferCallbackStore.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace hal::sim;
|
||||
using namespace wpi::java;
|
||||
|
||||
static hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, SpiReadAutoReceiveBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
void InitializeSpiBufferStore() {
|
||||
static hal::UnlimitedHandleResource<SIM_JniHandle,
|
||||
SpiReadAutoReceiveBufferCallbackStore,
|
||||
hal::HAL_HandleEnum::SimulationJni>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
|
||||
void SpiReadAutoReceiveBufferCallbackStore::create(JNIEnv* env, jobject obj) {
|
||||
m_call = JGlobal<jobject>(env, obj);
|
||||
}
|
||||
|
||||
int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback(
|
||||
const char* name, uint32_t* buffer, int32_t numToRead) {
|
||||
JNIEnv* env;
|
||||
JavaVM* vm = sim::GetJVM();
|
||||
bool didAttachThread = false;
|
||||
int tryGetEnv = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (tryGetEnv == JNI_EDETACHED) {
|
||||
// Thread not attached
|
||||
didAttachThread = true;
|
||||
if (vm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) != 0) {
|
||||
// Failed to attach, log and return
|
||||
wpi::outs() << "Failed to attach\n";
|
||||
wpi::outs().flush();
|
||||
return -1;
|
||||
}
|
||||
} else if (tryGetEnv == JNI_EVERSION) {
|
||||
wpi::outs() << "Invalid JVM Version requested\n";
|
||||
wpi::outs().flush();
|
||||
}
|
||||
|
||||
auto toCallbackArr = MakeJIntArray(
|
||||
env, wpi::ArrayRef<uint32_t>{buffer, static_cast<size_t>(numToRead)});
|
||||
|
||||
jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(),
|
||||
MakeJString(env, name), toCallbackArr,
|
||||
(jint)numToRead);
|
||||
|
||||
jint* fromCallbackArr = reinterpret_cast<jint*>(
|
||||
env->GetPrimitiveArrayCritical(toCallbackArr, nullptr));
|
||||
|
||||
for (int i = 0; i < ret; i++) {
|
||||
buffer[i] = fromCallbackArr[i];
|
||||
}
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(toCallbackArr, fromCallbackArr, JNI_ABORT);
|
||||
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
}
|
||||
|
||||
if (didAttachThread) {
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SpiReadAutoReceiveBufferCallbackStore::free(JNIEnv* env) {
|
||||
m_call.free(env);
|
||||
}
|
||||
|
||||
SIM_JniHandle sim::AllocateSpiBufferCallback(
|
||||
JNIEnv* env, jint index, jobject callback,
|
||||
RegisterSpiBufferCallbackFunc createCallback) {
|
||||
auto callbackStore =
|
||||
std::make_shared<SpiReadAutoReceiveBufferCallbackStore>();
|
||||
|
||||
auto handle = callbackHandles->Allocate(callbackStore);
|
||||
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uintptr_t handleAsPtr = static_cast<uintptr_t>(handle);
|
||||
void* handleAsVoidPtr = reinterpret_cast<void*>(handleAsPtr);
|
||||
|
||||
callbackStore->create(env, callback);
|
||||
|
||||
auto callbackFunc = [](const char* name, void* param, uint32_t* buffer,
|
||||
int32_t numToRead, int32_t* outputCount) {
|
||||
uintptr_t handleTmp = reinterpret_cast<uintptr_t>(param);
|
||||
SIM_JniHandle handle = static_cast<SIM_JniHandle>(handleTmp);
|
||||
auto data = callbackHandles->Get(handle);
|
||||
if (!data) return;
|
||||
|
||||
*outputCount = data->performCallback(name, buffer, numToRead);
|
||||
};
|
||||
|
||||
auto id = createCallback(index, callbackFunc, handleAsVoidPtr);
|
||||
|
||||
callbackStore->setCallbackId(id);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void sim::FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeSpiBufferCallbackFunc freeCallback) {
|
||||
auto callback = callbackHandles->Free(handle);
|
||||
freeCallback(index, callback->getCallbackId());
|
||||
callback->free(env);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "SimulatorJNI.h"
|
||||
#include "hal/Types.h"
|
||||
#include "hal/Value.h"
|
||||
#include "hal/handles/UnlimitedHandleResource.h"
|
||||
#include "hal/simulation/NotifyListener.h"
|
||||
#include "hal/simulation/SPIData.h"
|
||||
|
||||
namespace hal {
|
||||
namespace sim {
|
||||
class SpiReadAutoReceiveBufferCallbackStore {
|
||||
public:
|
||||
void create(JNIEnv* env, jobject obj);
|
||||
int32_t performCallback(const char* name, uint32_t* buffer,
|
||||
int32_t numToRead);
|
||||
void free(JNIEnv* env);
|
||||
void setCallbackId(int32_t id) { callbackId = id; }
|
||||
int32_t getCallbackId() { return callbackId; }
|
||||
|
||||
private:
|
||||
wpi::java::JGlobal<jobject> m_call;
|
||||
int32_t callbackId;
|
||||
};
|
||||
|
||||
void InitializeSpiBufferStore();
|
||||
|
||||
typedef int32_t (*RegisterSpiBufferCallbackFunc)(
|
||||
int32_t index, HAL_SpiReadAutoReceiveBufferCallback callback, void* param);
|
||||
typedef void (*FreeSpiBufferCallbackFunc)(int32_t index, int32_t uid);
|
||||
|
||||
SIM_JniHandle AllocateSpiBufferCallback(
|
||||
JNIEnv* env, jint index, jobject callback,
|
||||
RegisterSpiBufferCallbackFunc createCallback);
|
||||
void FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
|
||||
FreeSpiBufferCallbackFunc freeCallback);
|
||||
} // namespace sim
|
||||
} // namespace hal
|
||||
Reference in New Issue
Block a user