From b417d961ec32a8749843fe94409ddfe201049bed Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 13 Jun 2021 16:38:05 -0700 Subject: [PATCH] Split Sendable into NT and non-NT portions (#3432) The non-NT portion has been moved to wpiutil. The NT portion has been moved to ntcore (as NTSendable). SendableBuilder similarly split and moved. SendableRegistry moved to wpiutil. In C++, SendableHelper also moved to wpiutil. This enables use of Sendable from wpimath and also enables moving several classes from wpilib to wpimath. --- .../wpi/first/networktables/NTSendable.java | 25 +++++++ .../networktables/NTSendableBuilder.java | 51 ++++++++++++++ .../native/cpp/networktables/NTSendable.cpp | 17 +++++ .../cpp/networktables/NTSendableBuilder.cpp | 11 +++ .../native/include/networktables/NTSendable.h | 28 ++++++++ .../include/networktables/NTSendableBuilder.h | 65 +++++++++++++++++ .../first/wpilibj2/command/CommandBase.java | 6 +- .../wpilibj2/command/CommandScheduler.java | 10 +-- .../first/wpilibj2/command/SubsystemBase.java | 6 +- .../first/wpilibj2/command/WaitCommand.java | 2 +- .../native/cpp/frc2/command/CommandBase.cpp | 16 ++--- .../cpp/frc2/command/CommandScheduler.cpp | 10 +-- .../native/cpp/frc2/command/SubsystemBase.cpp | 20 +++--- .../native/include/frc2/command/CommandBase.h | 10 +-- .../include/frc2/command/CommandScheduler.h | 10 +-- .../include/frc2/command/SubsystemBase.h | 12 ++-- .../java/edu/wpi/first/wpilibj/PIDBase.java | 5 +- .../edu/wpi/first/wpilibj/PIDController.java | 2 +- .../wpi/first/wpilibj/buttons/Trigger.java | 4 +- .../wpi/first/wpilibj/command/Command.java | 6 +- .../wpi/first/wpilibj/command/PIDCommand.java | 2 +- .../wpi/first/wpilibj/command/Scheduler.java | 10 +-- .../wpi/first/wpilibj/command/Subsystem.java | 6 +- .../src/main/native/cpp/PIDBase.cpp | 8 +-- .../src/main/native/cpp/PIDController.cpp | 5 +- .../src/main/native/cpp/buttons/Trigger.cpp | 5 +- .../src/main/native/cpp/commands/Command.cpp | 22 +++--- .../main/native/cpp/commands/PIDCommand.cpp | 4 +- .../main/native/cpp/commands/Scheduler.cpp | 12 ++-- .../main/native/cpp/commands/Subsystem.cpp | 35 +++++----- .../src/main/native/include/frc/PIDBase.h | 12 ++-- .../main/native/include/frc/PIDController.h | 2 +- .../main/native/include/frc/buttons/Trigger.h | 8 +-- .../native/include/frc/commands/Command.h | 8 +-- .../native/include/frc/commands/PIDCommand.h | 2 +- .../native/include/frc/commands/Scheduler.h | 8 +-- .../native/include/frc/commands/Subsystem.h | 20 +++--- .../shuffleboard/ShuffleboardTabTest.java | 2 +- .../cpp/shuffleboard/ShuffleboardTabTest.cpp | 1 - .../shuffleboard/ShuffleboardWidgetTest.cpp | 1 - wpilibc/src/main/native/cpp/ADXL345_I2C.cpp | 9 ++- wpilibc/src/main/native/cpp/ADXL345_SPI.cpp | 9 ++- wpilibc/src/main/native/cpp/ADXL362.cpp | 8 +-- wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp | 8 +-- .../main/native/cpp/AnalogAccelerometer.cpp | 12 ++-- wpilibc/src/main/native/cpp/AnalogEncoder.cpp | 8 +-- wpilibc/src/main/native/cpp/AnalogGyro.cpp | 14 ++-- wpilibc/src/main/native/cpp/AnalogInput.cpp | 8 +-- wpilibc/src/main/native/cpp/AnalogOutput.cpp | 8 +-- .../main/native/cpp/AnalogPotentiometer.cpp | 12 ++-- wpilibc/src/main/native/cpp/AnalogTrigger.cpp | 10 +-- .../main/native/cpp/AnalogTriggerOutput.cpp | 2 +- .../main/native/cpp/BuiltInAccelerometer.cpp | 8 +-- wpilibc/src/main/native/cpp/Counter.cpp | 12 ++-- .../main/native/cpp/DigitalGlitchFilter.cpp | 8 +-- wpilibc/src/main/native/cpp/DigitalInput.cpp | 8 +-- wpilibc/src/main/native/cpp/DigitalOutput.cpp | 8 +-- .../src/main/native/cpp/DoubleSolenoid.cpp | 8 +-- wpilibc/src/main/native/cpp/DutyCycle.cpp | 6 +- .../src/main/native/cpp/DutyCycleEncoder.cpp | 8 +-- wpilibc/src/main/native/cpp/Encoder.cpp | 14 ++-- wpilibc/src/main/native/cpp/PWM.cpp | 8 +-- .../native/cpp/PowerDistributionPanel.cpp | 9 +-- wpilibc/src/main/native/cpp/Relay.cpp | 8 +-- wpilibc/src/main/native/cpp/Servo.cpp | 9 ++- wpilibc/src/main/native/cpp/Solenoid.cpp | 10 +-- .../main/native/cpp/SpeedControllerGroup.cpp | 11 +-- wpilibc/src/main/native/cpp/Ultrasonic.cpp | 12 ++-- .../native/cpp/controller/PIDController.cpp | 8 +-- .../native/cpp/drive/DifferentialDrive.cpp | 8 +-- .../main/native/cpp/drive/KilloughDrive.cpp | 8 +-- .../main/native/cpp/drive/MecanumDrive.cpp | 8 +-- .../main/native/cpp/livewindow/LiveWindow.cpp | 26 +++---- .../cpp/motorcontrol/MotorControllerGroup.cpp | 11 +-- .../cpp/motorcontrol/NidecBrushless.cpp | 9 ++- .../cpp/motorcontrol/PWMMotorController.cpp | 8 +-- .../native/cpp/motorcontrol/PWMSparkMax.cpp | 2 - .../native/cpp/shuffleboard/ComplexWidget.cpp | 29 ++++---- .../shuffleboard/SendableCameraWrapper.cpp | 11 ++- .../shuffleboard/ShuffleboardContainer.cpp | 9 +-- .../native/cpp/smartdashboard/Field2d.cpp | 8 +-- .../native/cpp/smartdashboard/Mechanism2d.cpp | 4 +- .../cpp/smartdashboard/MechanismRoot2d.cpp | 2 - .../smartdashboard/SendableBuilderImpl.cpp | 4 +- .../smartdashboard/SendableChooserBase.cpp | 4 +- .../cpp/smartdashboard/SmartDashboard.cpp | 27 ++++--- .../src/main/native/include/frc/ADXL345_I2C.h | 12 ++-- .../src/main/native/include/frc/ADXL345_SPI.h | 10 +-- wpilibc/src/main/native/include/frc/ADXL362.h | 12 ++-- .../main/native/include/frc/ADXRS450_Gyro.h | 10 +-- .../native/include/frc/AnalogAccelerometer.h | 13 ++-- .../main/native/include/frc/AnalogEncoder.h | 9 +-- .../src/main/native/include/frc/AnalogGyro.h | 10 +-- .../src/main/native/include/frc/AnalogInput.h | 11 ++- .../main/native/include/frc/AnalogOutput.h | 12 ++-- .../native/include/frc/AnalogPotentiometer.h | 13 ++-- .../main/native/include/frc/AnalogTrigger.h | 10 +-- .../native/include/frc/AnalogTriggerOutput.h | 11 +-- .../native/include/frc/BuiltInAccelerometer.h | 13 ++-- wpilibc/src/main/native/include/frc/Counter.h | 11 ++- .../native/include/frc/DigitalGlitchFilter.h | 10 +-- .../main/native/include/frc/DigitalInput.h | 12 ++-- .../main/native/include/frc/DigitalOutput.h | 12 ++-- .../main/native/include/frc/DoubleSolenoid.h | 11 ++- .../src/main/native/include/frc/DutyCycle.h | 9 ++- .../native/include/frc/DutyCycleEncoder.h | 10 +-- wpilibc/src/main/native/include/frc/Encoder.h | 11 ++- wpilibc/src/main/native/include/frc/PWM.h | 10 ++- .../include/frc/PowerDistributionPanel.h | 14 ++-- wpilibc/src/main/native/include/frc/Relay.h | 12 ++-- wpilibc/src/main/native/include/frc/Servo.h | 2 +- .../src/main/native/include/frc/Solenoid.h | 10 ++- .../native/include/frc/SpeedControllerGroup.h | 10 +-- .../src/main/native/include/frc/Ultrasonic.h | 9 +-- .../include/frc/controller/PIDController.h | 11 ++- .../frc/controller/ProfiledPIDController.h | 12 ++-- .../include/frc/drive/DifferentialDrive.h | 11 +-- .../native/include/frc/drive/KilloughDrive.h | 11 +-- .../native/include/frc/drive/MecanumDrive.h | 11 +-- .../include/frc/livewindow/LiveWindow.h | 10 +-- .../frc/motorcontrol/MotorControllerGroup.h | 11 +-- .../include/frc/motorcontrol/NidecBrushless.h | 13 ++-- .../frc/motorcontrol/PWMMotorController.h | 11 +-- .../include/frc/shuffleboard/ComplexWidget.h | 17 +++-- .../frc/shuffleboard/SendableCameraWrapper.h | 13 ++-- .../frc/shuffleboard/ShuffleboardComponent.h | 2 - .../shuffleboard/ShuffleboardComponentBase.h | 2 - .../frc/shuffleboard/ShuffleboardContainer.h | 9 ++- .../include/frc/smartdashboard/Field2d.h | 8 +-- .../include/frc/smartdashboard/Mechanism2d.h | 9 +-- .../frc/smartdashboard/SendableBuilderImpl.h | 11 ++- .../frc/smartdashboard/SendableChooser.h | 3 +- .../frc/smartdashboard/SendableChooser.inc | 4 +- .../frc/smartdashboard/SendableChooserBase.h | 9 ++- .../frc/smartdashboard/SmartDashboard.h | 13 ++-- .../cpp/shuffleboard/MockActuatorSendable.cpp | 9 ++- .../shuffleboard/MockActuatorSendable.h | 7 +- .../edu/wpi/first/wpilibj/ADXL345_I2C.java | 9 +-- .../edu/wpi/first/wpilibj/ADXL345_SPI.java | 9 +-- .../java/edu/wpi/first/wpilibj/ADXL362.java | 9 +-- .../edu/wpi/first/wpilibj/ADXRS450_Gyro.java | 5 +- .../first/wpilibj/AnalogAccelerometer.java | 5 +- .../edu/wpi/first/wpilibj/AnalogEncoder.java | 5 +- .../edu/wpi/first/wpilibj/AnalogGyro.java | 5 +- .../edu/wpi/first/wpilibj/AnalogInput.java | 5 +- .../edu/wpi/first/wpilibj/AnalogOutput.java | 5 +- .../first/wpilibj/AnalogPotentiometer.java | 5 +- .../edu/wpi/first/wpilibj/AnalogTrigger.java | 5 +- .../first/wpilibj/AnalogTriggerOutput.java | 3 +- .../first/wpilibj/BuiltInAccelerometer.java | 5 +- .../java/edu/wpi/first/wpilibj/Counter.java | 5 +- .../first/wpilibj/DigitalGlitchFilter.java | 5 +- .../edu/wpi/first/wpilibj/DigitalInput.java | 5 +- .../edu/wpi/first/wpilibj/DigitalOutput.java | 5 +- .../edu/wpi/first/wpilibj/DoubleSolenoid.java | 5 +- .../java/edu/wpi/first/wpilibj/DutyCycle.java | 5 +- .../wpi/first/wpilibj/DutyCycleEncoder.java | 5 +- .../java/edu/wpi/first/wpilibj/Encoder.java | 5 +- .../main/java/edu/wpi/first/wpilibj/PWM.java | 5 +- .../first/wpilibj/PowerDistributionPanel.java | 5 +- .../java/edu/wpi/first/wpilibj/Relay.java | 5 +- .../java/edu/wpi/first/wpilibj/Servo.java | 4 +- .../java/edu/wpi/first/wpilibj/Solenoid.java | 5 +- .../first/wpilibj/SpeedControllerGroup.java | 5 +- .../edu/wpi/first/wpilibj/Ultrasonic.java | 5 +- .../wpilibj/controller/PIDController.java | 6 +- .../controller/ProfiledPIDController.java | 4 +- .../wpilibj/drive/DifferentialDrive.java | 6 +- .../first/wpilibj/drive/KilloughDrive.java | 6 +- .../wpi/first/wpilibj/drive/MecanumDrive.java | 6 +- .../first/wpilibj/livewindow/LiveWindow.java | 17 +++-- .../motorcontrol/MotorControllerGroup.java | 6 +- .../wpilibj/motorcontrol/NidecBrushless.java | 6 +- .../motorcontrol/PWMMotorController.java | 6 +- .../wpilibj/shuffleboard/ComplexWidget.java | 5 +- .../wpilibj/shuffleboard/ContainerHelper.java | 4 +- .../shuffleboard/SendableCameraWrapper.java | 6 +- .../shuffleboard/ShuffleboardContainer.java | 2 +- .../shuffleboard/ShuffleboardLayout.java | 2 +- .../wpilibj/shuffleboard/ShuffleboardTab.java | 2 +- .../first/wpilibj/smartdashboard/Field2d.java | 8 ++- .../wpilibj/smartdashboard/Mechanism2d.java | 7 +- .../smartdashboard/SendableBuilderImpl.java | 10 ++- .../smartdashboard/SendableChooser.java | 8 ++- .../smartdashboard/SmartDashboard.java | 8 ++- .../shuffleboard/MockActuatorSendable.java | 6 +- .../java/edu/wpi/first/wpilibj/PIDTest.java | 2 +- .../first/wpilibj/RelayCrossConnectTest.java | 12 ++-- .../wpi/first/util/sendable}/Sendable.java | 6 +- .../first/util/sendable}/SendableBuilder.java | 56 ++++++--------- .../util/sendable}/SendableRegistry.java | 58 ++++++++++----- .../native/cpp/sendable}/SendableRegistry.cpp | 63 +++++++++++------ .../native/include/wpi/sendable}/Sendable.h | 4 +- .../include/wpi/sendable}/SendableBuilder.h | 70 ++++++++----------- .../include/wpi/sendable}/SendableHelper.h | 9 ++- .../include/wpi/sendable}/SendableRegistry.h | 32 +++++---- 196 files changed, 1147 insertions(+), 891 deletions(-) create mode 100644 ntcore/src/main/java/edu/wpi/first/networktables/NTSendable.java create mode 100644 ntcore/src/main/java/edu/wpi/first/networktables/NTSendableBuilder.java create mode 100644 ntcore/src/main/native/cpp/networktables/NTSendable.cpp create mode 100644 ntcore/src/main/native/cpp/networktables/NTSendableBuilder.cpp create mode 100644 ntcore/src/main/native/include/networktables/NTSendable.h create mode 100644 ntcore/src/main/native/include/networktables/NTSendableBuilder.h rename {wpilibj/src/main/java/edu/wpi/first/wpilibj => wpiutil/src/main/java/edu/wpi/first/util/sendable}/Sendable.java (77%) rename {wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard => wpiutil/src/main/java/edu/wpi/first/util/sendable}/SendableBuilder.java (75%) rename {wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard => wpiutil/src/main/java/edu/wpi/first/util/sendable}/SendableRegistry.java (91%) rename {wpilibc/src/main/native/cpp/smartdashboard => wpiutil/src/main/native/cpp/sendable}/SendableRegistry.cpp (88%) rename {wpilibc/src/main/native/include/frc/smartdashboard => wpiutil/src/main/native/include/wpi/sendable}/Sendable.h (93%) rename {wpilibc/src/main/native/include/frc/smartdashboard => wpiutil/src/main/native/include/wpi/sendable}/SendableBuilder.h (82%) rename {wpilibc/src/main/native/include/frc/smartdashboard => wpiutil/src/main/native/include/wpi/sendable}/SendableHelper.h (97%) rename {wpilibc/src/main/native/include/frc/smartdashboard => wpiutil/src/main/native/include/wpi/sendable}/SendableRegistry.h (92%) diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NTSendable.java b/ntcore/src/main/java/edu/wpi/first/networktables/NTSendable.java new file mode 100644 index 0000000000..641224d3fc --- /dev/null +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NTSendable.java @@ -0,0 +1,25 @@ +// 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.networktables; + +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; + +/** Interface for NetworkTable Sendable objects. */ +public interface NTSendable extends Sendable { + /** + * Initializes this {@link Sendable} object. + * + * @param builder sendable builder + */ + void initSendable(NTSendableBuilder builder); + + @Override + default void initSendable(SendableBuilder builder) { + if (builder.getBackendKind() == SendableBuilder.BackendKind.kNetworkTables) { + initSendable((NTSendableBuilder) builder); + } + } +} diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NTSendableBuilder.java b/ntcore/src/main/java/edu/wpi/first/networktables/NTSendableBuilder.java new file mode 100644 index 0000000000..65bfbca893 --- /dev/null +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NTSendableBuilder.java @@ -0,0 +1,51 @@ +// 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.networktables; + +import edu.wpi.first.util.sendable.SendableBuilder; +import java.util.function.Consumer; +import java.util.function.Supplier; + +public interface NTSendableBuilder extends SendableBuilder { + /** + * Set the function that should be called to update the network table for things other than + * properties. Note this function is not passed the network table object; instead it should use + * the entry handles returned by getEntry(). + * + * @param func function + */ + void setUpdateTable(Runnable func); + + /** + * Add a property without getters or setters. This can be used to get entry handles for the + * function called by setUpdateTable(). + * + * @param key property name + * @return Network table entry + */ + NetworkTableEntry getEntry(String key); + + /** + * Add a NetworkTableValue property. + * + * @param key property name + * @param getter getter function (returns current value) + * @param setter setter function (sets new value) + */ + void addValueProperty( + String key, Supplier getter, Consumer setter); + + /** + * Get the network table. + * + * @return The network table + */ + NetworkTable getTable(); + + @Override + default BackendKind getBackendKind() { + return BackendKind.kNetworkTables; + } +} diff --git a/ntcore/src/main/native/cpp/networktables/NTSendable.cpp b/ntcore/src/main/native/cpp/networktables/NTSendable.cpp new file mode 100644 index 0000000000..211fcc5977 --- /dev/null +++ b/ntcore/src/main/native/cpp/networktables/NTSendable.cpp @@ -0,0 +1,17 @@ +// 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 "networktables/NTSendable.h" + +#include + +#include "networktables/NTSendableBuilder.h" + +using namespace nt; + +void NTSendable::InitSendable(wpi::SendableBuilder& builder) { + if (builder.GetBackendKind() == wpi::SendableBuilder::kNetworkTables) { + InitSendable(static_cast(builder)); + } +} diff --git a/ntcore/src/main/native/cpp/networktables/NTSendableBuilder.cpp b/ntcore/src/main/native/cpp/networktables/NTSendableBuilder.cpp new file mode 100644 index 0000000000..df9fc47855 --- /dev/null +++ b/ntcore/src/main/native/cpp/networktables/NTSendableBuilder.cpp @@ -0,0 +1,11 @@ +// 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 "networktables/NTSendableBuilder.h" + +using namespace nt; + +NTSendableBuilder::BackendKind NTSendableBuilder::GetBackendKind() const { + return kNetworkTables; +} diff --git a/ntcore/src/main/native/include/networktables/NTSendable.h b/ntcore/src/main/native/include/networktables/NTSendable.h new file mode 100644 index 0000000000..88924f8731 --- /dev/null +++ b/ntcore/src/main/native/include/networktables/NTSendable.h @@ -0,0 +1,28 @@ +// 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 + +namespace nt { + +class NTSendableBuilder; + +/** + * Interface for NetworkTable Sendable objects. + */ +class NTSendable : public wpi::Sendable { + public: + /** + * Initializes this Sendable object. + * + * @param builder sendable builder + */ + virtual void InitSendable(NTSendableBuilder& builder) = 0; + + void InitSendable(wpi::SendableBuilder& builder) override; +}; + +} // namespace nt diff --git a/ntcore/src/main/native/include/networktables/NTSendableBuilder.h b/ntcore/src/main/native/include/networktables/NTSendableBuilder.h new file mode 100644 index 0000000000..8ff265b46f --- /dev/null +++ b/ntcore/src/main/native/include/networktables/NTSendableBuilder.h @@ -0,0 +1,65 @@ +// 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 "networktables/NetworkTable.h" +#include "networktables/NetworkTableEntry.h" +#include "networktables/NetworkTableValue.h" + +namespace nt { + +class NTSendableBuilder : public wpi::SendableBuilder { + public: + /** + * Set the function that should be called to update the network table + * for things other than properties. Note this function is not passed + * the network table object; instead it should use the entry handles + * returned by GetEntry(). + * + * @param func function + */ + virtual void SetUpdateTable(std::function func) = 0; + + /** + * Add a property without getters or setters. This can be used to get + * entry handles for the function called by SetUpdateTable(). + * + * @param key property name + * @return Network table entry + */ + virtual NetworkTableEntry GetEntry(std::string_view key) = 0; + + /** + * Add a NetworkTableValue property. + * + * @param key property name + * @param getter getter function (returns current value) + * @param setter setter function (sets new value) + */ + virtual void AddValueProperty( + std::string_view key, std::function()> getter, + std::function)> setter) = 0; + + /** + * Get the network table. + * @return The network table + */ + virtual std::shared_ptr GetTable() = 0; + + /** + * Gets the kind of backend being used. + * + * @return Backend kind + */ + BackendKind GetBackendKind() const override; +}; + +} // namespace nt diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java index 004cb91cdf..9a55ffd13a 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java @@ -4,9 +4,9 @@ package edu.wpi.first.wpilibj2.command; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.HashSet; import java.util.Set; diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 6cc87cf415..79be1bf348 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -7,15 +7,15 @@ package edu.wpi.first.wpilibj2.command; import edu.wpi.first.hal.FRCNetComm.tInstances; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.RobotBase; import edu.wpi.first.wpilibj.RobotState; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.Watchdog; import edu.wpi.first.wpilibj.livewindow.LiveWindow; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -34,7 +34,7 @@ import java.util.function.Consumer; * CommandScheduler#registerSubsystem(Subsystem...)} in order for their {@link Subsystem#periodic()} * methods to be called and for their default commands to be scheduled. */ -public final class CommandScheduler implements Sendable, AutoCloseable { +public final class CommandScheduler implements NTSendable, AutoCloseable { /** The Singleton Instance. */ private static CommandScheduler instance; @@ -501,7 +501,7 @@ public final class CommandScheduler implements Sendable, AutoCloseable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("Scheduler"); final NetworkTableEntry namesEntry = builder.getEntry("Names"); final NetworkTableEntry idsEntry = builder.getEntry("Ids"); diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java index f0a0fae6d5..7dc62674ca 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java @@ -4,9 +4,9 @@ package edu.wpi.first.wpilibj2.command; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * A base for subsystems that handles registration in the constructor, and provides a more intuitive diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java index 0a901b08c1..b2856693b3 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitCommand.java @@ -4,8 +4,8 @@ package edu.wpi.first.wpilibj2.command; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * A command that does nothing but takes a specified amount of time to finish. Useful for diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp index c1415a4282..ca5eb69dd3 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp @@ -4,13 +4,13 @@ #include "frc2/command/CommandBase.h" -#include -#include +#include +#include using namespace frc2; CommandBase::CommandBase() { - frc::SendableRegistry::GetInstance().Add(this, GetTypeName(*this)); + wpi::SendableRegistry::GetInstance().Add(this, GetTypeName(*this)); } void CommandBase::AddRequirements( @@ -31,22 +31,22 @@ wpi::SmallSet CommandBase::GetRequirements() const { } void CommandBase::SetName(std::string_view name) { - frc::SendableRegistry::GetInstance().SetName(this, name); + wpi::SendableRegistry::GetInstance().SetName(this, name); } std::string CommandBase::GetName() const { - return frc::SendableRegistry::GetInstance().GetName(this); + return wpi::SendableRegistry::GetInstance().GetName(this); } std::string CommandBase::GetSubsystem() const { - return frc::SendableRegistry::GetInstance().GetSubsystem(this); + return wpi::SendableRegistry::GetInstance().GetSubsystem(this); } void CommandBase::SetSubsystem(std::string_view subsystem) { - frc::SendableRegistry::GetInstance().SetSubsystem(this, subsystem); + wpi::SendableRegistry::GetInstance().SetSubsystem(this, subsystem); } -void CommandBase::InitSendable(frc::SendableBuilder& builder) { +void CommandBase::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Command"); builder.AddStringProperty( ".name", [this] { return GetName(); }, nullptr); diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp index 295134a76b..530b5edb72 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp @@ -10,13 +10,13 @@ #include #include #include -#include -#include #include #include +#include #include #include #include +#include #include "frc2/command/CommandGroupBase.h" #include "frc2/command/CommandState.h" @@ -70,7 +70,7 @@ CommandScheduler::CommandScheduler() }) { HAL_Report(HALUsageReporting::kResourceType_Command, HALUsageReporting::kCommand2_Scheduler); - frc::SendableRegistry::GetInstance().AddLW(this, "Scheduler"); + wpi::SendableRegistry::GetInstance().AddLW(this, "Scheduler"); auto scheduler = frc::LiveWindow::GetInstance(); scheduler->enabled = [this] { this->Disable(); @@ -80,7 +80,7 @@ CommandScheduler::CommandScheduler() } CommandScheduler::~CommandScheduler() { - frc::SendableRegistry::GetInstance().Remove(this); + wpi::SendableRegistry::GetInstance().Remove(this); auto scheduler = frc::LiveWindow::GetInstance(); scheduler->enabled = nullptr; scheduler->disabled = nullptr; @@ -428,7 +428,7 @@ void CommandScheduler::OnCommandFinish(Action action) { m_impl->finishActions.emplace_back(std::move(action)); } -void CommandScheduler::InitSendable(frc::SendableBuilder& builder) { +void CommandScheduler::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("Scheduler"); auto namesEntry = builder.GetEntry("Names"); auto idsEntry = builder.GetEntry("Ids"); diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp index c19a22e5c4..d312ec45df 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp @@ -4,8 +4,8 @@ #include "frc2/command/SubsystemBase.h" -#include -#include +#include +#include #include "frc2/command/Command.h" #include "frc2/command/CommandScheduler.h" @@ -13,11 +13,11 @@ using namespace frc2; SubsystemBase::SubsystemBase() { - frc::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this)); + wpi::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this)); CommandScheduler::GetInstance().RegisterSubsystem({this}); } -void SubsystemBase::InitSendable(frc::SendableBuilder& builder) { +void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Subsystem"); builder.AddBooleanProperty( ".hasDefault", [this] { return GetDefaultCommand() != nullptr; }, @@ -48,22 +48,22 @@ void SubsystemBase::InitSendable(frc::SendableBuilder& builder) { } std::string SubsystemBase::GetName() const { - return frc::SendableRegistry::GetInstance().GetName(this); + return wpi::SendableRegistry::GetInstance().GetName(this); } void SubsystemBase::SetName(std::string_view name) { - frc::SendableRegistry::GetInstance().SetName(this, name); + wpi::SendableRegistry::GetInstance().SetName(this, name); } std::string SubsystemBase::GetSubsystem() const { - return frc::SendableRegistry::GetInstance().GetSubsystem(this); + return wpi::SendableRegistry::GetInstance().GetSubsystem(this); } void SubsystemBase::SetSubsystem(std::string_view name) { - frc::SendableRegistry::GetInstance().SetSubsystem(this, name); + wpi::SendableRegistry::GetInstance().SetSubsystem(this, name); } -void SubsystemBase::AddChild(std::string name, frc::Sendable* child) { - auto& registry = frc::SendableRegistry::GetInstance(); +void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) { + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddLW(child, GetSubsystem(), name); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h index 473daae48c..c187ceede6 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h @@ -8,9 +8,9 @@ #include #include -#include -#include #include +#include +#include #include #include "frc2/command/Command.h" @@ -20,8 +20,8 @@ namespace frc2 { * A Sendable base class for Commands. */ class CommandBase : public Command, - public frc::Sendable, - public frc::SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Adds the specified requirements to the command. @@ -69,7 +69,7 @@ class CommandBase : public Command, */ void SetSubsystem(std::string_view subsystem); - void InitSendable(frc::SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: CommandBase(); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index e041670c09..71f833b671 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -10,10 +10,10 @@ #include #include -#include -#include +#include #include #include +#include #include namespace frc2 { @@ -27,8 +27,8 @@ class Subsystem; * with the scheduler using RegisterSubsystem() in order for their Periodic() * methods to be called and for their default commands to be scheduled. */ -class CommandScheduler final : public frc::Sendable, - public frc::SendableHelper { +class CommandScheduler final : public nt::NTSendable, + public wpi::SendableHelper { public: /** * Returns the Scheduler instance. @@ -332,7 +332,7 @@ class CommandScheduler final : public frc::Sendable, */ void OnCommandFinish(Action action); - void InitSendable(frc::SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; private: // Constructor; private as this is a singleton diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h index 06ea69e4a4..ddcecaca48 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h @@ -7,8 +7,8 @@ #include #include -#include -#include +#include +#include #include "frc2/command/Subsystem.h" @@ -18,10 +18,10 @@ namespace frc2 { * provides a more intuitive method for setting the default command. */ class SubsystemBase : public Subsystem, - public frc::Sendable, - public frc::SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: - void InitSendable(frc::SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; /** * Gets the name of this Subsystem. @@ -58,7 +58,7 @@ class SubsystemBase : public Subsystem, * @param name name to give child * @param child sendable */ - void AddChild(std::string name, frc::Sendable* child); + void AddChild(std::string name, wpi::Sendable* child); protected: SubsystemBase(); diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDBase.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDBase.java index d970451178..75a6d08aff 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDBase.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDBase.java @@ -10,8 +10,9 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.util.BoundaryException; import edu.wpi.first.math.filter.LinearFilter; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.concurrent.locks.ReentrantLock; /** diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDController.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDController.java index ad7046e6a4..de5e07846d 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDController.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/PIDController.java @@ -4,7 +4,7 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; +import edu.wpi.first.util.sendable.SendableBuilder; /** * Class implements a PID Control Loop. diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java index d5120e9d0f..22db6f65f6 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java @@ -4,10 +4,10 @@ package edu.wpi.first.wpilibj.buttons; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * This class provides an easy way to link commands to inputs. diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Command.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Command.java index 8c7be01459..234fed4fc3 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Command.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Command.java @@ -4,11 +4,11 @@ package edu.wpi.first.wpilibj.command; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.RobotState; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.util.Enumeration; /** diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java index 5fca479fbc..03343163f8 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java @@ -4,11 +4,11 @@ package edu.wpi.first.wpilibj.command; +import edu.wpi.first.util.sendable.SendableBuilder; import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * This class defines a {@link Command} which interacts heavily with a PID loop. diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java index 4b2384bcc0..ca1ed330c7 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java @@ -7,12 +7,12 @@ package edu.wpi.first.wpilibj.command; import edu.wpi.first.hal.FRCNetComm.tInstances; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.buttons.Trigger.ButtonScheduler; import edu.wpi.first.wpilibj.livewindow.LiveWindow; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.util.Enumeration; import java.util.Hashtable; import java.util.Map; @@ -30,7 +30,7 @@ import java.util.Vector; * * @see Command */ -public final class Scheduler implements Sendable, AutoCloseable { +public final class Scheduler implements NTSendable, AutoCloseable { /** The Singleton Instance. */ private static Scheduler instance; @@ -301,7 +301,7 @@ public final class Scheduler implements Sendable, AutoCloseable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("Scheduler"); final NetworkTableEntry namesEntry = builder.getEntry("Names"); final NetworkTableEntry idsEntry = builder.getEntry("Ids"); diff --git a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java index f596ed68f4..2ba01af3bf 100644 --- a/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java +++ b/wpilibOldCommands/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java @@ -4,9 +4,9 @@ package edu.wpi.first.wpilibj.command; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.Collections; /** diff --git a/wpilibOldCommands/src/main/native/cpp/PIDBase.cpp b/wpilibOldCommands/src/main/native/cpp/PIDBase.cpp index 65bb471ddf..0525b4a957 100644 --- a/wpilibOldCommands/src/main/native/cpp/PIDBase.cpp +++ b/wpilibOldCommands/src/main/native/cpp/PIDBase.cpp @@ -8,10 +8,10 @@ #include #include +#include +#include #include "frc/PIDOutput.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -41,7 +41,7 @@ PIDBase::PIDBase(double Kp, double Ki, double Kd, double Kf, PIDSource& source, static int instances = 0; instances++; HAL_Report(HALUsageReporting::kResourceType_PIDController, instances); - SendableRegistry::GetInstance().Add(this, "PIDController", instances); + wpi::SendableRegistry::GetInstance().Add(this, "PIDController", instances); } double PIDBase::Get() const { @@ -228,7 +228,7 @@ void PIDBase::PIDWrite(double output) { SetSetpoint(output); } -void PIDBase::InitSendable(SendableBuilder& builder) { +void PIDBase::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("PIDController"); builder.SetSafeState([=] { Reset(); }); builder.AddDoubleProperty( diff --git a/wpilibOldCommands/src/main/native/cpp/PIDController.cpp b/wpilibOldCommands/src/main/native/cpp/PIDController.cpp index 5adbe1cdf8..ee8382c1ef 100644 --- a/wpilibOldCommands/src/main/native/cpp/PIDController.cpp +++ b/wpilibOldCommands/src/main/native/cpp/PIDController.cpp @@ -4,9 +4,10 @@ #include "frc/PIDController.h" +#include + #include "frc/Notifier.h" #include "frc/PIDOutput.h" -#include "frc/smartdashboard/SendableBuilder.h" using namespace frc; @@ -75,7 +76,7 @@ void PIDController::Reset() { PIDBase::Reset(); } -void PIDController::InitSendable(SendableBuilder& builder) { +void PIDController::InitSendable(wpi::SendableBuilder& builder) { PIDBase::InitSendable(builder); builder.AddBooleanProperty( "enabled", [=] { return IsEnabled(); }, diff --git a/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp b/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp index 6739aa2839..9040df6c36 100644 --- a/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp +++ b/wpilibOldCommands/src/main/native/cpp/buttons/Trigger.cpp @@ -2,13 +2,14 @@ // 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 "frc/buttons/Button.h" #include "frc/buttons/CancelButtonScheduler.h" #include "frc/buttons/HeldButtonScheduler.h" #include "frc/buttons/PressedButtonScheduler.h" #include "frc/buttons/ReleasedButtonScheduler.h" #include "frc/buttons/ToggleButtonScheduler.h" -#include "frc/smartdashboard/SendableBuilder.h" using namespace frc; @@ -62,7 +63,7 @@ void Trigger::ToggleWhenActive(Command* command) { tbs->Start(); } -void Trigger::InitSendable(SendableBuilder& builder) { +void Trigger::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Button"); builder.SetSafeState([=] { m_sendablePressed = false; }); builder.AddBooleanProperty( diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp index 2f662bad42..25c08d7ea8 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Command.cpp @@ -6,14 +6,15 @@ #include +#include +#include + #include "frc/Errors.h" #include "frc/RobotState.h" #include "frc/Timer.h" #include "frc/commands/CommandGroup.h" #include "frc/commands/Scheduler.h" #include "frc/livewindow/LiveWindow.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -40,10 +41,10 @@ Command::Command(std::string_view name, units::second_t timeout) { // If name contains an empty string if (name.empty()) { - SendableRegistry::GetInstance().Add( + wpi::SendableRegistry::GetInstance().Add( this, fmt::format("Command_{}", typeid(*this).name())); } else { - SendableRegistry::GetInstance().Add(this, name); + wpi::SendableRegistry::GetInstance().Add(this, name); } } @@ -277,25 +278,26 @@ void Command::StartTiming() { } std::string Command::GetName() const { - return SendableRegistry::GetInstance().GetName(this); + return wpi::SendableRegistry::GetInstance().GetName(this); } void Command::SetName(std::string_view name) { - SendableRegistry::GetInstance().SetName(this, name); + wpi::SendableRegistry::GetInstance().SetName(this, name); } std::string Command::GetSubsystem() const { - return SendableRegistry::GetInstance().GetSubsystem(this); + return wpi::SendableRegistry::GetInstance().GetSubsystem(this); } void Command::SetSubsystem(std::string_view name) { - SendableRegistry::GetInstance().SetSubsystem(this, name); + wpi::SendableRegistry::GetInstance().SetSubsystem(this, name); } -void Command::InitSendable(SendableBuilder& builder) { +void Command::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Command"); builder.AddStringProperty( - ".name", [=] { return SendableRegistry::GetInstance().GetName(this); }, + ".name", + [=] { return wpi::SendableRegistry::GetInstance().GetName(this); }, nullptr); builder.AddBooleanProperty( "running", [=] { return IsRunning(); }, diff --git a/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp index 152149e9cd..e71556afee 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/PIDCommand.cpp @@ -4,7 +4,7 @@ #include "frc/commands/PIDCommand.h" -#include "frc/smartdashboard/SendableBuilder.h" +#include using namespace frc; @@ -112,7 +112,7 @@ double PIDCommand::GetPosition() { return ReturnPIDInput(); } -void PIDCommand::InitSendable(SendableBuilder& builder) { +void PIDCommand::InitSendable(wpi::SendableBuilder& builder) { m_controller->InitSendable(builder); Command::InitSendable(builder); builder.SetSmartDashboardType("PIDCommand"); diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Scheduler.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Scheduler.cpp index b28da54770..f98345e23c 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Scheduler.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Scheduler.cpp @@ -10,16 +10,16 @@ #include #include +#include #include #include +#include #include "frc/Errors.h" #include "frc/buttons/ButtonScheduler.h" #include "frc/commands/Command.h" #include "frc/commands/Subsystem.h" #include "frc/livewindow/LiveWindow.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -157,7 +157,7 @@ void Scheduler::SetEnabled(bool enabled) { m_impl->enabled = enabled; } -void Scheduler::InitSendable(SendableBuilder& builder) { +void Scheduler::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("Scheduler"); auto namesEntry = builder.GetEntry("Names"); auto idsEntry = builder.GetEntry("Ids"); @@ -186,7 +186,7 @@ void Scheduler::InitSendable(SendableBuilder& builder) { if (m_impl->runningCommandsChanged) { m_impl->commandsBuf.resize(0); m_impl->idsBuf.resize(0); - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); for (const auto& command : m_impl->commands) { m_impl->commandsBuf.emplace_back(registry.GetName(command)); m_impl->idsBuf.emplace_back(command->GetID()); @@ -200,7 +200,7 @@ void Scheduler::InitSendable(SendableBuilder& builder) { Scheduler::Scheduler() : m_impl(new Impl) { HAL_Report(HALUsageReporting::kResourceType_Command, HALUsageReporting::kCommand_Scheduler); - SendableRegistry::GetInstance().AddLW(this, "Scheduler"); + wpi::SendableRegistry::GetInstance().AddLW(this, "Scheduler"); auto scheduler = frc::LiveWindow::GetInstance(); scheduler->enabled = [this] { this->SetEnabled(false); @@ -210,7 +210,7 @@ Scheduler::Scheduler() : m_impl(new Impl) { } Scheduler::~Scheduler() { - SendableRegistry::GetInstance().Remove(this); + wpi::SendableRegistry::GetInstance().Remove(this); auto scheduler = frc::LiveWindow::GetInstance(); scheduler->enabled = nullptr; scheduler->disabled = nullptr; diff --git a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp index 5b9e888cb8..caad34a060 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/Subsystem.cpp @@ -4,17 +4,18 @@ #include "frc/commands/Subsystem.h" +#include +#include + #include "frc/Errors.h" #include "frc/commands/Command.h" #include "frc/commands/Scheduler.h" #include "frc/livewindow/LiveWindow.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; Subsystem::Subsystem(std::string_view name) { - SendableRegistry::GetInstance().AddLW(this, name, name); + wpi::SendableRegistry::GetInstance().AddLW(this, name, name); Scheduler::GetInstance()->RegisterSubsystem(this); } @@ -43,7 +44,7 @@ Command* Subsystem::GetDefaultCommand() { std::string Subsystem::GetDefaultCommandName() { Command* defaultCommand = GetDefaultCommand(); if (defaultCommand) { - return SendableRegistry::GetInstance().GetName(defaultCommand); + return wpi::SendableRegistry::GetInstance().GetName(defaultCommand); } else { return {}; } @@ -61,7 +62,7 @@ Command* Subsystem::GetCurrentCommand() const { std::string Subsystem::GetCurrentCommandName() const { Command* currentCommand = GetCurrentCommand(); if (currentCommand) { - return SendableRegistry::GetInstance().GetName(currentCommand); + return wpi::SendableRegistry::GetInstance().GetName(currentCommand); } else { return {}; } @@ -72,19 +73,19 @@ void Subsystem::Periodic() {} void Subsystem::InitDefaultCommand() {} std::string Subsystem::GetName() const { - return SendableRegistry::GetInstance().GetName(this); + return wpi::SendableRegistry::GetInstance().GetName(this); } void Subsystem::SetName(std::string_view name) { - SendableRegistry::GetInstance().SetName(this, name); + wpi::SendableRegistry::GetInstance().SetName(this, name); } std::string Subsystem::GetSubsystem() const { - return SendableRegistry::GetInstance().GetSubsystem(this); + return wpi::SendableRegistry::GetInstance().GetSubsystem(this); } void Subsystem::SetSubsystem(std::string_view name) { - SendableRegistry::GetInstance().SetSubsystem(this, name); + wpi::SendableRegistry::GetInstance().SetSubsystem(this, name); } void Subsystem::AddChild(std::string_view name, @@ -92,25 +93,25 @@ void Subsystem::AddChild(std::string_view name, AddChild(name, *child); } -void Subsystem::AddChild(std::string_view name, Sendable* child) { +void Subsystem::AddChild(std::string_view name, wpi::Sendable* child) { AddChild(name, *child); } -void Subsystem::AddChild(std::string_view name, Sendable& child) { - auto& registry = SendableRegistry::GetInstance(); +void Subsystem::AddChild(std::string_view name, wpi::Sendable& child) { + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddLW(&child, registry.GetSubsystem(this), name); } -void Subsystem::AddChild(std::shared_ptr child) { +void Subsystem::AddChild(std::shared_ptr child) { AddChild(*child); } -void Subsystem::AddChild(Sendable* child) { +void Subsystem::AddChild(wpi::Sendable* child) { AddChild(*child); } -void Subsystem::AddChild(Sendable& child) { - auto& registry = SendableRegistry::GetInstance(); +void Subsystem::AddChild(wpi::Sendable& child) { + auto& registry = wpi::SendableRegistry::GetInstance(); registry.SetSubsystem(&child, registry.GetSubsystem(this)); registry.EnableLiveWindow(&child); } @@ -121,7 +122,7 @@ void Subsystem::ConfirmCommand() { } } -void Subsystem::InitSendable(SendableBuilder& builder) { +void Subsystem::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Subsystem"); builder.AddBooleanProperty( diff --git a/wpilibOldCommands/src/main/native/include/frc/PIDBase.h b/wpilibOldCommands/src/main/native/include/frc/PIDBase.h index e2ffe31bbd..60f6991297 100644 --- a/wpilibOldCommands/src/main/native/include/frc/PIDBase.h +++ b/wpilibOldCommands/src/main/native/include/frc/PIDBase.h @@ -9,19 +9,17 @@ #include #include +#include +#include #include "frc/PIDInterface.h" #include "frc/PIDOutput.h" #include "frc/PIDSource.h" #include "frc/Timer.h" #include "frc/filter/LinearFilter.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Class implements a PID Control Loop. * @@ -36,8 +34,8 @@ class SendableBuilder; */ class PIDBase : public PIDInterface, public PIDOutput, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Allocate a PID object with the given constants for P, I, D. @@ -301,7 +299,7 @@ class PIDBase : public PIDInterface, */ void PIDWrite(double output) override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: // Is the pid controller enabled diff --git a/wpilibOldCommands/src/main/native/include/frc/PIDController.h b/wpilibOldCommands/src/main/native/include/frc/PIDController.h index d852611b0b..cd932dd5e6 100644 --- a/wpilibOldCommands/src/main/native/include/frc/PIDController.h +++ b/wpilibOldCommands/src/main/native/include/frc/PIDController.h @@ -126,7 +126,7 @@ class PIDController : public PIDBase, public Controller { */ void Reset() override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: std::unique_ptr m_controlLoop; diff --git a/wpilibOldCommands/src/main/native/include/frc/buttons/Trigger.h b/wpilibOldCommands/src/main/native/include/frc/buttons/Trigger.h index 2d893bd147..f75713c381 100644 --- a/wpilibOldCommands/src/main/native/include/frc/buttons/Trigger.h +++ b/wpilibOldCommands/src/main/native/include/frc/buttons/Trigger.h @@ -6,8 +6,8 @@ #include -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { @@ -26,7 +26,7 @@ class Command; * only have to write the {@link Trigger#Get()} method to get the full * functionality of the Trigger class. */ -class Trigger : public Sendable, public SendableHelper { +class Trigger : public wpi::Sendable, public wpi::SendableHelper { public: Trigger() = default; ~Trigger() override = default; @@ -44,7 +44,7 @@ class Trigger : public Sendable, public SendableHelper { void CancelWhenActive(Command* command); void ToggleWhenActive(Command* command); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: std::atomic_bool m_sendablePressed{false}; diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/Command.h b/wpilibOldCommands/src/main/native/include/frc/commands/Command.h index 4cbdf1f149..aa7d5d042e 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/Command.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/Command.h @@ -10,10 +10,10 @@ #include #include +#include +#include #include "frc/commands/Subsystem.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -43,7 +43,7 @@ class CommandGroup; * @see CommandGroup * @see Subsystem */ -class Command : public Sendable, public SendableHelper { +class Command : public wpi::Sendable, public wpi::SendableHelper { friend class CommandGroup; friend class Scheduler; @@ -482,7 +482,7 @@ class Command : public Sendable, public SendableHelper { static int m_commandCounter; public: - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; }; } // namespace frc diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h b/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h index 257b67f052..7eb85ec4fc 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/PIDCommand.h @@ -64,7 +64,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource { std::shared_ptr m_controller; public: - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; }; } // namespace frc diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/Scheduler.h b/wpilibOldCommands/src/main/native/include/frc/commands/Scheduler.h index 83372dc278..68285d2c4d 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/Scheduler.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/Scheduler.h @@ -6,8 +6,8 @@ #include -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { @@ -15,7 +15,7 @@ class ButtonScheduler; class Command; class Subsystem; -class Scheduler : public Sendable, public SendableHelper { +class Scheduler : public nt::NTSendable, public wpi::SendableHelper { public: /** * Returns the Scheduler, creating it if one does not exist. @@ -78,7 +78,7 @@ class Scheduler : public Sendable, public SendableHelper { void SetEnabled(bool enabled); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; private: Scheduler(); diff --git a/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h b/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h index 71c9ce4cf2..bdf1ee858c 100644 --- a/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h +++ b/wpilibOldCommands/src/main/native/include/frc/commands/Subsystem.h @@ -8,14 +8,14 @@ #include #include -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { class Command; -class Subsystem : public Sendable, public SendableHelper { +class Subsystem : public wpi::Sendable, public wpi::SendableHelper { friend class Scheduler; public: @@ -127,7 +127,7 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(std::string_view name, std::shared_ptr child); + void AddChild(std::string_view name, std::shared_ptr child); /** * Associate a Sendable with this Subsystem. @@ -136,7 +136,7 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(std::string_view name, Sendable* child); + void AddChild(std::string_view name, wpi::Sendable* child); /** * Associate a Sendable with this Subsystem. @@ -145,28 +145,28 @@ class Subsystem : public Sendable, public SendableHelper { * @param name name to give child * @param child sendable */ - void AddChild(std::string_view name, Sendable& child); + void AddChild(std::string_view name, wpi::Sendable& child); /** * Associate a {@link Sendable} with this Subsystem. * * @param child sendable */ - void AddChild(std::shared_ptr child); + void AddChild(std::shared_ptr child); /** * Associate a {@link Sendable} with this Subsystem. * * @param child sendable */ - void AddChild(Sendable* child); + void AddChild(wpi::Sendable* child); /** * Associate a {@link Sendable} with this Subsystem. * * @param child sendable */ - void AddChild(Sendable& child); + void AddChild(wpi::Sendable& child); private: /** @@ -185,7 +185,7 @@ class Subsystem : public Sendable, public SendableHelper { bool m_initializedDefaultCommand = false; public: - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; }; } // namespace frc diff --git a/wpilibOldCommands/src/test/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTabTest.java b/wpilibOldCommands/src/test/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTabTest.java index ddb84e5f13..6236e627cc 100644 --- a/wpilibOldCommands/src/test/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTabTest.java +++ b/wpilibOldCommands/src/test/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTabTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; import edu.wpi.first.wpilibj.command.InstantCommand; import java.util.HashMap; import java.util.Map; diff --git a/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardTabTest.cpp b/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardTabTest.cpp index df82295026..4cbad010f9 100644 --- a/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardTabTest.cpp +++ b/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardTabTest.cpp @@ -12,7 +12,6 @@ #include "frc/commands/InstantCommand.h" #include "frc/shuffleboard/ShuffleboardInstance.h" #include "frc/shuffleboard/ShuffleboardTab.h" -#include "frc/smartdashboard/Sendable.h" #include "gtest/gtest.h" using namespace frc; diff --git a/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp b/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp index 6bffe05214..94603300ea 100644 --- a/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp +++ b/wpilibOldCommands/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp @@ -14,7 +14,6 @@ #include "frc/shuffleboard/ShuffleboardInstance.h" #include "frc/shuffleboard/ShuffleboardTab.h" #include "frc/shuffleboard/ShuffleboardWidget.h" -#include "frc/smartdashboard/Sendable.h" #include "gtest/gtest.h" using namespace frc; diff --git a/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp b/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp index 222c78b05a..cb40288bd6 100644 --- a/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp +++ b/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp @@ -5,9 +5,8 @@ #include "frc/ADXL345_I2C.h" #include - -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -30,7 +29,7 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress) HAL_Report(HALUsageReporting::kResourceType_ADXL345, HALUsageReporting::kADXL345_I2C, 0); - SendableRegistry::GetInstance().AddLW(this, "ADXL345_I2C", port); + wpi::SendableRegistry::GetInstance().AddLW(this, "ADXL345_I2C", port); } void ADXL345_I2C::SetRange(Range range) { @@ -84,7 +83,7 @@ ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations() { return data; } -void ADXL345_I2C::InitSendable(SendableBuilder& builder) { +void ADXL345_I2C::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("3AxisAccelerometer"); auto x = builder.GetEntry("X").GetHandle(); auto y = builder.GetEntry("Y").GetHandle(); diff --git a/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp b/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp index 958cadf083..d1c0dfef5c 100644 --- a/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp +++ b/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp @@ -5,9 +5,8 @@ #include "frc/ADXL345_SPI.h" #include - -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -38,7 +37,7 @@ ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range) HAL_Report(HALUsageReporting::kResourceType_ADXL345, HALUsageReporting::kADXL345_SPI); - SendableRegistry::GetInstance().AddLW(this, "ADXL345_SPI", port); + wpi::SendableRegistry::GetInstance().AddLW(this, "ADXL345_SPI", port); } void ADXL345_SPI::SetRange(Range range) { @@ -115,7 +114,7 @@ ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations() { return data; } -void ADXL345_SPI::InitSendable(SendableBuilder& builder) { +void ADXL345_SPI::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("3AxisAccelerometer"); auto x = builder.GetEntry("X").GetHandle(); auto y = builder.GetEntry("Y").GetHandle(); diff --git a/wpilibc/src/main/native/cpp/ADXL362.cpp b/wpilibc/src/main/native/cpp/ADXL362.cpp index ae60f9d4f9..937239efa1 100644 --- a/wpilibc/src/main/native/cpp/ADXL362.cpp +++ b/wpilibc/src/main/native/cpp/ADXL362.cpp @@ -5,10 +5,10 @@ #include "frc/ADXL362.h" #include +#include +#include #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -72,7 +72,7 @@ ADXL362::ADXL362(SPI::Port port, Range range) HAL_Report(HALUsageReporting::kResourceType_ADXL362, port + 1); - SendableRegistry::GetInstance().AddLW(this, "ADXL362", port); + wpi::SendableRegistry::GetInstance().AddLW(this, "ADXL362", port); } void ADXL362::SetRange(Range range) { @@ -178,7 +178,7 @@ ADXL362::AllAxes ADXL362::GetAccelerations() { return data; } -void ADXL362::InitSendable(SendableBuilder& builder) { +void ADXL362::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("3AxisAccelerometer"); auto x = builder.GetEntry("X").GetHandle(); auto y = builder.GetEntry("Y").GetHandle(); diff --git a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp index e9ad1bcabe..ac82aa740e 100644 --- a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp +++ b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp @@ -5,11 +5,11 @@ #include "frc/ADXRS450_Gyro.h" #include +#include +#include #include "frc/Errors.h" #include "frc/Timer.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -58,7 +58,7 @@ ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port) HAL_Report(HALUsageReporting::kResourceType_ADXRS450, port + 1); - SendableRegistry::GetInstance().AddLW(this, "ADXRS450_Gyro", port); + wpi::SendableRegistry::GetInstance().AddLW(this, "ADXRS450_Gyro", port); } static bool CalcParity(int v) { @@ -136,7 +136,7 @@ int ADXRS450_Gyro::GetPort() const { return m_port; } -void ADXRS450_Gyro::InitSendable(SendableBuilder& builder) { +void ADXRS450_Gyro::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Gyro"); builder.AddDoubleProperty( "Value", [=] { return GetAngle(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp index 34b01573f6..72a83eaeb9 100644 --- a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp @@ -6,16 +6,16 @@ #include #include +#include +#include #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; AnalogAccelerometer::AnalogAccelerometer(int channel) : AnalogAccelerometer(std::make_shared(channel)) { - SendableRegistry::GetInstance().AddChild(this, m_analogInput.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_analogInput.get()); } AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel) @@ -46,7 +46,7 @@ void AnalogAccelerometer::SetZero(double zero) { m_zeroGVoltage = zero; } -void AnalogAccelerometer::InitSendable(SendableBuilder& builder) { +void AnalogAccelerometer::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Accelerometer"); builder.AddDoubleProperty( "Value", [=] { return GetAcceleration(); }, nullptr); @@ -56,6 +56,6 @@ void AnalogAccelerometer::InitAccelerometer() { HAL_Report(HALUsageReporting::kResourceType_Accelerometer, m_analogInput->GetChannel() + 1); - SendableRegistry::GetInstance().AddLW(this, "Accelerometer", - m_analogInput->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "Accelerometer", + m_analogInput->GetChannel()); } diff --git a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp index 77552c9b06..6314f18f5e 100644 --- a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp +++ b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp @@ -5,11 +5,11 @@ #include "frc/AnalogEncoder.h" #include +#include #include "frc/AnalogInput.h" #include "frc/Counter.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" using namespace frc; @@ -50,8 +50,8 @@ void AnalogEncoder::Init() { m_counter.SetDownSource( m_analogTrigger.CreateOutput(AnalogTriggerType::kFallingPulse)); - SendableRegistry::GetInstance().AddLW(this, "DutyCycle Encoder", - m_analogInput->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "DutyCycle Encoder", + m_analogInput->GetChannel()); } units::turn_t AnalogEncoder::Get() const { @@ -105,7 +105,7 @@ int AnalogEncoder::GetChannel() const { return m_analogInput->GetChannel(); } -void AnalogEncoder::InitSendable(SendableBuilder& builder) { +void AnalogEncoder::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("AbsoluteEncoder"); builder.AddDoubleProperty( "Distance", [this] { return this->GetDistance(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/AnalogGyro.cpp b/wpilibc/src/main/native/cpp/AnalogGyro.cpp index 2221f1a6df..5175834d4f 100644 --- a/wpilibc/src/main/native/cpp/AnalogGyro.cpp +++ b/wpilibc/src/main/native/cpp/AnalogGyro.cpp @@ -12,18 +12,18 @@ #include #include #include +#include +#include #include "frc/AnalogInput.h" #include "frc/Errors.h" #include "frc/Timer.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; AnalogGyro::AnalogGyro(int channel) : AnalogGyro(std::make_shared(channel)) { - SendableRegistry::GetInstance().AddChild(this, m_analog.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_analog.get()); } AnalogGyro::AnalogGyro(AnalogInput* channel) @@ -41,7 +41,7 @@ AnalogGyro::AnalogGyro(std::shared_ptr channel) AnalogGyro::AnalogGyro(int channel, int center, double offset) : AnalogGyro(std::make_shared(channel), center, offset) { - SendableRegistry::GetInstance().AddChild(this, m_analog.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_analog.get()); } AnalogGyro::AnalogGyro(std::shared_ptr channel, int center, @@ -124,8 +124,8 @@ void AnalogGyro::InitGyro() { HAL_Report(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel() + 1); - SendableRegistry::GetInstance().AddLW(this, "AnalogGyro", - m_analog->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogGyro", + m_analog->GetChannel()); } void AnalogGyro::Calibrate() { @@ -138,7 +138,7 @@ std::shared_ptr AnalogGyro::GetAnalogInput() const { return m_analog; } -void AnalogGyro::InitSendable(SendableBuilder& builder) { +void AnalogGyro::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Gyro"); builder.AddDoubleProperty( "Value", [=] { return GetAngle(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp index 2b06d97f13..1cf891690c 100644 --- a/wpilibc/src/main/native/cpp/AnalogInput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp @@ -10,12 +10,12 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" #include "frc/Timer.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -34,7 +34,7 @@ AnalogInput::AnalogInput(int channel) { HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel + 1); - SendableRegistry::GetInstance().AddLW(this, "AnalogInput", channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogInput", channel); } AnalogInput::~AnalogInput() { @@ -194,7 +194,7 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) { HAL_SetAnalogInputSimDevice(m_port, device); } -void AnalogInput::InitSendable(SendableBuilder& builder) { +void AnalogInput::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Analog Input"); builder.AddDoubleProperty( "Value", [=] { return GetAverageVoltage(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp index e853f5e44c..bc542751d8 100644 --- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp @@ -12,11 +12,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -34,7 +34,7 @@ AnalogOutput::AnalogOutput(int channel) { FRC_CheckErrorStatus(status, "Channel {}", channel); HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel + 1); - SendableRegistry::GetInstance().AddLW(this, "AnalogOutput", m_channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogOutput", m_channel); } AnalogOutput::~AnalogOutput() { @@ -58,7 +58,7 @@ int AnalogOutput::GetChannel() const { return m_channel; } -void AnalogOutput::InitSendable(SendableBuilder& builder) { +void AnalogOutput::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Analog Output"); builder.AddDoubleProperty( "Value", [=] { return GetVoltage(); }, diff --git a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp index f5d0880d35..112c054afd 100644 --- a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp @@ -7,10 +7,10 @@ #include #include +#include +#include #include "frc/RobotController.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -18,7 +18,7 @@ AnalogPotentiometer::AnalogPotentiometer(int channel, double fullRange, double offset) : AnalogPotentiometer(std::make_shared(channel), fullRange, offset) { - SendableRegistry::GetInstance().AddChild(this, m_analog_input.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_analog_input.get()); } AnalogPotentiometer::AnalogPotentiometer(AnalogInput* input, double fullRange, @@ -32,8 +32,8 @@ AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr input, : m_analog_input(std::move(input)), m_fullRange(fullRange), m_offset(offset) { - SendableRegistry::GetInstance().AddLW(this, "AnalogPotentiometer", - m_analog_input->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogPotentiometer", + m_analog_input->GetChannel()); } double AnalogPotentiometer::Get() const { @@ -43,7 +43,7 @@ double AnalogPotentiometer::Get() const { m_offset; } -void AnalogPotentiometer::InitSendable(SendableBuilder& builder) { +void AnalogPotentiometer::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Analog Input"); builder.AddDoubleProperty( "Value", [=] { return Get(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp index 7ff8ab2ab5..2f464e55ba 100644 --- a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp +++ b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp @@ -9,18 +9,18 @@ #include #include #include +#include #include "frc/AnalogInput.h" #include "frc/DutyCycle.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; AnalogTrigger::AnalogTrigger(int channel) : AnalogTrigger(new AnalogInput(channel)) { m_ownsAnalog = true; - SendableRegistry::GetInstance().AddChild(this, m_analogInput); + wpi::SendableRegistry::GetInstance().AddChild(this, m_analogInput); } AnalogTrigger::AnalogTrigger(AnalogInput* input) { @@ -31,7 +31,7 @@ AnalogTrigger::AnalogTrigger(AnalogInput* input) { int index = GetIndex(); HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, index + 1); - SendableRegistry::GetInstance().AddLW(this, "AnalogTrigger", index); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogTrigger", index); } AnalogTrigger::AnalogTrigger(DutyCycle* input) { @@ -42,7 +42,7 @@ AnalogTrigger::AnalogTrigger(DutyCycle* input) { int index = GetIndex(); HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, index + 1); - SendableRegistry::GetInstance().AddLW(this, "AnalogTrigger", index); + wpi::SendableRegistry::GetInstance().AddLW(this, "AnalogTrigger", index); } AnalogTrigger::~AnalogTrigger() { @@ -113,7 +113,7 @@ std::shared_ptr AnalogTrigger::CreateOutput( wpi::NullDeleter()); } -void AnalogTrigger::InitSendable(SendableBuilder& builder) { +void AnalogTrigger::InitSendable(wpi::SendableBuilder& builder) { if (m_ownsAnalog) { m_analogInput->InitSendable(builder); } diff --git a/wpilibc/src/main/native/cpp/AnalogTriggerOutput.cpp b/wpilibc/src/main/native/cpp/AnalogTriggerOutput.cpp index 80ad3fa8c7..93d19693d2 100644 --- a/wpilibc/src/main/native/cpp/AnalogTriggerOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogTriggerOutput.cpp @@ -38,7 +38,7 @@ int AnalogTriggerOutput::GetChannel() const { return m_trigger->GetIndex(); } -void AnalogTriggerOutput::InitSendable(SendableBuilder&) {} +void AnalogTriggerOutput::InitSendable(wpi::SendableBuilder&) {} AnalogTriggerOutput::AnalogTriggerOutput(const AnalogTrigger& trigger, AnalogTriggerType outputType) diff --git a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp index 94fa33428b..3635b8d9e6 100644 --- a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp +++ b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp @@ -6,10 +6,10 @@ #include #include +#include +#include #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -18,7 +18,7 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) { HAL_Report(HALUsageReporting::kResourceType_Accelerometer, 0, 0, "Built-in accelerometer"); - SendableRegistry::GetInstance().AddLW(this, "BuiltInAccel"); + wpi::SendableRegistry::GetInstance().AddLW(this, "BuiltInAccel"); } void BuiltInAccelerometer::SetRange(Range range) { @@ -44,7 +44,7 @@ double BuiltInAccelerometer::GetZ() { return HAL_GetAccelerometerZ(); } -void BuiltInAccelerometer::InitSendable(SendableBuilder& builder) { +void BuiltInAccelerometer::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("3AxisAccelerometer"); builder.AddDoubleProperty( "X", [=] { return GetX(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/Counter.cpp b/wpilibc/src/main/native/cpp/Counter.cpp index 6ad7876a2c..69bdadd8ac 100644 --- a/wpilibc/src/main/native/cpp/Counter.cpp +++ b/wpilibc/src/main/native/cpp/Counter.cpp @@ -9,12 +9,12 @@ #include #include #include +#include +#include #include "frc/AnalogTrigger.h" #include "frc/DigitalInput.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -27,7 +27,7 @@ Counter::Counter(Mode mode) { SetMaxPeriod(0.5_s); HAL_Report(HALUsageReporting::kResourceType_Counter, m_index + 1, mode + 1); - SendableRegistry::GetInstance().AddLW(this, "Counter", m_index); + wpi::SendableRegistry::GetInstance().AddLW(this, "Counter", m_index); } Counter::Counter(int channel) : Counter(kTwoPulse) { @@ -97,7 +97,7 @@ Counter::~Counter() { void Counter::SetUpSource(int channel) { SetUpSource(std::make_shared(channel)); - SendableRegistry::GetInstance().AddChild(this, m_upSource.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_upSource.get()); } void Counter::SetUpSource(AnalogTrigger* analogTrigger, @@ -152,7 +152,7 @@ void Counter::ClearUpSource() { void Counter::SetDownSource(int channel) { SetDownSource(std::make_shared(channel)); - SendableRegistry::GetInstance().AddChild(this, m_downSource.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_downSource.get()); } void Counter::SetDownSource(AnalogTrigger* analogTrigger, @@ -306,7 +306,7 @@ bool Counter::GetDirection() const { return value; } -void Counter::InitSendable(SendableBuilder& builder) { +void Counter::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Counter"); builder.AddDoubleProperty( "Value", [=] { return Get(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp index bb71fd3a38..880d0bb6e2 100644 --- a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp +++ b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp @@ -11,12 +11,12 @@ #include #include #include +#include #include "frc/Counter.h" #include "frc/Encoder.h" #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -35,8 +35,8 @@ DigitalGlitchFilter::DigitalGlitchFilter() { HAL_Report(HALUsageReporting::kResourceType_DigitalGlitchFilter, m_channelIndex + 1); - SendableRegistry::GetInstance().AddLW(this, "DigitalGlitchFilter", - m_channelIndex); + wpi::SendableRegistry::GetInstance().AddLW(this, "DigitalGlitchFilter", + m_channelIndex); } DigitalGlitchFilter::~DigitalGlitchFilter() { @@ -125,4 +125,4 @@ uint64_t DigitalGlitchFilter::GetPeriodNanoSeconds() { static_cast(HAL_GetSystemClockTicksPerMicrosecond() / 4); } -void DigitalGlitchFilter::InitSendable(SendableBuilder&) {} +void DigitalGlitchFilter::InitSendable(wpi::SendableBuilder&) {} diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index f5c8f93e73..df982c530a 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -12,11 +12,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -33,7 +33,7 @@ DigitalInput::DigitalInput(int channel) { FRC_CheckErrorStatus(status, "Channel {}", channel); HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel + 1); - SendableRegistry::GetInstance().AddLW(this, "DigitalInput", channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "DigitalInput", channel); } DigitalInput::~DigitalInput() { @@ -67,7 +67,7 @@ int DigitalInput::GetChannel() const { return m_channel; } -void DigitalInput::InitSendable(SendableBuilder& builder) { +void DigitalInput::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Digital Input"); builder.AddBooleanProperty( "Value", [=] { return Get(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index 4dcd6bdc78..eb9ad70cf5 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -11,11 +11,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -33,7 +33,7 @@ DigitalOutput::DigitalOutput(int channel) { FRC_CheckErrorStatus(status, "Channel {}", channel); HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel + 1); - SendableRegistry::GetInstance().AddLW(this, "DigitalOutput", channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "DigitalOutput", channel); } DigitalOutput::~DigitalOutput() { @@ -140,7 +140,7 @@ void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) { HAL_SetDIOSimDevice(m_handle, device); } -void DigitalOutput::InitSendable(SendableBuilder& builder) { +void DigitalOutput::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Digital Output"); builder.AddBooleanProperty( "Value", [=] { return Get(); }, [=](bool value) { Set(value); }); diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp index 5ec8ee86b0..15a85470f3 100644 --- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp @@ -10,11 +10,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -53,7 +53,7 @@ DoubleSolenoid::DoubleSolenoid(std::shared_ptr module, m_module->GetModuleNumber() + 1); HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel + 1, m_module->GetModuleNumber() + 1); - SendableRegistry::GetInstance().AddLW( + wpi::SendableRegistry::GetInstance().AddLW( this, "DoubleSolenoid", m_module->GetModuleNumber(), m_forwardChannel); } @@ -115,7 +115,7 @@ bool DoubleSolenoid::IsRevSolenoidDisabled() const { return (m_module->GetSolenoidDisabledList() & m_reverseMask) != 0; } -void DoubleSolenoid::InitSendable(SendableBuilder& builder) { +void DoubleSolenoid::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Double Solenoid"); builder.SetActuator(true); builder.SetSafeState([=] { Set(kOff); }); diff --git a/wpilibc/src/main/native/cpp/DutyCycle.cpp b/wpilibc/src/main/native/cpp/DutyCycle.cpp index 022b6864ba..3e05eaab1b 100644 --- a/wpilibc/src/main/native/cpp/DutyCycle.cpp +++ b/wpilibc/src/main/native/cpp/DutyCycle.cpp @@ -7,10 +7,10 @@ #include #include #include +#include #include "frc/DigitalSource.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" using namespace frc; @@ -49,7 +49,7 @@ void DutyCycle::InitDutyCycle() { FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel()); int index = GetFPGAIndex(); HAL_Report(HALUsageReporting::kResourceType_DutyCycle, index + 1); - SendableRegistry::GetInstance().AddLW(this, "Duty Cycle", index); + wpi::SendableRegistry::GetInstance().AddLW(this, "Duty Cycle", index); } int DutyCycle::GetFPGAIndex() const { @@ -91,7 +91,7 @@ int DutyCycle::GetSourceChannel() const { return m_source->GetChannel(); } -void DutyCycle::InitSendable(SendableBuilder& builder) { +void DutyCycle::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Duty Cycle"); builder.AddDoubleProperty( "Frequency", [this] { return this->GetFrequency(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp index dac3fbf137..b9d9ed7c6b 100644 --- a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp +++ b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp @@ -5,13 +5,13 @@ #include "frc/DutyCycleEncoder.h" #include +#include #include "frc/Counter.h" #include "frc/DigitalInput.h" #include "frc/DigitalSource.h" #include "frc/DutyCycle.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" using namespace frc; @@ -72,8 +72,8 @@ void DutyCycleEncoder::Init() { m_analogTrigger->CreateOutput(AnalogTriggerType::kFallingPulse)); } - SendableRegistry::GetInstance().AddLW(this, "DutyCycle Encoder", - m_dutyCycle->GetSourceChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "DutyCycle Encoder", + m_dutyCycle->GetSourceChannel()); } units::turn_t DutyCycleEncoder::Get() const { @@ -148,7 +148,7 @@ int DutyCycleEncoder::GetSourceChannel() const { return m_dutyCycle->GetSourceChannel(); } -void DutyCycleEncoder::InitSendable(SendableBuilder& builder) { +void DutyCycleEncoder::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("AbsoluteEncoder"); builder.AddDoubleProperty( "Distance", [this] { return this->GetDistance(); }, nullptr); diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index 7192176b8e..87db3db232 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -9,11 +9,11 @@ #include #include #include +#include +#include #include "frc/DigitalInput.h" #include "frc/Errors.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -22,7 +22,7 @@ Encoder::Encoder(int aChannel, int bChannel, bool reverseDirection, m_aSource = std::make_shared(aChannel); m_bSource = std::make_shared(bChannel); InitEncoder(reverseDirection, encodingType); - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, m_aSource.get()); registry.AddChild(this, m_bSource.get()); } @@ -181,7 +181,7 @@ int Encoder::GetSamplesToAverage() const { void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) { // Force digital input if just given an index m_indexSource = std::make_shared(channel); - SendableRegistry::GetInstance().AddChild(this, m_indexSource.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, m_indexSource.get()); SetIndexSource(*m_indexSource.get(), type); } @@ -207,7 +207,7 @@ int Encoder::GetFPGAIndex() const { return val; } -void Encoder::InitSendable(SendableBuilder& builder) { +void Encoder::InitSendable(wpi::SendableBuilder& builder) { int32_t status = 0; HAL_EncoderEncodingType type = HAL_GetEncoderEncodingType(m_encoder, &status); FRC_CheckErrorStatus(status, "{}", "GetEncodingType"); @@ -240,8 +240,8 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex() + 1, encodingType); - SendableRegistry::GetInstance().AddLW(this, "Encoder", - m_aSource->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "Encoder", + m_aSource->GetChannel()); } double Encoder::DecodingScaleFactor() const { diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp index bb018ae483..1b18c5b625 100644 --- a/wpilibc/src/main/native/cpp/PWM.cpp +++ b/wpilibc/src/main/native/cpp/PWM.cpp @@ -11,11 +11,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -40,7 +40,7 @@ PWM::PWM(int channel, bool registerSendable) { HAL_Report(HALUsageReporting::kResourceType_PWM, channel + 1); if (registerSendable) { - SendableRegistry::GetInstance().AddLW(this, "PWM", channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "PWM", channel); } } @@ -163,7 +163,7 @@ int PWM::GetChannel() const { return m_channel; } -void PWM::InitSendable(SendableBuilder& builder) { +void PWM::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("PWM"); builder.SetActuator(true); builder.SetSafeState([=] { SetDisabled(); }); diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp index a033fc1820..c59934f4d3 100644 --- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp +++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp @@ -8,11 +8,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -24,7 +24,8 @@ PowerDistributionPanel::PowerDistributionPanel(int module) : m_module(module) { FRC_CheckErrorStatus(status, "Module {}", module); HAL_Report(HALUsageReporting::kResourceType_PDP, module + 1); - SendableRegistry::GetInstance().AddLW(this, "PowerDistributionPanel", module); + wpi::SendableRegistry::GetInstance().AddLW(this, "PowerDistributionPanel", + module); } double PowerDistributionPanel::GetVoltage() const { @@ -93,7 +94,7 @@ int PowerDistributionPanel::GetModule() const { return m_module; } -void PowerDistributionPanel::InitSendable(SendableBuilder& builder) { +void PowerDistributionPanel::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("PowerDistributionPanel"); for (int i = 0; i < SensorUtil::kPDPChannels; ++i) { builder.AddDoubleProperty( diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp index 1dbc9092c1..efcbbc4616 100644 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ b/wpilibc/src/main/native/cpp/Relay.cpp @@ -12,11 +12,11 @@ #include #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -56,7 +56,7 @@ Relay::Relay(int channel, Relay::Direction direction) FRC_CheckErrorStatus(status, "Channel {}", m_channel); } - SendableRegistry::GetInstance().AddLW(this, "Relay", m_channel); + wpi::SendableRegistry::GetInstance().AddLW(this, "Relay", m_channel); } Relay::~Relay() { @@ -172,7 +172,7 @@ std::string Relay::GetDescription() const { return fmt::format("Relay {}", GetChannel()); } -void Relay::InitSendable(SendableBuilder& builder) { +void Relay::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Relay"); builder.SetActuator(true); builder.SetSafeState([=] { Set(kOff); }); diff --git a/wpilibc/src/main/native/cpp/Servo.cpp b/wpilibc/src/main/native/cpp/Servo.cpp index b1676410b5..7dae590927 100644 --- a/wpilibc/src/main/native/cpp/Servo.cpp +++ b/wpilibc/src/main/native/cpp/Servo.cpp @@ -5,9 +5,8 @@ #include "frc/Servo.h" #include - -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -25,7 +24,7 @@ Servo::Servo(int channel) : PWM(channel) { SetPeriodMultiplier(kPeriodMultiplier_4X); HAL_Report(HALUsageReporting::kResourceType_Servo, channel + 1); - SendableRegistry::GetInstance().SetName(this, "Servo", channel); + wpi::SendableRegistry::GetInstance().SetName(this, "Servo", channel); } void Servo::Set(double value) { @@ -62,7 +61,7 @@ double Servo::GetMinAngle() const { return kMinServoAngle; } -void Servo::InitSendable(SendableBuilder& builder) { +void Servo::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Servo"); builder.AddDoubleProperty( "Value", [=] { return Get(); }, [=](double value) { Set(value); }); diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp index 1e499d470b..dd6538a660 100644 --- a/wpilibc/src/main/native/cpp/Solenoid.cpp +++ b/wpilibc/src/main/native/cpp/Solenoid.cpp @@ -8,11 +8,11 @@ #include #include +#include +#include #include "frc/Errors.h" #include "frc/SensorUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -36,8 +36,8 @@ Solenoid::Solenoid(std::shared_ptr module, int channel) HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_channel + 1, m_module->GetModuleNumber() + 1); - SendableRegistry::GetInstance().AddLW(this, "Solenoid", - m_module->GetModuleNumber(), m_channel); + wpi::SendableRegistry::GetInstance().AddLW( + this, "Solenoid", m_module->GetModuleNumber(), m_channel); } Solenoid::~Solenoid() {} @@ -72,7 +72,7 @@ void Solenoid::StartPulse() { m_module->FireOneShot(m_channel); } -void Solenoid::InitSendable(SendableBuilder& builder) { +void Solenoid::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Solenoid"); builder.SetActuator(true); builder.SetSafeState([=] { Set(false); }); diff --git a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp index fb15695705..a212347f6e 100644 --- a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp +++ b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp @@ -4,8 +4,8 @@ #include "frc/SpeedControllerGroup.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -20,11 +20,12 @@ SpeedControllerGroup::SpeedControllerGroup( void SpeedControllerGroup::Initialize() { for (auto& speedController : m_speedControllers) { - SendableRegistry::GetInstance().AddChild(this, &speedController.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, &speedController.get()); } static int instances = 0; ++instances; - SendableRegistry::GetInstance().Add(this, "SpeedControllerGroup", instances); + wpi::SendableRegistry::GetInstance().Add(this, "SpeedControllerGroup", + instances); } void SpeedControllerGroup::Set(double speed) { @@ -60,7 +61,7 @@ void SpeedControllerGroup::StopMotor() { } } -void SpeedControllerGroup::InitSendable(SendableBuilder& builder) { +void SpeedControllerGroup::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Speed Controller"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/Ultrasonic.cpp b/wpilibc/src/main/native/cpp/Ultrasonic.cpp index 2f9d6f873b..93df25e6c6 100644 --- a/wpilibc/src/main/native/cpp/Ultrasonic.cpp +++ b/wpilibc/src/main/native/cpp/Ultrasonic.cpp @@ -8,14 +8,14 @@ #include #include +#include +#include #include "frc/Counter.h" #include "frc/DigitalInput.h" #include "frc/DigitalOutput.h" #include "frc/Errors.h" #include "frc/Timer.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -30,7 +30,7 @@ Ultrasonic::Ultrasonic(int pingChannel, int echoChannel) m_echoChannel(std::make_shared(echoChannel)), m_counter(m_echoChannel) { Initialize(); - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, m_pingChannel.get()); registry.AddChild(this, m_echoChannel.get()); } @@ -156,7 +156,7 @@ void Ultrasonic::SetEnabled(bool enable) { m_enabled = enable; } -void Ultrasonic::InitSendable(SendableBuilder& builder) { +void Ultrasonic::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Ultrasonic"); builder.AddDoubleProperty( "Value", [=] { return units::inch_t{GetRange()}.to(); }, nullptr); @@ -185,8 +185,8 @@ void Ultrasonic::Initialize() { static int instances = 0; instances++; HAL_Report(HALUsageReporting::kResourceType_Ultrasonic, instances); - SendableRegistry::GetInstance().AddLW(this, "Ultrasonic", - m_echoChannel->GetChannel()); + wpi::SendableRegistry::GetInstance().AddLW(this, "Ultrasonic", + m_echoChannel->GetChannel()); } void Ultrasonic::UltrasonicChecker() { diff --git a/wpilibc/src/main/native/cpp/controller/PIDController.cpp b/wpilibc/src/main/native/cpp/controller/PIDController.cpp index 054b045227..88dd9e674c 100644 --- a/wpilibc/src/main/native/cpp/controller/PIDController.cpp +++ b/wpilibc/src/main/native/cpp/controller/PIDController.cpp @@ -8,11 +8,11 @@ #include #include +#include +#include #include "frc/Errors.h" #include "frc/MathUtil.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc2; @@ -31,7 +31,7 @@ PIDController::PIDController(double Kp, double Ki, double Kd, static int instances = 0; instances++; HAL_Report(HALUsageReporting::kResourceType_PIDController2, instances); - frc::SendableRegistry::GetInstance().Add(this, "PIDController", instances); + wpi::SendableRegistry::GetInstance().Add(this, "PIDController", instances); } void PIDController::SetPID(double Kp, double Ki, double Kd) { @@ -161,7 +161,7 @@ void PIDController::Reset() { m_totalError = 0; } -void PIDController::InitSendable(frc::SendableBuilder& builder) { +void PIDController::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("PIDController"); builder.AddDoubleProperty( "p", [this] { return GetP(); }, [this](double value) { SetP(value); }); diff --git a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp index 9024c48197..517eeb05c4 100644 --- a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp @@ -8,10 +8,10 @@ #include #include +#include +#include #include "frc/SpeedController.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -26,7 +26,7 @@ using namespace frc; DifferentialDrive::DifferentialDrive(SpeedController& leftMotor, SpeedController& rightMotor) : m_leftMotor(&leftMotor), m_rightMotor(&rightMotor) { - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, m_leftMotor); registry.AddChild(this, m_rightMotor); static int instances = 0; @@ -193,7 +193,7 @@ std::string DifferentialDrive::GetDescription() const { return "DifferentialDrive"; } -void DifferentialDrive::InitSendable(SendableBuilder& builder) { +void DifferentialDrive::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("DifferentialDrive"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp index 88d6fad9bf..4f0ecc266e 100644 --- a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp @@ -9,10 +9,10 @@ #include #include +#include +#include #include "frc/SpeedController.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -43,7 +43,7 @@ KilloughDrive::KilloughDrive(SpeedController& leftMotor, std::sin(rightMotorAngle * (wpi::numbers::pi / 180.0))}; m_backVec = {std::cos(backMotorAngle * (wpi::numbers::pi / 180.0)), std::sin(backMotorAngle * (wpi::numbers::pi / 180.0))}; - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, m_leftMotor); registry.AddChild(this, m_rightMotor); registry.AddChild(this, m_backMotor); @@ -118,7 +118,7 @@ std::string KilloughDrive::GetDescription() const { return "KilloughDrive"; } -void KilloughDrive::InitSendable(SendableBuilder& builder) { +void KilloughDrive::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("KilloughDrive"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp index 745494cd9d..dcf0c1ab26 100644 --- a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp +++ b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp @@ -9,11 +9,11 @@ #include #include +#include +#include #include "frc/SpeedController.h" #include "frc/drive/Vector2d.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -33,7 +33,7 @@ MecanumDrive::MecanumDrive(SpeedController& frontLeftMotor, m_rearLeftMotor(&rearLeftMotor), m_frontRightMotor(&frontRightMotor), m_rearRightMotor(&rearRightMotor) { - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, m_frontLeftMotor); registry.AddChild(this, m_rearLeftMotor); registry.AddChild(this, m_frontRightMotor); @@ -113,7 +113,7 @@ std::string MecanumDrive::GetDescription() const { return "MecanumDrive"; } -void MecanumDrive::InitSendable(SendableBuilder& builder) { +void MecanumDrive::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("MecanumDrive"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp index 081c2cac5c..bfec5773c9 100644 --- a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp +++ b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp @@ -8,10 +8,10 @@ #include #include #include +#include +#include -#include "frc/smartdashboard/Sendable.h" #include "frc/smartdashboard/SendableBuilderImpl.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -25,7 +25,7 @@ struct LiveWindow::Impl { wpi::mutex mutex; - SendableRegistry& registry; + wpi::SendableRegistry& registry; int dataHandle; std::shared_ptr liveWindowTable; @@ -36,20 +36,22 @@ struct LiveWindow::Impl { bool liveWindowEnabled = false; bool telemetryEnabled = true; - std::shared_ptr GetOrAdd(Sendable* sendable); + std::shared_ptr GetOrAdd(wpi::Sendable* sendable); }; LiveWindow::Impl::Impl() - : registry(SendableRegistry::GetInstance()), + : registry(wpi::SendableRegistry::GetInstance()), dataHandle(registry.GetDataHandle()), liveWindowTable( nt::NetworkTableInstance::GetDefault().GetTable("LiveWindow")) { + registry.SetLiveWindowBuilderFactory( + [] { return std::make_unique(); }); statusTable = liveWindowTable->GetSubTable(".status"); enabledEntry = statusTable->GetEntry("LW Enabled"); } std::shared_ptr LiveWindow::Impl::GetOrAdd( - Sendable* sendable) { + wpi::Sendable* sendable) { auto data = std::static_pointer_cast( registry.GetData(sendable, dataHandle)); if (!data) { @@ -64,14 +66,14 @@ LiveWindow* LiveWindow::GetInstance() { return &instance; } -void LiveWindow::EnableTelemetry(Sendable* sendable) { +void LiveWindow::EnableTelemetry(wpi::Sendable* sendable) { std::scoped_lock lock(m_impl->mutex); // Re-enable global setting in case DisableAllTelemetry() was called. m_impl->telemetryEnabled = true; m_impl->GetOrAdd(sendable)->telemetryEnabled = true; } -void LiveWindow::DisableTelemetry(Sendable* sendable) { +void LiveWindow::DisableTelemetry(wpi::Sendable* sendable) { std::scoped_lock lock(m_impl->mutex); m_impl->GetOrAdd(sendable)->telemetryEnabled = false; } @@ -108,7 +110,7 @@ void LiveWindow::SetEnabled(bool enabled) { } } else { m_impl->registry.ForeachLiveWindow(m_impl->dataHandle, [&](auto& cbdata) { - cbdata.builder.StopLiveWindowMode(); + static_cast(cbdata.builder).StopLiveWindowMode(); }); if (this->disabled) { this->disabled(); @@ -160,7 +162,7 @@ void LiveWindow::UpdateValuesUnsafe() { table = ssTable->GetSubTable(cbdata.name); } table->GetEntry(".name").SetString(cbdata.name); - cbdata.builder.SetTable(table); + static_cast(cbdata.builder).SetTable(table); cbdata.sendable->InitSendable(cbdata.builder); ssTable->GetEntry(".type").SetString("LW Subsystem"); @@ -168,9 +170,9 @@ void LiveWindow::UpdateValuesUnsafe() { } if (m_impl->startLiveWindow) { - cbdata.builder.StartLiveWindowMode(); + static_cast(cbdata.builder).StartLiveWindowMode(); } - cbdata.builder.UpdateTable(); + cbdata.builder.Update(); }); m_impl->startLiveWindow = false; diff --git a/wpilibc/src/main/native/cpp/motorcontrol/MotorControllerGroup.cpp b/wpilibc/src/main/native/cpp/motorcontrol/MotorControllerGroup.cpp index 1303ee46fe..197aacfff5 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/MotorControllerGroup.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/MotorControllerGroup.cpp @@ -4,8 +4,8 @@ #include "frc/motorcontrol/MotorControllerGroup.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -20,11 +20,12 @@ MotorControllerGroup::MotorControllerGroup( void MotorControllerGroup::Initialize() { for (auto& motorController : m_motorControllers) { - SendableRegistry::GetInstance().AddChild(this, &motorController.get()); + wpi::SendableRegistry::GetInstance().AddChild(this, &motorController.get()); } static int instances = 0; ++instances; - SendableRegistry::GetInstance().Add(this, "MotorControllerGroup", instances); + wpi::SendableRegistry::GetInstance().Add(this, "MotorControllerGroup", + instances); } void MotorControllerGroup::Set(double speed) { @@ -60,7 +61,7 @@ void MotorControllerGroup::StopMotor() { } } -void MotorControllerGroup::InitSendable(SendableBuilder& builder) { +void MotorControllerGroup::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Motor Controller"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp b/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp index 8e207b123e..0b9a3982f8 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/NidecBrushless.cpp @@ -6,15 +6,14 @@ #include #include - -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; NidecBrushless::NidecBrushless(int pwmChannel, int dioChannel) : m_dio(dioChannel), m_pwm(pwmChannel) { - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); registry.AddChild(this, &m_dio); registry.AddChild(this, &m_pwm); SetExpiration(0_s); @@ -72,7 +71,7 @@ int NidecBrushless::GetChannel() const { return m_pwm.GetChannel(); } -void NidecBrushless::InitSendable(SendableBuilder& builder) { +void NidecBrushless::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Nidec Brushless"); builder.SetActuator(true); builder.SetSafeState([=] { StopMotor(); }); diff --git a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp index b36fda65c1..2b57656ad3 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp @@ -5,8 +5,8 @@ #include "frc/motorcontrol/PWMMotorController.h" #include - -#include "frc/smartdashboard/SendableBuilder.h" +#include +#include using namespace frc; @@ -44,10 +44,10 @@ int PWMMotorController::GetChannel() const { PWMMotorController::PWMMotorController(std::string_view name, int channel) : m_pwm(channel, false) { - SendableRegistry::GetInstance().AddLW(this, name, channel); + wpi::SendableRegistry::GetInstance().AddLW(this, name, channel); } -void PWMMotorController::InitSendable(SendableBuilder& builder) { +void PWMMotorController::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Motor Controller"); builder.SetActuator(true); builder.SetSafeState([=] { Disable(); }); diff --git a/wpilibc/src/main/native/cpp/motorcontrol/PWMSparkMax.cpp b/wpilibc/src/main/native/cpp/motorcontrol/PWMSparkMax.cpp index 666f1e928c..608d452939 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/PWMSparkMax.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/PWMSparkMax.cpp @@ -6,8 +6,6 @@ #include -#include "frc/smartdashboard/SendableRegistry.h" - using namespace frc; PWMSparkMax::PWMSparkMax(int channel) diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp index 1153c0df2b..eaac17366f 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ComplexWidget.cpp @@ -4,36 +4,41 @@ #include "frc/shuffleboard/ComplexWidget.h" -#include "frc/smartdashboard/Sendable.h" +#include + +#include "frc/smartdashboard/SendableBuilderImpl.h" using namespace frc; ComplexWidget::ComplexWidget(ShuffleboardContainer& parent, - std::string_view title, Sendable& sendable) + std::string_view title, wpi::Sendable& sendable) : ShuffleboardValue(title), ShuffleboardWidget(parent, title), m_sendable(sendable) {} +ComplexWidget::~ComplexWidget() = default; + void ComplexWidget::EnableIfActuator() { - if (m_builder.IsActuator()) { - m_builder.StartLiveWindowMode(); + if (m_builder && static_cast(*m_builder).IsActuator()) { + static_cast(*m_builder).StartLiveWindowMode(); } } void ComplexWidget::DisableIfActuator() { - if (m_builder.IsActuator()) { - m_builder.StopLiveWindowMode(); + if (m_builder && static_cast(*m_builder).IsActuator()) { + static_cast(*m_builder).StopLiveWindowMode(); } } void ComplexWidget::BuildInto(std::shared_ptr parentTable, std::shared_ptr metaTable) { BuildMetadata(metaTable); - if (!m_builderInit) { - m_builder.SetTable(parentTable->GetSubTable(GetTitle())); - m_sendable.InitSendable(m_builder); - m_builder.StartListeners(); - m_builderInit = true; + if (!m_builder) { + m_builder = std::make_unique(); + static_cast(*m_builder) + .SetTable(parentTable->GetSubTable(GetTitle())); + m_sendable.InitSendable(static_cast(*m_builder)); + static_cast(*m_builder).StartListeners(); } - m_builder.UpdateTable(); + m_builder->Update(); } diff --git a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp index 4dda98bb5b..1c41d0644a 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp @@ -9,9 +9,8 @@ #include #include - -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include namespace frc { namespace detail { @@ -21,12 +20,12 @@ std::shared_ptr& GetSendableCameraWrapper( return wrappers[static_cast(source)]; } -void AddToSendableRegistry(frc::Sendable* sendable, std::string name) { - SendableRegistry::GetInstance().Add(sendable, name); +void AddToSendableRegistry(wpi::Sendable* sendable, std::string name) { + wpi::SendableRegistry::GetInstance().Add(sendable, name); } } // namespace detail -void SendableCameraWrapper::InitSendable(SendableBuilder& builder) { +void SendableCameraWrapper::InitSendable(wpi::SendableBuilder& builder) { builder.AddStringProperty( ".ShuffleboardURI", [this] { return m_uri; }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp index 2112a4d317..b41d76953c 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp @@ -4,12 +4,13 @@ #include "frc/shuffleboard/ShuffleboardContainer.h" +#include + #include "frc/Errors.h" #include "frc/shuffleboard/ComplexWidget.h" #include "frc/shuffleboard/ShuffleboardComponent.h" #include "frc/shuffleboard/ShuffleboardLayout.h" #include "frc/shuffleboard/SimpleWidget.h" -#include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -57,7 +58,7 @@ ShuffleboardLayout& ShuffleboardContainer::GetLayout(std::string_view title) { } ComplexWidget& ShuffleboardContainer::Add(std::string_view title, - Sendable& sendable) { + wpi::Sendable& sendable) { CheckTitle(title); auto widget = std::make_unique(*this, title, sendable); auto ptr = widget.get(); @@ -65,8 +66,8 @@ ComplexWidget& ShuffleboardContainer::Add(std::string_view title, return *ptr; } -ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) { - auto name = SendableRegistry::GetInstance().GetName(&sendable); +ComplexWidget& ShuffleboardContainer::Add(wpi::Sendable& sendable) { + auto name = wpi::SendableRegistry::GetInstance().GetName(&sendable); if (name.empty()) { FRC_ReportError(err::Error, "{}", "Sendable must have a name"); } diff --git a/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp index 13123b6fa4..438753759e 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/Field2d.cpp @@ -4,8 +4,8 @@ #include "frc/smartdashboard/Field2d.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include +#include using namespace frc; @@ -13,7 +13,7 @@ Field2d::Field2d() { m_objects.emplace_back( std::make_unique("Robot", FieldObject2d::private_init{})); m_objects[0]->SetPose(Pose2d{}); - SendableRegistry::GetInstance().Add(this, "Field"); + wpi::SendableRegistry::GetInstance().Add(this, "Field"); } Field2d::Field2d(Field2d&& rhs) : SendableHelper(std::move(rhs)) { @@ -67,7 +67,7 @@ FieldObject2d* Field2d::GetRobotObject() { return m_objects[0].get(); } -void Field2d::InitSendable(SendableBuilder& builder) { +void Field2d::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("Field2d"); m_table = builder.GetTable(); diff --git a/wpilibc/src/main/native/cpp/smartdashboard/Mechanism2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/Mechanism2d.cpp index 868ad48175..4dcdffaa13 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/Mechanism2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/Mechanism2d.cpp @@ -6,7 +6,7 @@ #include -#include "frc/smartdashboard/SendableBuilder.h" +#include using namespace frc; @@ -41,7 +41,7 @@ void Mechanism2d::SetBackgroundColor(const Color8Bit& color) { } } -void Mechanism2d::InitSendable(SendableBuilder& builder) { +void Mechanism2d::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("Mechanism2d"); m_table = builder.GetTable(); diff --git a/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp b/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp index 0e0c12ce58..4444f25980 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/MechanismRoot2d.cpp @@ -4,8 +4,6 @@ #include "frc/smartdashboard/MechanismRoot2d.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" #include "frc/util/Color8Bit.h" using namespace frc; diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp index 3e294dc337..48af1988a7 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp @@ -20,7 +20,7 @@ std::shared_ptr SendableBuilderImpl::GetTable() { return m_table; } -bool SendableBuilderImpl::HasTable() const { +bool SendableBuilderImpl::IsPublished() const { return m_table != nullptr; } @@ -28,7 +28,7 @@ bool SendableBuilderImpl::IsActuator() const { return m_actuator; } -void SendableBuilderImpl::UpdateTable() { +void SendableBuilderImpl::Update() { uint64_t time = nt::Now(); for (auto& property : m_properties) { if (property.update) { diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableChooserBase.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableChooserBase.cpp index a3d06e0b17..946e85df7d 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableChooserBase.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableChooserBase.cpp @@ -4,14 +4,14 @@ #include "frc/smartdashboard/SendableChooserBase.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include using namespace frc; std::atomic_int SendableChooserBase::s_instances{0}; SendableChooserBase::SendableChooserBase() : m_instance{s_instances++} { - SendableRegistry::GetInstance().Add(this, "SendableChooser", m_instance); + wpi::SendableRegistry::GetInstance().Add(this, "SendableChooser", m_instance); } SendableChooserBase::SendableChooserBase(SendableChooserBase&& oth) diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp index d8743fcb63..b15184663e 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp @@ -9,9 +9,10 @@ #include #include #include +#include #include "frc/Errors.h" -#include "frc/smartdashboard/SendableRegistry.h" +#include "frc/smartdashboard/SendableBuilderImpl.h" using namespace frc; @@ -21,7 +22,7 @@ class Singleton { static Singleton& GetInstance(); std::shared_ptr table; - wpi::StringMap tablesToData; + wpi::StringMap tablesToData; wpi::mutex tablesToDataMutex; private: @@ -84,41 +85,45 @@ nt::NetworkTableEntry SmartDashboard::GetEntry(std::string_view key) { return Singleton::GetInstance().table->GetEntry(key); } -void SmartDashboard::PutData(std::string_view key, Sendable* data) { +void SmartDashboard::PutData(std::string_view key, wpi::Sendable* data) { if (!data) { throw FRC_MakeError(err::NullParameter, "{}", "value"); } auto& inst = Singleton::GetInstance(); std::scoped_lock lock(inst.tablesToDataMutex); auto& uid = inst.tablesToData[key]; - auto& registry = SendableRegistry::GetInstance(); - Sendable* sddata = registry.GetSendable(uid); + auto& registry = wpi::SendableRegistry::GetInstance(); + wpi::Sendable* sddata = registry.GetSendable(uid); if (sddata != data) { uid = registry.GetUniqueId(data); auto dataTable = inst.table->GetSubTable(key); - registry.Publish(uid, dataTable); + auto builder = std::make_unique(); + auto builderPtr = builder.get(); + builderPtr->SetTable(dataTable); + registry.Publish(uid, std::move(builder)); + builderPtr->StartListeners(); dataTable->GetEntry(".name").SetString(key); } } -void SmartDashboard::PutData(Sendable* value) { +void SmartDashboard::PutData(wpi::Sendable* value) { if (!value) { throw FRC_MakeError(err::NullParameter, "{}", "value"); } - auto name = SendableRegistry::GetInstance().GetName(value); + auto name = wpi::SendableRegistry::GetInstance().GetName(value); if (!name.empty()) { PutData(name, value); } } -Sendable* SmartDashboard::GetData(std::string_view key) { +wpi::Sendable* SmartDashboard::GetData(std::string_view key) { auto& inst = Singleton::GetInstance(); std::scoped_lock lock(inst.tablesToDataMutex); auto it = inst.tablesToData.find(key); if (it == inst.tablesToData.end()) { throw FRC_MakeError(err::SmartDashboardMissingKey, "{}", key); } - return SendableRegistry::GetInstance().GetSendable(it->getValue()); + return wpi::SendableRegistry::GetInstance().GetSendable(it->getValue()); } bool SmartDashboard::PutBoolean(std::string_view keyName, bool value) { @@ -257,7 +262,7 @@ void SmartDashboard::PostListenerTask(std::function task) { } void SmartDashboard::UpdateValues() { - auto& registry = SendableRegistry::GetInstance(); + auto& registry = wpi::SendableRegistry::GetInstance(); auto& inst = Singleton::GetInstance(); listenerExecutor.RunListenerTasks(); std::scoped_lock lock(inst.tablesToDataMutex); diff --git a/wpilibc/src/main/native/include/frc/ADXL345_I2C.h b/wpilibc/src/main/native/include/frc/ADXL345_I2C.h index feedd4c67d..9fe97129a5 100644 --- a/wpilibc/src/main/native/include/frc/ADXL345_I2C.h +++ b/wpilibc/src/main/native/include/frc/ADXL345_I2C.h @@ -5,16 +5,14 @@ #pragma once #include +#include +#include #include "frc/I2C.h" #include "frc/interfaces/Accelerometer.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * ADXL345 Accelerometer on I2C. * @@ -23,8 +21,8 @@ class SendableBuilder; * 0x1D (7-bit address). */ class ADXL345_I2C : public Accelerometer, - public Sendable, - public SendableHelper { + public nt::NTSendable, + public wpi::SendableHelper { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; @@ -70,7 +68,7 @@ class ADXL345_I2C : public Accelerometer, */ virtual AllAxes GetAccelerations(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; protected: I2C m_i2c; diff --git a/wpilibc/src/main/native/include/frc/ADXL345_SPI.h b/wpilibc/src/main/native/include/frc/ADXL345_SPI.h index bc6122343d..f5bbc4bba0 100644 --- a/wpilibc/src/main/native/include/frc/ADXL345_SPI.h +++ b/wpilibc/src/main/native/include/frc/ADXL345_SPI.h @@ -5,11 +5,11 @@ #pragma once #include +#include +#include #include "frc/SPI.h" #include "frc/interfaces/Accelerometer.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -20,8 +20,8 @@ namespace frc { * via SPI. This class assumes the sensor is wired in 4-wire SPI mode. */ class ADXL345_SPI : public Accelerometer, - public Sendable, - public SendableHelper { + public nt::NTSendable, + public wpi::SendableHelper { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; @@ -66,7 +66,7 @@ class ADXL345_SPI : public Accelerometer, */ virtual AllAxes GetAccelerations(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; protected: SPI m_spi; diff --git a/wpilibc/src/main/native/include/frc/ADXL362.h b/wpilibc/src/main/native/include/frc/ADXL362.h index ca9bc9129c..ebd230eaa6 100644 --- a/wpilibc/src/main/native/include/frc/ADXL362.h +++ b/wpilibc/src/main/native/include/frc/ADXL362.h @@ -5,24 +5,22 @@ #pragma once #include +#include +#include #include "frc/SPI.h" #include "frc/interfaces/Accelerometer.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * ADXL362 SPI Accelerometer. * * This class allows access to an Analog Devices ADXL362 3-axis accelerometer. */ class ADXL362 : public Accelerometer, - public Sendable, - public SendableHelper { + public nt::NTSendable, + public wpi::SendableHelper { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; struct AllAxes { @@ -74,7 +72,7 @@ class ADXL362 : public Accelerometer, */ virtual AllAxes GetAccelerations(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; private: SPI m_spi; diff --git a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h index 69b6492f72..5bb1f29147 100644 --- a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h +++ b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h @@ -7,11 +7,11 @@ #include #include +#include +#include #include "frc/SPI.h" #include "frc/interfaces/Gyro.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -29,8 +29,8 @@ namespace frc { * Only one instance of an ADXRS Gyro is supported. */ class ADXRS450_Gyro : public Gyro, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Gyro constructor on onboard CS0. @@ -100,7 +100,7 @@ class ADXRS450_Gyro : public Gyro, */ int GetPort() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: SPI m_spi; diff --git a/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h b/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h index acc5c5f8d1..b14ff7c179 100644 --- a/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h +++ b/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h @@ -6,14 +6,13 @@ #include +#include +#include + #include "frc/AnalogInput.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Handle operation of an analog accelerometer. * @@ -21,8 +20,8 @@ class SendableBuilder; * sensors have multiple axis and can be treated as multiple devices. Each is * calibrated by finding the center value over a period of time. */ -class AnalogAccelerometer : public Sendable, - public SendableHelper { +class AnalogAccelerometer : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Create a new instance of an accelerometer. @@ -93,7 +92,7 @@ class AnalogAccelerometer : public Sendable, */ void SetZero(double zero); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: /** diff --git a/wpilibc/src/main/native/include/frc/AnalogEncoder.h b/wpilibc/src/main/native/include/frc/AnalogEncoder.h index 44b3f02339..6f12cb8a06 100644 --- a/wpilibc/src/main/native/include/frc/AnalogEncoder.h +++ b/wpilibc/src/main/native/include/frc/AnalogEncoder.h @@ -9,11 +9,11 @@ #include #include #include +#include +#include #include "frc/AnalogTrigger.h" #include "frc/Counter.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class AnalogInput; @@ -21,7 +21,8 @@ class AnalogInput; /** * Class for supporting continuous analog encoders, such as the US Digital MA3. */ -class AnalogEncoder : public Sendable, public SendableHelper { +class AnalogEncoder : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Construct a new AnalogEncoder attached to a specific AnalogIn channel. @@ -116,7 +117,7 @@ class AnalogEncoder : public Sendable, public SendableHelper { */ int GetChannel() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: void Init(); diff --git a/wpilibc/src/main/native/include/frc/AnalogGyro.h b/wpilibc/src/main/native/include/frc/AnalogGyro.h index ef36ab0126..9a8e900a92 100644 --- a/wpilibc/src/main/native/include/frc/AnalogGyro.h +++ b/wpilibc/src/main/native/include/frc/AnalogGyro.h @@ -7,10 +7,10 @@ #include #include +#include +#include #include "frc/interfaces/Gyro.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -30,8 +30,8 @@ class AnalogInput; * This class is for gyro sensors that connect to an analog input. */ class AnalogGyro : public Gyro, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: static constexpr int kOversampleBits = 10; static constexpr int kAverageBits = 0; @@ -192,7 +192,7 @@ class AnalogGyro : public Gyro, */ std::shared_ptr GetAnalogInput() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: std::shared_ptr m_analog; diff --git a/wpilibc/src/main/native/include/frc/AnalogInput.h b/wpilibc/src/main/native/include/frc/AnalogInput.h index 6b1828225e..45ecb388af 100644 --- a/wpilibc/src/main/native/include/frc/AnalogInput.h +++ b/wpilibc/src/main/native/include/frc/AnalogInput.h @@ -7,13 +7,11 @@ #include #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { -class SendableBuilder; class DMA; class DMASample; @@ -29,7 +27,8 @@ class DMASample; * are divided by the number of samples to retain the resolution, but get more * stable values. */ -class AnalogInput : public Sendable, public SendableHelper { +class AnalogInput : public wpi::Sendable, + public wpi::SendableHelper { friend class AnalogTrigger; friend class AnalogGyro; friend class DMA; @@ -282,7 +281,7 @@ class AnalogInput : public Sendable, public SendableHelper { */ void SetSimDevice(HAL_SimDeviceHandle device); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/AnalogOutput.h b/wpilibc/src/main/native/include/frc/AnalogOutput.h index f93511a903..ccb3c9c91f 100644 --- a/wpilibc/src/main/native/include/frc/AnalogOutput.h +++ b/wpilibc/src/main/native/include/frc/AnalogOutput.h @@ -5,18 +5,16 @@ #pragma once #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { -class SendableBuilder; - /** * MXP analog output class. */ -class AnalogOutput : public Sendable, public SendableHelper { +class AnalogOutput : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Construct an analog output on the given channel. @@ -51,7 +49,7 @@ class AnalogOutput : public Sendable, public SendableHelper { */ int GetChannel() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h index 8c470bbf45..29618bb6f3 100644 --- a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h +++ b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h @@ -6,22 +6,21 @@ #include +#include +#include + #include "frc/AnalogInput.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Class for reading analog potentiometers. Analog potentiometers read in an * analog voltage that corresponds to a position. The position is in whichever * units you choose, by way of the scaling and offset constants passed to the * constructor. */ -class AnalogPotentiometer : public Sendable, - public SendableHelper { +class AnalogPotentiometer : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Construct an Analog Potentiometer object from a channel number. @@ -103,7 +102,7 @@ class AnalogPotentiometer : public Sendable, */ double Get() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: std::shared_ptr m_analog_input; diff --git a/wpilibc/src/main/native/include/frc/AnalogTrigger.h b/wpilibc/src/main/native/include/frc/AnalogTrigger.h index e11b2d2821..3d250544ac 100644 --- a/wpilibc/src/main/native/include/frc/AnalogTrigger.h +++ b/wpilibc/src/main/native/include/frc/AnalogTrigger.h @@ -7,18 +7,18 @@ #include #include +#include +#include #include "frc/AnalogTriggerOutput.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class AnalogInput; class DutyCycle; -class SendableBuilder; -class AnalogTrigger : public Sendable, public SendableHelper { +class AnalogTrigger : public wpi::Sendable, + public wpi::SendableHelper { friend class AnalogTriggerOutput; public: @@ -148,7 +148,7 @@ class AnalogTrigger : public Sendable, public SendableHelper { std::shared_ptr CreateOutput( AnalogTriggerType type) const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int GetSourceChannel() const; diff --git a/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h b/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h index 0629976bb1..6f52cab452 100644 --- a/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h +++ b/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h @@ -4,9 +4,10 @@ #pragma once +#include +#include + #include "frc/DigitalSource.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -44,8 +45,8 @@ class AnalogTrigger; * may help with this, but rotational speeds of the sensor will then be limited. */ class AnalogTriggerOutput : public DigitalSource, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { friend class AnalogTrigger; public: @@ -77,7 +78,7 @@ class AnalogTriggerOutput : public DigitalSource, */ int GetChannel() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: /** diff --git a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h index 517b7ae483..0e5bee68f3 100644 --- a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h +++ b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h @@ -4,22 +4,21 @@ #pragma once +#include +#include + #include "frc/interfaces/Accelerometer.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Built-in accelerometer. * * This class allows access to the roboRIO's internal accelerometer. */ class BuiltInAccelerometer : public Accelerometer, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Constructor. @@ -56,7 +55,7 @@ class BuiltInAccelerometer : public Accelerometer, */ double GetZ() override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/Counter.h b/wpilibc/src/main/native/include/frc/Counter.h index a5474e8b25..720f10348c 100644 --- a/wpilibc/src/main/native/include/frc/Counter.h +++ b/wpilibc/src/main/native/include/frc/Counter.h @@ -8,16 +8,15 @@ #include #include +#include +#include #include "frc/AnalogTrigger.h" #include "frc/CounterBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class DigitalGlitchFilter; -class SendableBuilder; class DMA; class DMASample; @@ -32,8 +31,8 @@ class DMASample; * to be zeroed before use. */ class Counter : public CounterBase, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { friend class DMA; friend class DMASample; @@ -421,7 +420,7 @@ class Counter : public CounterBase, */ bool GetDirection() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; protected: // Makes the counter count up. diff --git a/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h b/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h index fe48e4a630..7172f21db3 100644 --- a/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h +++ b/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h @@ -9,10 +9,10 @@ #include #include +#include +#include #include "frc/DigitalSource.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -26,8 +26,8 @@ class Counter; * filter. The filter lets the user configure the time that an input must remain * high or low before it is classified as high or low. */ -class DigitalGlitchFilter : public Sendable, - public SendableHelper { +class DigitalGlitchFilter : public wpi::Sendable, + public wpi::SendableHelper { public: DigitalGlitchFilter(); ~DigitalGlitchFilter() override; @@ -114,7 +114,7 @@ class DigitalGlitchFilter : public Sendable, */ uint64_t GetPeriodNanoSeconds(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: // Sets the filter for the input to be the requested index. A value of 0 diff --git a/wpilibc/src/main/native/include/frc/DigitalInput.h b/wpilibc/src/main/native/include/frc/DigitalInput.h index e30b46ab2a..cee31fdc39 100644 --- a/wpilibc/src/main/native/include/frc/DigitalInput.h +++ b/wpilibc/src/main/native/include/frc/DigitalInput.h @@ -4,14 +4,14 @@ #pragma once +#include +#include + #include "frc/DigitalSource.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class DigitalGlitchFilter; -class SendableBuilder; /** * Class to read a digital input. @@ -23,8 +23,8 @@ class SendableBuilder; * implemented anywhere else. */ class DigitalInput : public DigitalSource, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Create an instance of a Digital Input class. @@ -75,7 +75,7 @@ class DigitalInput : public DigitalSource, */ void SetSimDevice(HAL_SimDeviceHandle device); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/DigitalOutput.h b/wpilibc/src/main/native/include/frc/DigitalOutput.h index 6e812a3443..0e124f104e 100644 --- a/wpilibc/src/main/native/include/frc/DigitalOutput.h +++ b/wpilibc/src/main/native/include/frc/DigitalOutput.h @@ -5,15 +5,13 @@ #pragma once #include +#include +#include #include "frc/DigitalSource.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Class to write to digital outputs. * @@ -22,8 +20,8 @@ class SendableBuilder; * shouldn't be done here. */ class DigitalOutput : public DigitalSource, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Create an instance of a digital output. @@ -145,7 +143,7 @@ class DigitalOutput : public DigitalSource, */ void SetSimDevice(HAL_SimDeviceHandle device); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h index 7dc13833b0..62957d7f13 100644 --- a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h +++ b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h @@ -7,15 +7,13 @@ #include #include +#include +#include #include "frc/PneumaticsBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * DoubleSolenoid class for running 2 channels of high voltage Digital Output * (PCM). @@ -23,7 +21,8 @@ class SendableBuilder; * The DoubleSolenoid class is typically used for pneumatics solenoids that * have two positions controlled by two separate channels. */ -class DoubleSolenoid : public Sendable, public SendableHelper { +class DoubleSolenoid : public wpi::Sendable, + public wpi::SendableHelper { public: enum Value { kOff, kForward, kReverse }; @@ -98,7 +97,7 @@ class DoubleSolenoid : public Sendable, public SendableHelper { */ bool IsRevSolenoidDisabled() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_forwardChannel; // The forward channel on the module to control. diff --git a/wpilibc/src/main/native/include/frc/DutyCycle.h b/wpilibc/src/main/native/include/frc/DutyCycle.h index 0cdf8c3019..7f45d068c1 100644 --- a/wpilibc/src/main/native/include/frc/DutyCycle.h +++ b/wpilibc/src/main/native/include/frc/DutyCycle.h @@ -7,9 +7,8 @@ #include #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { class DigitalSource; @@ -28,7 +27,7 @@ class DMASample; * order to implement rollover checking. * */ -class DutyCycle : public Sendable, public SendableHelper { +class DutyCycle : public wpi::Sendable, public wpi::SendableHelper { friend class AnalogTrigger; friend class DMA; friend class DMASample; @@ -119,7 +118,7 @@ class DutyCycle : public Sendable, public SendableHelper { int GetSourceChannel() const; protected: - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: void InitDutyCycle(); diff --git a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h index fc1d0108ea..50d612da29 100644 --- a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h +++ b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h @@ -9,11 +9,11 @@ #include #include #include +#include +#include #include "frc/AnalogTrigger.h" #include "frc/Counter.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class DutyCycle; @@ -24,8 +24,8 @@ class DigitalSource; * PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag * Encoder. */ -class DutyCycleEncoder : public Sendable, - public SendableHelper { +class DutyCycleEncoder : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Construct a new DutyCycleEncoder on a specific channel. @@ -163,7 +163,7 @@ class DutyCycleEncoder : public Sendable, */ int GetSourceChannel() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: void Init(); diff --git a/wpilibc/src/main/native/include/frc/Encoder.h b/wpilibc/src/main/native/include/frc/Encoder.h index 2d1eb1216e..fa52b6f22e 100644 --- a/wpilibc/src/main/native/include/frc/Encoder.h +++ b/wpilibc/src/main/native/include/frc/Encoder.h @@ -7,17 +7,16 @@ #include #include +#include +#include #include "frc/Counter.h" #include "frc/CounterBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class DigitalSource; class DigitalGlitchFilter; -class SendableBuilder; class DMA; class DMASample; @@ -37,8 +36,8 @@ class DMASample; * to be zeroed before use. */ class Encoder : public CounterBase, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { friend class DMA; friend class DMASample; @@ -340,7 +339,7 @@ class Encoder : public CounterBase, int GetFPGAIndex() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: /** diff --git a/wpilibc/src/main/native/include/frc/PWM.h b/wpilibc/src/main/native/include/frc/PWM.h index 65de64ba55..aaf92f5d39 100644 --- a/wpilibc/src/main/native/include/frc/PWM.h +++ b/wpilibc/src/main/native/include/frc/PWM.h @@ -7,13 +7,11 @@ #include #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { class AddressableLED; -class SendableBuilder; /** * Class implements the PWM generation in the FPGA. @@ -32,7 +30,7 @@ class SendableBuilder; * - 1 = minimum pulse width (currently 0.5ms) * - 0 = disabled (i.e. PWM output is held low) */ -class PWM : public Sendable, public SendableHelper { +class PWM : public wpi::Sendable, public wpi::SendableHelper { public: friend class AddressableLED; /** @@ -224,7 +222,7 @@ class PWM : public Sendable, public SendableHelper { int GetChannel() const; protected: - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h index 9e5ebbaae8..b8466b2765 100644 --- a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h +++ b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h @@ -5,20 +5,18 @@ #pragma once #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { -class SendableBuilder; - /** * Class for getting voltage, current, temperature, power and energy from the * CAN PDP. */ -class PowerDistributionPanel : public Sendable, - public SendableHelper { +class PowerDistributionPanel + : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Constructs a PowerDistributionPanel. @@ -96,7 +94,7 @@ class PowerDistributionPanel : public Sendable, */ int GetModule() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: hal::Handle m_handle; diff --git a/wpilibc/src/main/native/include/frc/Relay.h b/wpilibc/src/main/native/include/frc/Relay.h index a8aaf49579..4765c64a6a 100644 --- a/wpilibc/src/main/native/include/frc/Relay.h +++ b/wpilibc/src/main/native/include/frc/Relay.h @@ -8,15 +8,13 @@ #include #include +#include +#include #include "frc/MotorSafety.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Class for Spike style relay outputs. * @@ -30,8 +28,8 @@ class SendableBuilder; * a solenoid). */ class Relay : public MotorSafety, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: enum Value { kOff, kOn, kForward, kReverse }; enum Direction { kBothDirections, kForwardOnly, kReverseOnly }; @@ -93,7 +91,7 @@ class Relay : public MotorSafety, std::string GetDescription() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: int m_channel; diff --git a/wpilibc/src/main/native/include/frc/Servo.h b/wpilibc/src/main/native/include/frc/Servo.h index feaaf0f557..d1bede35e8 100644 --- a/wpilibc/src/main/native/include/frc/Servo.h +++ b/wpilibc/src/main/native/include/frc/Servo.h @@ -92,7 +92,7 @@ class Servo : public PWM { */ double GetMinAngle() const; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: double GetServoAngleRange() const; diff --git a/wpilibc/src/main/native/include/frc/Solenoid.h b/wpilibc/src/main/native/include/frc/Solenoid.h index ca02441a7c..97ba2939cb 100644 --- a/wpilibc/src/main/native/include/frc/Solenoid.h +++ b/wpilibc/src/main/native/include/frc/Solenoid.h @@ -8,22 +8,20 @@ #include #include +#include +#include #include "frc/PneumaticsBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Solenoid class for running high voltage Digital Output (PCM). * * The Solenoid class is typically used for pneumatics solenoids, but could be * used for any device within the current spec of the PCM. */ -class Solenoid : public Sendable, public SendableHelper { +class Solenoid : public wpi::Sendable, public wpi::SendableHelper { public: Solenoid(PneumaticsBase& module, int channel); Solenoid(PneumaticsBase* module, int channel); @@ -93,7 +91,7 @@ class Solenoid : public Sendable, public SendableHelper { */ void StartPulse(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: std::shared_ptr m_module; diff --git a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h index 5552c80ebe..23e5b017a2 100644 --- a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h +++ b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h @@ -8,17 +8,17 @@ #include #include +#include +#include #include "frc/motorcontrol/MotorController.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup - : public Sendable, + : public wpi::Sendable, public MotorController, - public SendableHelper { + public wpi::SendableHelper { public: template explicit SpeedControllerGroup(SpeedController& speedController, @@ -36,7 +36,7 @@ class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup void Disable() override; void StopMotor() override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: bool m_isInverted = false; diff --git a/wpilibc/src/main/native/include/frc/Ultrasonic.h b/wpilibc/src/main/native/include/frc/Ultrasonic.h index 25624bf850..28df3136e1 100644 --- a/wpilibc/src/main/native/include/frc/Ultrasonic.h +++ b/wpilibc/src/main/native/include/frc/Ultrasonic.h @@ -13,10 +13,10 @@ #include #include #include +#include +#include #include "frc/Counter.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -35,7 +35,8 @@ class DigitalOutput; * received. The time that the line is high determines the round trip distance * (time of flight). */ -class Ultrasonic : public Sendable, public SendableHelper { +class Ultrasonic : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Create an instance of the Ultrasonic Sensor. @@ -136,7 +137,7 @@ class Ultrasonic : public Sendable, public SendableHelper { void SetEnabled(bool enable); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: /** diff --git a/wpilibc/src/main/native/include/frc/controller/PIDController.h b/wpilibc/src/main/native/include/frc/controller/PIDController.h index 29d9ad4f06..a496ac54a2 100644 --- a/wpilibc/src/main/native/include/frc/controller/PIDController.h +++ b/wpilibc/src/main/native/include/frc/controller/PIDController.h @@ -8,17 +8,16 @@ #include #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc2 { /** * Implements a PID control loop. */ -class PIDController : public frc::Sendable, - public frc::SendableHelper { +class PIDController : public wpi::Sendable, + public wpi::SendableHelper { public: /** * Allocates a PIDController with the given constants for Kp, Ki, and Kd. @@ -193,7 +192,7 @@ class PIDController : public frc::Sendable, */ void Reset(); - void InitSendable(frc::SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: // Factor for "proportional" control diff --git a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h index 1afbba2694..6b010ba7cf 100644 --- a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h +++ b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h @@ -10,12 +10,12 @@ #include #include +#include +#include +#include #include "frc/MathUtil.h" #include "frc/controller/PIDController.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableHelper.h" #include "frc/trajectory/TrapezoidProfile.h" namespace frc { @@ -29,8 +29,8 @@ void ReportProfiledPIDController(); */ template class ProfiledPIDController - : public Sendable, - public SendableHelper> { + : public wpi::Sendable, + public wpi::SendableHelper> { public: using Distance_t = units::unit_t; using Velocity = @@ -340,7 +340,7 @@ class ProfiledPIDController Reset(measuredPosition, Velocity_t(0)); } - void InitSendable(frc::SendableBuilder& builder) override { + void InitSendable(wpi::SendableBuilder& builder) override { builder.SetSmartDashboardType("ProfiledPIDController"); builder.AddDoubleProperty( "p", [this] { return GetP(); }, [this](double value) { SetP(value); }); diff --git a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h index 0b3b239019..c5d4512f61 100644 --- a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h @@ -6,9 +6,10 @@ #include +#include +#include + #include "frc/drive/RobotDriveBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -97,8 +98,8 @@ class SpeedController; * with SetDeadband(). */ class DifferentialDrive : public RobotDriveBase, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: struct WheelSpeeds { double left = 0.0; @@ -208,7 +209,7 @@ class DifferentialDrive : public RobotDriveBase, void StopMotor() override; std::string GetDescription() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: SpeedController* m_leftMotor; diff --git a/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h b/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h index 7df65974c6..1acc69f9b4 100644 --- a/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h @@ -7,10 +7,11 @@ #include #include +#include +#include + #include "frc/drive/RobotDriveBase.h" #include "frc/drive/Vector2d.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -54,8 +55,8 @@ class SpeedController; * clockwise rotation around the Z axis is positive. */ class KilloughDrive : public RobotDriveBase, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: static constexpr double kDefaultLeftMotorAngle = 60.0; static constexpr double kDefaultRightMotorAngle = 120.0; @@ -160,7 +161,7 @@ class KilloughDrive : public RobotDriveBase, void StopMotor() override; std::string GetDescription() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: SpeedController* m_leftMotor; diff --git a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h index ac1ac92d13..191bf64ba0 100644 --- a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h @@ -7,9 +7,10 @@ #include #include +#include +#include + #include "frc/drive/RobotDriveBase.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -72,8 +73,8 @@ class SpeedController; * deadband of 0 is used. */ class MecanumDrive : public RobotDriveBase, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: struct WheelSpeeds { double frontLeft = 0.0; @@ -150,7 +151,7 @@ class MecanumDrive : public RobotDriveBase, void StopMotor() override; std::string GetDescription() const override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: SpeedController* m_frontLeftMotor; diff --git a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h index f3b6092b52..62dd95d626 100644 --- a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h +++ b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h @@ -7,9 +7,11 @@ #include #include -namespace frc { - +namespace wpi { class Sendable; +} // namespace wpi + +namespace frc { /** * The LiveWindow class is the public interface for putting sensors and @@ -36,14 +38,14 @@ class LiveWindow { * * @param sendable component */ - void EnableTelemetry(Sendable* component); + void EnableTelemetry(wpi::Sendable* component); /** * Disable telemetry for a single component. * * @param sendable component */ - void DisableTelemetry(Sendable* component); + void DisableTelemetry(wpi::Sendable* component); /** * Disable ALL telemetry. diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h b/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h index 584eb02da9..9d2a1daa27 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h @@ -7,15 +7,16 @@ #include #include +#include +#include + #include "frc/motorcontrol/MotorController.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class MotorControllerGroup : public Sendable, +class MotorControllerGroup : public wpi::Sendable, public MotorController, - public SendableHelper { + public wpi::SendableHelper { public: template explicit MotorControllerGroup(MotorController& motorController, @@ -33,7 +34,7 @@ class MotorControllerGroup : public Sendable, void Disable() override; void StopMotor() override; - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: bool m_isInverted = false; diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h b/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h index bf5e5e7239..cc95d7115d 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/NidecBrushless.h @@ -6,24 +6,23 @@ #include +#include +#include + #include "frc/DigitalOutput.h" #include "frc/MotorSafety.h" #include "frc/PWM.h" #include "frc/motorcontrol/MotorController.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SendableBuilder; - /** * Nidec Brushless Motor. */ class NidecBrushless : public MotorController, public MotorSafety, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: /** * Constructor. @@ -86,7 +85,7 @@ class NidecBrushless : public MotorController, int GetChannel() const; // Sendable interface - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: bool m_isInverted = false; diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h index 5cb493a69e..3fe67f518d 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h @@ -7,11 +7,12 @@ #include #include +#include +#include + #include "frc/MotorSafety.h" #include "frc/PWM.h" #include "frc/motorcontrol/MotorController.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -20,8 +21,8 @@ namespace frc { */ class PWMMotorController : public MotorController, public MotorSafety, - public Sendable, - public SendableHelper { + public wpi::Sendable, + public wpi::SendableHelper { public: PWMMotorController(PWMMotorController&&) = default; PWMMotorController& operator=(PWMMotorController&&) = default; @@ -67,7 +68,7 @@ class PWMMotorController : public MotorController, */ PWMMotorController(std::string_view name, int channel); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; PWM m_pwm; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h index 90dbf4f80e..86e2009a74 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ComplexWidget.h @@ -10,12 +10,14 @@ #include #include "frc/shuffleboard/ShuffleboardWidget.h" -#include "frc/smartdashboard/SendableBuilder.h" -#include "frc/smartdashboard/SendableBuilderImpl.h" + +namespace wpi { +class Sendable; +class SendableBuilder; +} // namespace wpi namespace frc { -class Sendable; class ShuffleboardContainer; /** @@ -25,7 +27,9 @@ class ShuffleboardContainer; class ComplexWidget final : public ShuffleboardWidget { public: ComplexWidget(ShuffleboardContainer& parent, std::string_view title, - Sendable& sendable); + wpi::Sendable& sendable); + + ~ComplexWidget() override; void EnableIfActuator() override; @@ -35,9 +39,8 @@ class ComplexWidget final : public ShuffleboardWidget { std::shared_ptr metaTable) override; private: - Sendable& m_sendable; - SendableBuilderImpl m_builder; - bool m_builderInit = false; + wpi::Sendable& m_sendable; + std::unique_ptr m_builder; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/SendableCameraWrapper.h b/wpilibc/src/main/native/include/frc/shuffleboard/SendableCameraWrapper.h index f3c7c5659c..e7c9a81842 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/SendableCameraWrapper.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/SendableCameraWrapper.h @@ -18,8 +18,8 @@ using CS_Handle = int; // NOLINT using CS_Source = CS_Handle; // NOLINT #endif -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include +#include namespace frc { @@ -29,14 +29,15 @@ namespace detail { constexpr const char* kProtocol = "camera_server://"; std::shared_ptr& GetSendableCameraWrapper( CS_Source source); -void AddToSendableRegistry(Sendable* sendable, std::string name); +void AddToSendableRegistry(wpi::Sendable* sendable, std::string name); } // namespace detail /** * A wrapper to make video sources sendable and usable from Shuffleboard. */ -class SendableCameraWrapper : public Sendable, - public SendableHelper { +class SendableCameraWrapper + : public wpi::Sendable, + public wpi::SendableHelper { private: struct private_init {}; @@ -60,7 +61,7 @@ class SendableCameraWrapper : public Sendable, static SendableCameraWrapper& Wrap(const cs::VideoSource& source); static SendableCameraWrapper& Wrap(CS_Source source); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; private: std::string m_uri; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h index 4414bc20a9..24f65a37b2 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h @@ -29,8 +29,6 @@ class ShuffleboardComponent : public ShuffleboardComponentBase { ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title, std::string_view type = ""); - ~ShuffleboardComponent() override = default; - /** * Sets custom properties for this component. Property names are * case-sensitive and whitespace-insensitive (capitalization and spaces do not diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h index 7055c5ece7..d33a2346f0 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponentBase.h @@ -26,8 +26,6 @@ class ShuffleboardComponentBase : public virtual ShuffleboardValue { ShuffleboardComponentBase(ShuffleboardContainer& parent, std::string_view title, std::string_view type = ""); - ~ShuffleboardComponentBase() override = default; - void SetType(std::string_view type); void BuildMetadata(std::shared_ptr metaTable); diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h index 2bfc9902a0..f748997ad5 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h @@ -26,10 +26,13 @@ namespace cs { class VideoSource; } // namespace cs +namespace wpi { +class Sendable; +} // namespace wpi + namespace frc { class ComplexWidget; -class Sendable; class ShuffleboardLayout; class SimpleWidget; @@ -111,7 +114,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * @throws IllegalArgumentException if a widget already exists in this * container with the given title */ - ComplexWidget& Add(std::string_view title, Sendable& sendable); + ComplexWidget& Add(std::string_view title, wpi::Sendable& sendable); /** * Adds a widget to this container to display the given video stream. @@ -133,7 +136,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue { * container with the given title, or if the sendable's name has not been * specified */ - ComplexWidget& Add(Sendable& sendable); + ComplexWidget& Add(wpi::Sendable& sendable); /** * Adds a widget to this container to display the given video stream. diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h index d718a11c5c..61d7a7207b 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/Field2d.h @@ -8,16 +8,16 @@ #include #include +#include #include #include #include #include +#include #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" #include "frc/smartdashboard/FieldObject2d.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -39,7 +39,7 @@ namespace frc { * also be shown by using the GetObject() function. Other objects can * also have multiple poses (which will show the object at multiple locations). */ -class Field2d : public Sendable, public SendableHelper { +class Field2d : public nt::NTSendable, public wpi::SendableHelper { public: using Entry = size_t; @@ -85,7 +85,7 @@ class Field2d : public Sendable, public SendableHelper { */ FieldObject2d* GetRobotObject(); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; private: std::shared_ptr m_table; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/Mechanism2d.h b/wpilibc/src/main/native/include/frc/smartdashboard/Mechanism2d.h index 7ddc976c36..b9063e34f5 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/Mechanism2d.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/Mechanism2d.h @@ -7,13 +7,13 @@ #include #include +#include #include #include #include +#include #include "frc/smartdashboard/MechanismRoot2d.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" #include "frc/util/Color8Bit.h" namespace frc { @@ -36,7 +36,8 @@ namespace frc { * @see MechanismLigament2d * @see MechanismRoot2d */ -class Mechanism2d : public Sendable, public SendableHelper { +class Mechanism2d : public nt::NTSendable, + public wpi::SendableHelper { public: /** * Create a new Mechanism2d with the given dimensions and background color. @@ -68,7 +69,7 @@ class Mechanism2d : public Sendable, public SendableHelper { */ void SetBackgroundColor(const Color8Bit& color); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; private: double m_width; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h index 10125fbd40..36830f6dc1 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h @@ -11,17 +11,16 @@ #include #include +#include #include #include #include #include #include -#include "frc/smartdashboard/SendableBuilder.h" - namespace frc { -class SendableBuilderImpl : public SendableBuilder { +class SendableBuilderImpl : public nt::NTSendableBuilder { public: SendableBuilderImpl() = default; ~SendableBuilderImpl() override = default; @@ -46,7 +45,7 @@ class SendableBuilderImpl : public SendableBuilder { * Return whether this sendable has an associated table. * @return True if it has a table, false if not. */ - bool HasTable() const; + bool IsPublished() const override; /** * Return whether this sendable should be treated as an actuator. @@ -57,7 +56,7 @@ class SendableBuilderImpl : public SendableBuilder { /** * Update the network table values by calling the getters for all properties. */ - void UpdateTable(); + void Update() override; /** * Hook setters for all properties. @@ -84,7 +83,7 @@ class SendableBuilderImpl : public SendableBuilder { /** * Clear properties. */ - void ClearProperties(); + void ClearProperties() override; void SetSmartDashboardType(std::string_view type) override; void SetActuator(bool value) override; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h index 26a1671ab6..b693762a72 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h @@ -10,7 +10,6 @@ #include #include -#include "frc/smartdashboard/SendableBuilder.h" #include "frc/smartdashboard/SendableChooserBase.h" namespace frc { @@ -112,7 +111,7 @@ class SendableChooser : public SendableChooserBase { */ auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""])); - void InitSendable(SendableBuilder& builder) override; + void InitSendable(nt::NTSendableBuilder& builder) override; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc index 13ec1b21a6..25e25511c1 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc @@ -11,6 +11,8 @@ #include #include +#include + #include "frc/smartdashboard/SendableChooser.h" namespace frc { @@ -44,7 +46,7 @@ auto SendableChooser::GetSelected() } template -void SendableChooser::InitSendable(SendableBuilder& builder) { +void SendableChooser::InitSendable(nt::NTSendableBuilder& builder) { builder.SetSmartDashboardType("String Chooser"); builder.GetEntry(kInstance).SetDouble(m_instance); builder.AddStringArrayProperty( diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h index 6f433ecf54..78f891a461 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h @@ -7,12 +7,11 @@ #include #include +#include #include #include #include - -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" +#include namespace frc { @@ -22,8 +21,8 @@ namespace frc { * It contains static, non-templated variables to avoid their duplication in the * template class. */ -class SendableChooserBase : public Sendable, - public SendableHelper { +class SendableChooserBase : public nt::NTSendable, + public wpi::SendableHelper { public: SendableChooserBase(); ~SendableChooserBase() override = default; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h b/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h index ef3830b38f..5b35938fdd 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h @@ -11,15 +11,16 @@ #include #include +#include +#include #include #include "frc/smartdashboard/ListenerExecutor.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" namespace frc { -class SmartDashboard : public Sendable, public SendableHelper { +class SmartDashboard : public wpi::Sendable, + public wpi::SendableHelper { public: static void init(); @@ -115,7 +116,7 @@ class SmartDashboard : public Sendable, public SendableHelper { * @param keyName the key * @param value the value */ - static void PutData(std::string_view key, Sendable* data); + static void PutData(std::string_view key, wpi::Sendable* data); /** * Maps the specified key (where the key is the name of the Sendable) @@ -129,7 +130,7 @@ class SmartDashboard : public Sendable, public SendableHelper { * * @param value the value */ - static void PutData(Sendable* value); + static void PutData(wpi::Sendable* value); /** * Returns the value at the specified key. @@ -137,7 +138,7 @@ class SmartDashboard : public Sendable, public SendableHelper { * @param keyName the key * @return the value */ - static Sendable* GetData(std::string_view keyName); + static wpi::Sendable* GetData(std::string_view keyName); /** * Maps the specified key to the specified value in this table. diff --git a/wpilibc/src/test/native/cpp/shuffleboard/MockActuatorSendable.cpp b/wpilibc/src/test/native/cpp/shuffleboard/MockActuatorSendable.cpp index 6d7897eb5e..5e769e09c9 100644 --- a/wpilibc/src/test/native/cpp/shuffleboard/MockActuatorSendable.cpp +++ b/wpilibc/src/test/native/cpp/shuffleboard/MockActuatorSendable.cpp @@ -4,14 +4,13 @@ #include "shuffleboard/MockActuatorSendable.h" -#include "frc/smartdashboard/SendableRegistry.h" - -using namespace frc; +#include +#include MockActuatorSendable::MockActuatorSendable(std::string_view name) { - SendableRegistry::GetInstance().Add(this, name); + wpi::SendableRegistry::GetInstance().Add(this, name); } -void MockActuatorSendable::InitSendable(SendableBuilder& builder) { +void MockActuatorSendable::InitSendable(wpi::SendableBuilder& builder) { builder.SetActuator(true); } diff --git a/wpilibc/src/test/native/include/shuffleboard/MockActuatorSendable.h b/wpilibc/src/test/native/include/shuffleboard/MockActuatorSendable.h index b6e6be2957..8baf2a2db4 100644 --- a/wpilibc/src/test/native/include/shuffleboard/MockActuatorSendable.h +++ b/wpilibc/src/test/native/include/shuffleboard/MockActuatorSendable.h @@ -6,15 +6,14 @@ #include -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableBuilder.h" +#include /** * A mock sendable that marks itself as an actuator. */ -class MockActuatorSendable : public frc::Sendable { +class MockActuatorSendable : public wpi::Sendable { public: explicit MockActuatorSendable(std::string_view name); - void InitSendable(frc::SendableBuilder& builder) override; + void InitSendable(wpi::SendableBuilder& builder) override; }; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java index 90cb114a6d..e63f5215bc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java @@ -10,16 +10,17 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; import edu.wpi.first.hal.SimEnum; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Accelerometer; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** ADXL345 I2C Accelerometer. */ @SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) -public class ADXL345_I2C implements Accelerometer, Sendable, AutoCloseable { +public class ADXL345_I2C implements Accelerometer, NTSendable, AutoCloseable { private static final byte kAddress = 0x1D; private static final byte kPowerCtlRegister = 0x2D; private static final byte kDataFormatRegister = 0x31; @@ -215,7 +216,7 @@ public class ADXL345_I2C implements Accelerometer, Sendable, AutoCloseable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("3AxisAccelerometer"); NetworkTableEntry entryX = builder.getEntry("X"); NetworkTableEntry entryY = builder.getEntry("Y"); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java index 48397c6321..183a407271 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java @@ -10,16 +10,17 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; import edu.wpi.first.hal.SimEnum; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Accelerometer; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** ADXL345 SPI Accelerometer. */ @SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) -public class ADXL345_SPI implements Accelerometer, Sendable, AutoCloseable { +public class ADXL345_SPI implements Accelerometer, NTSendable, AutoCloseable { private static final int kPowerCtlRegister = 0x2D; private static final int kDataFormatRegister = 0x31; private static final int kDataRegister = 0x32; @@ -229,7 +230,7 @@ public class ADXL345_SPI implements Accelerometer, Sendable, AutoCloseable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("3AxisAccelerometer"); NetworkTableEntry entryX = builder.getEntry("X"); NetworkTableEntry entryY = builder.getEntry("Y"); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java index 724a7127cd..761203a4f0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java @@ -9,10 +9,11 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; import edu.wpi.first.hal.SimEnum; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Accelerometer; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -21,7 +22,7 @@ import java.nio.ByteOrder; * *

This class allows access to an Analog Devices ADXL362 3-axis accelerometer. */ -public class ADXL362 implements Accelerometer, Sendable, AutoCloseable { +public class ADXL362 implements Accelerometer, NTSendable, AutoCloseable { private static final byte kRegWrite = 0x0A; private static final byte kRegRead = 0x0B; @@ -258,7 +259,7 @@ public class ADXL362 implements Accelerometer, Sendable, AutoCloseable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("3AxisAccelerometer"); NetworkTableEntry entryX = builder.getEntry("X"); NetworkTableEntry entryY = builder.getEntry("Y"); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java index 183960a60d..1a771fd916 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java @@ -9,9 +9,10 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimBoolean; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Gyro; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java index b0395b859a..a2405b8a69 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java @@ -8,8 +8,9 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Handle operation of an analog accelerometer. The accelerometer reads acceleration directly diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java index c5dc5a2946..24989ddd9b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogEncoder.java @@ -7,9 +7,10 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDevice.Direction; import edu.wpi.first.hal.SimDouble; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** Class for supporting continuous analog encoders, such as the US Digital MA3. */ public class AnalogEncoder implements Sendable, AutoCloseable { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java index 2b250d3bbc..c9b9126547 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java @@ -9,9 +9,10 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; import edu.wpi.first.hal.AnalogGyroJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Gyro; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * Use a rate gyro to return the robots heading relative to a starting position. The Gyro class diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java index 91392bbe46..e3bedcbf48 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java @@ -10,8 +10,9 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.util.AllocationException; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Analog channel class. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java index cab2d794fa..299d89c2ec 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java @@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** Analog output class. */ public class AnalogOutput implements Sendable, AutoCloseable { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java index b752ddba05..4a5bd75724 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java @@ -4,8 +4,9 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class for reading analog potentiometers. Analog potentiometers read in an analog voltage that diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java index 4e370e476b..d5825c1865 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java @@ -8,9 +8,10 @@ import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.util.BoundaryException; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** Class for creating and configuring Analog Triggers. */ public class AnalogTrigger implements Sendable, AutoCloseable { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java index 2681f8a9b2..0f513b4490 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java @@ -9,7 +9,8 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; /** * Class to represent a specific output from an analog trigger. This class is used to get the diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java index 4c9bb145be..76c282a537 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java @@ -7,9 +7,10 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.AccelerometerJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.interfaces.Accelerometer; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * Built-in accelerometer. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java index d6ef798ba1..feb33d6135 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java @@ -10,9 +10,10 @@ import static java.util.Objects.requireNonNull; import edu.wpi.first.hal.CounterJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java index 297eb5e196..7e12a8f03e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java @@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.DigitalGlitchFilterJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java index c74ef3c1a2..5b4cf5e829 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java @@ -8,8 +8,9 @@ import edu.wpi.first.hal.DIOJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class to read a digital input. This class will read digital inputs and return the current value diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java index 4bf63ae86f..eb07d8bfee 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -8,8 +8,9 @@ import edu.wpi.first.hal.DIOJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class to write digital outputs. This class will write digital outputs. Other devices that are diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index f866b381c9..c9ae390732 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -6,8 +6,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.Objects; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java index 3e41b37507..3332f49eaf 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java @@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.DutyCycleJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class to read a duty cycle PWM input. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycleEncoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycleEncoder.java index d7cfa36361..ce5b684a56 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycleEncoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycleEncoder.java @@ -7,9 +7,10 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.SimBoolean; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * Class for supporting duty cycle/PWM encoders, such as the US Digital MA3 with PWM Output, the diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java index 2c9a204590..6f7aacdabd 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java @@ -11,8 +11,9 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.util.AllocationException; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class to read quadrature encoders. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java index 43393ee613..133e5af399 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java @@ -8,8 +8,9 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.PWMConfigDataResult; import edu.wpi.first.hal.PWMJNI; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class implements the PWM generation in the FPGA. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java index c8f70e69a9..af31aeaaf1 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java @@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.PDPJNI; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Class for getting voltage, current, temperature, power and energy from the Power Distribution diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java index 3c2543fbe9..afb5d03d6e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java @@ -10,8 +10,9 @@ 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.UncleanStatusException; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +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; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java index 7251efc68d..f11f8f92d4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java @@ -6,8 +6,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** * Standard hobby style servo. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java index a6ee4725fa..d660f269c7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java @@ -6,8 +6,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.Objects; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SpeedControllerGroup.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SpeedControllerGroup.java index fe25a9db7c..d2217b77b5 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SpeedControllerGroup.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SpeedControllerGroup.java @@ -4,9 +4,10 @@ package edu.wpi.first.wpilibj; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.motorcontrol.MotorController; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.util.Arrays; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java index 346ddb9738..e57976d188 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -12,8 +12,9 @@ import edu.wpi.first.hal.SimBoolean; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDevice.Direction; import edu.wpi.first.hal.SimDouble; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.ArrayList; import java.util.List; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/PIDController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/PIDController.java index 61ed62c5be..f5282133fc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/PIDController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/PIDController.java @@ -7,9 +7,9 @@ package edu.wpi.first.wpilibj.controller; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.math.MathUtil; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** Implements a PID control loop. */ public class PIDController implements Sendable, AutoCloseable { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/ProfiledPIDController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/ProfiledPIDController.java index 802100382f..34a32dda71 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/ProfiledPIDController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/controller/ProfiledPIDController.java @@ -8,8 +8,8 @@ import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.trajectory.TrapezoidProfile; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; /** * Implements a PID control loop whose setpoint is constrained by a trapezoid profile. Users should diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java index a6b35e16b8..1d94b44f54 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java @@ -10,10 +10,10 @@ import edu.wpi.first.hal.FRCNetComm.tInstances; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.math.MathUtil; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.SpeedController; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * A class for driving differential drive/skid-steer drive platforms such as the Kit of Parts drive diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/KilloughDrive.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/KilloughDrive.java index 7536897521..9b629dc373 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/KilloughDrive.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/KilloughDrive.java @@ -10,10 +10,10 @@ import edu.wpi.first.hal.FRCNetComm.tInstances; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.math.MathUtil; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.SpeedController; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * A class for driving Killough drive platforms. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java index 4b6b10355d..637d83e8e9 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java @@ -10,10 +10,10 @@ import edu.wpi.first.hal.FRCNetComm.tInstances; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; import edu.wpi.first.math.MathUtil; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.SpeedController; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** * A class for driving Mecanum drive platforms. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java index 74129368c1..ff3e8ef5fe 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java @@ -7,8 +7,9 @@ package edu.wpi.first.wpilibj.livewindow; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl; /** * The LiveWindow class is the public interface for putting sensors and actuators on the LiveWindow. @@ -31,6 +32,10 @@ public class LiveWindow { private static Runnable enabledListener; private static Runnable disabledListener; + static { + SendableRegistry.setLiveWindowBuilderFactory(() -> new SendableBuilderImpl()); + } + private static Component getOrAdd(Sendable sendable) { Component data = (Component) SendableRegistry.getData(sendable, dataHandle); if (data == null) { @@ -84,7 +89,7 @@ public class LiveWindow { SendableRegistry.foreachLiveWindow( dataHandle, cbdata -> { - cbdata.builder.stopLiveWindowMode(); + ((SendableBuilderImpl) cbdata.builder).stopLiveWindowMode(); }); if (disabledListener != null) { disabledListener.run(); @@ -173,7 +178,7 @@ public class LiveWindow { table = ssTable.getSubTable(cbdata.name); } table.getEntry(".name").setString(cbdata.name); - cbdata.builder.setTable(table); + ((SendableBuilderImpl) cbdata.builder).setTable(table); cbdata.sendable.initSendable(cbdata.builder); ssTable.getEntry(".type").setString("LW Subsystem"); @@ -181,9 +186,9 @@ public class LiveWindow { } if (startLiveWindow) { - cbdata.builder.startLiveWindowMode(); + ((SendableBuilderImpl) cbdata.builder).startLiveWindowMode(); } - cbdata.builder.updateTable(); + cbdata.builder.update(); }); startLiveWindow = false; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java index 8c74870dfb..714aac5c85 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java @@ -4,9 +4,9 @@ package edu.wpi.first.wpilibj.motorcontrol; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +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; /** Allows multiple {@link MotorController} objects to be linked together. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java index c23827c8af..13daf68996 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/NidecBrushless.java @@ -6,12 +6,12 @@ package edu.wpi.first.wpilibj.motorcontrol; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.DigitalOutput; import edu.wpi.first.wpilibj.MotorSafety; import edu.wpi.first.wpilibj.PWM; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** Nidec Brushless Motor. */ public class NidecBrushless extends MotorSafety diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java index 34e712102c..378e78ac9c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java @@ -4,11 +4,11 @@ package edu.wpi.first.wpilibj.motorcontrol; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import edu.wpi.first.wpilibj.MotorSafety; import edu.wpi.first.wpilibj.PWM; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** Common base class for all PWM Motor Controllers. */ public abstract class PWMMotorController extends MotorSafety diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ComplexWidget.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ComplexWidget.java index 0349b7e672..0f2de32c85 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ComplexWidget.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ComplexWidget.java @@ -5,8 +5,7 @@ package edu.wpi.first.wpilibj.shuffleboard; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; +import edu.wpi.first.util.sendable.Sendable; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl; /** @@ -31,7 +30,7 @@ public final class ComplexWidget extends ShuffleboardWidget { m_sendable.initSendable(m_builder); m_builder.startListeners(); } - m_builder.updateTable(); + m_builder.update(); } /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ContainerHelper.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ContainerHelper.java index f5b6714704..58ac678474 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ContainerHelper.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ContainerHelper.java @@ -5,8 +5,8 @@ package edu.wpi.first.wpilibj.shuffleboard; import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java index b80831c786..ee723031c1 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java @@ -5,9 +5,9 @@ package edu.wpi.first.wpilibj.shuffleboard; import edu.wpi.first.cscore.VideoSource; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.Map; import java.util.WeakHashMap; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardContainer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardContainer.java index 98231503e1..7495534e5e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardContainer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardContainer.java @@ -5,7 +5,7 @@ package edu.wpi.first.wpilibj.shuffleboard; import edu.wpi.first.cscore.VideoSource; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; import java.util.List; import java.util.NoSuchElementException; import java.util.function.BooleanSupplier; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardLayout.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardLayout.java index 2234215dc0..726f9cc72a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardLayout.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardLayout.java @@ -7,7 +7,7 @@ package edu.wpi.first.wpilibj.shuffleboard; import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; import java.util.List; import java.util.NoSuchElementException; import java.util.function.BooleanSupplier; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTab.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTab.java index de53bac5c4..172d86fe35 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTab.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardTab.java @@ -5,7 +5,7 @@ package edu.wpi.first.wpilibj.shuffleboard; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; import java.util.List; import java.util.NoSuchElementException; import java.util.function.BooleanSupplier; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Field2d.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Field2d.java index 3064f74870..f83ee07fcd 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Field2d.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Field2d.java @@ -6,8 +6,10 @@ package edu.wpi.first.wpilibj.smartdashboard; import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.ArrayList; import java.util.List; @@ -27,7 +29,7 @@ import java.util.List; * using the getObject() function. Other objects can also have multiple poses (which will show the * object at multiple locations). */ -public class Field2d implements Sendable { +public class Field2d implements NTSendable { /** Constructor. */ public Field2d() { FieldObject2d obj = new FieldObject2d("Robot"); @@ -98,7 +100,7 @@ public class Field2d implements Sendable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("Field2d"); m_table = builder.getTable(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Mechanism2d.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Mechanism2d.java index 3646efeab9..e16bbd253b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Mechanism2d.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/Mechanism2d.java @@ -4,8 +4,9 @@ package edu.wpi.first.wpilibj.smartdashboard; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.util.Color8Bit; import java.util.HashMap; import java.util.Map; @@ -21,7 +22,7 @@ import java.util.Map.Entry; * @see MechanismLigament2d * @see MechanismRoot2d */ -public final class Mechanism2d implements Sendable { +public final class Mechanism2d implements NTSendable { private static final String kBackgroundColor = "backgroundColor"; private NetworkTable m_table; private final Map m_roots; @@ -89,7 +90,7 @@ public final class Mechanism2d implements Sendable { } @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("Mechanism2d"); m_table = builder.getTable(); m_table.getEntry("dims").setDoubleArray(m_dims); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java index 0dbb7ed6f1..a14ee7dc46 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java @@ -5,6 +5,7 @@ package edu.wpi.first.wpilibj.smartdashboard; import edu.wpi.first.networktables.EntryListenerFlags; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableValue; @@ -17,7 +18,7 @@ import java.util.function.DoubleSupplier; import java.util.function.Function; import java.util.function.Supplier; -public class SendableBuilderImpl implements SendableBuilder { +public class SendableBuilderImpl implements NTSendableBuilder { private static class Property { Property(NetworkTable table, String key) { m_entry = table.getEntry(key); @@ -80,7 +81,8 @@ public class SendableBuilderImpl implements SendableBuilder { * * @return True if it has a table, false if not. */ - public boolean hasTable() { + @Override + public boolean isPublished() { return m_table != null; } @@ -94,7 +96,8 @@ public class SendableBuilderImpl implements SendableBuilder { } /** Update the network table values by calling the getters for all properties. */ - public void updateTable() { + @Override + public void update() { for (Property property : m_properties) { if (property.m_update != null) { property.m_update.accept(property.m_entry); @@ -148,6 +151,7 @@ public class SendableBuilderImpl implements SendableBuilder { } /** Clear properties. */ + @Override public void clearProperties() { stopListeners(); m_properties.clear(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java index ac4d52033f..2614edfa32 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java @@ -6,8 +6,10 @@ package edu.wpi.first.wpilibj.smartdashboard; import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; +import edu.wpi.first.networktables.NTSendable; +import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -27,7 +29,7 @@ import java.util.concurrent.locks.ReentrantLock; * * @param The type of the values to be stored */ -public class SendableChooser implements Sendable, AutoCloseable { +public class SendableChooser implements NTSendable, AutoCloseable { /** The key for the default value. */ private static final String DEFAULT = "default"; /** The key for the selected option. */ @@ -130,7 +132,7 @@ public class SendableChooser implements Sendable, AutoCloseable { private final ReentrantLock m_mutex = new ReentrantLock(); @Override - public void initSendable(SendableBuilder builder) { + public void initSendable(NTSendableBuilder builder) { builder.setSmartDashboardType("String Chooser"); builder.getEntry(INSTANCE).setDouble(m_instance); builder.addStringProperty(DEFAULT, () -> m_defaultChoice, null); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java index 9aef88b840..be5684b4e5 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java @@ -9,7 +9,8 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; -import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableRegistry; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; @@ -58,7 +59,10 @@ public final class SmartDashboard { if (sddata == null || sddata != data) { tablesToData.put(key, data); NetworkTable dataTable = table.getSubTable(key); - SendableRegistry.publish(data, dataTable); + SendableBuilderImpl builder = new SendableBuilderImpl(); + builder.setTable(dataTable); + SendableRegistry.publish(data, builder); + builder.startListeners(); dataTable.getEntry(".name").setString(key); } } diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/shuffleboard/MockActuatorSendable.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/shuffleboard/MockActuatorSendable.java index 5822118554..04397c2c4c 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/shuffleboard/MockActuatorSendable.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/shuffleboard/MockActuatorSendable.java @@ -4,9 +4,9 @@ package edu.wpi.first.wpilibj.shuffleboard; -import edu.wpi.first.wpilibj.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; +import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.util.sendable.SendableBuilder; +import edu.wpi.first.util.sendable.SendableRegistry; /** A mock sendable that marks itself as an actuator. */ public class MockActuatorSendable implements Sendable { diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java index fe9cd6f9d4..98cf4cb09c 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java @@ -127,7 +127,7 @@ public class PIDTest extends AbstractComsSetup { reference, m_controller.getPositionError(), 0); - m_builder.updateTable(); + m_builder.update(); assertEquals(k_p, m_table.getEntry("Kp").getDouble(9999999), 0); assertEquals(k_i, m_table.getEntry("Ki").getDouble(9999999), 0); assertEquals(k_d, m_table.getEntry("Kd").getDouble(9999999), 0); diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java index 91685efc70..cc520c3f8b 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java @@ -49,7 +49,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { public void testBothHigh() { m_relayFixture.getRelay().setDirection(Direction.kBoth); m_relayFixture.getRelay().set(Value.kOn); - m_builder.updateTable(); + m_builder.update(); assertTrue( "Input one was not high when relay set both high", m_relayFixture.getInputOne().get()); assertTrue( @@ -62,7 +62,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { public void testFirstHigh() { m_relayFixture.getRelay().setDirection(Direction.kBoth); m_relayFixture.getRelay().set(Value.kForward); - m_builder.updateTable(); + m_builder.update(); assertFalse( "Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne().get()); assertTrue( @@ -75,7 +75,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { public void testSecondHigh() { m_relayFixture.getRelay().setDirection(Direction.kBoth); m_relayFixture.getRelay().set(Value.kReverse); - m_builder.updateTable(); + m_builder.update(); assertTrue( "Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne().get()); assertFalse( @@ -88,7 +88,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { public void testForwardDirection() { m_relayFixture.getRelay().setDirection(Direction.kForward); m_relayFixture.getRelay().set(Value.kOn); - m_builder.updateTable(); + m_builder.update(); assertFalse( "Input one was not low when relay set Value.kOn in kForward Direction", m_relayFixture.getInputOne().get()); @@ -103,7 +103,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { public void testReverseDirection() { m_relayFixture.getRelay().setDirection(Direction.kReverse); m_relayFixture.getRelay().set(Value.kOn); - m_builder.updateTable(); + m_builder.update(); assertTrue( "Input one was not high when relay set Value.kOn in kReverse Direction", m_relayFixture.getInputOne().get()); @@ -128,7 +128,7 @@ public class RelayCrossConnectTest extends AbstractComsSetup { @Test public void testInitialSettings() { - m_builder.updateTable(); + m_builder.update(); assertEquals(Value.kOff, m_relayFixture.getRelay().get()); // Initially both outputs should be off assertFalse(m_relayFixture.getInputOne().get()); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Sendable.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/Sendable.java similarity index 77% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/Sendable.java rename to wpiutil/src/main/java/edu/wpi/first/util/sendable/Sendable.java index eb57341c35..ad1fe28d09 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Sendable.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/Sendable.java @@ -2,11 +2,9 @@ // 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; +package edu.wpi.first.util.sendable; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; - -/** The base interface for objects that can be sent over the network through network tables. */ +/** The base interface for objects that can be sent over the network. */ public interface Sendable { /** * Initializes this {@link Sendable} object. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java similarity index 75% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java rename to wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java index 46d965d58e..7d5bcf4835 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java @@ -2,11 +2,8 @@ // 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.smartdashboard; +package edu.wpi.first.util.sendable; -import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.networktables.NetworkTableValue; import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.DoubleConsumer; @@ -14,12 +11,11 @@ import java.util.function.DoubleSupplier; import java.util.function.Supplier; public interface SendableBuilder { - /** - * Get the network table. - * - * @return The network table - */ - NetworkTable getTable(); + /** The backend kinds used for the sendable builder. */ + enum BackendKind { + kUnknown, + kNetworkTables + } /** * Set the string representation of the named data type that will be used by the smart dashboard @@ -45,24 +41,6 @@ public interface SendableBuilder { */ void setSafeState(Runnable func); - /** - * Set the function that should be called to update the network table for things other than - * properties. Note this function is not passed the network table object; instead it should use - * the entry handles returned by getEntry(). - * - * @param func function - */ - void setUpdateTable(Runnable func); - - /** - * Add a property without getters or setters. This can be used to get entry handles for the - * function called by setUpdateTable(). - * - * @param key property name - * @return Network table entry - */ - NetworkTableEntry getEntry(String key); - /** * Represents an operation that accepts a single boolean-valued argument and returns no result. * This is the primitive type specialization of Consumer for boolean. Unlike most other functional @@ -144,12 +122,22 @@ public interface SendableBuilder { void addRawProperty(String key, Supplier getter, Consumer setter); /** - * Add a NetworkTableValue property. + * Gets the kind of backend being used. * - * @param key property name - * @param getter getter function (returns current value) - * @param setter setter function (sets new value) + * @return Backend kind */ - void addValueProperty( - String key, Supplier getter, Consumer setter); + BackendKind getBackendKind(); + + /** + * Return whether this sendable has been published. + * + * @return True if it has been published, false if not. + */ + boolean isPublished(); + + /** Update the published values by calling the getters for all properties. */ + void update(); + + /** Clear properties. */ + void clearProperties(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableRegistry.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java similarity index 91% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableRegistry.java rename to wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java index 86fb408c1f..e37c32efa9 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableRegistry.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableRegistry.java @@ -2,11 +2,8 @@ // 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.smartdashboard; +package edu.wpi.first.util.sendable; -import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.wpilibj.DriverStation; -import edu.wpi.first.wpilibj.Sendable; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; @@ -14,6 +11,7 @@ import java.util.List; import java.util.Map; import java.util.WeakHashMap; import java.util.function.Consumer; +import java.util.function.Supplier; /** * The SendableRegistry class is the public interface for registering sensors and actuators for use @@ -28,7 +26,7 @@ public class SendableRegistry { } WeakReference m_sendable; - SendableBuilderImpl m_builder = new SendableBuilderImpl(); + SendableBuilder m_builder; String m_name; String m_subsystem = "Ungrouped"; WeakReference m_parent; @@ -44,6 +42,7 @@ public class SendableRegistry { } } + private static Supplier liveWindowFactory; private static final Map components = new WeakHashMap<>(); private static int nextDataHandle; @@ -64,6 +63,15 @@ public class SendableRegistry { throw new UnsupportedOperationException("This is a utility class!"); } + /** + * Sets the factory for LiveWindow builders. + * + * @param factory factory function + */ + public static synchronized void setLiveWindowBuilderFactory(Supplier factory) { + liveWindowFactory = factory; + } + /** * Adds an object to the registry. * @@ -122,6 +130,9 @@ public class SendableRegistry { */ public static synchronized void addLW(Sendable sendable, String name) { Component comp = getOrAdd(sendable); + if (liveWindowFactory != null) { + comp.m_builder = liveWindowFactory.get(); + } comp.m_liveWindow = true; comp.m_name = name; } @@ -135,6 +146,9 @@ public class SendableRegistry { */ public static synchronized void addLW(Sendable sendable, String moduleType, int channel) { Component comp = getOrAdd(sendable); + if (liveWindowFactory != null) { + comp.m_builder = liveWindowFactory.get(); + } comp.m_liveWindow = true; comp.setName(moduleType, channel); } @@ -150,6 +164,9 @@ public class SendableRegistry { public static synchronized void addLW( Sendable sendable, String moduleType, int moduleNumber, int channel) { Component comp = getOrAdd(sendable); + if (liveWindowFactory != null) { + comp.m_builder = liveWindowFactory.get(); + } comp.m_liveWindow = true; comp.setName(moduleType, moduleNumber, channel); } @@ -163,6 +180,9 @@ public class SendableRegistry { */ public static synchronized void addLW(Sendable sendable, String subsystem, String name) { Component comp = getOrAdd(sendable); + if (liveWindowFactory != null) { + comp.m_builder = liveWindowFactory.get(); + } comp.m_liveWindow = true; comp.m_name = name; comp.m_subsystem = subsystem; @@ -377,18 +397,19 @@ public class SendableRegistry { } /** - * Publishes an object in the registry to a network table. + * Publishes an object in the registry to a builder. * * @param sendable object - * @param table network table + * @param builder sendable builder */ - public static synchronized void publish(Sendable sendable, NetworkTable table) { + public static synchronized void publish(Sendable sendable, SendableBuilder builder) { Component comp = getOrAdd(sendable); - comp.m_builder.clearProperties(); - comp.m_builder.setTable(table); + if (comp.m_builder != null) { + comp.m_builder.clearProperties(); + } + comp.m_builder = builder; // clear any current builder sendable.initSendable(comp.m_builder); - comp.m_builder.updateTable(); - comp.m_builder.startListeners(); + comp.m_builder.update(); } /** @@ -398,8 +419,8 @@ public class SendableRegistry { */ public static synchronized void update(Sendable sendable) { Component comp = components.get(sendable); - if (comp != null) { - comp.m_builder.updateTable(); + if (comp != null && comp.m_builder != null) { + comp.m_builder.update(); } } @@ -427,7 +448,7 @@ public class SendableRegistry { /** Sendable builder for the sendable. */ @SuppressWarnings("MemberName") - public SendableBuilderImpl builder; + public SendableBuilder builder; } // As foreachLiveWindow is single threaded, cache the components it @@ -448,7 +469,7 @@ public class SendableRegistry { foreachComponents.clear(); foreachComponents.addAll(components.values()); for (Component comp : foreachComponents) { - if (comp.m_sendable == null) { + if (comp.m_builder == null || comp.m_sendable == null) { continue; } cbdata.sendable = comp.m_sendable.get(); @@ -473,12 +494,11 @@ public class SendableRegistry { if (cause != null) { throwable = cause; } - DriverStation.reportError( + System.out.println( "Unhandled exception calling LiveWindow for " + comp.m_name + ": " - + throwable.toString(), - false); + + throwable.toString()); comp.m_liveWindow = false; } if (cbdata.data != null) { diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp b/wpiutil/src/main/native/cpp/sendable/SendableRegistry.cpp similarity index 88% rename from wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp rename to wpiutil/src/main/native/cpp/sendable/SendableRegistry.cpp index 1d6b03798e..f975aaae21 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp +++ b/wpiutil/src/main/native/cpp/sendable/SendableRegistry.cpp @@ -2,25 +2,24 @@ // 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/smartdashboard/SendableRegistry.h" +#include "wpi/sendable/SendableRegistry.h" #include -#include -#include -#include -#include -#include +#include "fmt/format.h" +#include "wpi/DenseMap.h" +#include "wpi/SmallVector.h" +#include "wpi/UidVector.h" +#include "wpi/mutex.h" +#include "wpi/sendable/Sendable.h" +#include "wpi/sendable/SendableBuilder.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableBuilderImpl.h" - -using namespace frc; +using namespace wpi; struct SendableRegistry::Impl { struct Component { Sendable* sendable = nullptr; - SendableBuilderImpl builder; + std::unique_ptr builder; std::string name; std::string subsystem = "Ungrouped"; Sendable* parent = nullptr; @@ -38,6 +37,7 @@ struct SendableRegistry::Impl { wpi::recursive_mutex mutex; + std::function()> liveWindowFactory; wpi::UidVector, 32> components; wpi::DenseMap componentMap; int nextDataHandle = 0; @@ -63,6 +63,11 @@ SendableRegistry& SendableRegistry::GetInstance() { return instance; } +void SendableRegistry::SetLiveWindowBuilderFactory( + std::function()> factory) { + m_impl->liveWindowFactory = std::move(factory); +} + void SendableRegistry::Add(Sendable* sendable, std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); @@ -99,6 +104,9 @@ void SendableRegistry::AddLW(Sendable* sendable, std::string_view name) { std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; + if (m_impl->liveWindowFactory) { + comp.builder = m_impl->liveWindowFactory(); + } comp.liveWindow = true; comp.name = name; } @@ -108,6 +116,9 @@ void SendableRegistry::AddLW(Sendable* sendable, std::string_view moduleType, std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; + if (m_impl->liveWindowFactory) { + comp.builder = m_impl->liveWindowFactory(); + } comp.liveWindow = true; comp.SetName(moduleType, channel); } @@ -117,6 +128,9 @@ void SendableRegistry::AddLW(Sendable* sendable, std::string_view moduleType, std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; + if (m_impl->liveWindowFactory) { + comp.builder = m_impl->liveWindowFactory(); + } comp.liveWindow = true; comp.SetName(moduleType, moduleNumber, channel); } @@ -126,6 +140,9 @@ void SendableRegistry::AddLW(Sendable* sendable, std::string_view subsystem, std::scoped_lock lock(m_impl->mutex); auto& comp = m_impl->GetOrAdd(sendable); comp.sendable = sendable; + if (m_impl->liveWindowFactory) { + comp.builder = m_impl->liveWindowFactory(); + } comp.liveWindow = true; comp.name = name; comp.subsystem = subsystem; @@ -173,10 +190,10 @@ void SendableRegistry::Move(Sendable* to, Sendable* from) { m_impl->componentMap[to] = compUid; auto& comp = *m_impl->components[compUid - 1]; comp.sendable = to; - if (comp.builder.HasTable()) { + if (comp.builder && comp.builder->IsPublished()) { // rebuild builder, as lambda captures can point to "from" - comp.builder.ClearProperties(); - to->InitSendable(comp.builder); + comp.builder->ClearProperties(); + to->InitSendable(*comp.builder); } // update any parent pointers for (auto&& comp : m_impl->components) { @@ -349,18 +366,16 @@ Sendable* SendableRegistry::GetSendable(UID uid) { } void SendableRegistry::Publish(UID sendableUid, - std::shared_ptr table) { + std::unique_ptr builder) { std::scoped_lock lock(m_impl->mutex); if (sendableUid == 0 || (sendableUid - 1) >= m_impl->components.size() || !m_impl->components[sendableUid - 1]) { return; } auto& comp = *m_impl->components[sendableUid - 1]; - comp.builder = SendableBuilderImpl{}; // clear any current builder - comp.builder.SetTable(table); - comp.sendable->InitSendable(comp.builder); - comp.builder.UpdateTable(); - comp.builder.StartListeners(); + comp.builder = std::move(builder); // clear any current builder + comp.sendable->InitSendable(*comp.builder); + comp.builder->Update(); } void SendableRegistry::Update(UID sendableUid) { @@ -372,7 +387,9 @@ void SendableRegistry::Update(UID sendableUid) { !m_impl->components[sendableUid - 1]) { return; } - m_impl->components[sendableUid - 1]->builder.UpdateTable(); + if (m_impl->components[sendableUid - 1]->builder) { + m_impl->components[sendableUid - 1]->builder->Update(); + } } void SendableRegistry::ForeachLiveWindow( @@ -385,13 +402,13 @@ void SendableRegistry::ForeachLiveWindow( components.emplace_back(comp.get()); } for (auto comp : components) { - if (comp && comp->sendable && comp->liveWindow) { + if (comp && comp->builder && comp->sendable && comp->liveWindow) { if (static_cast(dataHandle) >= comp->data.size()) { comp->data.resize(dataHandle + 1); } CallbackData cbdata{comp->sendable, comp->name, comp->subsystem, comp->parent, - comp->data[dataHandle], comp->builder}; + comp->data[dataHandle], *comp->builder}; callback(cbdata); } } diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h b/wpiutil/src/main/native/include/wpi/sendable/Sendable.h similarity index 93% rename from wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h rename to wpiutil/src/main/native/include/wpi/sendable/Sendable.h index a4c0ffec6b..84ebc06b2d 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h +++ b/wpiutil/src/main/native/include/wpi/sendable/Sendable.h @@ -4,7 +4,7 @@ #pragma once -namespace frc { +namespace wpi { class SendableBuilder; @@ -23,4 +23,4 @@ class Sendable { virtual void InitSendable(SendableBuilder& builder) = 0; }; -} // namespace frc +} // namespace wpi diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h b/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h similarity index 82% rename from wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h rename to wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h index e7bc2d09ab..e092a1ef50 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilder.h +++ b/wpiutil/src/main/native/include/wpi/sendable/SendableBuilder.h @@ -10,16 +10,18 @@ #include #include -#include -#include -#include -#include -#include +#include "wpi/SmallVector.h" +#include "wpi/span.h" -namespace frc { +namespace wpi { class SendableBuilder { public: + /** + * The backend kinds used for the sendable builder. + */ + enum BackendKind { kUnknown, kNetworkTables }; + virtual ~SendableBuilder() = default; /** @@ -46,25 +48,6 @@ class SendableBuilder { */ virtual void SetSafeState(std::function func) = 0; - /** - * Set the function that should be called to update the network table - * for things other than properties. Note this function is not passed - * the network table object; instead it should use the entry handles - * returned by GetEntry(). - * - * @param func function - */ - virtual void SetUpdateTable(std::function func) = 0; - - /** - * Add a property without getters or setters. This can be used to get - * entry handles for the function called by SetUpdateTable(). - * - * @param key property name - * @return Network table entry - */ - virtual nt::NetworkTableEntry GetEntry(std::string_view key) = 0; - /** * Add a boolean property. * @@ -142,17 +125,6 @@ class SendableBuilder { std::function getter, std::function setter) = 0; - /** - * Add a NetworkTableValue property. - * - * @param key property name - * @param getter getter function (returns current value) - * @param setter setter function (sets new value) - */ - virtual void AddValueProperty( - std::string_view key, std::function()> getter, - std::function)> setter) = 0; - /** * Add a string property (SmallString form). * @@ -218,10 +190,28 @@ class SendableBuilder { std::function setter) = 0; /** - * Get the network table. - * @return The network table + * Gets the kind of backend being used. + * + * @return Backend kind */ - virtual std::shared_ptr GetTable() = 0; + virtual BackendKind GetBackendKind() const = 0; + + /** + * Return whether this sendable has been published. + * + * @return True if it has been published, false if not. + */ + virtual bool IsPublished() const = 0; + + /** + * Update the published values by calling the getters for all properties. + */ + virtual void Update() = 0; + + /** + * Clear properties. + */ + virtual void ClearProperties() = 0; }; -} // namespace frc +} // namespace wpi diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h b/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h similarity index 97% rename from wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h rename to wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h index 44b628a0a2..1a2831e7cb 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h +++ b/wpiutil/src/main/native/include/wpi/sendable/SendableHelper.h @@ -8,11 +8,10 @@ #include #include -#include +#include "wpi/deprecated.h" +#include "wpi/sendable/SendableRegistry.h" -#include "frc/smartdashboard/SendableRegistry.h" - -namespace frc { +namespace wpi { /** * A helper class for use with objects that add themselves to SendableRegistry. @@ -173,4 +172,4 @@ class SendableHelper { } }; -} // namespace frc +} // namespace wpi diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h b/wpiutil/src/main/native/include/wpi/sendable/SendableRegistry.h similarity index 92% rename from wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h rename to wpiutil/src/main/native/include/wpi/sendable/SendableRegistry.h index 2109ec245f..8324cc93a2 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableRegistry.h +++ b/wpiutil/src/main/native/include/wpi/sendable/SendableRegistry.h @@ -4,17 +4,17 @@ #pragma once +#include #include #include #include -#include -#include +#include "wpi/function_ref.h" -namespace frc { +namespace wpi { class Sendable; -class SendableBuilderImpl; +class SendableBuilder; /** * The SendableRegistry class is the public interface for registering sensors @@ -35,6 +35,14 @@ class SendableRegistry { */ static SendableRegistry& GetInstance(); + /** + * Sets the factory for LiveWindow builders. + * + * @param factory factory function + */ + void SetLiveWindowBuilderFactory( + std::function()> factory); + /** * Adds an object to the registry. * @@ -280,15 +288,15 @@ class SendableRegistry { Sendable* GetSendable(UID uid); /** - * Publishes an object in the registry to a network table. + * Publishes an object in the registry. * * @param sendableUid sendable unique id - * @param table network table + * @param builder publisher backend */ - void Publish(UID sendableUid, std::shared_ptr table); + void Publish(UID sendableUid, std::unique_ptr builder); /** - * Updates network table information from an object. + * Updates published information from an object. * * @param sendableUid sendable unique id */ @@ -299,8 +307,8 @@ class SendableRegistry { */ struct CallbackData { CallbackData(Sendable* sendable_, std::string_view name_, - std::string_view subsystem_, Sendable* parent_, - std::shared_ptr& data_, SendableBuilderImpl& builder_) + std::string_view subsystem_, wpi::Sendable* parent_, + std::shared_ptr& data_, SendableBuilder& builder_) : sendable(sendable_), name(name_), subsystem(subsystem_), @@ -313,7 +321,7 @@ class SendableRegistry { std::string_view subsystem; Sendable* parent; std::shared_ptr& data; - SendableBuilderImpl& builder; + SendableBuilder& builder; }; /** @@ -335,4 +343,4 @@ class SendableRegistry { std::unique_ptr m_impl; }; -} // namespace frc +} // namespace wpi