mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[hal, wpilib] Remove relay (#7695)
This commit is contained in:
@@ -169,32 +169,6 @@ Java_edu_wpi_first_hal_PortsJNI_getNumInterrupts
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumRelayChannels
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumRelayChannels
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumRelayChannels();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumRelayHeaders
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_PortsJNI_getNumRelayHeaders
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
jint value = HAL_GetNumRelayHeaders();
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_PortsJNI
|
||||
* Method: getNumCTREPCMModules
|
||||
|
||||
@@ -1,93 +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_RelayJNI.h"
|
||||
#include "hal/Ports.h"
|
||||
#include "hal/Relay.h"
|
||||
#include "hal/handles/HandlesInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_RelayJNI
|
||||
* Method: initializeRelayPort
|
||||
* Signature: (IZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_RelayJNI_initializeRelayPort
|
||||
(JNIEnv* env, jclass, jint id, jboolean fwd)
|
||||
{
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
|
||||
HAL_RelayHandle handle = HAL_InitializeRelayPort(
|
||||
(HAL_PortHandle)id, static_cast<uint8_t>(fwd), stack.c_str(), &status);
|
||||
CheckStatusForceThrow(env, status);
|
||||
return (jint)handle;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_RelayJNI
|
||||
* Method: freeRelayPort
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_RelayJNI_freeRelayPort
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
if (id != HAL_kInvalidHandle) {
|
||||
HAL_FreeRelayPort((HAL_RelayHandle)id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_RelayJNI
|
||||
* Method: checkRelayChannel
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_RelayJNI_checkRelayChannel
|
||||
(JNIEnv* env, jclass, jint channel)
|
||||
{
|
||||
return (jboolean)HAL_CheckRelayChannel(static_cast<uint8_t>(channel));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_RelayJNI
|
||||
* Method: setRelay
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_RelayJNI_setRelay
|
||||
(JNIEnv* env, jclass, jint id, jboolean value)
|
||||
{
|
||||
int32_t status = 0;
|
||||
HAL_SetRelay((HAL_RelayHandle)id, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_RelayJNI
|
||||
* Method: getRelay
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_RelayJNI_getRelay
|
||||
(JNIEnv* env, jclass, jint id)
|
||||
{
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = HAL_GetRelay((HAL_RelayHandle)id, &status);
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,227 +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_RelayDataJNI.h"
|
||||
#include "hal/simulation/RelayData.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerInitializedForwardCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerInitializedForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayInitializedForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelInitializedForwardCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelInitializedForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayInitializedForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getInitializedForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getInitializedForward
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayInitializedForward(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setInitializedForward
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setInitializedForward
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayInitializedForward(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerInitializedReverseCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerInitializedReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayInitializedReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelInitializedReverseCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelInitializedReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayInitializedReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getInitializedReverse
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getInitializedReverse
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayInitializedReverse(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setInitializedReverse
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setInitializedReverse
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayInitializedReverse(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerForwardCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelForwardCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelForwardCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayForwardCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getForward
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getForward
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayForward(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setForward
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setForward
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayForward(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: registerReverseCallback
|
||||
* Signature: (ILjava/lang/Object;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_registerReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
|
||||
{
|
||||
return sim::AllocateCallback(env, index, callback, initialNotify,
|
||||
&HALSIM_RegisterRelayReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: cancelReverseCallback
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_cancelReverseCallback
|
||||
(JNIEnv* env, jclass, jint index, jint handle)
|
||||
{
|
||||
return sim::FreeCallback(env, handle, index,
|
||||
&HALSIM_CancelRelayReverseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: getReverse
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_getReverse
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
return HALSIM_GetRelayReverse(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: setReverse
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_setReverse
|
||||
(JNIEnv*, jclass, jint index, jboolean value)
|
||||
{
|
||||
HALSIM_SetRelayReverse(index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_simulation_RelayDataJNI
|
||||
* Method: resetData
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_hal_simulation_RelayDataJNI_resetData
|
||||
(JNIEnv*, jclass, jint index)
|
||||
{
|
||||
HALSIM_ResetRelayData(index);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "hal/PWM.h"
|
||||
#include "hal/Ports.h"
|
||||
#include "hal/Power.h"
|
||||
#include "hal/Relay.h"
|
||||
#include "hal/SPI.h"
|
||||
#include "hal/SerialPort.h"
|
||||
#include "hal/SimDevice.h"
|
||||
|
||||
@@ -100,20 +100,6 @@ int32_t HAL_GetNumEncoders(void);
|
||||
*/
|
||||
int32_t HAL_GetNumInterrupts(void);
|
||||
|
||||
/**
|
||||
* Gets the number of relay channels in the current system.
|
||||
*
|
||||
* @return the number of relay channels
|
||||
*/
|
||||
int32_t HAL_GetNumRelayChannels(void);
|
||||
|
||||
/**
|
||||
* Gets the number of relay headers in the current system.
|
||||
*
|
||||
* @return the number of relay headers
|
||||
*/
|
||||
int32_t HAL_GetNumRelayHeaders(void);
|
||||
|
||||
/**
|
||||
* Gets the number of PCM modules in the current system.
|
||||
*
|
||||
|
||||
@@ -1,75 +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_relay Relay Output Functions
|
||||
* @ingroup hal_capi
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes a relay.
|
||||
*
|
||||
* Note this call will only initialize either the forward or reverse port of the
|
||||
* relay. If you need both, you will need to initialize 2 relays.
|
||||
*
|
||||
* @param[in] portHandle the port handle to initialize
|
||||
* @param[in] fwd true for the forward port, false for the
|
||||
* reverse 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 relay handle
|
||||
*/
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
const char* allocationLocation,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Frees a relay port.
|
||||
*
|
||||
* @param relayPortHandle the relay handle
|
||||
*/
|
||||
void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle);
|
||||
|
||||
/**
|
||||
* Checks if a relay channel is valid.
|
||||
*
|
||||
* @param channel the channel to check
|
||||
* @return true if the channel is valid, otherwise false
|
||||
*/
|
||||
HAL_Bool HAL_CheckRelayChannel(int32_t channel);
|
||||
|
||||
/**
|
||||
* Sets the state of a relay output.
|
||||
*
|
||||
* @param[in] relayPortHandle the relay handle
|
||||
* @param[in] on true for on, false for off
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
*/
|
||||
void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on,
|
||||
int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets the current state of the relay channel.
|
||||
*
|
||||
* @param[in] relayPortHandle the relay handle
|
||||
* @param[out] status Error status variable. 0 on success.
|
||||
* @return true for on, false for off
|
||||
*/
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/** @} */
|
||||
@@ -1,53 +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_ResetRelayData(int32_t index);
|
||||
int32_t HALSIM_RegisterRelayInitializedForwardCallback(
|
||||
int32_t index, HAL_NotifyCallback callback, void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelRelayInitializedForwardCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetRelayInitializedForward(int32_t index);
|
||||
void HALSIM_SetRelayInitializedForward(int32_t index,
|
||||
HAL_Bool initializedForward);
|
||||
|
||||
int32_t HALSIM_RegisterRelayInitializedReverseCallback(
|
||||
int32_t index, HAL_NotifyCallback callback, void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelRelayInitializedReverseCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetRelayInitializedReverse(int32_t index);
|
||||
void HALSIM_SetRelayInitializedReverse(int32_t index,
|
||||
HAL_Bool initializedReverse);
|
||||
|
||||
int32_t HALSIM_RegisterRelayForwardCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelRelayForwardCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetRelayForward(int32_t index);
|
||||
void HALSIM_SetRelayForward(int32_t index, HAL_Bool forward);
|
||||
|
||||
int32_t HALSIM_RegisterRelayReverseCallback(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify);
|
||||
void HALSIM_CancelRelayReverseCallback(int32_t index, int32_t uid);
|
||||
HAL_Bool HALSIM_GetRelayReverse(int32_t index);
|
||||
void HALSIM_SetRelayReverse(int32_t index, HAL_Bool reverse);
|
||||
|
||||
void HALSIM_RegisterRelayAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback, void* param,
|
||||
HAL_Bool initialNotify);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -84,7 +84,6 @@ void InitializeHAL() {
|
||||
InitializeREVPHData();
|
||||
InitializePowerDistributionData();
|
||||
InitializePWMData();
|
||||
InitializeRelayData();
|
||||
InitializeRoboRioData();
|
||||
InitializeSimDeviceData();
|
||||
InitializeSPIAccelerometerData();
|
||||
@@ -117,7 +116,6 @@ void InitializeHAL() {
|
||||
InitializeCTREPCM();
|
||||
InitializeREVPH();
|
||||
InitializePWM();
|
||||
InitializeRelay();
|
||||
InitializeSerialPort();
|
||||
InitializeSimDevice();
|
||||
InitializeSPI();
|
||||
|
||||
@@ -35,7 +35,6 @@ extern void InitializeCTREPCMData();
|
||||
extern void InitializeREVPHData();
|
||||
extern void InitializePowerDistributionData();
|
||||
extern void InitializePWMData();
|
||||
extern void InitializeRelayData();
|
||||
extern void InitializeRoboRioData();
|
||||
extern void InitializeSimDeviceData();
|
||||
extern void InitializeSPIAccelerometerData();
|
||||
@@ -68,7 +67,6 @@ extern void InitializePower();
|
||||
extern void InitializeCTREPCM();
|
||||
extern void InitializeREVPH();
|
||||
extern void InitializePWM();
|
||||
extern void InitializeRelay();
|
||||
extern void InitializeSerialPort();
|
||||
extern void InitializeSimDevice();
|
||||
extern void InitializeSPI();
|
||||
|
||||
@@ -49,12 +49,6 @@ int32_t HAL_GetNumEncoders(void) {
|
||||
int32_t HAL_GetNumInterrupts(void) {
|
||||
return kNumInterrupts;
|
||||
}
|
||||
int32_t HAL_GetNumRelayChannels(void) {
|
||||
return kNumRelayChannels;
|
||||
}
|
||||
int32_t HAL_GetNumRelayHeaders(void) {
|
||||
return kNumRelayHeaders;
|
||||
}
|
||||
int32_t HAL_GetNumCTREPCMModules(void) {
|
||||
return kNumCTREPCMModules;
|
||||
}
|
||||
|
||||
@@ -1,136 +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/Relay.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/handles/IndexedHandleResource.h"
|
||||
#include "mockdata/RelayDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace {
|
||||
struct Relay {
|
||||
uint8_t channel;
|
||||
bool fwd;
|
||||
std::string previousAllocation;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_RelayHandle, Relay, kNumRelayChannels,
|
||||
HAL_HandleEnum::Relay>* relayHandles;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeRelay() {
|
||||
static IndexedHandleResource<HAL_RelayHandle, Relay, kNumRelayChannels,
|
||||
HAL_HandleEnum::Relay>
|
||||
rH;
|
||||
relayHandles = &rH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
if (*status != 0) {
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
int16_t channel = getPortHandleChannel(portHandle);
|
||||
if (channel == InvalidHandleIndex || channel >= kNumRelayChannels) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
|
||||
kNumRelayChannels, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
if (!fwd) {
|
||||
channel += kNumRelayHeaders; // add 4 to reverse channels
|
||||
}
|
||||
|
||||
HAL_RelayHandle handle;
|
||||
auto port = relayHandles->Allocate(channel, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "Relay", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Relay", 0,
|
||||
kNumRelayChannels, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
if (!fwd) {
|
||||
// Subtract number of headers to put channel in range
|
||||
channel -= kNumRelayHeaders;
|
||||
|
||||
port->fwd = false; // set to reverse
|
||||
|
||||
SimRelayData[channel].initializedReverse = true;
|
||||
} else {
|
||||
port->fwd = true; // set to forward
|
||||
SimRelayData[channel].initializedForward = true;
|
||||
}
|
||||
|
||||
port->channel = static_cast<uint8_t>(channel);
|
||||
port->previousAllocation = allocationLocation ? allocationLocation : "";
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle) {
|
||||
auto port = relayHandles->Get(relayPortHandle);
|
||||
relayHandles->Free(relayPortHandle);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (port->fwd) {
|
||||
SimRelayData[port->channel].initializedForward = false;
|
||||
} else {
|
||||
SimRelayData[port->channel].initializedReverse = false;
|
||||
}
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckRelayChannel(int32_t channel) {
|
||||
// roboRIO only has 4 headers, and the FPGA has
|
||||
// separate functions for forward and reverse,
|
||||
// instead of separate channel IDs
|
||||
return channel < kNumRelayHeaders && channel >= 0;
|
||||
}
|
||||
|
||||
void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on,
|
||||
int32_t* status) {
|
||||
auto port = relayHandles->Get(relayPortHandle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
if (port->fwd) {
|
||||
SimRelayData[port->channel].forward = on;
|
||||
} else {
|
||||
SimRelayData[port->channel].reverse = on;
|
||||
}
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status) {
|
||||
auto port = relayHandles->Get(relayPortHandle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
if (port->fwd) {
|
||||
return SimRelayData[port->channel].forward;
|
||||
} else {
|
||||
return SimRelayData[port->channel].reverse;
|
||||
}
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,50 +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 "RelayDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeRelayData() {
|
||||
static RelayData srd[kNumRelayHeaders];
|
||||
::hal::SimRelayData = srd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
RelayData* hal::SimRelayData;
|
||||
void RelayData::ResetData() {
|
||||
initializedForward.Reset(false);
|
||||
initializedReverse.Reset(false);
|
||||
forward.Reset(false);
|
||||
reverse.Reset(false);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetRelayData(int32_t index) {
|
||||
SimRelayData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, Relay##CAPINAME, SimRelayData, \
|
||||
LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, InitializedForward, initializedForward)
|
||||
DEFINE_CAPI(HAL_Bool, InitializedReverse, initializedReverse)
|
||||
DEFINE_CAPI(HAL_Bool, Forward, forward)
|
||||
DEFINE_CAPI(HAL_Bool, Reverse, reverse)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimRelayData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
||||
|
||||
void HALSIM_RegisterRelayAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback, void* param,
|
||||
HAL_Bool initialNotify) {
|
||||
REGISTER(initializedForward);
|
||||
REGISTER(initializedReverse);
|
||||
REGISTER(forward);
|
||||
REGISTER(reverse);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,28 +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/RelayData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
class RelayData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(InitializedForward)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(InitializedReverse)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Forward)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Reverse)
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedForwardName>
|
||||
initializedForward{false};
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedReverseName>
|
||||
initializedReverse{false};
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetForwardName> forward{false};
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetReverseName> reverse{false};
|
||||
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern RelayData* SimRelayData;
|
||||
} // namespace hal
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <hal/simulation/PWMData.h>
|
||||
#include <hal/simulation/PowerDistributionData.h>
|
||||
#include <hal/simulation/REVPHData.h>
|
||||
#include <hal/simulation/RelayData.h>
|
||||
#include <hal/simulation/RoboRioData.h>
|
||||
#include <hal/simulation/SPIAccelerometerData.h>
|
||||
#include <hal/simulation/SPIData.h>
|
||||
@@ -88,10 +87,6 @@ extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
HALSIM_ResetPWMData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumRelayHeaders; i++) {
|
||||
HALSIM_ResetRelayData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kNumREVPHModules; i++) {
|
||||
HALSIM_ResetREVPHData(i);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ void InitializeHAL() {
|
||||
InitializePorts();
|
||||
InitializePower();
|
||||
InitializePWM();
|
||||
InitializeRelay();
|
||||
InitializeSerialPort();
|
||||
InitializeSmartIo();
|
||||
InitializeSPI();
|
||||
|
||||
@@ -48,7 +48,6 @@ extern void InitializeREVPDH();
|
||||
extern void InitializePorts();
|
||||
extern void InitializePower();
|
||||
extern void InitializePWM();
|
||||
extern void InitializeRelay();
|
||||
extern void InitializeSerialPort();
|
||||
extern void InitializeSmartIo();
|
||||
extern void InitializeSPI();
|
||||
|
||||
@@ -50,12 +50,6 @@ int32_t HAL_GetNumEncoders(void) {
|
||||
int32_t HAL_GetNumInterrupts(void) {
|
||||
return kNumInterrupts;
|
||||
}
|
||||
int32_t HAL_GetNumRelayChannels(void) {
|
||||
return kNumRelayChannels;
|
||||
}
|
||||
int32_t HAL_GetNumRelayHeaders(void) {
|
||||
return kNumRelayHeaders;
|
||||
}
|
||||
int32_t HAL_GetNumCTREPCMModules(void) {
|
||||
return kNumCTREPCMModules;
|
||||
}
|
||||
|
||||
@@ -1,47 +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/Relay.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeRelay() {}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
void HAL_FreeRelayPort(HAL_RelayHandle relayPortHandle) {}
|
||||
|
||||
HAL_Bool HAL_CheckRelayChannel(int32_t channel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void HAL_SetRelay(HAL_RelayHandle relayPortHandle, HAL_Bool on,
|
||||
int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -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/RelayData.h"
|
||||
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetRelayData(int32_t index) {}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \
|
||||
HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, Relay##CAPINAME, RETURN)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, InitializedForward, false)
|
||||
DEFINE_CAPI(HAL_Bool, InitializedReverse, false)
|
||||
DEFINE_CAPI(HAL_Bool, Forward, false)
|
||||
DEFINE_CAPI(HAL_Bool, Reverse, false)
|
||||
|
||||
void HALSIM_RegisterRelayAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback, void* param,
|
||||
HAL_Bool initialNotify) {}
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user