[hal, wpilib] Remove analog accumulator and analog gyro (#7697)

The 2 high level classes were temporarily kept to keep the examples compiling. We will remove those when we have the interface into the built in IMU.
This commit is contained in:
Thad House
2025-01-17 12:58:31 -08:00
committed by GitHub
parent 92f0a3c961
commit f80874dd4b
76 changed files with 33 additions and 3886 deletions

View File

@@ -1,196 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include <cassert>
#include <wpi/jni_util.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_AnalogGyroJNI.h"
#include "hal/AnalogGyro.h"
#include "hal/handles/HandlesInternal.h"
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: initializeAnalogGyro
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_initializeAnalogGyro
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
HAL_GyroHandle handle = HAL_InitializeAnalogGyro((HAL_AnalogInputHandle)id,
stack.c_str(), &status);
// Analog input does range checking, so we don't need to do so.
CheckStatusForceThrow(env, status);
return (jint)handle;
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: setupAnalogGyro
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_setupAnalogGyro
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_SetupAnalogGyro((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: freeAnalogGyro
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_freeAnalogGyro
(JNIEnv* env, jclass, jint id)
{
if (id != HAL_kInvalidHandle) {
HAL_FreeAnalogGyro((HAL_GyroHandle)id);
}
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: setAnalogGyroParameters
* Signature: (IDDI)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_setAnalogGyroParameters
(JNIEnv* env, jclass, jint id, jdouble vPDPS, jdouble offset, jint center)
{
int32_t status = 0;
HAL_SetAnalogGyroParameters((HAL_GyroHandle)id, vPDPS, offset, center,
&status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: setAnalogGyroVoltsPerDegreePerSecond
* Signature: (ID)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_setAnalogGyroVoltsPerDegreePerSecond
(JNIEnv* env, jclass, jint id, jdouble vPDPS)
{
int32_t status = 0;
HAL_SetAnalogGyroVoltsPerDegreePerSecond((HAL_GyroHandle)id, vPDPS, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: resetAnalogGyro
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_resetAnalogGyro
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_ResetAnalogGyro((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: calibrateAnalogGyro
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_calibrateAnalogGyro
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_CalibrateAnalogGyro((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: setAnalogGyroDeadband
* Signature: (ID)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_setAnalogGyroDeadband
(JNIEnv* env, jclass, jint id, jdouble deadband)
{
int32_t status = 0;
HAL_SetAnalogGyroDeadband((HAL_GyroHandle)id, deadband, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: getAnalogGyroAngle
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_getAnalogGyroAngle
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jdouble value = HAL_GetAnalogGyroAngle((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
return value;
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: getAnalogGyroRate
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_getAnalogGyroRate
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jdouble value = HAL_GetAnalogGyroRate((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
return value;
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: getAnalogGyroOffset
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_getAnalogGyroOffset
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jdouble value = HAL_GetAnalogGyroOffset((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
return value;
}
/*
* Class: edu_wpi_first_hal_AnalogGyroJNI
* Method: getAnalogGyroCenter
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogGyroJNI_getAnalogGyroCenter
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jint value = HAL_GetAnalogGyroCenter((HAL_GyroHandle)id, &status);
CheckStatus(env, status);
return value;
}
} // extern "C"

View File

@@ -10,7 +10,6 @@
#include "HALUtil.h"
#include "edu_wpi_first_hal_AnalogJNI.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogInput.h"
#include "hal/AnalogTrigger.h"
#include "hal/Ports.h"
@@ -306,129 +305,6 @@ Java_edu_wpi_first_hal_AnalogJNI_getAnalogOffset
return returnValue;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: isAccumulatorChannel
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_AnalogJNI_isAccumulatorChannel
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jboolean returnValue =
HAL_IsAccumulatorChannel((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
return returnValue;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: initAccumulator
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_initAccumulator
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_InitAccumulator((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: resetAccumulator
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_resetAccumulator
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_ResetAccumulator((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: setAccumulatorCenter
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_setAccumulatorCenter
(JNIEnv* env, jclass, jint id, jint center)
{
int32_t status = 0;
HAL_SetAccumulatorCenter((HAL_AnalogInputHandle)id, center, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: setAccumulatorDeadband
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_setAccumulatorDeadband
(JNIEnv* env, jclass, jint id, jint deadband)
{
int32_t status = 0;
HAL_SetAccumulatorDeadband((HAL_AnalogInputHandle)id, deadband, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: getAccumulatorValue
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_AnalogJNI_getAccumulatorValue
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jlong returnValue =
HAL_GetAccumulatorValue((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
return returnValue;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: getAccumulatorCount
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogJNI_getAccumulatorCount
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
jint returnValue =
HAL_GetAccumulatorCount((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
return returnValue;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: getAccumulatorOutput
* Signature: (ILjava/lang/Object;)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_getAccumulatorOutput
(JNIEnv* env, jclass, jint id, jobject accumulatorResult)
{
int32_t status = 0;
int64_t value = 0;
int64_t count = 0;
HAL_GetAccumulatorOutput((HAL_AnalogInputHandle)id, &value, &count, &status);
SetAccumulatorResultObject(env, accumulatorResult, value, count);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: initializeAnalogTrigger

View File

@@ -51,7 +51,6 @@ static JClass powerDistributionVersionCls;
static JClass pwmConfigDataResultCls;
static JClass canStatusCls;
static JClass matchInfoDataCls;
static JClass accumulatorResultCls;
static JClass canDataCls;
static JClass canStreamMessageCls;
static JClass halValueCls;
@@ -65,7 +64,6 @@ static const JClassInit classes[] = {
{"edu/wpi/first/hal/PWMConfigDataResult", &pwmConfigDataResultCls},
{"edu/wpi/first/hal/can/CANStatus", &canStatusCls},
{"edu/wpi/first/hal/MatchInfoData", &matchInfoDataCls},
{"edu/wpi/first/hal/AccumulatorResult", &accumulatorResultCls},
{"edu/wpi/first/hal/CANData", &canDataCls},
{"edu/wpi/first/hal/CANStreamMessage", &canStreamMessageCls},
{"edu/wpi/first/hal/HALValue", &halValueCls},
@@ -306,15 +304,6 @@ void SetMatchInfoObject(JNIEnv* env, jobject matchStatus,
static_cast<jint>(matchInfo.matchType));
}
void SetAccumulatorResultObject(JNIEnv* env, jobject accumulatorResult,
int64_t value, int64_t count) {
static jmethodID func =
env->GetMethodID(accumulatorResultCls, "set", "(JJ)V");
env->CallVoidMethod(accumulatorResult, func, static_cast<jlong>(value),
static_cast<jlong>(count));
}
jbyteArray SetCANDataObject(JNIEnv* env, jobject canData, int32_t length,
uint64_t timestamp) {
static jmethodID func = env->GetMethodID(canDataCls, "setData", "(IJ)[B");

View File

@@ -75,9 +75,6 @@ void SetCanStatusObject(JNIEnv* env, jobject canStatus,
void SetMatchInfoObject(JNIEnv* env, jobject matchStatus,
const HAL_MatchInfo& matchInfo);
void SetAccumulatorResultObject(JNIEnv* env, jobject accumulatorResult,
int64_t value, int64_t count);
jbyteArray SetCANDataObject(JNIEnv* env, jobject canData, int32_t length,
uint64_t timestamp);

View File

@@ -13,19 +13,6 @@
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_PortsJNI
* Method: getNumAccumulators
* Signature: ()I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_PortsJNI_getNumAccumulators
(JNIEnv* env, jclass)
{
jint value = HAL_GetNumAccumulators();
return value;
}
/*
* Class: edu_wpi_first_hal_PortsJNI
* Method: getNumAnalogTriggers

View File

@@ -1,177 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include "CallbackStore.h"
#include "edu_wpi_first_hal_simulation_AnalogGyroDataJNI.h"
#include "hal/simulation/AnalogGyroData.h"
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: registerAngleCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerAngleCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroAngleCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: cancelAngleCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelAngleCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroAngleCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: getAngle
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getAngle
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogGyroAngle(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: setAngle
* Signature: (ID)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setAngle
(JNIEnv*, jclass, jint index, jdouble value)
{
HALSIM_SetAnalogGyroAngle(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: registerRateCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerRateCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroRateCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: cancelRateCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelRateCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroRateCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: getRate
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getRate
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogGyroRate(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: setRate
* Signature: (ID)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setRate
(JNIEnv*, jclass, jint index, jdouble value)
{
HALSIM_SetAnalogGyroRate(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: registerInitializedCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_registerInitializedCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterAnalogGyroInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_cancelInitializedCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogGyroInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_getInitialized
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogGyroInitialized(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_setInitialized
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetAnalogGyroInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogGyroDataJNI
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogGyroDataJNI_resetData
(JNIEnv*, jclass, jint index)
{
HALSIM_ResetAnalogGyroData(index);
}
} // extern "C"

View File

@@ -212,261 +212,6 @@ Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setVoltage
HALSIM_SetAnalogInVoltage(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: registerAccumulatorInitializedCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorInitializedCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: cancelAccumulatorInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorInitializedCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(
env, handle, index, &HALSIM_CancelAnalogInAccumulatorInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: getAccumulatorInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorInitialized
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogInAccumulatorInitialized(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: setAccumulatorInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorInitialized
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetAnalogInAccumulatorInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: registerAccumulatorValueCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorValueCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorValueCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: cancelAccumulatorValueCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorValueCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorValueCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: getAccumulatorValue
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorValue
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogInAccumulatorValue(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: setAccumulatorValue
* Signature: (IJ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorValue
(JNIEnv*, jclass, jint index, jlong value)
{
HALSIM_SetAnalogInAccumulatorValue(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: registerAccumulatorCountCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorCountCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCountCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: cancelAccumulatorCountCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorCountCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCountCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: getAccumulatorCount
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorCount
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogInAccumulatorCount(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: setAccumulatorCount
* Signature: (IJ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorCount
(JNIEnv*, jclass, jint index, jlong value)
{
HALSIM_SetAnalogInAccumulatorCount(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: registerAccumulatorCenterCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorCenterCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorCenterCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: cancelAccumulatorCenterCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorCenterCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorCenterCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: getAccumulatorCenter
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorCenter
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogInAccumulatorCenter(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: setAccumulatorCenter
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorCenter
(JNIEnv*, jclass, jint index, jint value)
{
HALSIM_SetAnalogInAccumulatorCenter(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: registerAccumulatorDeadbandCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_registerAccumulatorDeadbandCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(
env, index, callback, initialNotify,
&HALSIM_RegisterAnalogInAccumulatorDeadbandCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: cancelAccumulatorDeadbandCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_cancelAccumulatorDeadbandCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: getAccumulatorDeadband
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_getAccumulatorDeadband
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetAnalogInAccumulatorDeadband(index);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: setAccumulatorDeadband
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_AnalogInDataJNI_setAccumulatorDeadband
(JNIEnv*, jclass, jint index, jint value)
{
HALSIM_SetAnalogInAccumulatorDeadband(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_AnalogInDataJNI
* Method: resetData

View File

@@ -1,120 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <stdint.h>
#include "hal/Types.h"
/**
* @defgroup hal_analogaccumulator Analog Accumulator Functions
* @ingroup hal_capi
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Is the channel attached to an accumulator.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The analog channel is attached to an accumulator.
*/
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Initialize the accumulator.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Resets the accumulator to the initial value.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Set the center value of the accumulator.
*
* The center value is subtracted from each A/D value before it is added to the
* accumulator. This is used for the center value of devices like gyros and
* accelerometers to make integration work and to take the device offset into
* account when integrating.
*
* This center value is based on the output of the oversampled and averaged
* source from channel 1. Because of this, any non-zero oversample bits will
* affect the size of the value for this field.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] center The center value of the accumulator.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle,
int32_t center, int32_t* status);
/**
* Set the accumulator's deadband.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] deadband The deadband of the accumulator.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle,
int32_t deadband, int32_t* status);
/**
* Read the accumulated value.
*
* Read the value that has been accumulating on channel 1.
* The accumulator is attached after the oversample and average engine.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The 64-bit value accumulated since the last Reset().
*/
int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Read the number of accumulated values.
*
* Read the count of the accumulated values since the accumulator was last
* Reset().
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The number of times samples from the channel were accumulated.
*/
int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Read the accumulated value and the number of accumulated values atomically.
*
* This function reads the value and count from the FPGA atomically.
* This can be used for averaging.
*
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] value Pointer to the 64-bit accumulated output.
* @param[in] count Pointer to the number of accumulation cycles.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle,
int64_t* value, int64_t* count, int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */

View File

@@ -1,149 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <stdint.h>
#include "hal/Types.h"
/**
* @defgroup hal_analoggyro Analog Gyro Functions
* @ingroup hal_capi
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initializes an analog gyro.
*
* @param[in] handle handle to the analog input port
* @param[in] allocationLocation the location where the allocation is occurring
* (can be null)
* @param[out] status the error code, or 0 for success
* @return the initialized gyro handle
*/
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle,
const char* allocationLocation,
int32_t* status);
/**
* Sets up an analog gyro with the proper offsets and settings for the KOP
* analog gyro.
*
* @param[in] handle the gyro handle
* @param[out] status the error code, or 0 for success
*/
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status);
/**
* Frees an analog gyro.
*
* @param handle the gyro handle
*/
void HAL_FreeAnalogGyro(HAL_GyroHandle handle);
/**
* Sets the analog gyro parameters to the specified values.
*
* This is meant to be used if you want to reuse the values from a previous
* calibration.
*
* @param[in] handle the gyro handle
* @param[in] voltsPerDegreePerSecond the gyro volts scaling
* @param[in] offset the gyro offset
* @param[in] center the gyro center
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle,
double voltsPerDegreePerSecond, double offset,
int32_t center, int32_t* status);
/**
* Sets the analog gyro volts per degrees per second scaling.
*
* @param[in] handle the gyro handle
* @param[in] voltsPerDegreePerSecond the gyro volts scaling
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle,
double voltsPerDegreePerSecond,
int32_t* status);
/**
* Resets the analog gyro value to 0.
*
* @param[in] handle the gyro handle
* @param[out] status the error code, or 0 for success
*/
void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status);
/**
* Calibrates the analog gyro.
*
* This happens by calculating the average value of the gyro over 5 seconds, and
* setting that as the center. Note that this call blocks for 5 seconds to
* perform this.
*
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status);
/**
* Sets the deadband of the analog gyro.
*
* @param[in] handle the gyro handle
* @param[in] volts the voltage deadband
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts,
int32_t* status);
/**
* Gets the gyro angle in degrees.
*
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro angle in degrees
*/
double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status);
/**
* Gets the gyro rate in degrees/second.
*
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro rate in degrees/second
*/
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status);
/**
* Gets the calibrated gyro offset.
*
* Can be used to not repeat a calibration but reconstruct the gyro object.
*
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro offset
*/
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status);
/**
* Gets the calibrated gyro center.
*
* Can be used to not repeat a calibration but reconstruct the gyro object.
*
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro center
*/
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */

View File

@@ -7,8 +7,6 @@
#include <stdint.h>
#include "hal/Accelerometer.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogGyro.h"
#include "hal/AnalogInput.h"
#include "hal/AnalogTrigger.h"
#include "hal/CAN.h"

View File

@@ -16,13 +16,6 @@
extern "C" {
#endif
/**
* Gets the number of analog accumulators in the current system.
*
* @return the number of analog accumulators
*/
int32_t HAL_GetNumAccumulators(void);
/**
* Gets the number of analog triggers in the current system.
*

View File

@@ -1,44 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "hal/Types.h"
#include "hal/simulation/NotifyListener.h"
#ifdef __cplusplus
extern "C" {
#endif
void HALSIM_ResetAnalogGyroData(int32_t index);
int32_t HALSIM_RegisterAnalogGyroAngleCallback(int32_t index,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogGyroAngleCallback(int32_t index, int32_t uid);
double HALSIM_GetAnalogGyroAngle(int32_t index);
void HALSIM_SetAnalogGyroAngle(int32_t index, double angle);
int32_t HALSIM_RegisterAnalogGyroRateCallback(int32_t index,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogGyroRateCallback(int32_t index, int32_t uid);
double HALSIM_GetAnalogGyroRate(int32_t index);
void HALSIM_SetAnalogGyroRate(int32_t index, double rate);
int32_t HALSIM_RegisterAnalogGyroInitializedCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogGyroInitializedCallback(int32_t index, int32_t uid);
HAL_Bool HALSIM_GetAnalogGyroInitialized(int32_t index);
void HALSIM_SetAnalogGyroInitialized(int32_t index, HAL_Bool initialized);
void HALSIM_RegisterAnalogGyroAllCallbacks(int32_t index,
HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -45,48 +45,6 @@ void HALSIM_CancelAnalogInVoltageCallback(int32_t index, int32_t uid);
double HALSIM_GetAnalogInVoltage(int32_t index);
void HALSIM_SetAnalogInVoltage(int32_t index, double voltage);
int32_t HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogInAccumulatorInitializedCallback(int32_t index,
int32_t uid);
HAL_Bool HALSIM_GetAnalogInAccumulatorInitialized(int32_t index);
void HALSIM_SetAnalogInAccumulatorInitialized(int32_t index,
HAL_Bool accumulatorInitialized);
int32_t HALSIM_RegisterAnalogInAccumulatorValueCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogInAccumulatorValueCallback(int32_t index, int32_t uid);
int64_t HALSIM_GetAnalogInAccumulatorValue(int32_t index);
void HALSIM_SetAnalogInAccumulatorValue(int32_t index,
int64_t accumulatorValue);
int32_t HALSIM_RegisterAnalogInAccumulatorCountCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogInAccumulatorCountCallback(int32_t index, int32_t uid);
int64_t HALSIM_GetAnalogInAccumulatorCount(int32_t index);
void HALSIM_SetAnalogInAccumulatorCount(int32_t index,
int64_t accumulatorCount);
int32_t HALSIM_RegisterAnalogInAccumulatorCenterCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogInAccumulatorCenterCallback(int32_t index, int32_t uid);
int32_t HALSIM_GetAnalogInAccumulatorCenter(int32_t index);
void HALSIM_SetAnalogInAccumulatorCenter(int32_t index,
int32_t accumulatorCenter);
int32_t HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
int32_t index, HAL_NotifyCallback callback, void* param,
HAL_Bool initialNotify);
void HALSIM_CancelAnalogInAccumulatorDeadbandCallback(int32_t index,
int32_t uid);
int32_t HALSIM_GetAnalogInAccumulatorDeadband(int32_t index);
void HALSIM_SetAnalogInAccumulatorDeadband(int32_t index,
int32_t accumulatorDeadband);
void HALSIM_RegisterAnalogInAllCallbacks(int32_t index,
HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);

View File

@@ -1,109 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/AnalogAccumulator.h"
#include "AnalogInternal.h"
#include "mockdata/AnalogInDataInternal.h"
using namespace hal;
namespace hal::init {
void InitializeAnalogAccumulator() {}
} // namespace hal::init
extern "C" {
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return false;
}
for (int32_t i = 0; i < kNumAccumulators; i++) {
if (port->channel == kAccumulatorChannels[i]) {
return true;
}
}
return false;
}
void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
if (!HAL_IsAccumulatorChannel(analogPortHandle, status)) {
*status = HAL_INVALID_ACCUMULATOR_CHANNEL;
return;
}
SimAnalogInData[port->channel].accumulatorInitialized = true;
}
void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
SimAnalogInData[port->channel].accumulatorCenter = 0;
SimAnalogInData[port->channel].accumulatorCount = 0;
SimAnalogInData[port->channel].accumulatorValue = 0;
}
void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle,
int32_t center, int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
SimAnalogInData[port->channel].accumulatorCenter = center;
}
void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle,
int32_t deadband, int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
SimAnalogInData[port->channel].accumulatorDeadband = deadband;
}
int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
return SimAnalogInData[port->channel].accumulatorValue;
}
int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
return SimAnalogInData[port->channel].accumulatorCount;
}
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle,
int64_t* value, int64_t* count, int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
*count = SimAnalogInData[port->channel].accumulatorCount;
*value = SimAnalogInData[port->channel].accumulatorValue;
}
} // extern "C"

View File

@@ -1,151 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/AnalogGyro.h"
#include <string>
#include "HALInitializer.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/Errors.h"
#include "hal/handles/IndexedHandleResource.h"
#include "mockdata/AnalogGyroDataInternal.h"
namespace {
struct AnalogGyro {
HAL_AnalogInputHandle handle;
uint8_t index;
std::string previousAllocation;
};
} // namespace
using namespace hal;
static IndexedHandleResource<HAL_GyroHandle, AnalogGyro, kNumAccumulators,
HAL_HandleEnum::AnalogGyro>* analogGyroHandles;
namespace hal::init {
void InitializeAnalogGyro() {
static IndexedHandleResource<HAL_GyroHandle, AnalogGyro, kNumAccumulators,
HAL_HandleEnum::AnalogGyro>
agH;
analogGyroHandles = &agH;
}
} // namespace hal::init
extern "C" {
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle analogHandle,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
// Handle will be type checked by HAL_IsAccumulatorChannel
int16_t channel = getHandleIndex(analogHandle);
if (!HAL_IsAccumulatorChannel(analogHandle, status)) {
if (*status == 0) {
*status = HAL_INVALID_ACCUMULATOR_CHANNEL;
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
0, kNumAccumulators, channel);
}
return HAL_kInvalidHandle;
}
HAL_GyroHandle handle;
auto gyro = analogGyroHandles->Allocate(channel, &handle, status);
if (*status != 0) {
if (gyro) {
hal::SetLastErrorPreviouslyAllocated(status, "Analog Gyro", channel,
gyro->previousAllocation);
} else {
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Gyro",
0, kNumAccumulators, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
gyro->handle = analogHandle;
gyro->index = channel;
SimAnalogGyroData[channel].initialized = true;
gyro->previousAllocation = allocationLocation ? allocationLocation : "";
return handle;
}
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
// No op
}
void HAL_FreeAnalogGyro(HAL_GyroHandle handle) {
auto gyro = analogGyroHandles->Get(handle);
analogGyroHandles->Free(handle);
if (gyro == nullptr) {
return;
}
SimAnalogGyroData[gyro->index].initialized = false;
}
void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle,
double voltsPerDegreePerSecond, double offset,
int32_t center, int32_t* status) {
// No op
}
void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle,
double voltsPerDegreePerSecond,
int32_t* status) {
// No op
}
void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
auto gyro = analogGyroHandles->Get(handle);
if (gyro == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
SimAnalogGyroData[gyro->index].angle = 0.0;
}
void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
// Just do a reset
HAL_ResetAnalogGyro(handle, status);
}
void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts,
int32_t* status) {
// No op
}
double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status) {
auto gyro = analogGyroHandles->Get(handle);
if (gyro == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
return SimAnalogGyroData[gyro->index].angle;
}
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status) {
auto gyro = analogGyroHandles->Get(handle);
if (gyro == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
return SimAnalogGyroData[gyro->index].rate;
}
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status) {
return 0.0;
}
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status) {
return 0;
}
} // extern "C"

View File

@@ -8,7 +8,6 @@
#include "HALInitializer.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/handles/HandlesInternal.h"
#include "mockdata/AnalogInDataInternal.h"
@@ -46,14 +45,9 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
}
analog_port->channel = static_cast<uint8_t>(channel);
if (HAL_IsAccumulatorChannel(handle, status)) {
analog_port->isAccumulator = true;
} else {
analog_port->isAccumulator = false;
}
analog_port->isAccumulator = false;
SimAnalogInData[channel].initialized = true;
SimAnalogInData[channel].accumulatorInitialized = false;
SimAnalogInData[channel].simDevice = 0;
analog_port->previousAllocation =
@@ -69,7 +63,6 @@ void HAL_FreeAnalogInputPort(HAL_AnalogInputHandle analogPortHandle) {
return;
}
SimAnalogInData[port->channel].initialized = false;
SimAnalogInData[port->channel].accumulatorInitialized = false;
}
HAL_Bool HAL_CheckAnalogModule(int32_t module) {

View File

@@ -68,7 +68,6 @@ namespace hal::init {
void InitializeHAL() {
InitializeAccelerometerData();
InitializeAddressableLEDData();
InitializeAnalogGyroData();
InitializeAnalogInData();
InitializeAnalogTriggerData();
InitializeCanData();
@@ -87,8 +86,6 @@ void InitializeHAL() {
InitializeSimDeviceData();
InitializeAccelerometer();
InitializeAddressableLED();
InitializeAnalogAccumulator();
InitializeAnalogGyro();
InitializeAnalogInput();
InitializeAnalogInternal();
InitializeAnalogTrigger();

View File

@@ -18,7 +18,6 @@ inline void CheckInit() {
extern void InitializeAccelerometerData();
extern void InitializeAddressableLEDData();
extern void InitializeAnalogGyroData();
extern void InitializeAnalogInData();
extern void InitializeAnalogTriggerData();
extern void InitializeCanData();
@@ -38,8 +37,6 @@ extern void InitializeRoboRioData();
extern void InitializeSimDeviceData();
extern void InitializeAccelerometer();
extern void InitializeAddressableLED();
extern void InitializeAnalogAccumulator();
extern void InitializeAnalogGyro();
extern void InitializeAnalogInput();
extern void InitializeAnalogInternal();
extern void InitializeAnalogTrigger();

View File

@@ -13,9 +13,6 @@ void InitializePorts() {}
} // namespace hal::init
extern "C" {
int32_t HAL_GetNumAccumulators(void) {
return kNumAccumulators;
}
int32_t HAL_GetNumAnalogTriggers(void) {
return kNumAnalogTriggers;
}

View File

@@ -1,48 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "../PortsInternal.h"
#include "AnalogGyroDataInternal.h"
using namespace hal;
namespace hal::init {
void InitializeAnalogGyroData() {
static AnalogGyroData agd[kNumAccumulators];
::hal::SimAnalogGyroData = agd;
}
} // namespace hal::init
AnalogGyroData* hal::SimAnalogGyroData;
void AnalogGyroData::ResetData() {
angle.Reset(0.0);
rate.Reset(0.0);
initialized.Reset(false);
}
extern "C" {
void HALSIM_ResetAnalogGyroData(int32_t index) {
SimAnalogGyroData[index].ResetData();
}
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, AnalogGyro##CAPINAME, \
SimAnalogGyroData, LOWERNAME)
DEFINE_CAPI(double, Angle, angle)
DEFINE_CAPI(double, Rate, rate)
DEFINE_CAPI(HAL_Bool, Initialized, initialized)
#define REGISTER(NAME) \
SimAnalogGyroData[index].NAME.RegisterCallback(callback, param, initialNotify)
void HALSIM_RegisterAnalogGyroAllCallbacks(int32_t index,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify) {
REGISTER(angle);
REGISTER(rate);
REGISTER(initialized);
}
} // extern "C"

View File

@@ -1,25 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include "hal/simulation/AnalogGyroData.h"
#include "hal/simulation/SimDataValue.h"
namespace hal {
class AnalogGyroData {
HAL_SIMDATAVALUE_DEFINE_NAME(Angle)
HAL_SIMDATAVALUE_DEFINE_NAME(Rate)
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
public:
SimDataValue<double, HAL_MakeDouble, GetAngleName> angle{0.0};
SimDataValue<double, HAL_MakeDouble, GetRateName> rate{0.0};
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{
false};
virtual void ResetData();
};
extern AnalogGyroData* SimAnalogGyroData;
} // namespace hal

View File

@@ -21,11 +21,6 @@ void AnalogInData::ResetData() {
averageBits.Reset(7);
oversampleBits.Reset(0);
voltage.Reset(0.0);
accumulatorInitialized.Reset(false);
accumulatorValue.Reset(0);
accumulatorCount.Reset(0);
accumulatorCenter.Reset(0);
accumulatorDeadband.Reset(0);
}
extern "C" {
@@ -45,11 +40,6 @@ DEFINE_CAPI(HAL_Bool, Initialized, initialized)
DEFINE_CAPI(int32_t, AverageBits, averageBits)
DEFINE_CAPI(int32_t, OversampleBits, oversampleBits)
DEFINE_CAPI(double, Voltage, voltage)
DEFINE_CAPI(HAL_Bool, AccumulatorInitialized, accumulatorInitialized)
DEFINE_CAPI(int64_t, AccumulatorValue, accumulatorValue)
DEFINE_CAPI(int64_t, AccumulatorCount, accumulatorCount)
DEFINE_CAPI(int32_t, AccumulatorCenter, accumulatorCenter)
DEFINE_CAPI(int32_t, AccumulatorDeadband, accumulatorDeadband)
#define REGISTER(NAME) \
SimAnalogInData[index].NAME.RegisterCallback(callback, param, initialNotify)
@@ -61,10 +51,5 @@ void HALSIM_RegisterAnalogInAllCallbacks(int32_t index,
REGISTER(averageBits);
REGISTER(oversampleBits);
REGISTER(voltage);
REGISTER(accumulatorInitialized);
REGISTER(accumulatorValue);
REGISTER(accumulatorCount);
REGISTER(accumulatorCenter);
REGISTER(accumulatorDeadband);
}
} // extern "C"

View File

@@ -13,11 +13,6 @@ class AnalogInData {
HAL_SIMDATAVALUE_DEFINE_NAME(AverageBits)
HAL_SIMDATAVALUE_DEFINE_NAME(OversampleBits)
HAL_SIMDATAVALUE_DEFINE_NAME(Voltage)
HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorInitialized)
HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorValue)
HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorCount)
HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorCenter)
HAL_SIMDATAVALUE_DEFINE_NAME(AccumulatorDeadband)
public:
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{
@@ -26,16 +21,6 @@ class AnalogInData {
SimDataValue<int32_t, HAL_MakeInt, GetAverageBitsName> averageBits{7};
SimDataValue<int32_t, HAL_MakeInt, GetOversampleBitsName> oversampleBits{0};
SimDataValue<double, HAL_MakeDouble, GetVoltageName> voltage{0.0};
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetAccumulatorInitializedName>
accumulatorInitialized{false};
SimDataValue<int64_t, HAL_MakeLong, GetAccumulatorValueName> accumulatorValue{
0};
SimDataValue<int64_t, HAL_MakeLong, GetAccumulatorCountName> accumulatorCount{
0};
SimDataValue<int32_t, HAL_MakeInt, GetAccumulatorCenterName>
accumulatorCenter{0};
SimDataValue<int32_t, HAL_MakeInt, GetAccumulatorDeadbandName>
accumulatorDeadband{0};
virtual void ResetData();
};

View File

@@ -4,7 +4,6 @@
#include <hal/simulation/AccelerometerData.h>
#include <hal/simulation/AddressableLEDData.h>
#include <hal/simulation/AnalogGyroData.h>
#include <hal/simulation/AnalogInData.h>
#include <hal/simulation/AnalogTriggerData.h>
#include <hal/simulation/CTREPCMData.h>
@@ -32,10 +31,6 @@ extern "C" void HALSIM_ResetAllSimData(void) {
HALSIM_ResetAddressableLEDData(i);
}
for (int32_t i = 0; i < hal::kNumAccumulators; i++) {
HALSIM_ResetAnalogGyroData(i);
}
for (int32_t i = 0; i < hal::kNumAnalogInputs; i++) {
HALSIM_ResetAnalogInData(i);
}

View File

@@ -1,65 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/AnalogAccumulator.h"
#include "hal/HAL.h"
using namespace hal;
namespace hal::init {
void InitializeAnalogAccumulator() {}
} // namespace hal::init
extern "C" {
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return false;
}
void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle,
int32_t center, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle,
int32_t deadband, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle,
int64_t* value, int64_t* count, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
} // extern "C"

View File

@@ -1,92 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/AnalogGyro.h"
#include <cmath>
#include <string>
#include <thread>
#include <wpi/print.h>
#include "HALInitializer.h"
#include "HALInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogInput.h"
#include "hal/handles/IndexedHandleResource.h"
using namespace hal;
namespace hal::init {
void InitializeAnalogGyro() {}
} // namespace hal::init
extern "C" {
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle analogHandle,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_FreeAnalogGyro(HAL_GyroHandle handle) {}
void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle,
double voltsPerDegreePerSecond, double offset,
int32_t center, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle,
double voltsPerDegreePerSecond,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return 0;
}
} // extern "C"

View File

@@ -13,7 +13,6 @@
#include "HALInternal.h"
#include "PortsInternal.h"
#include "SmartIo.h"
#include "hal/AnalogAccumulator.h"
#include "hal/Errors.h"
#include "hal/cpp/fpga_clock.h"
#include "hal/handles/HandlesInternal.h"

View File

@@ -13,8 +13,6 @@
#include <wpi/print.h>
#include "PortsInternal.h"
#include "hal/AnalogAccumulator.h"
#include "hal/AnalogGyro.h"
#include "hal/AnalogInput.h"
#include "hal/Errors.h"
#include "hal/HALBase.h"

View File

@@ -50,8 +50,6 @@ void InitializeHAL() {
InitializeREVPH();
InitializeAddressableLED();
InitializeAccelerometer();
InitializeAnalogAccumulator();
InitializeAnalogGyro();
InitializeAnalogInput();
InitializeAnalogTrigger();
InitializeCAN();

View File

@@ -20,8 +20,6 @@ extern void InitializeCTREPCM();
extern void InitializeREVPH();
extern void InitializeAccelerometer();
extern void InitializeAddressableLED();
extern void InitializeAnalogAccumulator();
extern void InitializeAnalogGyro();
extern void InitializeAnalogInput();
extern void InitializeAnalogInternal();
extern void InitializeAnalogTrigger();

View File

@@ -13,10 +13,6 @@ void InitializePorts() {}
} // namespace hal::init
extern "C" {
int32_t HAL_GetNumAccumulators(void) {
return kNumAccumulators;
}
int32_t HAL_GetNumAnalogTriggers(void) {
return kNumAnalogTriggers;
}

View File

@@ -1,23 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/simulation/AnalogGyroData.h"
#include "hal/simulation/SimDataValue.h"
extern "C" {
void HALSIM_ResetAnalogGyroData(int32_t index) {}
#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \
HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogGyro##CAPINAME, RETURN)
DEFINE_CAPI(double, Angle, 0)
DEFINE_CAPI(double, Rate, 0)
DEFINE_CAPI(HAL_Bool, Initialized, false)
void HALSIM_RegisterAnalogGyroAllCallbacks(int32_t index,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify) {}
} // extern "C"

View File

@@ -20,11 +20,6 @@ DEFINE_CAPI(HAL_Bool, Initialized, false)
DEFINE_CAPI(int32_t, AverageBits, 0)
DEFINE_CAPI(int32_t, OversampleBits, 0)
DEFINE_CAPI(double, Voltage, 0)
DEFINE_CAPI(HAL_Bool, AccumulatorInitialized, false)
DEFINE_CAPI(int64_t, AccumulatorValue, 0)
DEFINE_CAPI(int64_t, AccumulatorCount, 0)
DEFINE_CAPI(int32_t, AccumulatorCenter, 0)
DEFINE_CAPI(int32_t, AccumulatorDeadband, 0)
void HALSIM_RegisterAnalogInAllCallbacks(int32_t index,
HAL_NotifyCallback callback,