mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal, wpilib] Remove analog output (#7696)
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
#include "edu_wpi_first_hal_AnalogJNI.h"
|
||||
#include "hal/AnalogAccumulator.h"
|
||||
#include "hal/AnalogInput.h"
|
||||
#include "hal/AnalogOutput.h"
|
||||
#include "hal/AnalogTrigger.h"
|
||||
#include "hal/Ports.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
@@ -52,37 +51,6 @@ Java_edu_wpi_first_hal_AnalogJNI_freeAnalogInputPort
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: initializeAnalogOutputPort
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogOutputPort
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
HAL_AnalogOutputHandle analog = HAL_InitializeAnalogOutputPort(
|
||||
(HAL_PortHandle)id, stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jlong)analog;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: freeAnalogOutputPort
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_freeAnalogOutputPort
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
if (id != HAL_kInvalidHandle) {
|
||||
HAL_FreeAnalogOutputPort((HAL_AnalogOutputHandle)id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: checkAnalogModule
|
||||
@@ -109,19 +77,6 @@ Java_edu_wpi_first_hal_AnalogJNI_checkAnalogInputChannel
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: checkAnalogOutputChannel
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_checkAnalogOutputChannel
|
||||
(JNIEnv*, jclass, jint value)
|
||||
{
|
||||
jboolean returnValue = HAL_CheckAnalogOutputChannel(value);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: setAnalogInputSimDevice
|
||||
@@ -135,35 +90,6 @@ Java_edu_wpi_first_hal_AnalogJNI_setAnalogInputSimDevice
|
||||
(HAL_SimDeviceHandle)device);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: setAnalogOutput
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_setAnalogOutput
|
||||
(JNIEnv* env, jclass, jint id, jdouble voltage)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogOutput((HAL_AnalogOutputHandle)id, voltage, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: getAnalogOutput
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_AnalogJNI_getAnalogOutput
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
double val = HAL_GetAnalogOutput((HAL_AnalogOutputHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_AnalogJNI
|
||||
* Method: setAnalogSampleRate
|
||||
|
||||
@@ -52,19 +52,6 @@ Java_edu_wpi_first_hal_PortsJNI_getNumAnalogInputs
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumAnalogOutputs
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumAnalogOutputs
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumAnalogOutputs();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumCounters
|
||||
|
||||
@@ -1,127 +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_AnalogOutDataJNI.h"
|
||||
#include "hal/simulation/AnalogOutData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: registerVoltageCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_registerVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogOutVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: cancelVoltageCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_cancelVoltageCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogOutVoltageCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: getVoltage
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_getVoltage
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogOutVoltage(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: setVoltage
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_setVoltage
|
||||
(JNIEnv*, jclass, jint index, jdouble value)
|
||||
{
|
||||
HALSIM_SetAnalogOutVoltage(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: registerInitializedCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_registerInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterAnalogOutInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: cancelInitializedCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_cancelInitializedCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelAnalogOutInitializedCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: getInitialized
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_getInitialized
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetAnalogOutInitialized(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: setInitialized
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_setInitialized
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetAnalogOutInitialized(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_AnalogOutDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_AnalogOutDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetAnalogOutData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,72 +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_analogoutput Analog Output Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes the analog output port using the given port object.
|
||||
*
|
||||
* @param[in] portHandle handle to the port
|
||||
* @param[in] allocationLocation the location where the allocation is occurring
|
||||
* (can be null)
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
* @return the created analog output handle
|
||||
*/
|
||||
HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
|
||||
HAL_PortHandle portHandle, const char* allocationLocation, int32_t* status);
|
||||
|
||||
/**
|
||||
* Frees an analog output port.
|
||||
*
|
||||
* @param analogOutputHandle the analog output handle
|
||||
*/
|
||||
void HAL_FreeAnalogOutputPort(HAL_AnalogOutputHandle analogOutputHandle);
|
||||
|
||||
/**
|
||||
* Sets an analog output value.
|
||||
*
|
||||
* @param[in] analogOutputHandle the analog output handle
|
||||
* @param[in] voltage the voltage (0-5v) to output
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
*/
|
||||
void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
double voltage, int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the current analog output value.
|
||||
*
|
||||
* @param[in] analogOutputHandle the analog output handle
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
* @return the current output voltage (0-5v)
|
||||
*/
|
||||
double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Checks that the analog output channel number is valid.
|
||||
*
|
||||
* Verifies that the analog channel number is one of the legal channel numbers.
|
||||
* Channel numbers are 0-based.
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
HAL_Bool HAL_CheckAnalogOutputChannel(int32_t channel);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/** @} */
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "hal/AnalogAccumulator.h"
|
||||
#include "hal/AnalogGyro.h"
|
||||
#include "hal/AnalogInput.h"
|
||||
#include "hal/AnalogOutput.h"
|
||||
#include "hal/AnalogTrigger.h"
|
||||
#include "hal/CAN.h"
|
||||
#include "hal/CANAPI.h"
|
||||
|
||||
@@ -37,13 +37,6 @@ int32_t HAL_GetNumAnalogTriggers(void);
|
||||
*/
|
||||
int32_t HAL_GetNumAnalogInputs(void);
|
||||
|
||||
/**
|
||||
* Gets the number of analog outputs in the current system.
|
||||
*
|
||||
* @return the number of analog outputs
|
||||
*/
|
||||
int32_t HAL_GetNumAnalogOutputs(void);
|
||||
|
||||
/**
|
||||
* Gets the number of counters in the current system.
|
||||
*
|
||||
|
||||
@@ -1,37 +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_ResetAnalogOutData(int32_t index);
|
||||
int32_t HALSIM_RegisterAnalogOutVoltageCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAnalogOutVoltageCallback(int32_t index, int32_t uid);
|
||||
double HALSIM_GetAnalogOutVoltage(int32_t index);
|
||||
void HALSIM_SetAnalogOutVoltage(int32_t index, double voltage);
|
||||
|
||||
int32_t HALSIM_RegisterAnalogOutInitializedCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelAnalogOutInitializedCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetAnalogOutInitialized(int32_t index);
|
||||
void HALSIM_SetAnalogOutInitialized(int32_t index, HAL_Bool initialized);
|
||||
|
||||
void HALSIM_RegisterAnalogOutAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param, HAL_Bool initialNotify);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -1,111 +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/AnalogOutput.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/Errors.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
#include "hal/handles/IndexedHandleResource.h"
|
||||
#include "mockdata/AnalogOutDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace {
|
||||
struct AnalogOutput {
|
||||
uint8_t channel;
|
||||
std::string previousAllocation;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_AnalogOutputHandle, AnalogOutput,
|
||||
kNumAnalogOutputs, HAL_HandleEnum::AnalogOutput>*
|
||||
analogOutputHandles;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAnalogOutput() {
|
||||
static IndexedHandleResource<HAL_AnalogOutputHandle, AnalogOutput,
|
||||
kNumAnalogOutputs, HAL_HandleEnum::AnalogOutput>
|
||||
aoH;
|
||||
analogOutputHandles = &aoH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
|
||||
HAL_PortHandle portHandle, const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
int16_t channel = getPortHandleChannel(portHandle);
|
||||
if (channel == InvalidHandleIndex || channel >= kNumAnalogOutputs) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Output",
|
||||
0, kNumAnalogOutputs, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
HAL_AnalogOutputHandle handle;
|
||||
auto port = analogOutputHandles->Allocate(channel, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "Analog Output", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for Analog Output", 0,
|
||||
kNumAnalogOutputs, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
port->channel = static_cast<uint8_t>(channel);
|
||||
|
||||
// Initialize sim analog input
|
||||
SimAnalogOutData[channel].initialized = true;
|
||||
|
||||
port->previousAllocation = allocationLocation ? allocationLocation : "";
|
||||
return handle;
|
||||
}
|
||||
|
||||
void HAL_FreeAnalogOutputPort(HAL_AnalogOutputHandle analogOutputHandle) {
|
||||
// no status, so no need to check for a proper free.
|
||||
auto port = analogOutputHandles->Get(analogOutputHandle);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
analogOutputHandles->Free(analogOutputHandle);
|
||||
SimAnalogOutData[port->channel].initialized = false;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckAnalogOutputChannel(int32_t channel) {
|
||||
return channel < kNumAnalogOutputs && channel >= 0;
|
||||
}
|
||||
|
||||
void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
double voltage, int32_t* status) {
|
||||
auto port = analogOutputHandles->Get(analogOutputHandle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
SimAnalogOutData[port->channel].voltage = voltage;
|
||||
}
|
||||
|
||||
double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
int32_t* status) {
|
||||
auto port = analogOutputHandles->Get(analogOutputHandle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return SimAnalogOutData[port->channel].voltage;
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -70,7 +70,6 @@ void InitializeHAL() {
|
||||
InitializeAddressableLEDData();
|
||||
InitializeAnalogGyroData();
|
||||
InitializeAnalogInData();
|
||||
InitializeAnalogOutData();
|
||||
InitializeAnalogTriggerData();
|
||||
InitializeCanData();
|
||||
InitializeCANAPI();
|
||||
@@ -94,7 +93,6 @@ void InitializeHAL() {
|
||||
InitializeAnalogGyro();
|
||||
InitializeAnalogInput();
|
||||
InitializeAnalogInternal();
|
||||
InitializeAnalogOutput();
|
||||
InitializeAnalogTrigger();
|
||||
InitializeCAN();
|
||||
InitializeConstants();
|
||||
|
||||
@@ -20,7 +20,6 @@ extern void InitializeAccelerometerData();
|
||||
extern void InitializeAddressableLEDData();
|
||||
extern void InitializeAnalogGyroData();
|
||||
extern void InitializeAnalogInData();
|
||||
extern void InitializeAnalogOutData();
|
||||
extern void InitializeAnalogTriggerData();
|
||||
extern void InitializeCanData();
|
||||
extern void InitializeCANAPI();
|
||||
@@ -45,7 +44,6 @@ extern void InitializeAnalogAccumulator();
|
||||
extern void InitializeAnalogGyro();
|
||||
extern void InitializeAnalogInput();
|
||||
extern void InitializeAnalogInternal();
|
||||
extern void InitializeAnalogOutput();
|
||||
extern void InitializeAnalogTrigger();
|
||||
extern void InitializeCAN();
|
||||
extern void InitializeConstants();
|
||||
|
||||
@@ -22,9 +22,6 @@ int32_t HAL_GetNumAnalogTriggers(void) {
|
||||
int32_t HAL_GetNumAnalogInputs(void) {
|
||||
return kNumAnalogInputs;
|
||||
}
|
||||
int32_t HAL_GetNumAnalogOutputs(void) {
|
||||
return kNumAnalogOutputs;
|
||||
}
|
||||
int32_t HAL_GetNumCounters(void) {
|
||||
return kNumCounters;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogOutDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAnalogOutData() {
|
||||
static AnalogOutData siod[kNumAnalogOutputs];
|
||||
::hal::SimAnalogOutData = siod;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
AnalogOutData* hal::SimAnalogOutData;
|
||||
void AnalogOutData::ResetData() {
|
||||
voltage.Reset(0.0);
|
||||
initialized.Reset(0);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetAnalogOutData(int32_t index) {
|
||||
SimAnalogOutData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, AnalogOut##CAPINAME, \
|
||||
SimAnalogOutData, LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(double, Voltage, voltage)
|
||||
DEFINE_CAPI(HAL_Bool, Initialized, initialized)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimAnalogOutData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
||||
|
||||
void HALSIM_RegisterAnalogOutAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param, HAL_Bool initialNotify) {
|
||||
REGISTER(voltage);
|
||||
REGISTER(initialized);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,22 +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/AnalogOutData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
class AnalogOutData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Voltage)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
||||
|
||||
public:
|
||||
SimDataValue<double, HAL_MakeDouble, GetVoltageName> voltage{0.0};
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{0};
|
||||
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern AnalogOutData* SimAnalogOutData;
|
||||
} // namespace hal
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <hal/simulation/AddressableLEDData.h>
|
||||
#include <hal/simulation/AnalogGyroData.h>
|
||||
#include <hal/simulation/AnalogInData.h>
|
||||
#include <hal/simulation/AnalogOutData.h>
|
||||
#include <hal/simulation/AnalogTriggerData.h>
|
||||
#include <hal/simulation/CTREPCMData.h>
|
||||
#include <hal/simulation/CanData.h>
|
||||
@@ -43,10 +42,6 @@ extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
HALSIM_ResetAnalogInData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumAnalogOutputs; i++) {
|
||||
HALSIM_ResetAnalogOutData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumAnalogTriggers; i++) {
|
||||
HALSIM_ResetAnalogTriggerData(i);
|
||||
}
|
||||
|
||||
@@ -1,51 +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/AnalogOutput.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/Errors.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
#include "hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeAnalogOutput() {}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
|
||||
HAL_PortHandle portHandle, const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckAnalogOutputChannel(int32_t channel) {
|
||||
return channel < kNumAnalogOutputs && channel >= 0;
|
||||
}
|
||||
|
||||
void HAL_FreeAnalogOutputPort(HAL_AnalogOutputHandle analogOutputHandle) {}
|
||||
|
||||
void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
double voltage, int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
|
||||
int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -53,7 +53,6 @@ void InitializeHAL() {
|
||||
InitializeAnalogAccumulator();
|
||||
InitializeAnalogGyro();
|
||||
InitializeAnalogInput();
|
||||
InitializeAnalogOutput();
|
||||
InitializeAnalogTrigger();
|
||||
InitializeCAN();
|
||||
InitializeCANAPI();
|
||||
|
||||
@@ -24,7 +24,6 @@ extern void InitializeAnalogAccumulator();
|
||||
extern void InitializeAnalogGyro();
|
||||
extern void InitializeAnalogInput();
|
||||
extern void InitializeAnalogInternal();
|
||||
extern void InitializeAnalogOutput();
|
||||
extern void InitializeAnalogTrigger();
|
||||
extern void InitializeCAN();
|
||||
extern void InitializeCANAPI();
|
||||
|
||||
@@ -23,9 +23,6 @@ int32_t HAL_GetNumAnalogTriggers(void) {
|
||||
int32_t HAL_GetNumAnalogInputs(void) {
|
||||
return kNumAnalogInputs;
|
||||
}
|
||||
int32_t HAL_GetNumAnalogOutputs(void) {
|
||||
return kNumAnalogOutputs;
|
||||
}
|
||||
int32_t HAL_GetNumCounters(void) {
|
||||
return kNumCounters;
|
||||
}
|
||||
|
||||
@@ -1,22 +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/AnalogOutData.h"
|
||||
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetAnalogOutData(int32_t index) {}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \
|
||||
HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, AnalogOut##CAPINAME, RETURN)
|
||||
|
||||
DEFINE_CAPI(double, Voltage, 0)
|
||||
DEFINE_CAPI(HAL_Bool, Initialized, false)
|
||||
|
||||
void HALSIM_RegisterAnalogOutAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param, HAL_Bool initialNotify) {
|
||||
}
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user