Adds JNI Simulator interface and updated Sim API (#1002)

The simulator was generated by https://github.com/ThadHouse/SimulatorGenerator
This commit is contained in:
Thad House
2018-05-11 12:38:23 -07:00
committed by Peter Johnson
parent 1046371349
commit 337e89cf6e
96 changed files with 8204 additions and 26 deletions

View File

@@ -0,0 +1,13 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "Simulation/CallbackStore.h"
void frc::sim::CallbackStoreThunk(const char* name, void* param,
const HAL_Value* value) {
reinterpret_cast<CallbackStore*>(param)->callback(name, value);
}

View File

@@ -0,0 +1,161 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/AccelerometerData.h"
#include "edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerActiveCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerActiveCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelActiveCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerActiveCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getActive(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAccelerometerActive(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setActive(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAccelerometerActive(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerRangeCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerRangeCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelRangeCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerRangeCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getRange(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAccelerometerRange(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setRange(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetAccelerometerRange(index,
static_cast<HAL_AccelerometerRange>(value));
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerXCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerXCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelXCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerXCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getX(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerX(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setX(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerX(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerYCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerYCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelYCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerYCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getY(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerY(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setY(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerY(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_registerZCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAccelerometerZCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_cancelZCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAccelerometerZCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_getZ(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAccelerometerZ(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_setZ(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAccelerometerZ(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI_resetData(JNIEnv*,
jclass,
jint index) {
HALSIM_ResetAccelerometerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,102 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/AnalogGyroData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerAngleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroAngleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelAngleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroAngleCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getAngle(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogGyroAngle(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setAngle(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogGyroAngle(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerRateCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroRateCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelRateCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroRateCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getRate(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogGyroRate(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setRate(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogGyroRate(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogGyroInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogGyroInitialized(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogGyroData(index);
}
} // extern "C"

View File

@@ -0,0 +1,266 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/AnalogInData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getInitialized(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAnalogInInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogInInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAverageBitsCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAverageBitsCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAverageBitsCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAverageBitsCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAverageBits(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetAnalogInAverageBits(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAverageBits(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetAnalogInAverageBits(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerOversampleBitsCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInOversampleBitsCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelOversampleBitsCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInOversampleBitsCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getOversampleBits(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInOversampleBits(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setOversampleBits(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInOversampleBits(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogInVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogInVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogInAccumulatorInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogInAccumulatorInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorValueCallback);
}
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorValue(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorValue(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorValue(
JNIEnv*, jclass, jint index, jlong value) {
HALSIM_SetAnalogInAccumulatorValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorCountCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCountCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorCountCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCountCallback);
}
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorCount(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorCount(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorCount(
JNIEnv*, jclass, jint index, jlong value) {
HALSIM_SetAnalogInAccumulatorCount(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorCenterCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCenterCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorCenterCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCenterCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorCenter(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorCenter(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorCenter(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInAccumulatorCenter(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_registerAccumulatorDeadbandCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorDeadbandCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_cancelAccumulatorDeadbandCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_getAccumulatorDeadband(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogInAccumulatorDeadband(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_setAccumulatorDeadband(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetAnalogInAccumulatorDeadband(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogInData(index);
}
} // extern "C"

View File

@@ -0,0 +1,75 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/AnalogOutData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogOutVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogOutVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetAnalogOutVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetAnalogOutVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogOutInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogOutInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogOutInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogOutInitialized(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetAnalogOutData(index);
}
} // extern "C"

View File

@@ -0,0 +1,104 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/AnalogTriggerData.h"
#include "edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogTriggerInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetAnalogTriggerInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerTriggerLowerBoundCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelTriggerLowerBoundCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getTriggerLowerBound(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerTriggerLowerBound(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setTriggerLowerBound(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetAnalogTriggerTriggerLowerBound(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_registerTriggerUpperBoundCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_cancelTriggerUpperBoundCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_getTriggerUpperBound(
JNIEnv*, jclass, jint index) {
return HALSIM_GetAnalogTriggerTriggerUpperBound(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_setTriggerUpperBound(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetAnalogTriggerTriggerUpperBound(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI_resetData(JNIEnv*,
jclass,
jint index) {
HALSIM_ResetAnalogTriggerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,124 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
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);
}

View File

@@ -0,0 +1,44 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
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

View File

@@ -0,0 +1,193 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
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);
}

View File

@@ -0,0 +1,65 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
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

View File

@@ -0,0 +1,116 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace sim {
void InitializeConstBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
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);
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
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

View File

@@ -0,0 +1,153 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/DIOData.h"
#include "edu_wpi_first_hal_sim_mockdata_DIODataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetDIOInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index, &HALSIM_CancelDIOValueCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getValue(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOValue(index);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setValue(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetDIOValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerPulseLengthCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOPulseLengthCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelPulseLengthCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOPulseLengthCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getPulseLength(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOPulseLength(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setPulseLength(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetDIOPulseLength(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerIsInputCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOIsInputCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelIsInputCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOIsInputCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getIsInput(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOIsInput(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setIsInput(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetDIOIsInput(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_registerFilterIndexCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDIOFilterIndexCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_cancelFilterIndexCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDIOFilterIndexCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_getFilterIndex(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDIOFilterIndex(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_setFilterIndex(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetDIOFilterIndex(index, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_DIODataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetDIOData(index);
}
} // extern "C"

View File

@@ -0,0 +1,102 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/DigitalPWMData.h"
#include "edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetDigitalPWMInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetDigitalPWMInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerDutyCycleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMDutyCycleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelDutyCycleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMDutyCycleCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getDutyCycle(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetDigitalPWMDutyCycle(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setDutyCycle(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetDigitalPWMDutyCycle(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_registerPinCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterDigitalPWMPinCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_cancelPinCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelDigitalPWMPinCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_getPin(JNIEnv*, jclass,
jint index) {
return HALSIM_GetDigitalPWMPin(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_setPin(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetDigitalPWMPin(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetDigitalPWMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,283 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/DriverStationData.h"
#include "edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerEnabledCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationEnabledCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelEnabledCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationEnabledCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getEnabled(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationEnabled();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setEnabled(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationEnabled(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerAutonomousCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationAutonomousCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelAutonomousCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationAutonomousCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getAutonomous(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationAutonomous();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setAutonomous(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationAutonomous(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerTestCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify, &HALSIM_RegisterDriverStationTestCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelTestCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationTestCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getTest(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationTest();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setTest(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationTest(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerEStopCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify, &HALSIM_RegisterDriverStationEStopCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelEStopCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelDriverStationEStopCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getEStop(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationEStop();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setEStop(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationEStop(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerFmsAttachedCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationFmsAttachedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelFmsAttachedCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationFmsAttachedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getFmsAttached(
JNIEnv*, jclass) {
return HALSIM_GetDriverStationFmsAttached();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setFmsAttached(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationFmsAttached(value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_registerDsAttachedCallback(
JNIEnv* env, jclass, jobject callback, jboolean initialNotify) {
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterDriverStationDsAttachedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_cancelDsAttachedCallback(
JNIEnv* env, jclass, jint handle) {
return sim::FreeCallbackNoIndex(
env, handle, &HALSIM_CancelDriverStationDsAttachedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_getDsAttached(JNIEnv*,
jclass) {
return HALSIM_GetDriverStationDsAttached();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setDsAttached(
JNIEnv*, jclass, jboolean value) {
HALSIM_SetDriverStationDsAttached(value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: setJoystickAxes
* Signature: (B[F)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_DriverStationSim
* Method: setJoystickPOVs
* Signature: (B[S)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_DriverStationSim
* Method: setJoystickButtons
* Signature: (BII)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_DriverStationSim
* Method: setMatchInfo
* Signature: (Ledu/wpi/first/wpilibj/hal/MatchInfoData;)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_setMatchInfo(
JNIEnv* env, jclass, jobject info) {}
/*
* Class: edu_wpi_first_hal_sim_mockdata_DriverStationSim
* Method: registerAllCallbacks
* Signature: (Ledu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_DriverStationSim
* Method: notifyNewData
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_notifyNewData(JNIEnv*,
jclass) {
HALSIM_NotifyDriverStationNewData();
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_DriverStationDataJNI_resetData(JNIEnv*,
jclass) {
HALSIM_ResetDriverStationData();
}
} // extern "C"

View File

@@ -0,0 +1,235 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/EncoderData.h"
#include "edu_wpi_first_hal_sim_mockdata_EncoderDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getInitialized(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetEncoderInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerCountCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderCountCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelCountCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderCountCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getCount(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderCount(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setCount(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetEncoderCount(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerPeriodCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderPeriodCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelPeriodCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderPeriodCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getPeriod(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderPeriod(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setPeriod(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetEncoderPeriod(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerResetCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderResetCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelResetCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderResetCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getReset(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderReset(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setReset(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetEncoderReset(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerMaxPeriodCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderMaxPeriodCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelMaxPeriodCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderMaxPeriodCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getMaxPeriod(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderMaxPeriod(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setMaxPeriod(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetEncoderMaxPeriod(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerDirectionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderDirectionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelDirectionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderDirectionCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getDirection(JNIEnv*, jclass,
jint index) {
return HALSIM_GetEncoderDirection(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setDirection(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderDirection(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerReverseDirectionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderReverseDirectionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelReverseDirectionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderReverseDirectionCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getReverseDirection(
JNIEnv*, jclass, jint index) {
return HALSIM_GetEncoderReverseDirection(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setReverseDirection(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetEncoderReverseDirection(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_registerSamplesToAverageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterEncoderSamplesToAverageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_cancelSamplesToAverageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelEncoderSamplesToAverageCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_getSamplesToAverage(
JNIEnv*, jclass, jint index) {
return HALSIM_GetEncoderSamplesToAverage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_setSamplesToAverage(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetEncoderSamplesToAverage(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_EncoderDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetEncoderData(index);
}
} // extern "C"

View File

@@ -0,0 +1,124 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/I2CData.h"
#include "edu_wpi_first_hal_sim_mockdata_I2CDataJNI.h"
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerInitializedCallback
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_I2CSim
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelI2CInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetI2CInitialized(index);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetI2CInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerReadCallback
* Signature: (ILedu/wpi/first/hal/sim/BufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_registerReadCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateBufferCallback(env, index, callback,
&HALSIM_RegisterI2CReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: cancelReadCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelReadCallback(JNIEnv* env,
jclass,
jint index,
jint handle) {
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelI2CReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: registerWriteCallback
* Signature: (ILedu/wpi/first/hal/sim/ConstBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_registerWriteCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateConstBufferCallback(env, index, callback,
&HALSIM_RegisterI2CWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: cancelWriteCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_cancelWriteCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeConstBufferCallback(env, handle, index,
&HALSIM_CancelI2CWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_I2CSim
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_I2CDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetI2CData(index);
}
} // extern "C"

View File

@@ -0,0 +1,246 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/PCMData.h"
#include "edu_wpi_first_hal_sim_mockdata_PCMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerSolenoidInitializedCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
&HALSIM_RegisterPCMSolenoidInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelSolenoidInitializedCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPCMSolenoidInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getSolenoidInitialized(
JNIEnv*, jclass, jint index, jint channel) {
return HALSIM_GetPCMSolenoidInitialized(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setSolenoidInitialized(
JNIEnv*, jclass, jint index, jint channel, jboolean value) {
HALSIM_SetPCMSolenoidInitialized(index, channel, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerSolenoidOutputCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
&HALSIM_RegisterPCMSolenoidOutputCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelSolenoidOutputCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPCMSolenoidOutputCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getSolenoidOutput(JNIEnv*,
jclass,
jint index,
jint channel) {
return HALSIM_GetPCMSolenoidOutput(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setSolenoidOutput(
JNIEnv*, jclass, jint index, jint channel, jboolean value) {
HALSIM_SetPCMSolenoidOutput(index, channel, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorInitialized(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMCompressorInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorInitialized(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMCompressorInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorOnCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorOnCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorOnCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorOnCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorOn(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPCMCompressorOn(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorOn(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPCMCompressorOn(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerClosedLoopEnabledCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMClosedLoopEnabledCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelClosedLoopEnabledCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMClosedLoopEnabledCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getClosedLoopEnabled(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMClosedLoopEnabled(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setClosedLoopEnabled(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMClosedLoopEnabled(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerPressureSwitchCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMPressureSwitchCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelPressureSwitchCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMPressureSwitchCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getPressureSwitch(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetPCMPressureSwitch(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setPressureSwitch(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetPCMPressureSwitch(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_registerCompressorCurrentCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPCMCompressorCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_cancelCompressorCurrentCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPCMCompressorCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_getCompressorCurrent(
JNIEnv*, jclass, jint index) {
return HALSIM_GetPCMCompressorCurrent(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_setCompressorCurrent(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetPCMCompressorCurrent(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_PCMSim
* Method: registerAllNonSolenoidCallbacks
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_PCMSim
* Method: registerAllSolenoidCallbacks
* Signature: (IILedu/wpi/first/hal/sim/NotifyCallback;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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;
});
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PCMDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPCMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,133 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/PDPData.h"
#include "edu_wpi_first_hal_sim_mockdata_PDPDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPDPInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerTemperatureCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPTemperatureCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelTemperatureCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPTemperatureCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getTemperature(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPTemperature(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setTemperature(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPDPTemperature(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPDPVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPDPVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getVoltage(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPDPVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setVoltage(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPDPVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_registerCurrentCallback(
JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify) {
return sim::AllocateChannelCallback(env, index, channel, callback,
initialNotify,
&HALSIM_RegisterPDPCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_cancelCurrentCallback(
JNIEnv* env, jclass, jint index, jint channel, jint handle) {
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelPDPCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_getCurrent(JNIEnv*, jclass,
jint index,
jint channel) {
return HALSIM_GetPDPCurrent(index, channel);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_setCurrent(JNIEnv*, jclass,
jint index,
jint channel,
jdouble value) {
HALSIM_SetPDPCurrent(index, channel, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PDPDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPDPData(index);
}
} // extern "C"

View File

@@ -0,0 +1,180 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/PWMData.h"
#include "edu_wpi_first_hal_sim_mockdata_PWMDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerInitializedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMInitializedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMInitializedCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMInitialized(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPWMInitialized(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerRawValueCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMRawValueCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelRawValueCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMRawValueCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getRawValue(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMRawValue(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setRawValue(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetPWMRawValue(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerSpeedCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMSpeedCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelSpeedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index, &HALSIM_CancelPWMSpeedCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getSpeed(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMSpeed(index);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setSpeed(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetPWMSpeed(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerPositionCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMPositionCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelPositionCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMPositionCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getPosition(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMPosition(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setPosition(JNIEnv*, jclass,
jint index,
jdouble value) {
HALSIM_SetPWMPosition(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerPeriodScaleCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMPeriodScaleCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelPeriodScaleCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMPeriodScaleCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getPeriodScale(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMPeriodScale(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setPeriodScale(JNIEnv*, jclass,
jint index,
jint value) {
HALSIM_SetPWMPeriodScale(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_registerZeroLatchCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterPWMZeroLatchCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_cancelZeroLatchCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelPWMZeroLatchCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_getZeroLatch(JNIEnv*, jclass,
jint index) {
return HALSIM_GetPWMZeroLatch(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_setZeroLatch(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetPWMZeroLatch(index, value);
}
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_PWMDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetPWMData(index);
}
} // extern "C"

View File

@@ -0,0 +1,128 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/RelayData.h"
#include "edu_wpi_first_hal_sim_mockdata_RelayDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerInitializedForwardCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayInitializedForwardCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelInitializedForwardCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayInitializedForwardCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getInitializedForward(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRelayInitializedForward(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setInitializedForward(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRelayInitializedForward(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerInitializedReverseCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayInitializedReverseCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelInitializedReverseCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayInitializedReverseCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getInitializedReverse(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRelayInitializedReverse(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setInitializedReverse(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRelayInitializedReverse(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerForwardCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayForwardCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelForwardCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayForwardCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getForward(JNIEnv*, jclass,
jint index) {
return HALSIM_GetRelayForward(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setForward(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetRelayForward(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_registerReverseCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRelayReverseCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_cancelReverseCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRelayReverseCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_getReverse(JNIEnv*, jclass,
jint index) {
return HALSIM_GetRelayReverse(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_setReverse(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetRelayReverse(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RelayDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetRelayData(index);
}
} // extern "C"

View File

@@ -0,0 +1,423 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/RoboRioData.h"
#include "edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerFPGAButtonCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioFPGAButtonCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelFPGAButtonCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioFPGAButtonCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getFPGAButton(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioFPGAButton(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setFPGAButton(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioFPGAButton(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerVInVoltageCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioVInVoltageCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelVInVoltageCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioVInVoltageCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getVInVoltage(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioVInVoltage(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setVInVoltage(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioVInVoltage(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerVInCurrentCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioVInCurrentCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelVInCurrentCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioVInCurrentCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getVInCurrent(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioVInCurrent(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setVInCurrent(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioVInCurrent(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage6VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage6V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage6V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent6VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent6V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent6V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive6VCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive6V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserActive6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive6V(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage5VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage5V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage5V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent5VCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent5V(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent5V(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive5VCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive5V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserActive5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive5V(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserVoltage3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserVoltage3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserVoltage3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserVoltage3V3Callback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserVoltage3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserVoltage3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserVoltage3V3(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserVoltage3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserCurrent3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserCurrent3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserCurrent3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserCurrent3V3Callback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserCurrent3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserCurrent3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserCurrent3V3(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetRoboRioUserCurrent3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserActive3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserActive3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserActive3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserActive3V3Callback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserActive3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserActive3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserActive3V3(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetRoboRioUserActive3V3(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults6VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults6VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults6VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults6VCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults6V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserFaults6V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults6V(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetRoboRioUserFaults6V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults5VCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults5VCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults5VCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults5VCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults5V(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetRoboRioUserFaults5V(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults5V(JNIEnv*,
jclass,
jint index,
jint value) {
HALSIM_SetRoboRioUserFaults5V(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_registerUserFaults3V3Callback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterRoboRioUserFaults3V3Callback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_cancelUserFaults3V3Callback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelRoboRioUserFaults3V3Callback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_getUserFaults3V3(
JNIEnv*, jclass, jint index) {
return HALSIM_GetRoboRioUserFaults3V3(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_setUserFaults3V3(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetRoboRioUserFaults3V3(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI_resetData(JNIEnv*, jclass,
jint index) {
HALSIM_ResetRoboRioData(index);
}
} // extern "C"

View File

@@ -0,0 +1,155 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/SPIAccelerometerData.h"
#include "edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI.h"
extern "C" {
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerActiveCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerActiveCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelActiveCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerActiveCallback);
}
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getActive(
JNIEnv*, jclass, jint index) {
return HALSIM_GetSPIAccelerometerActive(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setActive(
JNIEnv*, jclass, jint index, jboolean value) {
HALSIM_SetSPIAccelerometerActive(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerRangeCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerRangeCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelRangeCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerRangeCallback);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getRange(
JNIEnv*, jclass, jint index) {
return HALSIM_GetSPIAccelerometerRange(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setRange(
JNIEnv*, jclass, jint index, jint value) {
HALSIM_SetSPIAccelerometerRange(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerXCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerXCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelXCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerXCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getX(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerX(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setX(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerX(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerYCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerYCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelYCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerYCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getY(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerY(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setY(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerY(index, value);
}
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_registerZCallback(
JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify) {
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterSPIAccelerometerZCallback);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_cancelZCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIAccelerometerZCallback);
}
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_getZ(JNIEnv*,
jclass,
jint index) {
return HALSIM_GetSPIAccelerometerZ(index);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_setZ(
JNIEnv*, jclass, jint index, jdouble value) {
HALSIM_SetSPIAccelerometerZ(index, value);
}
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetSPIAccelerometerData(index);
}
} // extern "C"

View File

@@ -0,0 +1,149 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "MockData/SPIData.h"
#include "SpiReadAutoReceiveBufferCallbackStore.h"
#include "edu_wpi_first_hal_sim_mockdata_SPIDataJNI.h"
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerInitializedCallback
* Signature: (ILedu/wpi/first/hal/sim/NotifyCallback;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_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_sim_mockdata_SPISim
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelInitializedCallback(
JNIEnv* env, jclass, jint index, jint handle) {
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelSPIInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_getInitialized(JNIEnv*, jclass,
jint index) {
return HALSIM_GetSPIInitialized(index);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_setInitialized(JNIEnv*, jclass,
jint index,
jboolean value) {
HALSIM_SetSPIInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerReadCallback
* Signature: (ILedu/wpi/first/hal/sim/BufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerReadCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateBufferCallback(env, index, callback,
&HALSIM_RegisterSPIReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelReadCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelReadCallback(JNIEnv* env,
jclass,
jint index,
jint handle) {
sim::FreeBufferCallback(env, handle, index, &HALSIM_CancelSPIReadCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerWriteCallback
* Signature: (ILedu/wpi/first/hal/sim/ConstBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerWriteCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateConstBufferCallback(env, index, callback,
&HALSIM_RegisterSPIWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelWriteCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelWriteCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeConstBufferCallback(env, handle, index,
&HALSIM_CancelSPIWriteCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: registerReadAutoReceiveBufferCallback
* Signature: (ILedu/wpi/first/hal/sim/SpiReadAutoReceiveBufferCallback;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_registerReadAutoReceiveBufferCallback(
JNIEnv* env, jclass, jint index, jobject callback) {
return sim::AllocateSpiBufferCallback(
env, index, callback, &HALSIM_RegisterSPIReadAutoReceivedDataCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: cancelReadAutoReceiveBufferCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_cancelReadAutoReceiveBufferCallback(
JNIEnv* env, jclass, jint index, jint handle) {
sim::FreeSpiBufferCallback(env, handle, index,
&HALSIM_CancelSPIReadAutoReceivedDataCallback);
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SPISim
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_hal_sim_mockdata_SPIDataJNI_resetData(
JNIEnv*, jclass, jint index) {
HALSIM_ResetSPIData(index);
}
} // extern "C"

View File

@@ -0,0 +1,151 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "CallbackStore.h"
#include "ConstBufferCallbackStore.h"
#include "HAL/HAL.h"
#include "HAL/cpp/Log.h"
#include "HAL/handles/HandlesInternal.h"
#include "MockData/MockHooks.h"
#include "SimulatorJNI.h"
#include "SpiReadAutoReceiveBufferCallbackStore.h"
#include "edu_wpi_first_hal_sim_mockdata_SimulatorJNI.h"
using namespace wpi::java;
static JavaVM* jvm = nullptr;
static JClass simValueCls;
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 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;
simValueCls = JClass(env, "edu/wpi/first/wpilibj/sim/SimValue");
if (!simValueCls) return JNI_ERR;
notifyCallbackCls = JClass(env, "edu/wpi/first/wpilibj/sim/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/wpilibj/sim/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/wpilibj/sim/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/wpilibj/sim/SpiReadAutoReceiveBufferCallback");
if (!spiReadAutoReceiveBufferCallbackCls) return JNI_ERR;
spiReadAutoReceiveBufferCallbackCallback =
env->GetMethodID(spiReadAutoReceiveBufferCallbackCls, "callback",
"(Ljava/lang/String;[BI)I");
if (!spiReadAutoReceiveBufferCallbackCallback) return JNI_ERR;
InitializeStore();
InitializeBufferStore();
InitializeConstBufferStore();
InitializeSpiBufferStore();
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;
simValueCls.free(env);
notifyCallbackCls.free(env);
bufferCallbackCls.free(env);
constBufferCallbackCls.free(env);
spiReadAutoReceiveBufferCallbackCls.free(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
extern "C" {
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: waitForProgramStart
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_waitForProgramStart(JNIEnv*,
jclass) {
HALSIM_WaitForProgramStart();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: setProgramStarted
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_setProgramStarted(JNIEnv*,
jclass) {
HALSIM_SetProgramStarted();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: restartTiming
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_restartTiming(JNIEnv*,
jclass) {
HALSIM_RestartTiming();
}
/*
* Class: edu_wpi_first_hal_sim_mockdata_SimulatorJNI
* Method: resetHandles
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_sim_mockdata_SimulatorJNI_resetHandles(JNIEnv*, jclass) {
hal::HandleBase::ResetGlobalHandles();
}
} // extern "C"

View File

@@ -0,0 +1,25 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 <wpi/jni_util.h>
#include "HAL/Types.h"
#include "MockData/HAL_Value.h"
#include "jni.h"
typedef HAL_Handle SIM_JniHandle;
namespace sim {
JavaVM* GetJVM();
jmethodID GetNotifyCallback();
jmethodID GetBufferCallback();
jmethodID GetConstBufferCallback();
jmethodID GetSpiReadAutoReceiveBufferCallback();
} // namespace sim

View File

@@ -0,0 +1,130 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "SimulatorJNI.h"
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<
SIM_JniHandle, SpiReadAutoReceiveBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
namespace sim {
void InitializeSpiBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle,
SpiReadAutoReceiveBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>
cb;
callbackHandles = &cb;
}
} // namespace sim
void SpiReadAutoReceiveBufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);
}
int32_t SpiReadAutoReceiveBufferCallbackStore::performCallback(
const char* name, unsigned char* 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 =
MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
static_cast<size_t>(numToRead)});
jint ret = env->CallIntMethod(m_call, sim::GetBufferCallback(),
MakeJString(env, name), toCallbackArr,
(jint)numToRead);
jbyte* fromCallbackArr = reinterpret_cast<jbyte*>(
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, unsigned char* 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);
}

View File

@@ -0,0 +1,46 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 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 "HAL/Types.h"
#include "HAL/handles/UnlimitedHandleResource.h"
#include "MockData/HAL_Value.h"
#include "MockData/NotifyListener.h"
#include "MockData/SPIData.h"
#include "SimulatorJNI.h"
namespace sim {
class SpiReadAutoReceiveBufferCallbackStore {
public:
void create(JNIEnv* env, jobject obj);
int32_t performCallback(const char* name, unsigned char* 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

View File

@@ -1,23 +0,0 @@
// This will be removed when new sim is added in
#include <jni.h>
static JavaVM* jvm = nullptr;
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;
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;
jvm = nullptr;
}
}