From a29fc38ed95ae824edc06c0f4fbf316018baf175 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 13 Jan 2025 17:53:53 -0800 Subject: [PATCH 1/3] Remove relay --- .../src/main/native/cpp/RelayAnalogTest.cpp | 50 --- .../src/main/native/cpp/RelayDigitalTest.cpp | 104 ------ glass/src/lib/native/cpp/hardware/Relay.cpp | 85 ----- .../lib/native/include/glass/hardware/Relay.h | 36 -- .../main/java/edu/wpi/first/hal/PortsJNI.java | 16 - .../main/java/edu/wpi/first/hal/RelayJNI.java | 63 ---- .../first/hal/simulation/RelayDataJNI.java | 51 --- hal/src/main/native/cpp/jni/PortsJNI.cpp | 26 -- hal/src/main/native/cpp/jni/RelayJNI.cpp | 93 ----- .../cpp/jni/simulation/RelayDataJNI.cpp | 227 ------------- hal/src/main/native/include/hal/HAL.h | 1 - hal/src/main/native/include/hal/Ports.h | 14 - hal/src/main/native/include/hal/Relay.h | 75 ---- .../native/include/hal/simulation/RelayData.h | 53 --- hal/src/main/native/sim/HAL.cpp | 2 - hal/src/main/native/sim/HALInitializer.h | 2 - hal/src/main/native/sim/Ports.cpp | 6 - hal/src/main/native/sim/Relay.cpp | 136 -------- .../main/native/sim/mockdata/RelayData.cpp | 50 --- .../native/sim/mockdata/RelayDataInternal.h | 28 -- hal/src/main/native/sim/mockdata/Reset.cpp | 5 - hal/src/main/native/systemcore/HAL.cpp | 1 - .../main/native/systemcore/HALInitializer.h | 1 - hal/src/main/native/systemcore/Ports.cpp | 6 - hal/src/main/native/systemcore/Relay.cpp | 47 --- .../native/systemcore/mockdata/RelayData.cpp | 23 -- .../native/cpp/mockdata/RelayDataTest.cpp | 83 ----- shared/examplecheck.gradle | 2 +- .../src/main/native/cpp/RelaySimGui.cpp | 117 ------- .../src/main/native/cpp/RelaySimGui.h | 14 - .../halsim_gui/src/main/native/cpp/main.cpp | 2 - .../src/main/native/cpp/HALSimWSClient.cpp | 2 - .../halsim_ws_core/doc/hardware_ws_api.md | 12 - simulation/halsim_ws_core/doc/wpilib-ws.yaml | 31 -- .../src/main/native/cpp/WSProvider_Relay.cpp | 52 --- .../main/native/include/WSProvider_Relay.h | 32 -- .../src/main/native/cpp/HALSimWSServer.cpp | 2 - wpilibc/src/main/native/cpp/Relay.cpp | 201 ----------- wpilibc/src/main/native/cpp/SensorUtil.cpp | 9 - .../main/native/cpp/simulation/RelaySim.cpp | 90 ----- wpilibc/src/main/native/include/frc/Relay.h | 128 ------- .../src/main/native/include/frc/SensorUtil.h | 11 - .../native/include/frc/simulation/RelaySim.h | 145 -------- .../native/cpp/simulation/RelaySimTest.cpp | 204 ----------- .../cpp/simulation/SimInitializationTest.cpp | 2 - .../src/main/cpp/examples/Relay/cpp/Robot.cpp | 59 ---- .../src/main/cpp/examples/examples.json | 12 - .../src/main/native/cpp/RelayTest.cpp | 72 ---- .../java/edu/wpi/first/wpilibj/Relay.java | 321 ------------------ .../edu/wpi/first/wpilibj/SensorUtil.java | 21 -- .../first/wpilibj/simulation/RelaySim.java | 159 --------- .../edu/wpi/first/wpilibj/SensorUtilTest.java | 5 - .../wpilibj/simulation/RelaySimTest.java | 258 -------------- .../wpi/first/wpilibj/examples/examples.json | 13 - .../first/wpilibj/examples/relay/Main.java | 25 -- .../first/wpilibj/examples/relay/Robot.java | 50 --- .../wpi/first/wpilibj/ConstantsPortsTest.java | 6 - .../first/wpilibj/RelayCrossConnectTest.java | 143 -------- .../wpi/first/wpilibj/WpiLibJTestSuite.java | 1 - .../fixtures/RelayCrossConnectFixture.java | 90 ----- .../edu/wpi/first/wpilibj/test/TestBench.java | 22 -- 61 files changed, 1 insertion(+), 3596 deletions(-) delete mode 100644 crossConnIntegrationTests/src/main/native/cpp/RelayAnalogTest.cpp delete mode 100644 crossConnIntegrationTests/src/main/native/cpp/RelayDigitalTest.cpp delete mode 100644 glass/src/lib/native/cpp/hardware/Relay.cpp delete mode 100644 glass/src/lib/native/include/glass/hardware/Relay.h delete mode 100644 hal/src/main/java/edu/wpi/first/hal/RelayJNI.java delete mode 100644 hal/src/main/java/edu/wpi/first/hal/simulation/RelayDataJNI.java delete mode 100644 hal/src/main/native/cpp/jni/RelayJNI.cpp delete mode 100644 hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp delete mode 100644 hal/src/main/native/include/hal/Relay.h delete mode 100644 hal/src/main/native/include/hal/simulation/RelayData.h delete mode 100644 hal/src/main/native/sim/Relay.cpp delete mode 100644 hal/src/main/native/sim/mockdata/RelayData.cpp delete mode 100644 hal/src/main/native/sim/mockdata/RelayDataInternal.h delete mode 100644 hal/src/main/native/systemcore/Relay.cpp delete mode 100644 hal/src/main/native/systemcore/mockdata/RelayData.cpp delete mode 100644 hal/src/test/native/cpp/mockdata/RelayDataTest.cpp delete mode 100644 simulation/halsim_gui/src/main/native/cpp/RelaySimGui.cpp delete mode 100644 simulation/halsim_gui/src/main/native/cpp/RelaySimGui.h delete mode 100644 simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Relay.cpp delete mode 100644 simulation/halsim_ws_core/src/main/native/include/WSProvider_Relay.h delete mode 100644 wpilibc/src/main/native/cpp/Relay.cpp delete mode 100644 wpilibc/src/main/native/cpp/simulation/RelaySim.cpp delete mode 100644 wpilibc/src/main/native/include/frc/Relay.h delete mode 100644 wpilibc/src/main/native/include/frc/simulation/RelaySim.h delete mode 100644 wpilibc/src/test/native/cpp/simulation/RelaySimTest.cpp delete mode 100644 wpilibcExamples/src/main/cpp/examples/Relay/cpp/Robot.cpp delete mode 100644 wpilibcIntegrationTests/src/main/native/cpp/RelayTest.cpp delete mode 100644 wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java delete mode 100644 wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RelaySim.java delete mode 100644 wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RelaySimTest.java delete mode 100644 wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Main.java delete mode 100644 wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Robot.java delete mode 100644 wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java delete mode 100644 wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java diff --git a/crossConnIntegrationTests/src/main/native/cpp/RelayAnalogTest.cpp b/crossConnIntegrationTests/src/main/native/cpp/RelayAnalogTest.cpp deleted file mode 100644 index 0ba1e2d2a3e..00000000000 --- a/crossConnIntegrationTests/src/main/native/cpp/RelayAnalogTest.cpp +++ /dev/null @@ -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 -#include -#include -#include - -#include "CrossConnects.h" -#include "LifetimeWrappers.h" - -using namespace hlt; - -class RelayAnalogTest : public ::testing::TestWithParam> {}; - -TEST_P(RelayAnalogTest, RelayAnalogCross) { - auto param = GetParam(); - - int32_t status = 0; - RelayHandle relay{param.first, true, &status}; - ASSERT_EQ(0, status); - AnalogInputHandle analog{param.second, &status}; - ASSERT_EQ(0, status); - AnalogTriggerHandle trigger{analog, &status}; - ASSERT_EQ(0, status); - HAL_SetAnalogTriggerLimitsVoltage(trigger, 1.5, 3.0, &status); - ASSERT_EQ(0, status); - - HAL_SetRelay(relay, false, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_FALSE(HAL_GetAnalogTriggerTriggerState(trigger, &status)); - ASSERT_EQ(0, status); - - HAL_SetRelay(relay, true, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_TRUE(HAL_GetAnalogTriggerTriggerState(trigger, &status)); - ASSERT_EQ(0, status); - - HAL_SetRelay(relay, false, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_FALSE(HAL_GetAnalogTriggerTriggerState(trigger, &status)); - ASSERT_EQ(0, status); -} - -INSTANTIATE_TEST_SUITE_P(RelayAnalogCrossConnectsTests, RelayAnalogTest, - ::testing::ValuesIn(RelayAnalogCrossConnects)); diff --git a/crossConnIntegrationTests/src/main/native/cpp/RelayDigitalTest.cpp b/crossConnIntegrationTests/src/main/native/cpp/RelayDigitalTest.cpp deleted file mode 100644 index 54b39933c3d..00000000000 --- a/crossConnIntegrationTests/src/main/native/cpp/RelayDigitalTest.cpp +++ /dev/null @@ -1,104 +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 -#include -#include - -#include "CrossConnects.h" -#include "LifetimeWrappers.h" - -using namespace hlt; - -class RelayDigitalTest : public ::testing::TestWithParam {}; - -TEST_P(RelayDigitalTest, RelayCross) { - auto param = GetParam(); - int32_t status = 0; - RelayHandle fwd{param.Relay, true, &status}; - ASSERT_EQ(0, status); - RelayHandle rev{param.Relay, false, &status}; - ASSERT_EQ(0, status); - DIOHandle fwdInput{param.FwdDio, true, &status}; - ASSERT_EQ(0, status); - DIOHandle revInput{param.RevDio, true, &status}; - ASSERT_EQ(0, status); - - HAL_SetRelay(fwd, false, &status); - ASSERT_EQ(0, status); - HAL_SetRelay(rev, false, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_FALSE(HAL_GetDIO(fwdInput, &status)); - ASSERT_EQ(0, status); - ASSERT_FALSE(HAL_GetDIO(revInput, &status)); - ASSERT_EQ(0, status); - - HAL_SetRelay(fwd, false, &status); - ASSERT_EQ(0, status); - HAL_SetRelay(rev, true, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_FALSE(HAL_GetDIO(fwdInput, &status)); - ASSERT_EQ(0, status); - ASSERT_TRUE(HAL_GetDIO(revInput, &status)); - ASSERT_EQ(0, status); - - HAL_SetRelay(fwd, true, &status); - ASSERT_EQ(0, status); - HAL_SetRelay(rev, false, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_TRUE(HAL_GetDIO(fwdInput, &status)); - ASSERT_EQ(0, status); - ASSERT_FALSE(HAL_GetDIO(revInput, &status)); - ASSERT_EQ(0, status); - - HAL_SetRelay(fwd, true, &status); - ASSERT_EQ(0, status); - HAL_SetRelay(rev, true, &status); - ASSERT_EQ(0, status); - usleep(1000); - ASSERT_TRUE(HAL_GetDIO(fwdInput, &status)); - ASSERT_EQ(0, status); - ASSERT_TRUE(HAL_GetDIO(revInput, &status)); - ASSERT_EQ(0, status); -} - -TEST(RelayDigitalTest, AllocateAll) { - wpi::SmallVector relayHandles; - for (int i = 0; i < HAL_GetNumRelayChannels(); i++) { - int32_t status = 0; - relayHandles.emplace_back(i / 2, i % 2, &status); - ASSERT_EQ(status, 0); - } -} - -TEST(RelayDigitalTest, MultipleAllocateFails) { - int32_t status = 0; - RelayHandle handle(0, true, &status); - ASSERT_NE(handle, HAL_kInvalidHandle); - ASSERT_EQ(status, 0); - - RelayHandle handle2(0, true, &status); - ASSERT_EQ(handle2, HAL_kInvalidHandle); - ASSERT_LAST_ERROR_STATUS(status, RESOURCE_IS_ALLOCATED); -} - -TEST(RelayDigitalTest, OverAllocateFails) { - int32_t status = 0; - RelayHandle handle(HAL_GetNumRelayChannels(), true, &status); - ASSERT_EQ(handle, HAL_kInvalidHandle); - ASSERT_LAST_ERROR_STATUS(status, RESOURCE_OUT_OF_RANGE); -} - -TEST(RelayDigitalTest, UnderAllocateFails) { - int32_t status = 0; - RelayHandle handle(-1, true, &status); - ASSERT_EQ(handle, HAL_kInvalidHandle); - ASSERT_LAST_ERROR_STATUS(status, RESOURCE_OUT_OF_RANGE); -} - -INSTANTIATE_TEST_SUITE_P(RelayDigitalCrossConnectsTests, RelayDigitalTest, - ::testing::ValuesIn(RelayCrossConnects)); diff --git a/glass/src/lib/native/cpp/hardware/Relay.cpp b/glass/src/lib/native/cpp/hardware/Relay.cpp deleted file mode 100644 index a29832e8c7c..00000000000 --- a/glass/src/lib/native/cpp/hardware/Relay.cpp +++ /dev/null @@ -1,85 +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 "glass/hardware/Relay.h" - -#include - -#include - -#include "glass/Context.h" -#include "glass/DataSource.h" -#include "glass/Storage.h" -#include "glass/support/ExtraGuiWidgets.h" - -using namespace glass; - -void glass::DisplayRelay(RelayModel* model, int index, bool outputsEnabled) { - auto forwardData = model->GetForwardData(); - auto reverseData = model->GetReverseData(); - - if (!forwardData && !reverseData) { - return; - } - - bool forward = false; - bool reverse = false; - if (outputsEnabled) { - if (forwardData) { - forward = forwardData->GetValue(); - } - if (reverseData) { - reverse = reverseData->GetValue(); - } - } - - std::string& name = GetStorage().GetString("name"); - ImGui::PushID("name"); - if (!name.empty()) { - ImGui::Text("%s [%d]", name.c_str(), index); - } else { - ImGui::Text("Relay[%d]", index); - } - ImGui::PopID(); - if (PopupEditName("name", &name)) { - if (forwardData) { - forwardData->SetName(name); - } - if (reverseData) { - reverseData->SetName(name); - } - } - ImGui::SameLine(); - - // show forward and reverse as LED indicators - static const ImU32 colors[] = {IM_COL32(255, 255, 102, 255), - IM_COL32(255, 0, 0, 255), - IM_COL32(128, 128, 128, 255)}; - int values[2] = {reverseData ? (reverse ? 2 : -2) : -3, - forwardData ? (forward ? 1 : -1) : -3}; - BooleanSource* sources[2] = {reverseData, forwardData}; - DrawLEDSources(values, sources, 2, 2, colors); -} - -void glass::DisplayRelays(RelaysModel* model, bool outputsEnabled, - std::string_view noneMsg) { - bool hasAny = false; - bool first = true; - model->ForEachRelay([&](RelayModel& relay, int i) { - hasAny = true; - - if (!first) { - ImGui::Separator(); - } else { - first = false; - } - - PushID(i); - DisplayRelay(&relay, i, outputsEnabled); - PopID(); - }); - if (!hasAny && !noneMsg.empty()) { - ImGui::TextUnformatted(noneMsg.data(), noneMsg.data() + noneMsg.size()); - } -} diff --git a/glass/src/lib/native/include/glass/hardware/Relay.h b/glass/src/lib/native/include/glass/hardware/Relay.h deleted file mode 100644 index f320e6d2e2a..00000000000 --- a/glass/src/lib/native/include/glass/hardware/Relay.h +++ /dev/null @@ -1,36 +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 - -#include - -#include "glass/Model.h" - -namespace glass { - -class BooleanSource; - -class RelayModel : public Model { - public: - virtual BooleanSource* GetForwardData() = 0; - virtual BooleanSource* GetReverseData() = 0; - - virtual void SetForward(bool val) = 0; - virtual void SetReverse(bool val) = 0; -}; - -class RelaysModel : public Model { - public: - virtual void ForEachRelay( - wpi::function_ref func) = 0; -}; - -void DisplayRelay(RelayModel* model, int index, bool outputsEnabled); -void DisplayRelays(RelaysModel* model, bool outputsEnabled, - std::string_view noneMsg = "No relays"); - -} // namespace glass diff --git a/hal/src/main/java/edu/wpi/first/hal/PortsJNI.java b/hal/src/main/java/edu/wpi/first/hal/PortsJNI.java index b47697b0e62..949c0bf8f05 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PortsJNI.java +++ b/hal/src/main/java/edu/wpi/first/hal/PortsJNI.java @@ -106,22 +106,6 @@ public class PortsJNI extends JNIWrapper { */ public static native int getNumInterrupts(); - /** - * Gets the number of relay channels in the current system. - * - * @return the number of relay channels - * @see "HAL_GetNumRelayChannels" - */ - public static native int getNumRelayChannels(); - - /** - * Gets the number of relay headers in the current system. - * - * @return the number of relay headers - * @see "HAL_GetNumRelayHeaders" - */ - public static native int getNumRelayHeaders(); - /** * Gets the number of PCM modules in the current system. * diff --git a/hal/src/main/java/edu/wpi/first/hal/RelayJNI.java b/hal/src/main/java/edu/wpi/first/hal/RelayJNI.java deleted file mode 100644 index abe146e1a6c..00000000000 --- a/hal/src/main/java/edu/wpi/first/hal/RelayJNI.java +++ /dev/null @@ -1,63 +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. - -package edu.wpi.first.hal; - -/** - * Relay Output HAL JNI Functions. - * - * @see "hal/Relay.h" - */ -public class RelayJNI extends DIOJNI { - /** - * 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 halPortHandle the port handle to initialize - * @param forward true for the forward port, false for the reverse port - * @return the created relay handle - * @see "HAL_InitializeRelayPort" - */ - public static native int initializeRelayPort(int halPortHandle, boolean forward); - - /** - * Frees a relay port. - * - * @param relayPortHandle the relay handle - * @see "HAL_FreeRelayPort" - */ - public static native void freeRelayPort(int relayPortHandle); - - /** - * Checks if a relay channel is valid. - * - * @param channel the channel to check - * @return true if the channel is valid, otherwise false - * @see "HAL_CheckRelayChannel" - */ - public static native boolean checkRelayChannel(int channel); - - /** - * Sets the state of a relay output. - * - * @param relayPortHandle the relay handle - * @param on true for on, false for off - * @see "HAL_SetRelay" - */ - public static native void setRelay(int relayPortHandle, boolean on); - - /** - * Gets the current state of the relay channel. - * - * @param relayPortHandle the relay handle - * @return true for on, false for off - * @see "HAL_GetRelay" - */ - public static native boolean getRelay(int relayPortHandle); - - /** Utility class. */ - private RelayJNI() {} -} diff --git a/hal/src/main/java/edu/wpi/first/hal/simulation/RelayDataJNI.java b/hal/src/main/java/edu/wpi/first/hal/simulation/RelayDataJNI.java deleted file mode 100644 index 734371522b6..00000000000 --- a/hal/src/main/java/edu/wpi/first/hal/simulation/RelayDataJNI.java +++ /dev/null @@ -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. - -package edu.wpi.first.hal.simulation; - -import edu.wpi.first.hal.JNIWrapper; - -/** JNI for relay data. */ -public class RelayDataJNI extends JNIWrapper { - public static native int registerInitializedForwardCallback( - int index, NotifyCallback callback, boolean initialNotify); - - public static native void cancelInitializedForwardCallback(int index, int uid); - - public static native boolean getInitializedForward(int index); - - public static native void setInitializedForward(int index, boolean initializedForward); - - public static native int registerInitializedReverseCallback( - int index, NotifyCallback callback, boolean initialNotify); - - public static native void cancelInitializedReverseCallback(int index, int uid); - - public static native boolean getInitializedReverse(int index); - - public static native void setInitializedReverse(int index, boolean initializedReverse); - - public static native int registerForwardCallback( - int index, NotifyCallback callback, boolean initialNotify); - - public static native void cancelForwardCallback(int index, int uid); - - public static native boolean getForward(int index); - - public static native void setForward(int index, boolean forward); - - public static native int registerReverseCallback( - int index, NotifyCallback callback, boolean initialNotify); - - public static native void cancelReverseCallback(int index, int uid); - - public static native boolean getReverse(int index); - - public static native void setReverse(int index, boolean reverse); - - public static native void resetData(int index); - - /** Utility class. */ - private RelayDataJNI() {} -} diff --git a/hal/src/main/native/cpp/jni/PortsJNI.cpp b/hal/src/main/native/cpp/jni/PortsJNI.cpp index 9757f44fe08..9ee10781bb2 100644 --- a/hal/src/main/native/cpp/jni/PortsJNI.cpp +++ b/hal/src/main/native/cpp/jni/PortsJNI.cpp @@ -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 diff --git a/hal/src/main/native/cpp/jni/RelayJNI.cpp b/hal/src/main/native/cpp/jni/RelayJNI.cpp deleted file mode 100644 index c388999e607..00000000000 --- a/hal/src/main/native/cpp/jni/RelayJNI.cpp +++ /dev/null @@ -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 - -#include - -#include - -#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(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(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" diff --git a/hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp deleted file mode 100644 index 7a59327e291..00000000000 --- a/hal/src/main/native/cpp/jni/simulation/RelayDataJNI.cpp +++ /dev/null @@ -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 - -#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" diff --git a/hal/src/main/native/include/hal/HAL.h b/hal/src/main/native/include/hal/HAL.h index 84bee9f75ad..4ffbfcea4b9 100644 --- a/hal/src/main/native/include/hal/HAL.h +++ b/hal/src/main/native/include/hal/HAL.h @@ -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" diff --git a/hal/src/main/native/include/hal/Ports.h b/hal/src/main/native/include/hal/Ports.h index a6c610ac55f..4ba0c6e9dd0 100644 --- a/hal/src/main/native/include/hal/Ports.h +++ b/hal/src/main/native/include/hal/Ports.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. * diff --git a/hal/src/main/native/include/hal/Relay.h b/hal/src/main/native/include/hal/Relay.h deleted file mode 100644 index 9ee104b6a87..00000000000 --- a/hal/src/main/native/include/hal/Relay.h +++ /dev/null @@ -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 - -#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 -/** @} */ diff --git a/hal/src/main/native/include/hal/simulation/RelayData.h b/hal/src/main/native/include/hal/simulation/RelayData.h deleted file mode 100644 index d61c9e083f5..00000000000 --- a/hal/src/main/native/include/hal/simulation/RelayData.h +++ /dev/null @@ -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 diff --git a/hal/src/main/native/sim/HAL.cpp b/hal/src/main/native/sim/HAL.cpp index 0f4d2a41943..7fed2984998 100644 --- a/hal/src/main/native/sim/HAL.cpp +++ b/hal/src/main/native/sim/HAL.cpp @@ -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(); diff --git a/hal/src/main/native/sim/HALInitializer.h b/hal/src/main/native/sim/HALInitializer.h index 308e2f47cfb..db3f02ca507 100644 --- a/hal/src/main/native/sim/HALInitializer.h +++ b/hal/src/main/native/sim/HALInitializer.h @@ -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(); diff --git a/hal/src/main/native/sim/Ports.cpp b/hal/src/main/native/sim/Ports.cpp index 08ca975e71b..86118fcaa1e 100644 --- a/hal/src/main/native/sim/Ports.cpp +++ b/hal/src/main/native/sim/Ports.cpp @@ -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; } diff --git a/hal/src/main/native/sim/Relay.cpp b/hal/src/main/native/sim/Relay.cpp deleted file mode 100644 index 4dfcdaf2a4d..00000000000 --- a/hal/src/main/native/sim/Relay.cpp +++ /dev/null @@ -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 - -#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* relayHandles; - -namespace hal::init { -void InitializeRelay() { - static IndexedHandleResource - 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(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" diff --git a/hal/src/main/native/sim/mockdata/RelayData.cpp b/hal/src/main/native/sim/mockdata/RelayData.cpp deleted file mode 100644 index ffe3bd51211..00000000000 --- a/hal/src/main/native/sim/mockdata/RelayData.cpp +++ /dev/null @@ -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" diff --git a/hal/src/main/native/sim/mockdata/RelayDataInternal.h b/hal/src/main/native/sim/mockdata/RelayDataInternal.h deleted file mode 100644 index b6fec87cc36..00000000000 --- a/hal/src/main/native/sim/mockdata/RelayDataInternal.h +++ /dev/null @@ -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 - initializedForward{false}; - SimDataValue - initializedReverse{false}; - SimDataValue forward{false}; - SimDataValue reverse{false}; - - virtual void ResetData(); -}; -extern RelayData* SimRelayData; -} // namespace hal diff --git a/hal/src/main/native/sim/mockdata/Reset.cpp b/hal/src/main/native/sim/mockdata/Reset.cpp index bb8397321be..2a7e1073933 100644 --- a/hal/src/main/native/sim/mockdata/Reset.cpp +++ b/hal/src/main/native/sim/mockdata/Reset.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -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); } diff --git a/hal/src/main/native/systemcore/HAL.cpp b/hal/src/main/native/systemcore/HAL.cpp index 2775a612c97..374e83846d5 100644 --- a/hal/src/main/native/systemcore/HAL.cpp +++ b/hal/src/main/native/systemcore/HAL.cpp @@ -74,7 +74,6 @@ void InitializeHAL() { InitializePorts(); InitializePower(); InitializePWM(); - InitializeRelay(); InitializeSerialPort(); InitializeSmartIo(); InitializeSPI(); diff --git a/hal/src/main/native/systemcore/HALInitializer.h b/hal/src/main/native/systemcore/HALInitializer.h index eab0fe8018a..447e0f47fd9 100644 --- a/hal/src/main/native/systemcore/HALInitializer.h +++ b/hal/src/main/native/systemcore/HALInitializer.h @@ -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(); diff --git a/hal/src/main/native/systemcore/Ports.cpp b/hal/src/main/native/systemcore/Ports.cpp index d27ecbd75ca..55407daa7bf 100644 --- a/hal/src/main/native/systemcore/Ports.cpp +++ b/hal/src/main/native/systemcore/Ports.cpp @@ -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; } diff --git a/hal/src/main/native/systemcore/Relay.cpp b/hal/src/main/native/systemcore/Relay.cpp deleted file mode 100644 index cdc7a11049e..00000000000 --- a/hal/src/main/native/systemcore/Relay.cpp +++ /dev/null @@ -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 - -#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" diff --git a/hal/src/main/native/systemcore/mockdata/RelayData.cpp b/hal/src/main/native/systemcore/mockdata/RelayData.cpp deleted file mode 100644 index 7d8d439be7a..00000000000 --- a/hal/src/main/native/systemcore/mockdata/RelayData.cpp +++ /dev/null @@ -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" diff --git a/hal/src/test/native/cpp/mockdata/RelayDataTest.cpp b/hal/src/test/native/cpp/mockdata/RelayDataTest.cpp deleted file mode 100644 index 3815b89c964..00000000000 --- a/hal/src/test/native/cpp/mockdata/RelayDataTest.cpp +++ /dev/null @@ -1,83 +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 - -#include - -#include "hal/HAL.h" -#include "hal/Relay.h" -#include "hal/handles/HandlesInternal.h" -#include "hal/simulation/RelayData.h" - -namespace hal { - -std::string gTestRelayCallbackName; -HAL_Value gTestRelayCallbackValue; - -void TestRelayInitializationCallback(const char* name, void* param, - const struct HAL_Value* value) { - gTestRelayCallbackName = name; - gTestRelayCallbackValue = *value; -} - -TEST(RelaySimTest, RelayInitialization) { - const int INDEX_TO_TEST = 3; - - int callbackParam = 0; - int callbackId = HALSIM_RegisterRelayInitializedForwardCallback( - INDEX_TO_TEST, &TestRelayInitializationCallback, &callbackParam, false); - ASSERT_TRUE(0 != callbackId); - - int32_t status = 0; - HAL_PortHandle portHandle; - HAL_DigitalHandle pdpHandle; - - // Use out of range index - portHandle = 8000; - gTestRelayCallbackName = "Unset"; - pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status); - EXPECT_EQ(HAL_kInvalidHandle, pdpHandle); - EXPECT_EQ(HAL_USE_LAST_ERROR, status); - HAL_GetLastError(&status); - EXPECT_EQ(RESOURCE_OUT_OF_RANGE, status); - EXPECT_STREQ("Unset", gTestRelayCallbackName.c_str()); - - // Successful setup - status = 0; - portHandle = HAL_GetPort(INDEX_TO_TEST); - gTestRelayCallbackName = "Unset"; - pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status); - EXPECT_TRUE(HAL_kInvalidHandle != pdpHandle); - EXPECT_EQ(0, status); - EXPECT_STREQ("InitializedForward", gTestRelayCallbackName.c_str()); - - // Double initialize... should fail - status = 0; - portHandle = HAL_GetPort(INDEX_TO_TEST); - gTestRelayCallbackName = "Unset"; - pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status); - EXPECT_EQ(HAL_kInvalidHandle, pdpHandle); - EXPECT_EQ(HAL_USE_LAST_ERROR, status); - HAL_GetLastError(&status); - EXPECT_EQ(RESOURCE_IS_ALLOCATED, status); - EXPECT_STREQ("Unset", gTestRelayCallbackName.c_str()); - - // Reset, should allow you to re-register - hal::HandleBase::ResetGlobalHandles(); - HALSIM_ResetRelayData(INDEX_TO_TEST); - callbackId = HALSIM_RegisterRelayInitializedForwardCallback( - INDEX_TO_TEST, &TestRelayInitializationCallback, &callbackParam, false); - - status = 0; - portHandle = HAL_GetPort(INDEX_TO_TEST); - gTestRelayCallbackName = "Unset"; - pdpHandle = HAL_InitializeRelayPort(portHandle, true, nullptr, &status); - EXPECT_TRUE(HAL_kInvalidHandle != pdpHandle); - EXPECT_EQ(0, status); - EXPECT_STREQ("InitializedForward", gTestRelayCallbackName.c_str()); - HALSIM_CancelRelayInitializedForwardCallback(INDEX_TO_TEST, callbackId); -} - -} // namespace hal diff --git a/shared/examplecheck.gradle b/shared/examplecheck.gradle index 644c095cf21..719c43bbac8 100644 --- a/shared/examplecheck.gradle +++ b/shared/examplecheck.gradle @@ -72,7 +72,7 @@ def tagList = [ "LQR", "Pose Estimator", /* --- Hardware --- */ - "Analog", "Ultrasonic", "Gyro", "Pneumatics", "I2C", "Duty Cycle", "PDP", "DMA", "Relay", + "Analog", "Ultrasonic", "Gyro", "Pneumatics", "I2C", "Duty Cycle", "PDP", "DMA", "AddressableLEDs", "HAL", "Encoder", "Smart Motor Controller", "Digital Input", "Digital Output", diff --git a/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.cpp b/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.cpp deleted file mode 100644 index 286ec29bacf..00000000000 --- a/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.cpp +++ /dev/null @@ -1,117 +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 "RelaySimGui.h" - -#include -#include - -#include -#include -#include -#include - -#include "HALDataSource.h" -#include "HALSimGui.h" - -using namespace halsimgui; - -namespace { -HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(RelayForward, "RelayFwd"); -HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(RelayReverse, "RelayRev"); - -class RelaySimModel : public glass::RelayModel { - public: - explicit RelaySimModel(int32_t index) - : m_index{index}, m_forward{index}, m_reverse{index} {} - - void Update() override {} - - bool Exists() override { - return HALSIM_GetRelayInitializedForward(m_index) || - HALSIM_GetRelayInitializedReverse(m_index); - } - - glass::BooleanSource* GetForwardData() override { - return HALSIM_GetRelayInitializedForward(m_index) ? &m_forward : nullptr; - } - glass::BooleanSource* GetReverseData() override { - return HALSIM_GetRelayInitializedReverse(m_index) ? &m_reverse : nullptr; - } - - void SetForward(bool val) override { HALSIM_SetRelayForward(m_index, val); } - void SetReverse(bool val) override { HALSIM_SetRelayReverse(m_index, val); } - - private: - int32_t m_index; - RelayForwardSource m_forward; - RelayReverseSource m_reverse; -}; - -class RelaysSimModel : public glass::RelaysModel { - public: - RelaysSimModel() : m_models(HAL_GetNumRelayHeaders()) {} - - void Update() override; - - bool Exists() override { return true; } - - void ForEachRelay(wpi::function_ref - func) override; - - private: - // indexed by channel - std::vector> m_models; -}; -} // namespace - -void RelaysSimModel::Update() { - for (int32_t i = 0, iend = static_cast(m_models.size()); i < iend; - ++i) { - auto& model = m_models[i]; - if (HALSIM_GetRelayInitializedForward(i) || - HALSIM_GetRelayInitializedReverse(i)) { - if (!model) { - model = std::make_unique(i); - } - } else { - model.reset(); - } - } -} - -void RelaysSimModel::ForEachRelay( - wpi::function_ref func) { - for (int32_t i = 0, iend = static_cast(m_models.size()); i < iend; - ++i) { - if (auto model = m_models[i].get()) { - func(*model, i); - } - } -} - -static bool RelayAnyInitialized() { - static const int32_t num = HAL_GetNumRelayHeaders(); - for (int32_t i = 0; i < num; ++i) { - if (HALSIM_GetRelayInitializedForward(i) || - HALSIM_GetRelayInitializedReverse(i)) { - return true; - } - } - return false; -} - -void RelaySimGui::Initialize() { - HALSimGui::halProvider->Register( - "Relays", RelayAnyInitialized, - [] { return std::make_unique(); }, - [](glass::Window* win, glass::Model* model) { - win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize); - win->SetDefaultPos(180, 20); - return glass::MakeFunctionView([=] { - glass::DisplayRelays(static_cast(model), - HALSimGui::halProvider->AreOutputsEnabled()); - }); - }); -} diff --git a/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.h b/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.h deleted file mode 100644 index cb270576dbe..00000000000 --- a/simulation/halsim_gui/src/main/native/cpp/RelaySimGui.h +++ /dev/null @@ -1,14 +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 - -namespace halsimgui { - -class RelaySimGui { - public: - static void Initialize(); -}; - -} // namespace halsimgui diff --git a/simulation/halsim_gui/src/main/native/cpp/main.cpp b/simulation/halsim_gui/src/main/native/cpp/main.cpp index de3eae4babb..601f1b0120f 100644 --- a/simulation/halsim_gui/src/main/native/cpp/main.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/main.cpp @@ -30,7 +30,6 @@ #include "PHSimGui.h" #include "PWMSimGui.h" #include "PowerDistributionSimGui.h" -#include "RelaySimGui.h" #include "RoboRioSimGui.h" #include "SimDeviceGui.h" #include "TimingGui.h" @@ -86,7 +85,6 @@ __declspec(dllexport) PCMSimGui::Initialize(); PowerDistributionSimGui::Initialize(); PWMSimGui::Initialize(); - RelaySimGui::Initialize(); PHSimGui::Initialize(); RoboRioSimGui::Initialize(); TimingGui::Initialize(); diff --git a/simulation/halsim_ws_client/src/main/native/cpp/HALSimWSClient.cpp b/simulation/halsim_ws_client/src/main/native/cpp/HALSimWSClient.cpp index 14896926b6b..d4f2abd6ddc 100644 --- a/simulation/halsim_ws_client/src/main/native/cpp/HALSimWSClient.cpp +++ b/simulation/halsim_ws_client/src/main/native/cpp/HALSimWSClient.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +49,6 @@ bool HALSimWSClient::Initialize() { HALSimWSProviderJoystick::Initialize(registerFunc); HALSimWSProviderPCM::Initialize(registerFunc); HALSimWSProviderPWM::Initialize(registerFunc); - HALSimWSProviderRelay::Initialize(registerFunc); HALSimWSProviderRoboRIO::Initialize(registerFunc); HALSimWSProviderSolenoid::Initialize(registerFunc); diff --git a/simulation/halsim_ws_core/doc/hardware_ws_api.md b/simulation/halsim_ws_core/doc/hardware_ws_api.md index ca6c233c02a..0197eb71ab0 100644 --- a/simulation/halsim_ws_core/doc/hardware_ws_api.md +++ b/simulation/halsim_ws_core/doc/hardware_ws_api.md @@ -90,7 +90,6 @@ The “hardware“ (which might be a full-fledged 3D simulation engine, a physic | [``"HAL"``][] | HAL data | ``"HAL"`` | | [``"Joystick"``][] | Joystick data | Joystick number | | [``"PWM"``][] | PWM output | Port index, e.g. "1", "2" | -| [``"Relay"``][] | Relay output | Port index, e.g. "1", "2" | | [``"Solenoid"``][] | Solenoid output | Module +Port index, e.g. "0,1", "2,5" | #### Accelerometer ("Accel") @@ -294,17 +293,6 @@ PWMs may be used to control either motor controllers or servos. Typically only | ``" squelch every other value; `3` -> squelch 3 of 4 values) | | ``" -#include - -#define REGISTER(halsim, jsonid, ctype, haltype) \ - HALSIM_RegisterRelay##halsim##Callback( \ - m_channel, \ - [](const char* name, void* param, const struct HAL_Value* value) { \ - static_cast(param)->ProcessHalCallback( \ - {{jsonid, static_cast(value->data.v_##haltype)}}); \ - }, \ - this, true) - -namespace wpilibws { -void HALSimWSProviderRelay::Initialize(WSRegisterFunc webRegisterFunc) { - CreateProviders("Relay", HAL_GetNumRelayHeaders(), - webRegisterFunc); -} - -HALSimWSProviderRelay::~HALSimWSProviderRelay() { - DoCancelCallbacks(); -} - -void HALSimWSProviderRelay::RegisterCallbacks() { - m_initFwdCbKey = REGISTER(InitializedForward, " - -#include "WSHalProviders.h" - -namespace wpilibws { - -class HALSimWSProviderRelay : public HALSimWSHalChanProvider { - public: - static void Initialize(WSRegisterFunc webRegisterFunc); - - using HALSimWSHalChanProvider::HALSimWSHalChanProvider; - ~HALSimWSProviderRelay() override; - - protected: - void RegisterCallbacks() override; - void CancelCallbacks() override; - void DoCancelCallbacks(); - - private: - int32_t m_initFwdCbKey = 0; - int32_t m_initRevCbKey = 0; - int32_t m_fwdCbKey = 0; - int32_t m_revCbKey = 0; -}; - -} // namespace wpilibws diff --git a/simulation/halsim_ws_server/src/main/native/cpp/HALSimWSServer.cpp b/simulation/halsim_ws_server/src/main/native/cpp/HALSimWSServer.cpp index 0661b975d6c..dbd75bc5fa0 100644 --- a/simulation/halsim_ws_server/src/main/native/cpp/HALSimWSServer.cpp +++ b/simulation/halsim_ws_server/src/main/native/cpp/HALSimWSServer.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -49,7 +48,6 @@ bool HALSimWSServer::Initialize() { HALSimWSProviderJoystick::Initialize(registerFunc); HALSimWSProviderPCM::Initialize(registerFunc); HALSimWSProviderPWM::Initialize(registerFunc); - HALSimWSProviderRelay::Initialize(registerFunc); HALSimWSProviderRoboRIO::Initialize(registerFunc); HALSimWSProviderSolenoid::Initialize(registerFunc); diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp deleted file mode 100644 index c3cc70c2bc5..00000000000 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ /dev/null @@ -1,201 +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 "frc/Relay.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "frc/Errors.h" -#include "frc/SensorUtil.h" - -using namespace frc; - -Relay::Relay(int channel, Relay::Direction direction) - : m_channel(channel), m_direction(direction) { - if (!SensorUtil::CheckRelayChannel(m_channel)) { - throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", m_channel); - return; - } - - HAL_PortHandle portHandle = HAL_GetPort(channel); - - if (m_direction == kBothDirections || m_direction == kForwardOnly) { - int32_t status = 0; - std::string stackTrace = wpi::GetStackTrace(1); - m_forwardHandle = - HAL_InitializeRelayPort(portHandle, true, stackTrace.c_str(), &status); - FRC_CheckErrorStatus(status, "Channel {}", m_channel); - HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel + 1); - } - if (m_direction == kBothDirections || m_direction == kReverseOnly) { - int32_t status = 0; - std::string stackTrace = wpi::GetStackTrace(1); - m_reverseHandle = - HAL_InitializeRelayPort(portHandle, false, stackTrace.c_str(), &status); - FRC_CheckErrorStatus(status, "Channel {}", m_channel); - HAL_Report(HALUsageReporting::kResourceType_Relay, m_channel + 128); - } - - int32_t status = 0; - if (m_forwardHandle != HAL_kInvalidHandle) { - HAL_SetRelay(m_forwardHandle, false, &status); - FRC_CheckErrorStatus(status, "Channel {}", m_channel); - } - if (m_reverseHandle != HAL_kInvalidHandle) { - HAL_SetRelay(m_reverseHandle, false, &status); - FRC_CheckErrorStatus(status, "Channel {}", m_channel); - } - - wpi::SendableRegistry::AddLW(this, "Relay", m_channel); -} - -Relay::~Relay() { - int32_t status = 0; - if (m_forwardHandle != HAL_kInvalidHandle) { - HAL_SetRelay(m_forwardHandle, false, &status); - } - if (m_reverseHandle != HAL_kInvalidHandle) { - HAL_SetRelay(m_reverseHandle, false, &status); - } -} - -void Relay::Set(Relay::Value value) { - int32_t status = 0; - - switch (value) { - case kOff: - if (m_direction == kBothDirections || m_direction == kForwardOnly) { - HAL_SetRelay(m_forwardHandle, false, &status); - } - if (m_direction == kBothDirections || m_direction == kReverseOnly) { - HAL_SetRelay(m_reverseHandle, false, &status); - } - break; - case kOn: - if (m_direction == kBothDirections || m_direction == kForwardOnly) { - HAL_SetRelay(m_forwardHandle, true, &status); - } - if (m_direction == kBothDirections || m_direction == kReverseOnly) { - HAL_SetRelay(m_reverseHandle, true, &status); - } - break; - case kForward: - if (m_direction == kReverseOnly) { - FRC_ReportError(err::IncompatibleMode, "channel {} setting {}", - m_channel, "forward"); - break; - } - if (m_direction == kBothDirections || m_direction == kForwardOnly) { - HAL_SetRelay(m_forwardHandle, true, &status); - } - if (m_direction == kBothDirections) { - HAL_SetRelay(m_reverseHandle, false, &status); - } - break; - case kReverse: - if (m_direction == kForwardOnly) { - FRC_ReportError(err::IncompatibleMode, "channel {} setting {}", - m_channel, "reverse"); - break; - } - if (m_direction == kBothDirections) { - HAL_SetRelay(m_forwardHandle, false, &status); - } - if (m_direction == kBothDirections || m_direction == kReverseOnly) { - HAL_SetRelay(m_reverseHandle, true, &status); - } - break; - } - - FRC_CheckErrorStatus(status, "Channel {}", m_channel); -} - -Relay::Value Relay::Get() const { - Relay::Value value = kOff; - int32_t status = 0; - - if (m_direction == kForwardOnly) { - if (HAL_GetRelay(m_forwardHandle, &status)) { - value = kOn; - } else { - value = kOff; - } - } else if (m_direction == kReverseOnly) { - if (HAL_GetRelay(m_reverseHandle, &status)) { - value = kOn; - } else { - value = kOff; - } - } else { - if (HAL_GetRelay(m_forwardHandle, &status)) { - if (HAL_GetRelay(m_reverseHandle, &status)) { - value = kOn; - } else { - value = kForward; - } - } else { - if (HAL_GetRelay(m_reverseHandle, &status)) { - value = kReverse; - } else { - value = kOff; - } - } - } - - FRC_CheckErrorStatus(status, "Channel {}", m_channel); - - return value; -} - -int Relay::GetChannel() const { - return m_channel; -} - -void Relay::StopMotor() { - Set(kOff); -} - -std::string Relay::GetDescription() const { - return fmt::format("Relay {}", GetChannel()); -} - -void Relay::InitSendable(wpi::SendableBuilder& builder) { - builder.SetSmartDashboardType("Relay"); - builder.SetActuator(true); - builder.SetSafeState([=, this] { Set(kOff); }); - builder.AddSmallStringProperty( - "Value", - [=, this](wpi::SmallVectorImpl& buf) -> std::string_view { - switch (Get()) { - case kOn: - return "On"; - case kForward: - return "Forward"; - case kReverse: - return "Reverse"; - default: - return "Off"; - } - }, - [=, this](std::string_view value) { - if (value == "Off") { - Set(kOff); - } else if (value == "Forward") { - Set(kForward); - } else if (value == "Reverse") { - Set(kReverse); - } else if (value == "On") { - Set(kOn); - } - }); -} diff --git a/wpilibc/src/main/native/cpp/SensorUtil.cpp b/wpilibc/src/main/native/cpp/SensorUtil.cpp index 08847fbdaf5..42062b4abff 100644 --- a/wpilibc/src/main/native/cpp/SensorUtil.cpp +++ b/wpilibc/src/main/native/cpp/SensorUtil.cpp @@ -9,7 +9,6 @@ #include #include #include -#include using namespace frc; @@ -25,10 +24,6 @@ bool SensorUtil::CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); } -bool SensorUtil::CheckRelayChannel(int channel) { - return HAL_CheckRelayChannel(channel); -} - bool SensorUtil::CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); } @@ -56,7 +51,3 @@ int SensorUtil::GetNumAnalogOuputs() { int SensorUtil::GetNumPwmChannels() { return HAL_GetNumPWMChannels(); } - -int SensorUtil::GetNumRelayChannels() { - return HAL_GetNumRelayHeaders(); -} diff --git a/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp b/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp deleted file mode 100644 index 10e95bf3186..00000000000 --- a/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp +++ /dev/null @@ -1,90 +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 "frc/simulation/RelaySim.h" - -#include - -#include - -#include "frc/Relay.h" - -using namespace frc; -using namespace frc::sim; - -RelaySim::RelaySim(const Relay& relay) : m_index{relay.GetChannel()} {} - -RelaySim::RelaySim(int channel) : m_index{channel} {} - -std::unique_ptr RelaySim::RegisterInitializedForwardCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback); - store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback( - m_index, &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RelaySim::GetInitializedForward() const { - return HALSIM_GetRelayInitializedForward(m_index); -} - -void RelaySim::SetInitializedForward(bool initializedForward) { - HALSIM_SetRelayInitializedForward(m_index, initializedForward); -} - -std::unique_ptr RelaySim::RegisterInitializedReverseCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback); - store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback( - m_index, &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RelaySim::GetInitializedReverse() const { - return HALSIM_GetRelayInitializedReverse(m_index); -} - -void RelaySim::SetInitializedReverse(bool initializedReverse) { - HALSIM_SetRelayInitializedReverse(m_index, initializedReverse); -} - -std::unique_ptr RelaySim::RegisterForwardCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - m_index, -1, callback, &HALSIM_CancelRelayForwardCallback); - store->SetUid(HALSIM_RegisterRelayForwardCallback( - m_index, &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RelaySim::GetForward() const { - return HALSIM_GetRelayForward(m_index); -} - -void RelaySim::SetForward(bool forward) { - HALSIM_SetRelayForward(m_index, forward); -} - -std::unique_ptr RelaySim::RegisterReverseCallback( - NotifyCallback callback, bool initialNotify) { - auto store = std::make_unique( - m_index, -1, callback, &HALSIM_CancelRelayReverseCallback); - store->SetUid(HALSIM_RegisterRelayReverseCallback( - m_index, &CallbackStoreThunk, store.get(), initialNotify)); - return store; -} - -bool RelaySim::GetReverse() const { - return HALSIM_GetRelayReverse(m_index); -} - -void RelaySim::SetReverse(bool reverse) { - HALSIM_SetRelayReverse(m_index, reverse); -} - -void RelaySim::ResetData() { - HALSIM_ResetRelayData(m_index); -} diff --git a/wpilibc/src/main/native/include/frc/Relay.h b/wpilibc/src/main/native/include/frc/Relay.h deleted file mode 100644 index 72e10e0052e..00000000000 --- a/wpilibc/src/main/native/include/frc/Relay.h +++ /dev/null @@ -1,128 +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 -#include - -#include -#include -#include -#include - -#include "frc/MotorSafety.h" - -namespace frc { - -/** - * Class for Spike style relay outputs. - * - * Relays are intended to be connected to spikes or similar relays. The relay - * channels controls a pair of pins that are either both off, one on, the other - * on, or both on. This translates into two spike outputs at 0v, one at 12v and - * one at 0v, one at 0v and the other at 12v, or two spike outputs at 12V. This - * allows off, full forward, or full reverse control of motors without variable - * speed. It also allows the two channels (forward and reverse) to be used - * independently for something that does not care about voltage polarity (like - * a solenoid). - */ -class Relay : public MotorSafety, - public wpi::Sendable, - public wpi::SendableHelper { - public: - /** - * The state to drive a Relay to. - */ - enum Value { - /// Off. - kOff, - /// On. - kOn, - /// Forward. - kForward, - /// Reverse. - kReverse - }; - - /** - * The Direction(s) that a relay is configured to operate in. - */ - enum Direction { - /// Both directions are valid. - kBothDirections, - /// Only forward is valid. - kForwardOnly, - /// Only reverse is valid. - kReverseOnly - }; - - /** - * Relay constructor given a channel. - * - * This code initializes the relay and reserves all resources that need to be - * locked. Initially the relay is set to both lines at 0v. - * - * @param channel The channel number (0-3). - * @param direction The direction that the Relay object will control. - */ - explicit Relay(int channel, Direction direction = kBothDirections); - - Relay(Relay&&) = default; - Relay& operator=(Relay&&) = default; - - /** - * Free the resource associated with a relay. - * - * The relay channels are set to free and the relay output is turned off. - */ - ~Relay() override; - - /** - * Set the relay state. - * - * Valid values depend on which directions of the relay are controlled by the - * object. - * - * When set to kBothDirections, the relay can be any of the four states: - * 0v-0v, 0v-12v, 12v-0v, 12v-12v - * - * When set to kForwardOnly or kReverseOnly, you can specify the constant for - * the direction or you can simply specify kOff and kOn. Using only kOff and - * kOn is recommended. - * - * @param value The state to set the relay. - */ - void Set(Value value); - - /** - * Get the Relay State - * - * Gets the current state of the relay. - * - * When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not - * kForward/kReverse (per the recommendation in Set). - * - * @return The current state of the relay as a Relay::Value - */ - Value Get() const; - - int GetChannel() const; - - // MotorSafety interface - void StopMotor() override; - - std::string GetDescription() const override; - - void InitSendable(wpi::SendableBuilder& builder) override; - - private: - int m_channel; - Direction m_direction; - - hal::Handle m_forwardHandle; - hal::Handle m_reverseHandle; -}; - -} // namespace frc diff --git a/wpilibc/src/main/native/include/frc/SensorUtil.h b/wpilibc/src/main/native/include/frc/SensorUtil.h index b1d8b61d5fa..e94a5ef0534 100644 --- a/wpilibc/src/main/native/include/frc/SensorUtil.h +++ b/wpilibc/src/main/native/include/frc/SensorUtil.h @@ -38,16 +38,6 @@ class SensorUtil final { */ static bool CheckDigitalChannel(int channel); - /** - * Check that the relay channel number is valid. - * - * Verify that the channel number is one of the legal channel numbers. Channel - * numbers are 0-based. - * - * @return Relay channel is valid - */ - static bool CheckRelayChannel(int channel); - /** * Check that the digital channel number is valid. * @@ -82,7 +72,6 @@ class SensorUtil final { static int GetNumAnalogInputs(); static int GetNumAnalogOuputs(); static int GetNumPwmChannels(); - static int GetNumRelayChannels(); }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/simulation/RelaySim.h b/wpilibc/src/main/native/include/frc/simulation/RelaySim.h deleted file mode 100644 index ecc4ded139d..00000000000 --- a/wpilibc/src/main/native/include/frc/simulation/RelaySim.h +++ /dev/null @@ -1,145 +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 - -#include "frc/simulation/CallbackStore.h" - -namespace frc { - -class Relay; - -namespace sim { - -/** - * Class to control a simulated relay. - */ -class RelaySim { - public: - /** - * Constructs from a Relay object. - * - * @param relay Relay to simulate - */ - explicit RelaySim(const Relay& relay); - - /** - * Constructs from a relay channel number. - * - * @param channel Channel number - */ - explicit RelaySim(int channel); - - /** - * Register a callback to be run when the forward direction is initialized. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - std::unique_ptr RegisterInitializedForwardCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Check whether the forward direction has been initialized. - * - * @return true if initialized - */ - bool GetInitializedForward() const; - - /** - * Define whether the forward direction has been initialized. - * - * @param initializedForward whether this object is initialized - */ - void SetInitializedForward(bool initializedForward); - - /** - * Register a callback to be run when the reverse direction is initialized. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - std::unique_ptr RegisterInitializedReverseCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Check whether the reverse direction has been initialized. - * - * @return true if initialized - */ - bool GetInitializedReverse() const; - - /** - * Define whether the reverse direction has been initialized. - * - * @param initializedReverse whether this object is initialized - */ - void SetInitializedReverse(bool initializedReverse); - - /** - * Register a callback to be run when the forward direction changes state. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - std::unique_ptr RegisterForwardCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Check whether the forward direction is active. - * - * @return true if active - */ - bool GetForward() const; - - /** - * Set whether the forward direction is active. - * - * @param forward true to make active - */ - void SetForward(bool forward); - - /** - * Register a callback to be run when the reverse direction changes state. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the CallbackStore object associated with this callback - */ - [[nodiscard]] - std::unique_ptr RegisterReverseCallback( - NotifyCallback callback, bool initialNotify); - - /** - * Check whether the reverse direction is active. - * - * @return true if active - */ - bool GetReverse() const; - - /** - * Set whether the reverse direction is active. - * - * @param reverse true to make active - */ - void SetReverse(bool reverse); - - /** - * Reset all simulation data. - */ - void ResetData(); - - private: - int m_index; -}; -} // namespace sim -} // namespace frc diff --git a/wpilibc/src/test/native/cpp/simulation/RelaySimTest.cpp b/wpilibc/src/test/native/cpp/simulation/RelaySimTest.cpp deleted file mode 100644 index c48515bc2bf..00000000000 --- a/wpilibc/src/test/native/cpp/simulation/RelaySimTest.cpp +++ /dev/null @@ -1,204 +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 "frc/simulation/RelaySim.h" // NOLINT(build/include_order) - -#include -#include - -#include "callback_helpers/TestCallbackHelpers.h" -#include "frc/Relay.h" - -namespace frc::sim { - -TEST(RelaySimTest, InitializationBidirectional) { - HAL_Initialize(500, 0); - - RelaySim sim(0); - sim.ResetData(); - - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - EXPECT_FALSE(sim.GetInitializedForward()); - EXPECT_FALSE(sim.GetInitializedReverse()); - - auto fwdCb = sim.RegisterInitializedForwardCallback( - forwardCallback.GetCallback(), false); - auto revCb = sim.RegisterInitializedReverseCallback( - reverseCallback.GetCallback(), false); - Relay relay{0}; - - EXPECT_TRUE(sim.GetInitializedForward()); - EXPECT_TRUE(sim.GetInitializedReverse()); - - EXPECT_TRUE(forwardCallback.WasTriggered()); - EXPECT_TRUE(forwardCallback.GetLastValue()); - EXPECT_TRUE(reverseCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.GetLastValue()); -} - -TEST(RelaySimTest, InitializationForwardOnly) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - sim.ResetData(); - - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - EXPECT_FALSE(sim.GetInitializedForward()); - EXPECT_FALSE(sim.GetInitializedReverse()); - - auto fwdCb = sim.RegisterInitializedForwardCallback( - forwardCallback.GetCallback(), false); - auto revCb = sim.RegisterInitializedReverseCallback( - reverseCallback.GetCallback(), false); - Relay relay(0, Relay::kForwardOnly); - - EXPECT_TRUE(sim.GetInitializedForward()); - EXPECT_FALSE(sim.GetInitializedReverse()); - - EXPECT_TRUE(forwardCallback.WasTriggered()); - EXPECT_TRUE(forwardCallback.GetLastValue()); - EXPECT_FALSE(reverseCallback.WasTriggered()); -} - -TEST(RelaySimTest, InitializationReverseOnly) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - sim.ResetData(); - - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - EXPECT_FALSE(sim.GetInitializedForward()); - EXPECT_FALSE(sim.GetInitializedReverse()); - - auto fwdCb = sim.RegisterInitializedForwardCallback( - forwardCallback.GetCallback(), false); - auto revCb = sim.RegisterInitializedReverseCallback( - reverseCallback.GetCallback(), false); - Relay relay(0, Relay::kReverseOnly); - - EXPECT_FALSE(sim.GetInitializedForward()); - EXPECT_TRUE(sim.GetInitializedReverse()); - - EXPECT_FALSE(forwardCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.GetLastValue()); -} - -TEST(RelaySimTest, BidirectionalSetForward) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - Relay relay{0}; - auto fwdCb = - sim.RegisterForwardCallback(forwardCallback.GetCallback(), false); - auto revCb = - sim.RegisterReverseCallback(reverseCallback.GetCallback(), false); - - relay.Set(Relay::kForward); - EXPECT_EQ(Relay::kForward, relay.Get()); - EXPECT_TRUE(sim.GetForward()); - EXPECT_FALSE(sim.GetReverse()); - - EXPECT_TRUE(forwardCallback.WasTriggered()); - EXPECT_TRUE(forwardCallback.GetLastValue()); - EXPECT_FALSE(reverseCallback.WasTriggered()); -} - -TEST(RelaySimTest, BidirectionalSetReverse) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - Relay relay{0}; - auto fwdCb = - sim.RegisterForwardCallback(forwardCallback.GetCallback(), false); - auto revCb = - sim.RegisterReverseCallback(reverseCallback.GetCallback(), false); - - relay.Set(Relay::kReverse); - EXPECT_EQ(Relay::kReverse, relay.Get()); - EXPECT_FALSE(sim.GetForward()); - EXPECT_TRUE(sim.GetReverse()); - - EXPECT_FALSE(forwardCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.GetLastValue()); -} - -TEST(RelaySimTest, BidirectionalSetOn) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - Relay relay{0}; - auto fwdCb = - sim.RegisterForwardCallback(forwardCallback.GetCallback(), false); - auto revCb = - sim.RegisterReverseCallback(reverseCallback.GetCallback(), false); - - relay.Set(Relay::kOn); - EXPECT_EQ(Relay::kOn, relay.Get()); - EXPECT_TRUE(sim.GetForward()); - EXPECT_TRUE(sim.GetReverse()); - - EXPECT_TRUE(forwardCallback.WasTriggered()); - EXPECT_TRUE(forwardCallback.GetLastValue()); - EXPECT_TRUE(reverseCallback.WasTriggered()); - EXPECT_TRUE(reverseCallback.GetLastValue()); -} - -TEST(RelaySimTest, BidirectionalSetOff) { - HAL_Initialize(500, 0); - - RelaySim sim{0}; - BooleanCallback forwardCallback; - BooleanCallback reverseCallback; - - Relay relay{0}; - auto fwdCb = - sim.RegisterForwardCallback(forwardCallback.GetCallback(), false); - auto revCb = - sim.RegisterReverseCallback(reverseCallback.GetCallback(), false); - - // Bootstrap into a non-off state to verify the callbacks - relay.Set(Relay::kOn); - forwardCallback.Reset(); - reverseCallback.Reset(); - - relay.Set(Relay::kOff); - EXPECT_EQ(Relay::kOff, relay.Get()); - EXPECT_FALSE(sim.GetForward()); - EXPECT_FALSE(sim.GetReverse()); - - EXPECT_TRUE(forwardCallback.WasTriggered()); - EXPECT_FALSE(forwardCallback.GetLastValue()); - EXPECT_TRUE(reverseCallback.WasTriggered()); - EXPECT_FALSE(reverseCallback.GetLastValue()); -} - -TEST(RelaySimTest, StopMotor) { - Relay relay{0}; - RelaySim sim(relay); - - // Bootstrap into non-off state - relay.Set(Relay::kOn); - - relay.StopMotor(); - EXPECT_EQ(Relay::kOff, relay.Get()); -} - -} // namespace frc::sim diff --git a/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp b/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp index 51c5386644d..a1180002b3b 100644 --- a/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp +++ b/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp @@ -21,7 +21,6 @@ #include "frc/simulation/EncoderSim.h" #include "frc/simulation/PWMSim.h" #include "frc/simulation/PowerDistributionSim.h" -#include "frc/simulation/RelaySim.h" #include "frc/simulation/RoboRioSim.h" #include "frc/simulation/SPIAccelerometerSim.h" @@ -43,7 +42,6 @@ TEST(SimInitializationTest, AllInitialize) { CTREPCMSim pcmsim{0}; PowerDistributionSim pdpsim{0}; PWMSim pwmsim{0}; - RelaySim rsim{0}; RoboRioSim rrsim; (void)rrsim; SPIAccelerometerSim sasim{0}; diff --git a/wpilibcExamples/src/main/cpp/examples/Relay/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Relay/cpp/Robot.cpp deleted file mode 100644 index b4db999a39e..00000000000 --- a/wpilibcExamples/src/main/cpp/examples/Relay/cpp/Robot.cpp +++ /dev/null @@ -1,59 +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 -#include -#include - -/** - * This is a sample program which uses joystick buttons to control a relay. - * - * A Relay (generally a spike) has two outputs, each of which can be at either - * 0V or 12V and so can be used for actions such as turning a motor off, full - * forwards, or full reverse, and is generally used on the compressor. - * - * This program uses two buttons on a joystick and each button corresponds to - * one output; pressing the button sets the output to 12V and releasing sets it - * to 0V. - */ -class Robot : public frc::TimedRobot { - public: - void TeleopPeriodic() override { - /* Retrieve the button values. GetRawButton() will return true if the button - * is pressed and false if not. - */ - bool forward = m_stick.GetRawButton(kRelayForwardButton); - bool reverse = m_stick.GetRawButton(kRelayReverseButton); - - /* Depending on the button values, we want to use one of kOn, kOff, - * kForward, or kReverse. - * - * kOn sets both outputs to 12V, kOff sets both to 0V. - * kForward sets forward to 12V and reverse to 0V. - * kReverse sets reverse to 12V and forward to 0V. - */ - if (forward && reverse) { - m_relay.Set(frc::Relay::kOn); - } else if (forward) { - m_relay.Set(frc::Relay::kForward); - } else if (reverse) { - m_relay.Set(frc::Relay::kReverse); - } else { - m_relay.Set(frc::Relay::kOff); - } - } - - private: - frc::Joystick m_stick{0}; - frc::Relay m_relay{0}; - - static constexpr int kRelayForwardButton = 1; - static constexpr int kRelayReverseButton = 2; -}; - -#ifndef RUNNING_FRC_TESTS -int main() { - return frc::StartRobot(); -} -#endif diff --git a/wpilibcExamples/src/main/cpp/examples/examples.json b/wpilibcExamples/src/main/cpp/examples/examples.json index 8723e307cae..3857c37fdef 100644 --- a/wpilibcExamples/src/main/cpp/examples/examples.json +++ b/wpilibcExamples/src/main/cpp/examples/examples.json @@ -12,18 +12,6 @@ "gradlebase": "cpp", "commandversion": 2 }, - { - "name": "Relay", - "description": "Control a relay from joystick buttons.", - "tags": [ - "Hardware", - "Relay", - "Joystick" - ], - "foldername": "Relay", - "gradlebase": "cpp", - "commandversion": 2 - }, { "name": "PDP CAN Monitoring", "description": "Monitor Power Distribution data such as voltage, current, temperature, etc.", diff --git a/wpilibcIntegrationTests/src/main/native/cpp/RelayTest.cpp b/wpilibcIntegrationTests/src/main/native/cpp/RelayTest.cpp deleted file mode 100644 index 7e5c8d2106e..00000000000 --- a/wpilibcIntegrationTests/src/main/native/cpp/RelayTest.cpp +++ /dev/null @@ -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. - -#include "frc/Relay.h" // NOLINT(build/include_order) - -#include -#include - -#include "TestBench.h" -#include "frc/DigitalInput.h" -#include "frc/Timer.h" - -static constexpr auto kDelayTime = 10_ms; - -TEST(RelayTest, BothDirections) { - frc::Relay relay{TestBench::kRelayChannel}; - frc::DigitalInput forward{TestBench::kFakeRelayForward}; - frc::DigitalInput reverse{TestBench::kFakeRelayReverse}; - - // Set the relay to forward - relay.Set(frc::Relay::kForward); - frc::Wait(kDelayTime); - EXPECT_TRUE(forward.Get()) << "Relay did not set forward"; - EXPECT_FALSE(reverse.Get()) << "Relay did not set forward"; - EXPECT_EQ(relay.Get(), frc::Relay::kForward); - - // Set the relay to reverse - relay.Set(frc::Relay::kReverse); - frc::Wait(kDelayTime); - EXPECT_TRUE(reverse.Get()) << "Relay did not set reverse"; - EXPECT_FALSE(forward.Get()) << "Relay did not set reverse"; - EXPECT_EQ(relay.Get(), frc::Relay::kReverse); - - // Set the relay to off - relay.Set(frc::Relay::kOff); - frc::Wait(kDelayTime); - EXPECT_FALSE(forward.Get()) << "Relay did not set off"; - EXPECT_FALSE(reverse.Get()) << "Relay did not set off"; - EXPECT_EQ(relay.Get(), frc::Relay::kOff); - - // Set the relay to on - relay.Set(frc::Relay::kOn); - frc::Wait(kDelayTime); - EXPECT_TRUE(forward.Get()) << "Relay did not set on"; - EXPECT_TRUE(reverse.Get()) << "Relay did not set on"; - EXPECT_EQ(relay.Get(), frc::Relay::kOn); -} - -TEST(RelayTest, ForwardOnly) { - frc::Relay relay{TestBench::kRelayChannel, frc::Relay::kForwardOnly}; - frc::DigitalInput forward{TestBench::kFakeRelayForward}; - frc::DigitalInput reverse{TestBench::kFakeRelayReverse}; - - relay.Set(frc::Relay::kOn); - frc::Wait(kDelayTime); - EXPECT_TRUE(forward.Get()) << "Relay did not set forward"; - EXPECT_FALSE(reverse.Get()) << "Relay did not set forward"; - EXPECT_EQ(relay.Get(), frc::Relay::kOn); -} - -TEST(RelayTest, ReverseOnly) { - frc::Relay relay{TestBench::kRelayChannel, frc::Relay::kReverseOnly}; - frc::DigitalInput forward{TestBench::kFakeRelayForward}; - frc::DigitalInput reverse{TestBench::kFakeRelayReverse}; - - relay.Set(frc::Relay::kOn); - frc::Wait(kDelayTime); - EXPECT_FALSE(forward.Get()) << "Relay did not set reverse"; - EXPECT_TRUE(reverse.Get()) << "Relay did not set reverse"; - EXPECT_EQ(relay.Get(), frc::Relay::kOn); -} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java deleted file mode 100644 index b852a35fd59..00000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ /dev/null @@ -1,321 +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. - -package edu.wpi.first.wpilibj; - -import static edu.wpi.first.util.ErrorMessages.requireNonNullParam; - -import edu.wpi.first.hal.FRCNetComm.tResourceType; -import edu.wpi.first.hal.HAL; -import edu.wpi.first.hal.RelayJNI; -import edu.wpi.first.hal.util.HalHandleException; -import edu.wpi.first.hal.util.UncleanStatusException; -import edu.wpi.first.util.sendable.Sendable; -import edu.wpi.first.util.sendable.SendableBuilder; -import edu.wpi.first.util.sendable.SendableRegistry; -import java.util.Arrays; -import java.util.Optional; - -/** - * Class for VEX Robotics Spike style relay outputs. Relays are intended to be connected to Spikes - * or similar relays. The relay channels controls a pair of channels that are either both off, one - * on, the other on, or both on. This translates into two Spike outputs at 0v, one at 12v and one at - * 0v, one at 0v and the other at 12v, or two Spike outputs at 12V. This allows off, full forward, - * or full reverse control of motors without variable speed. It also allows the two channels - * (forward and reverse) to be used independently for something that does not care about voltage - * polarity (like a solenoid). - */ -public class Relay extends MotorSafety implements Sendable, AutoCloseable { - /** - * This class represents errors in trying to set relay values contradictory to the direction to - * which the relay is set. - */ - public static class InvalidValueException extends RuntimeException { - /** - * Create a new exception with the given message. - * - * @param message the message to pass with the exception - */ - public InvalidValueException(String message) { - super(message); - } - } - - /** The state to drive a Relay to. */ - public enum Value { - /** Off. */ - kOff("Off"), - /** On. */ - kOn("On"), - /** Forward. */ - kForward("Forward"), - /** Reverse. */ - kReverse("Reverse"); - - private final String m_prettyValue; - - Value(String prettyValue) { - m_prettyValue = prettyValue; - } - - /** - * Returns the pretty string representation of the value. - * - * @return The pretty string representation of the value. - */ - public String getPrettyValue() { - return m_prettyValue; - } - - /** - * Returns the value for a given pretty string. - * - * @param value The pretty string. - * @return The value or an empty optional if there is no corresponding value. - */ - public static Optional getValueOf(String value) { - return Arrays.stream(Value.values()).filter(v -> v.m_prettyValue.equals(value)).findFirst(); - } - } - - /** The Direction(s) that a relay is configured to operate in. */ - public enum Direction { - /** Both directions are valid. */ - kBoth, - /** Only forward is valid. */ - kForward, - /** Only reverse is valid. */ - kReverse - } - - private final int m_channel; - - private int m_forwardHandle; - private int m_reverseHandle; - - private Direction m_direction; - - /** - * Common relay initialization method. This code is common to all Relay constructors and - * initializes the relay and reserves all resources that need to be locked. Initially the relay is - * set to both lines at 0v. - */ - private void initRelay() { - SensorUtil.checkRelayChannel(m_channel); - - int portHandle = HAL.getPort((byte) m_channel); - if (m_direction == Direction.kBoth || m_direction == Direction.kForward) { - m_forwardHandle = RelayJNI.initializeRelayPort(portHandle, true); - HAL.report(tResourceType.kResourceType_Relay, m_channel + 1); - } - if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) { - m_reverseHandle = RelayJNI.initializeRelayPort(portHandle, false); - HAL.report(tResourceType.kResourceType_Relay, m_channel + 128); - } - - setSafetyEnabled(false); - - SendableRegistry.addLW(this, "Relay", m_channel); - } - - /** - * Relay constructor given a channel. - * - * @param channel The channel number for this relay (0 - 3). - * @param direction The direction that the Relay object will control. - */ - @SuppressWarnings("this-escape") - public Relay(final int channel, Direction direction) { - m_channel = channel; - m_direction = requireNonNullParam(direction, "direction", "Relay"); - initRelay(); - set(Value.kOff); - } - - /** - * Relay constructor given a channel, allowing both directions. - * - * @param channel The channel number for this relay (0 - 3). - */ - public Relay(final int channel) { - this(channel, Direction.kBoth); - } - - @Override - public void close() { - SendableRegistry.remove(this); - freeRelay(); - } - - private void freeRelay() { - try { - RelayJNI.setRelay(m_forwardHandle, false); - } catch (UncleanStatusException | HalHandleException ignored) { - // do nothing. Ignore - } - try { - RelayJNI.setRelay(m_reverseHandle, false); - } catch (UncleanStatusException | HalHandleException ignored) { - // do nothing. Ignore - } - - RelayJNI.freeRelayPort(m_forwardHandle); - RelayJNI.freeRelayPort(m_reverseHandle); - - m_forwardHandle = 0; - m_reverseHandle = 0; - } - - /** - * Set the relay state. - * - *

Valid values depend on which directions of the relay are controlled by the object. - * - *

When set to kBothDirections, the relay can be set to any of the four states: 0v-0v, 12v-0v, - * 0v-12v, 12v-12v - * - *

When set to kForwardOnly or kReverseOnly, you can specify the constant for the direction, or - * you can simply specify kOff and kOn. Using only kOff and kOn is recommended. - * - * @param value The state to set the relay. - */ - public void set(Value value) { - switch (value) { - case kOff -> { - if (m_direction == Direction.kBoth || m_direction == Direction.kForward) { - RelayJNI.setRelay(m_forwardHandle, false); - } - if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) { - RelayJNI.setRelay(m_reverseHandle, false); - } - } - case kOn -> { - if (m_direction == Direction.kBoth || m_direction == Direction.kForward) { - RelayJNI.setRelay(m_forwardHandle, true); - } - if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) { - RelayJNI.setRelay(m_reverseHandle, true); - } - } - case kForward -> { - if (m_direction == Direction.kReverse) { - throw new InvalidValueException( - "A relay configured for reverse cannot be set to " + "forward"); - } - if (m_direction == Direction.kBoth || m_direction == Direction.kForward) { - RelayJNI.setRelay(m_forwardHandle, true); - } - if (m_direction == Direction.kBoth) { - RelayJNI.setRelay(m_reverseHandle, false); - } - } - case kReverse -> { - if (m_direction == Direction.kForward) { - throw new InvalidValueException( - "A relay configured for forward cannot be set to " + "reverse"); - } - if (m_direction == Direction.kBoth) { - RelayJNI.setRelay(m_forwardHandle, false); - } - if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) { - RelayJNI.setRelay(m_reverseHandle, true); - } - } - default -> { - // Cannot hit this, limited by Value enum - } - } - } - - /** - * Get the Relay State. - * - *

Gets the current state of the relay. - * - *

When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not - * kForward/kReverse (per the recommendation in Set) - * - * @return The current state of the relay as a Relay::Value - */ - public Value get() { - if (m_direction == Direction.kForward) { - if (RelayJNI.getRelay(m_forwardHandle)) { - return Value.kOn; - } else { - return Value.kOff; - } - } else if (m_direction == Direction.kReverse) { - if (RelayJNI.getRelay(m_reverseHandle)) { - return Value.kOn; - } else { - return Value.kOff; - } - } else { - if (RelayJNI.getRelay(m_forwardHandle)) { - if (RelayJNI.getRelay(m_reverseHandle)) { - return Value.kOn; - } else { - return Value.kForward; - } - } else { - if (RelayJNI.getRelay(m_reverseHandle)) { - return Value.kReverse; - } else { - return Value.kOff; - } - } - } - } - - /** - * Get the channel number. - * - * @return The channel number. - */ - public int getChannel() { - return m_channel; - } - - @Override - public void stopMotor() { - set(Value.kOff); - } - - @Override - public String getDescription() { - return "Relay ID " + getChannel(); - } - - /** - * Set the Relay Direction. - * - *

Changes which values the relay can be set to depending on which direction is used - * - *

Valid inputs are kBothDirections, kForwardOnly, and kReverseOnly - * - * @param direction The direction for the relay to operate in - */ - @SuppressWarnings("this-escape") - public void setDirection(Direction direction) { - requireNonNullParam(direction, "direction", "setDirection"); - if (m_direction == direction) { - return; - } - - freeRelay(); - m_direction = direction; - initRelay(); - } - - @Override - public void initSendable(SendableBuilder builder) { - builder.setSmartDashboardType("Relay"); - builder.setActuator(true); - builder.setSafeState(() -> set(Value.kOff)); - builder.addStringProperty( - "Value", - () -> get().getPrettyValue(), - value -> set(Value.getValueOf(value).orElse(Value.kOff))); - } -} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java index 258fbc7c606..832fcc3504b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java @@ -9,7 +9,6 @@ import edu.wpi.first.hal.DIOJNI; import edu.wpi.first.hal.PWMJNI; import edu.wpi.first.hal.PortsJNI; -import edu.wpi.first.hal.RelayJNI; /** * Stores most recent status information as well as containing utility functions for checking @@ -35,9 +34,6 @@ public final class SensorUtil { /** Number of PWM channels per roboRIO. */ public static final int kPwmChannels = PortsJNI.getNumPWMChannels(); - /** Number of relay channels per roboRIO. */ - public static final int kRelayChannels = PortsJNI.getNumRelayHeaders(); - /** Number of power distribution channels per PDP. */ public static final int kCTREPDPChannels = PortsJNI.getNumCTREPDPChannels(); @@ -70,23 +66,6 @@ public static void checkDigitalChannel(final int channel) { } } - /** - * Check that the digital channel number is valid. Verify that the channel number is one of the - * legal channel numbers. Channel numbers are 0-based. - * - * @param channel The channel number to check. - */ - public static void checkRelayChannel(final int channel) { - if (!RelayJNI.checkRelayChannel(channel)) { - String buf = - "Requested relay channel is out of range. Minimum: 0, Maximum: " - + kRelayChannels - + ", Requested: " - + channel; - throw new IllegalArgumentException(buf); - } - } - /** * Check that the digital channel number is valid. Verify that the channel number is one of the * legal channel numbers. Channel numbers are 0-based. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RelaySim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RelaySim.java deleted file mode 100644 index e47589ca5a5..00000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/RelaySim.java +++ /dev/null @@ -1,159 +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. - -package edu.wpi.first.wpilibj.simulation; - -import edu.wpi.first.hal.simulation.NotifyCallback; -import edu.wpi.first.hal.simulation.RelayDataJNI; -import edu.wpi.first.wpilibj.Relay; - -/** Class to control a simulated relay. */ -public class RelaySim { - private final int m_index; - - /** - * Constructs from a Relay object. - * - * @param relay Relay to simulate - */ - public RelaySim(Relay relay) { - m_index = relay.getChannel(); - } - - /** - * Constructs from a relay channel number. - * - * @param channel Channel number - */ - public RelaySim(int channel) { - m_index = channel; - } - - /** - * Register a callback to be run when the forward direction is initialized. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public CallbackStore registerInitializedForwardCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RelayDataJNI.registerInitializedForwardCallback(m_index, callback, initialNotify); - return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedForwardCallback); - } - - /** - * Check whether the forward direction has been initialized. - * - * @return true if initialized - */ - public boolean getInitializedForward() { - return RelayDataJNI.getInitializedForward(m_index); - } - - /** - * Define whether the forward direction has been initialized. - * - * @param initializedForward whether this object is initialized - */ - public void setInitializedForward(boolean initializedForward) { - RelayDataJNI.setInitializedForward(m_index, initializedForward); - } - - /** - * Register a callback to be run when the reverse direction is initialized. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public CallbackStore registerInitializedReverseCallback( - NotifyCallback callback, boolean initialNotify) { - int uid = RelayDataJNI.registerInitializedReverseCallback(m_index, callback, initialNotify); - return new CallbackStore(m_index, uid, RelayDataJNI::cancelInitializedReverseCallback); - } - - /** - * Check whether the reverse direction has been initialized. - * - * @return true if initialized - */ - public boolean getInitializedReverse() { - return RelayDataJNI.getInitializedReverse(m_index); - } - - /** - * Define whether the reverse direction has been initialized. - * - * @param initializedReverse whether this object is initialized - */ - public void setInitializedReverse(boolean initializedReverse) { - RelayDataJNI.setInitializedReverse(m_index, initializedReverse); - } - - /** - * Register a callback to be run when the forward direction changes state. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public CallbackStore registerForwardCallback(NotifyCallback callback, boolean initialNotify) { - int uid = RelayDataJNI.registerForwardCallback(m_index, callback, initialNotify); - return new CallbackStore(m_index, uid, RelayDataJNI::cancelForwardCallback); - } - - /** - * Check whether the forward direction is active. - * - * @return true if active - */ - public boolean getForward() { - return RelayDataJNI.getForward(m_index); - } - - /** - * Set whether the forward direction is active. - * - * @param forward true to make active - */ - public void setForward(boolean forward) { - RelayDataJNI.setForward(m_index, forward); - } - - /** - * Register a callback to be run when the reverse direction changes state. - * - * @param callback the callback - * @param initialNotify whether to run the callback with the initial state - * @return the {@link CallbackStore} object associated with this callback. - */ - public CallbackStore registerReverseCallback(NotifyCallback callback, boolean initialNotify) { - int uid = RelayDataJNI.registerReverseCallback(m_index, callback, initialNotify); - return new CallbackStore(m_index, uid, RelayDataJNI::cancelReverseCallback); - } - - /** - * Check whether the reverse direction is active. - * - * @return true if active - */ - public boolean getReverse() { - return RelayDataJNI.getReverse(m_index); - } - - /** - * Set whether the reverse direction is active. - * - * @param reverse true to make active - */ - public void setReverse(boolean reverse) { - RelayDataJNI.setReverse(m_index, reverse); - } - - /** Reset all simulation data. */ - public void resetData() { - RelayDataJNI.resetData(m_index); - } -} diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/SensorUtilTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/SensorUtilTest.java index bf6876e5a28..5c1fcddce36 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/SensorUtilTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/SensorUtilTest.java @@ -30,11 +30,6 @@ void testInvalidPwmChannel() { assertThrows(IllegalArgumentException.class, () -> SensorUtil.checkPWMChannel(100)); } - @Test - void testInvalidRelayModule() { - assertThrows(IllegalArgumentException.class, () -> SensorUtil.checkRelayChannel(100)); - } - @Test void testgetDefaultCtrePcmModule() { assertEquals(0, SensorUtil.getDefaultCTREPCMModule()); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RelaySimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RelaySimTest.java deleted file mode 100644 index c7538cc5b5a..00000000000 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/RelaySimTest.java +++ /dev/null @@ -1,258 +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. - -package edu.wpi.first.wpilibj.simulation; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.Relay; -import edu.wpi.first.wpilibj.simulation.testutils.BooleanCallback; -import org.junit.jupiter.api.Test; - -class RelaySimTest { - @Test - void testInitializationBidirectional() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - sim.resetData(); - - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - assertFalse(sim.getInitializedForward()); - assertFalse(sim.getInitializedReverse()); - - try (CallbackStore fwdCb = sim.registerInitializedForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerInitializedReverseCallback(reverseCallback, false); - Relay relay = new Relay(0)) { - assertTrue(sim.getInitializedForward()); - assertTrue(sim.getInitializedReverse()); - - assertTrue(forwardCallback.wasTriggered()); - assertTrue(forwardCallback.getSetValue()); - assertTrue(reverseCallback.wasTriggered()); - assertTrue(reverseCallback.getSetValue()); - } - } - - @Test - void testInitializationForwardOnly() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - sim.resetData(); - - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - assertFalse(sim.getInitializedForward()); - assertFalse(sim.getInitializedReverse()); - - try (CallbackStore fwdCb = sim.registerInitializedForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerInitializedReverseCallback(reverseCallback, false); - Relay relay = new Relay(0, Relay.Direction.kForward)) { - assertTrue(sim.getInitializedForward()); - assertFalse(sim.getInitializedReverse()); - - assertTrue(forwardCallback.wasTriggered()); - assertTrue(forwardCallback.getSetValue()); - assertFalse(reverseCallback.wasTriggered()); - assertNull(reverseCallback.getSetValue()); - } - } - - @Test - void testInitializationReverseOnly() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - sim.resetData(); - - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - assertFalse(sim.getInitializedForward()); - assertFalse(sim.getInitializedReverse()); - - try (CallbackStore fwdCb = sim.registerInitializedForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerInitializedReverseCallback(reverseCallback, false); - Relay relay = new Relay(0, Relay.Direction.kReverse)) { - assertFalse(sim.getInitializedForward()); - assertTrue(sim.getInitializedReverse()); - - assertFalse(forwardCallback.wasTriggered()); - assertNull(forwardCallback.getSetValue()); - assertTrue(reverseCallback.wasTriggered()); - assertTrue(reverseCallback.getSetValue()); - } - } - - @Test - void testBidirectionalSetForward() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - try (Relay relay = new Relay(0); - CallbackStore fwdCb = sim.registerForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerReverseCallback(reverseCallback, false)) { - relay.set(Relay.Value.kForward); - assertEquals(Relay.Value.kForward, relay.get()); - assertTrue(sim.getForward()); - assertFalse(sim.getReverse()); - - assertTrue(forwardCallback.wasTriggered()); - assertTrue(forwardCallback.getSetValue()); - assertFalse(reverseCallback.wasTriggered()); - assertNull(reverseCallback.getSetValue()); - } - } - - @Test - void testBidirectionalSetReverse() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - try (Relay relay = new Relay(0); - CallbackStore fwdCb = sim.registerForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerReverseCallback(reverseCallback, false)) { - relay.set(Relay.Value.kReverse); - assertEquals(Relay.Value.kReverse, relay.get()); - assertFalse(sim.getForward()); - assertTrue(sim.getReverse()); - - assertFalse(forwardCallback.wasTriggered()); - assertNull(forwardCallback.getSetValue()); - assertTrue(reverseCallback.wasTriggered()); - assertTrue(reverseCallback.getSetValue()); - } - } - - @Test - void testBidirectionalSetOn() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - try (Relay relay = new Relay(0); - CallbackStore fwdCb = sim.registerForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerReverseCallback(reverseCallback, false)) { - relay.set(Relay.Value.kOn); - assertEquals(Relay.Value.kOn, relay.get()); - assertTrue(sim.getForward()); - assertTrue(sim.getReverse()); - - assertTrue(forwardCallback.wasTriggered()); - assertTrue(forwardCallback.getSetValue()); - assertTrue(reverseCallback.wasTriggered()); - assertTrue(reverseCallback.getSetValue()); - } - } - - @Test - void testBidirectionalSetOff() { - HAL.initialize(500, 0); - - RelaySim sim = new RelaySim(0); - BooleanCallback forwardCallback = new BooleanCallback(); - BooleanCallback reverseCallback = new BooleanCallback(); - - try (Relay relay = new Relay(0); - CallbackStore fwdCb = sim.registerForwardCallback(forwardCallback, false); - CallbackStore revCb = sim.registerReverseCallback(reverseCallback, false)) { - // Bootstrap into a non-off state to verify the callbacks - relay.set(Relay.Value.kOn); - forwardCallback.reset(); - reverseCallback.reset(); - - relay.set(Relay.Value.kOff); - assertEquals(Relay.Value.kOff, relay.get()); - assertFalse(sim.getForward()); - assertFalse(sim.getReverse()); - - assertTrue(forwardCallback.wasTriggered()); - assertFalse(forwardCallback.getSetValue()); - assertTrue(reverseCallback.wasTriggered()); - assertFalse(reverseCallback.getSetValue()); - } - } - - @Test - void testStopMotor() { - try (Relay relay = new Relay(0)) { - // Bootstrap into non-off state - relay.set(Relay.Value.kOn); - - relay.stopMotor(); - assertEquals(Relay.Value.kOff, relay.get()); - } - } - - @Test - void testForwardOnlyCannotGoReverse() { - try (Relay relay = new Relay(0, Relay.Direction.kForward)) { - relay.set(Relay.Value.kForward); - assertEquals(Relay.Value.kOn, relay.get()); - - relay.set(Relay.Value.kOff); - assertEquals(Relay.Value.kOff, relay.get()); - - assertThrows(Relay.InvalidValueException.class, () -> relay.set(Relay.Value.kReverse)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOn)); - } - } - - @Test - void testReverseOnlyCannotGoForwards() { - try (Relay relay = new Relay(0, Relay.Direction.kReverse)) { - relay.set(Relay.Value.kReverse); - assertEquals(Relay.Value.kOn, relay.get()); - - relay.set(Relay.Value.kOff); - assertEquals(Relay.Value.kOff, relay.get()); - - assertThrows(Relay.InvalidValueException.class, () -> relay.set(Relay.Value.kForward)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOn)); - } - } - - @Test - void testSwitchDirections() { - try (Relay relay = new Relay(0, Relay.Direction.kBoth)) { - // Start with both. Should be able to set all 4 values - assertDoesNotThrow(() -> relay.set(Relay.Value.kOff)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kForward)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kReverse)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOn)); - - // Switch it to forward only - relay.setDirection(Relay.Direction.kForward); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOff)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kForward)); - assertThrows(Relay.InvalidValueException.class, () -> relay.set(Relay.Value.kReverse)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOn)); - - // Switch it to Reverse only - relay.setDirection(Relay.Direction.kReverse); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOff)); - assertThrows(Relay.InvalidValueException.class, () -> relay.set(Relay.Value.kForward)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kReverse)); - assertDoesNotThrow(() -> relay.set(Relay.Value.kOn)); - } - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json index 1abd22855bf..8bb03fbccad 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/examples.json @@ -102,19 +102,6 @@ "mainclass": "Main", "commandversion": 2 }, - { - "name": "Relay", - "description": "Control a relay from joystick buttons.", - "tags": [ - "Hardware", - "Relay", - "Joystick" - ], - "foldername": "relay", - "gradlebase": "java", - "mainclass": "Main", - "commandversion": 2 - }, { "name": "Ultrasonic", "description": "View values from a ping-response ultrasonic sensor.", diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Main.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Main.java deleted file mode 100644 index c005ec73e6f..00000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Main.java +++ /dev/null @@ -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. - -package edu.wpi.first.wpilibj.examples.relay; - -import edu.wpi.first.wpilibj.RobotBase; - -/** - * Do NOT add any static variables to this class, or any initialization at all. Unless you know what - * you are doing, do not modify this file except to change the parameter class to the startRobot - * call. - */ -public final class Main { - private Main() {} - - /** - * Main initialization function. Do not perform any initialization here. - * - *

If you change your main robot class, change the parameter type. - */ - public static void main(String... args) { - RobotBase.startRobot(Robot::new); - } -} diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Robot.java deleted file mode 100644 index 39e505e1f1b..00000000000 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/relay/Robot.java +++ /dev/null @@ -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. - -package edu.wpi.first.wpilibj.examples.relay; - -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.Relay; -import edu.wpi.first.wpilibj.TimedRobot; - -/** - * This is a sample program which uses joystick buttons to control a relay. A Relay (generally a - * spike) has two outputs, each of which can be at either 0V or 12V and so can be used for actions - * such as turning a motor off, full forwards, or full reverse, and is generally used on the - * compressor. This program uses two buttons on a joystick and each button corresponds to one - * output; pressing the button sets the output to 12V and releasing sets it to 0V. - */ -public class Robot extends TimedRobot { - private final Joystick m_stick = new Joystick(0); - private final Relay m_relay = new Relay(0); - - private static final int kRelayForwardButton = 1; - private static final int kRelayReverseButton = 2; - - @Override - public void teleopPeriodic() { - /* - * Retrieve the button values. GetRawButton will - * return true if the button is pressed and false if not. - */ - boolean forward = m_stick.getRawButton(kRelayForwardButton); - boolean reverse = m_stick.getRawButton(kRelayReverseButton); - - /* - * Depending on the button values, we want to use one of - * kOn, kOff, kForward, or kReverse. kOn sets both outputs to 12V, - * kOff sets both to 0V, kForward sets forward to 12V - * and reverse to 0V, and kReverse sets reverse to 12V and forward to 0V. - */ - if (forward && reverse) { - m_relay.set(Relay.Value.kOn); - } else if (forward) { - m_relay.set(Relay.Value.kForward); - } else if (reverse) { - m_relay.set(Relay.Value.kReverse); - } else { - m_relay.set(Relay.Value.kOff); - } - } -} diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java index 63ea22a7f25..ec6e930f07c 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java @@ -42,10 +42,4 @@ public void testAnalogOutputChannels() { public void testPwmChannels() { assertEquals(20, SensorUtil.kPwmChannels); } - - /** kRelayChannels. */ - @Test - public void testRelayChannels() { - assertEquals(4, SensorUtil.kRelayChannels); - } } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java deleted file mode 100644 index cc520c3f8b7..00000000000 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java +++ /dev/null @@ -1,143 +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. - -package edu.wpi.first.wpilibj; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.networktables.NetworkTableInstance; -import edu.wpi.first.wpilibj.Relay.Direction; -import edu.wpi.first.wpilibj.Relay.InvalidValueException; -import edu.wpi.first.wpilibj.Relay.Value; -import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl; -import edu.wpi.first.wpilibj.test.AbstractComsSetup; -import edu.wpi.first.wpilibj.test.TestBench; -import java.util.logging.Logger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** Tests the {@link RelayCrossConnectFixture}. */ -public class RelayCrossConnectTest extends AbstractComsSetup { - private static final Logger logger = Logger.getLogger(RelayCrossConnectTest.class.getName()); - private static final NetworkTable table = - NetworkTableInstance.getDefault().getTable("_RELAY_CROSS_CONNECT_TEST_"); - private RelayCrossConnectFixture m_relayFixture; - private SendableBuilderImpl m_builder; - - @Before - public void setUp() { - m_relayFixture = TestBench.getRelayCrossConnectFixture(); - m_relayFixture.setup(); - m_builder = new SendableBuilderImpl(); - m_builder.setTable(table); - m_relayFixture.getRelay().initSendable(m_builder); - } - - @After - public void tearDown() { - m_relayFixture.reset(); - m_relayFixture.teardown(); - } - - @Test - public void testBothHigh() { - m_relayFixture.getRelay().setDirection(Direction.kBoth); - m_relayFixture.getRelay().set(Value.kOn); - m_builder.update(); - assertTrue( - "Input one was not high when relay set both high", m_relayFixture.getInputOne().get()); - assertTrue( - "Input two was not high when relay set both high", m_relayFixture.getInputTwo().get()); - assertEquals(Value.kOn, m_relayFixture.getRelay().get()); - assertEquals("On", table.getEntry("Value").getString("")); - } - - @Test - public void testFirstHigh() { - m_relayFixture.getRelay().setDirection(Direction.kBoth); - m_relayFixture.getRelay().set(Value.kForward); - m_builder.update(); - assertFalse( - "Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne().get()); - assertTrue( - "Input two was not high when relay set Value.kForward", m_relayFixture.getInputTwo().get()); - assertEquals(Value.kForward, m_relayFixture.getRelay().get()); - assertEquals("Forward", table.getEntry("Value").getString("")); - } - - @Test - public void testSecondHigh() { - m_relayFixture.getRelay().setDirection(Direction.kBoth); - m_relayFixture.getRelay().set(Value.kReverse); - m_builder.update(); - assertTrue( - "Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne().get()); - assertFalse( - "Input two was not low when relay set Value.kReverse", m_relayFixture.getInputTwo().get()); - assertEquals(Value.kReverse, m_relayFixture.getRelay().get()); - assertEquals("Reverse", table.getEntry("Value").getString("")); - } - - @Test - public void testForwardDirection() { - m_relayFixture.getRelay().setDirection(Direction.kForward); - m_relayFixture.getRelay().set(Value.kOn); - m_builder.update(); - assertFalse( - "Input one was not low when relay set Value.kOn in kForward Direction", - m_relayFixture.getInputOne().get()); - assertTrue( - "Input two was not high when relay set Value.kOn in kForward Direction", - m_relayFixture.getInputTwo().get()); - assertEquals(Value.kOn, m_relayFixture.getRelay().get()); - assertEquals("On", table.getEntry("Value").getString("")); - } - - @Test - public void testReverseDirection() { - m_relayFixture.getRelay().setDirection(Direction.kReverse); - m_relayFixture.getRelay().set(Value.kOn); - m_builder.update(); - assertTrue( - "Input one was not high when relay set Value.kOn in kReverse Direction", - m_relayFixture.getInputOne().get()); - assertFalse( - "Input two was not low when relay set Value.kOn in kReverse Direction", - m_relayFixture.getInputTwo().get()); - assertEquals(Value.kOn, m_relayFixture.getRelay().get()); - assertEquals("On", table.getEntry("Value").getString("")); - } - - @Test(expected = InvalidValueException.class) - public void testSetValueForwardWithDirectionReverseThrowingException() { - m_relayFixture.getRelay().setDirection(Direction.kForward); - m_relayFixture.getRelay().set(Value.kReverse); - } - - @Test(expected = InvalidValueException.class) - public void testSetValueReverseWithDirectionForwardThrowingException() { - m_relayFixture.getRelay().setDirection(Direction.kReverse); - m_relayFixture.getRelay().set(Value.kForward); - } - - @Test - public void testInitialSettings() { - m_builder.update(); - assertEquals(Value.kOff, m_relayFixture.getRelay().get()); - // Initially both outputs should be off - assertFalse(m_relayFixture.getInputOne().get()); - assertFalse(m_relayFixture.getInputTwo().get()); - assertEquals("Off", table.getEntry("Value").getString("")); - } - - @Override - protected Logger getClassLogger() { - return logger; - } -} diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java index e7d968f9e2c..d92acbc0212 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java @@ -31,7 +31,6 @@ PCMTest.class, PDPTest.class, PIDTest.class, - RelayCrossConnectTest.class, SampleTest.class, TimerTest.class }) diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java deleted file mode 100644 index 3076caf19a1..00000000000 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java +++ /dev/null @@ -1,90 +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. - -package edu.wpi.first.wpilibj.fixtures; - -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.Relay; - -/** A connection between a {@link Relay} and two {@link DigitalInput DigitalInputs}. */ -public abstract class RelayCrossConnectFixture implements ITestFixture { - private DigitalInput m_inputOne; - private DigitalInput m_inputTwo; - private Relay m_relay; - - private boolean m_initialized = false; - private boolean m_freed = false; - - protected abstract Relay giveRelay(); - - protected abstract DigitalInput giveInputOne(); - - protected abstract DigitalInput giveInputTwo(); - - private void initialize() { - synchronized (this) { - if (!m_initialized) { - m_relay = giveRelay(); - m_inputOne = giveInputOne(); - m_inputTwo = giveInputTwo(); - m_initialized = true; - } - } - } - - public Relay getRelay() { - initialize(); - return m_relay; - } - - public DigitalInput getInputOne() { - initialize(); - return m_inputOne; - } - - public DigitalInput getInputTwo() { - initialize(); - return m_inputTwo; - } - - /* - * (non-Javadoc) - * - * @see edu.wpi.first.wpilibj.fixtures.ITestFixture#setup() - */ - @Override - public void setup() { - initialize(); - } - - /* - * (non-Javadoc) - * - * @see edu.wpi.first.wpilibj.fixtures.ITestFixture#reset() - */ - @Override - public void reset() { - initialize(); - } - - /* - * (non-Javadoc) - * - * @see edu.wpi.first.wpilibj.fixtures.ITestFixture#teardown() - */ - @Override - public void teardown() { - if (!m_freed) { - m_relay.close(); - m_inputOne.close(); - m_inputTwo.close(); - m_freed = true; - } else { - throw new RuntimeException( - "You attempted to free the " - + RelayCrossConnectFixture.class.getSimpleName() - + " multiple times"); - } - } -} diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java index cba5a357132..b4316d2633a 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java @@ -8,12 +8,10 @@ import edu.wpi.first.wpilibj.AnalogInput; import edu.wpi.first.wpilibj.AnalogOutput; import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.Relay; import edu.wpi.first.wpilibj.Servo; import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture; import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture; import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; -import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture; import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture; import edu.wpi.first.wpilibj.motorcontrol.Jaguar; import edu.wpi.first.wpilibj.motorcontrol.Talon; @@ -225,26 +223,6 @@ protected AnalogInput giveAnalogInput() { }; } - /** Returns the relay cross-connect fixture. */ - public static RelayCrossConnectFixture getRelayCrossConnectFixture() { - return new RelayCrossConnectFixture() { - @Override - protected Relay giveRelay() { - return new Relay(0); - } - - @Override - protected DigitalInput giveInputTwo() { - return new DigitalInput(18); - } - - @Override - protected DigitalInput giveInputOne() { - return new DigitalInput(19); - } - }; - } - /** * Return a single Collection containing all of the DIOCrossConnectFixtures in all two pair * combinations. From c8aa1c7ee80c8410b0b0214f35949ee56aab3c97 Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 16 Jan 2025 17:42:15 -0800 Subject: [PATCH 2/3] Fix doc builds --- .../edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java index c034a4a433a..bdce8093aa8 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java @@ -395,10 +395,6 @@ public enum BuiltInWidgets implements WidgetType { * Displays a relay with toggle buttons for each supported mode (off, on, forward, reverse).
* Supported types: * - *

    - *
  • {@link edu.wpi.first.wpilibj.Relay} - *
- * *
* This widget has no custom properties. */ From 1377019eb9383b124c0ab50d4e3ddcc05da8f7a8 Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 16 Jan 2025 17:53:49 -0800 Subject: [PATCH 3/3] Check thing --- .../edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java index bdce8093aa8..f4157aad875 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/BuiltInWidgets.java @@ -393,9 +393,6 @@ public enum BuiltInWidgets implements WidgetType { kGyro("Gyro"), /** * Displays a relay with toggle buttons for each supported mode (off, on, forward, reverse).
- * Supported types: - * - *
* This widget has no custom properties. */ kRelay("Relay"),