[hal] Change usage reporting to string-based (#7763)

This commit is contained in:
Peter Johnson
2025-02-07 12:37:23 -08:00
committed by GitHub
parent bfff891b5c
commit 764ada9b66
188 changed files with 637 additions and 2298 deletions

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDouble;
@@ -134,7 +132,7 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
setRange(range);
HAL.report(tResourceType.kResourceType_ADXL345, tInstances.kADXL345_I2C);
HAL.reportUsage("I2C[" + port.value + "][" + deviceAddress + "]", "ADXL345");
SendableRegistry.add(this, "ADXL345_I2C", port.value);
}

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.AddressableLEDJNI;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.PWMJNI;
@@ -30,7 +29,7 @@ public class AddressableLED implements AutoCloseable {
public AddressableLED(int port) {
m_pwmHandle = PWMJNI.initializePWMPort(port);
m_handle = AddressableLEDJNI.initialize(m_pwmHandle);
HAL.report(tResourceType.kResourceType_AddressableLEDs, port + 1);
HAL.reportUsage("IO", port, "AddressableLED");
}
@Override

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
@@ -25,7 +24,7 @@ public class AnalogAccelerometer implements Sendable, AutoCloseable {
/** Common initialization. */
private void initAccelerometer() {
HAL.report(tResourceType.kResourceType_Accelerometer, m_analogChannel.getChannel() + 1);
HAL.reportUsage("IO", m_analogChannel.getChannel(), "Accelerometer");
SendableRegistry.add(this, "Accelerometer", m_analogChannel.getChannel());
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
@@ -83,6 +84,8 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
m_fullRange = fullRange;
m_expectedZero = expectedZero;
HAL.reportUsage("IO", m_analogInput.getChannel(), "AnalogEncoder");
SendableRegistry.add(this, "Analog Encoder", m_analogInput.getChannel());
}

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.util.sendable.Sendable;
@@ -28,7 +27,7 @@ public class AnalogGyro implements Sendable, AutoCloseable {
/** Initialize the gyro. Calibration is handled by calibrate(). */
private void initGyro() {
HAL.report(tResourceType.kResourceType_Gyro, m_analog.getChannel() + 1);
HAL.reportUsage("AnalogGyro", m_analog.getChannel(), "");
SendableRegistry.add(this, "AnalogGyro", m_analog.getChannel());
}

View File

@@ -5,7 +5,6 @@
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.hal.SimDevice;
import edu.wpi.first.util.sendable.Sendable;
@@ -40,7 +39,7 @@ public class AnalogInput implements Sendable, AutoCloseable {
m_port = AnalogJNI.initializeAnalogInputPort(channel);
HAL.report(tResourceType.kResourceType_AnalogChannel, channel + 1);
HAL.reportUsage("IO", channel, "AnalogInput");
SendableRegistry.add(this, "AnalogInput", channel);
}

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.CANAPIJNI;
import edu.wpi.first.hal.CANAPITypes;
import edu.wpi.first.hal.CANData;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import java.io.Closeable;
@@ -37,8 +36,7 @@ public class CAN implements Closeable {
* @param deviceId The device id
*/
public CAN(int deviceId) {
m_handle = CANAPIJNI.initializeCAN(kTeamManufacturer, deviceId, kTeamDeviceType);
HAL.report(tResourceType.kResourceType_CAN, deviceId + 1);
this(kTeamManufacturer, deviceId, kTeamDeviceType);
}
/**
@@ -51,7 +49,7 @@ public class CAN implements Closeable {
*/
public CAN(int deviceId, int deviceManufacturer, int deviceType) {
m_handle = CANAPIJNI.initializeCAN(deviceManufacturer, deviceId, deviceType);
HAL.report(tResourceType.kResourceType_CAN, deviceId + 1);
HAL.reportUsage("CAN[" + deviceType + "][" + deviceManufacturer + "][" + deviceId + "]", "");
}
/** Closes the CAN communication. */

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.util.AllocationException;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
@@ -44,7 +42,7 @@ public class Compressor implements Sendable, AutoCloseable {
m_module.enableCompressorDigital();
HAL.report(tResourceType.kResourceType_Compressor, module + 1);
m_module.reportUsage("Compressor", "");
SendableRegistry.add(this, "Compressor", module);
}

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
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.NetworkTableInstance;
import edu.wpi.first.util.FileLogger;
@@ -247,7 +245,7 @@ public final class DataLogManager {
if (!new File("/u/logs").mkdir()) {
// ignored
}
HAL.report(tResourceType.kResourceType_DataLogManager, tInstances.kDataLogLocation_USB);
HAL.reportUsage("DataLogManager", "USB");
return "/u/logs";
}
} catch (IOException ex) {
@@ -262,7 +260,7 @@ public final class DataLogManager {
if (!new File("/home/lvuser/logs").mkdir()) {
// ignored
}
HAL.report(tResourceType.kResourceType_DataLogManager, tInstances.kDataLogLocation_Onboard);
HAL.reportUsage("DataLogManager", "Onboard");
return "/home/lvuser/logs";
}
String logDir = Filesystem.getOperatingDirectory().getAbsolutePath() + "/logs";

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.wpilibj;
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.util.sendable.Sendable;
@@ -34,7 +33,7 @@ public class DigitalInput implements AutoCloseable, Sendable {
m_handle = DIOJNI.initializeDIOPort(channel, true);
HAL.report(tResourceType.kResourceType_DigitalInput, channel + 1);
HAL.reportUsage("IO", channel, "DigitalInput");
SendableRegistry.add(this, "DigitalInput", channel);
}

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.wpilibj;
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.util.sendable.Sendable;
@@ -36,7 +35,7 @@ public class DigitalOutput implements AutoCloseable, Sendable {
m_handle = DIOJNI.initializeDIOPort(channel, false);
HAL.report(tResourceType.kResourceType_DigitalOutput, channel + 1);
HAL.reportUsage("IO", channel, "DigitalOutput");
SendableRegistry.add(this, "DigitalOutput", channel);
}

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.util.AllocationException;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
@@ -95,10 +93,8 @@ public class DoubleSolenoid implements Sendable, AutoCloseable {
}
allocatedSolenoids = true;
HAL.report(
tResourceType.kResourceType_Solenoid, forwardChannel + 1, m_module.getModuleNumber() + 1);
HAL.report(
tResourceType.kResourceType_Solenoid, reverseChannel + 1, m_module.getModuleNumber() + 1);
m_module.reportUsage(
"Solenoid[" + forwardChannel + "," + reverseChannel + "]", "DoubleSolenoid");
SendableRegistry.add(this, "DoubleSolenoid", m_module.getModuleNumber(), forwardChannel);
successfulCompletion = true;
} finally {

View File

@@ -5,7 +5,6 @@
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.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
@@ -35,7 +34,7 @@ public class DutyCycle implements Sendable, AutoCloseable {
m_handle = DutyCycleJNI.initialize(channel);
m_channel = channel;
HAL.report(tResourceType.kResourceType_DutyCycle, channel + 1);
HAL.reportUsage("IO", channel, "DutyCycle");
SendableRegistry.add(this, "Duty Cycle", channel);
}

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.EncoderJNI;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.util.sendable.Sendable;
@@ -46,8 +45,16 @@ public class Encoder implements CounterBase, Sendable, AutoCloseable {
int aChannel, int bChannel, boolean reverseDirection, final EncodingType type) {
m_encoder = EncoderJNI.initializeEncoder(aChannel, bChannel, reverseDirection, type.value);
String typeStr =
switch (type) {
case k1X -> "Encoder:1x";
case k2X -> "Encoder:2x";
case k4X -> "Encoder:4x";
default -> "Encoder";
};
HAL.reportUsage("IO[" + aChannel + "," + bChannel + "]", typeStr);
int fpgaIndex = getFPGAIndex();
HAL.report(tResourceType.kResourceType_Encoder, fpgaIndex + 1, type.value + 1);
SendableRegistry.add(this, "Encoder", fpgaIndex);
}

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.I2CJNI;
import edu.wpi.first.hal.util.BoundaryException;
@@ -49,7 +48,7 @@ public class I2C implements AutoCloseable {
I2CJNI.i2CInitialize((byte) port.value);
HAL.report(tResourceType.kResourceType_I2C, deviceAddress);
HAL.reportUsage("I2C[" + port.value + "][" + deviceAddress + "]", "");
}
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.event.BooleanEvent;
import edu.wpi.first.wpilibj.event.EventLoop;
@@ -84,7 +83,7 @@ public class Joystick extends GenericHID {
m_axes[AxisType.kTwist.value] = kDefaultTwistChannel;
m_axes[AxisType.kThrottle.value] = kDefaultThrottleChannel;
HAL.report(tResourceType.kResourceType_Joystick, port + 1);
HAL.reportUsage("HID", port, "Joystick");
}
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj;
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;
@@ -65,7 +64,7 @@ public class PWM implements Sendable, AutoCloseable {
PWMJNI.setPWMEliminateDeadband(m_handle, false);
HAL.report(tResourceType.kResourceType_PWM, channel + 1);
HAL.reportUsage("IO", channel, "PWM");
if (registerSendable) {
SendableRegistry.add(this, "PWM", channel);
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.PortsJNI;
import edu.wpi.first.hal.REVPHFaults;
import edu.wpi.first.hal.REVPHJNI;
@@ -438,4 +439,9 @@ public class PneumaticHub implements PneumaticsBase {
public double getSolenoidsVoltage() {
return REVPHJNI.getSolenoidVoltage(m_handle);
}
@Override
public void reportUsage(String device, String data) {
HAL.reportUsage("PH[" + m_dataStore.m_module + "]/" + device, data);
}
}

View File

@@ -245,4 +245,12 @@ public interface PneumaticsBase extends AutoCloseable {
* @return Compressor object
*/
Compressor makeCompressor();
/**
* Report usage.
*
* @param device device and channel as appropriate
* @param data arbitrary usage data
*/
void reportUsage(String device, String data);
}

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.CTREPCMJNI;
import edu.wpi.first.hal.HAL;
import java.util.HashMap;
import java.util.Map;
@@ -344,4 +345,9 @@ public class PneumaticsControlModule implements PneumaticsBase {
public double getPressure(int channel) {
return 0;
}
@Override
public void reportUsage(String device, String data) {
HAL.reportUsage("PCM[" + m_dataStore.m_module + "]/" + device, data);
}
}

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.PowerDistributionFaults;
import edu.wpi.first.hal.PowerDistributionJNI;
@@ -53,9 +51,9 @@ public class PowerDistribution implements Sendable, AutoCloseable {
m_module = PowerDistributionJNI.getModuleNumber(m_handle);
if (moduleType == ModuleType.kCTRE) {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_CTRE);
HAL.reportUsage("PDP", m_module, "");
} else {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
HAL.reportUsage("PDH", m_module, "");
}
SendableRegistry.add(this, "PowerDistribution", m_module);
}
@@ -71,9 +69,9 @@ public class PowerDistribution implements Sendable, AutoCloseable {
m_module = PowerDistributionJNI.getModuleNumber(m_handle);
if (PowerDistributionJNI.getType(m_handle) == PowerDistributionJNI.CTRE_TYPE) {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_CTRE);
HAL.reportUsage("PowerDistribution", m_module, "CTRE");
} else {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
HAL.reportUsage("PowerDistribution", m_module, "Rev");
}
SendableRegistry.add(this, "PowerDistribution", m_module);

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.networktables.MultiSubscriber;
import edu.wpi.first.networktables.NetworkTable;
@@ -51,7 +50,7 @@ public final class Preferences {
static {
setNetworkTableInstance(NetworkTableInstance.getDefault());
HAL.report(tResourceType.kResourceType_Preferences, 0);
HAL.reportUsage("Preferences", "");
}
/**

View File

@@ -6,13 +6,10 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.cameraserver.CameraServerShared;
import edu.wpi.first.cameraserver.CameraServerSharedStore;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.HALUtil;
import edu.wpi.first.math.MathShared;
import edu.wpi.first.math.MathSharedStore;
import edu.wpi.first.math.MathUsageId;
import edu.wpi.first.networktables.MultiSubscriber;
import edu.wpi.first.networktables.NetworkTableEvent;
import edu.wpi.first.networktables.NetworkTableInstance;
@@ -44,19 +41,12 @@ public abstract class RobotBase implements AutoCloseable {
private final int m_connListenerHandle;
private boolean m_dashboardDetected;
private static void setupCameraServerShared() {
CameraServerShared shared =
new CameraServerShared() {
@Override
public void reportVideoServer(int id) {
HAL.report(tResourceType.kResourceType_PCVideoServer, id + 1);
}
@Override
public void reportUsbCamera(int id) {
HAL.report(tResourceType.kResourceType_UsbCamera, id + 1);
public void reportUsage(String resource, String data) {
HAL.reportUsage(resource, data);
}
@Override
@@ -64,11 +54,6 @@ public abstract class RobotBase implements AutoCloseable {
DriverStation.reportError(error, true);
}
@Override
public void reportAxisCamera(int id) {
HAL.report(tResourceType.kResourceType_AxisCamera, id + 1);
}
@Override
public Long getRobotMainThreadId() {
return RobotBase.getMainThreadId();
@@ -92,35 +77,8 @@ public abstract class RobotBase implements AutoCloseable {
}
@Override
public void reportUsage(MathUsageId id, int count) {
switch (id) {
case kKinematics_DifferentialDrive -> HAL.report(
tResourceType.kResourceType_Kinematics, tInstances.kKinematics_DifferentialDrive);
case kKinematics_MecanumDrive -> HAL.report(
tResourceType.kResourceType_Kinematics, tInstances.kKinematics_MecanumDrive);
case kKinematics_SwerveDrive -> HAL.report(
tResourceType.kResourceType_Kinematics, tInstances.kKinematics_SwerveDrive);
case kTrajectory_TrapezoidProfile -> HAL.report(
tResourceType.kResourceType_TrapezoidProfile, count);
case kFilter_Linear -> HAL.report(tResourceType.kResourceType_LinearFilter, count);
case kOdometry_DifferentialDrive -> HAL.report(
tResourceType.kResourceType_Odometry, tInstances.kOdometry_DifferentialDrive);
case kOdometry_SwerveDrive -> HAL.report(
tResourceType.kResourceType_Odometry, tInstances.kOdometry_SwerveDrive);
case kOdometry_MecanumDrive -> HAL.report(
tResourceType.kResourceType_Odometry, tInstances.kOdometry_MecanumDrive);
case kController_PIDController2 -> HAL.report(
tResourceType.kResourceType_PIDController2, count);
case kController_ProfiledPIDController -> HAL.report(
tResourceType.kResourceType_ProfiledPIDController, count);
case kController_BangBangController -> HAL.report(
tResourceType.kResourceType_BangBangController, count);
case kTrajectory_PathWeaver -> HAL.report(
tResourceType.kResourceType_PathWeaverTrajectory, count);
default -> {
// NOP
}
}
public void reportUsage(String resource, String data) {
HAL.reportUsage(resource, data);
}
@Override
@@ -170,57 +128,7 @@ public abstract class RobotBase implements AutoCloseable {
false,
event -> {
if (event.is(NetworkTableEvent.Kind.kConnected)) {
if (event.connInfo.remote_id.startsWith("glass")) {
HAL.report(tResourceType.kResourceType_Dashboard, tInstances.kDashboard_Glass);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("SmartDashboard")) {
HAL.report(
tResourceType.kResourceType_Dashboard, tInstances.kDashboard_SmartDashboard);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("shuffleboard")) {
HAL.report(
tResourceType.kResourceType_Dashboard, tInstances.kDashboard_Shuffleboard);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("elastic")
|| event.connInfo.remote_id.startsWith("Elastic")) {
HAL.report(tResourceType.kResourceType_Dashboard, tInstances.kDashboard_Elastic);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("Dashboard")) {
HAL.report(tResourceType.kResourceType_Dashboard, tInstances.kDashboard_LabVIEW);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("AdvantageScope")) {
HAL.report(
tResourceType.kResourceType_Dashboard, tInstances.kDashboard_AdvantageScope);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("QFRCDashboard")) {
HAL.report(
tResourceType.kResourceType_Dashboard, tInstances.kDashboard_QFRCDashboard);
m_dashboardDetected = true;
} else if (event.connInfo.remote_id.startsWith("FRC Web Components")) {
HAL.report(
tResourceType.kResourceType_Dashboard,
tInstances.kDashboard_FRCWebComponents);
m_dashboardDetected = true;
} else {
// Only report unknown if there wasn't another dashboard already reported
// (unknown could also be another device)
if (!m_dashboardDetected) {
int delim = event.connInfo.remote_id.indexOf('@');
if (delim != -1) {
HAL.report(
tResourceType.kResourceType_Dashboard,
tInstances.kDashboard_Unknown,
0,
event.connInfo.remote_id.substring(0, delim));
} else {
HAL.report(
tResourceType.kResourceType_Dashboard,
tInstances.kDashboard_Unknown,
0,
event.connInfo.remote_id);
}
}
}
HAL.reportUsage("NT/" + event.connInfo.remote_id, "");
}
});
}
@@ -471,8 +379,8 @@ public abstract class RobotBase implements AutoCloseable {
// Force refresh DS data
DriverStation.refreshData();
HAL.report(
tResourceType.kResourceType_Language, tInstances.kLanguage_Java, 0, WPILibVersion.Version);
HAL.reportUsage("Language", "Java");
HAL.reportUsage("WPILibVersion", WPILibVersion.Version);
if (!Notifier.setHALThreadPriority(true, 40)) {
DriverStation.reportWarning("Setting HAL Notifier RT priority to 40 failed", false);

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SerialPortJNI;
import java.nio.charset.StandardCharsets;
@@ -134,7 +133,7 @@ public class SerialPort implements AutoCloseable {
disableTermination();
HAL.report(tResourceType.kResourceType_SerialPort, port.value + 1);
HAL.reportUsage("SerialPort", port.value, "");
}
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.util.sendable.SendableRegistry;
@@ -37,7 +36,7 @@ public class Servo extends PWM {
setBoundsMicroseconds(kDefaultMaxServoPWM, 0, 0, 0, kDefaultMinServoPWM);
setPeriodMultiplier(PeriodMultiplier.k4X);
HAL.report(tResourceType.kResourceType_Servo, getChannel() + 1);
HAL.reportUsage("IO", getChannel(), "Servo");
SendableRegistry.setName(this, "Servo", getChannel());
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDevice.Direction;
import edu.wpi.first.hal.SimDouble;
@@ -89,6 +90,7 @@ public class SharpIR implements Sendable, AutoCloseable {
m_minCM = minCM;
m_maxCM = maxCM;
HAL.reportUsage("IO", channel, "SharpIR");
SendableRegistry.add(this, "SharpIR", channel);
m_simDevice = SimDevice.create("SharpIR", m_sensor.getChannel());

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.util.AllocationException;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
@@ -56,7 +54,7 @@ public class Solenoid implements Sendable, AutoCloseable {
throw new AllocationException("Solenoid already allocated");
}
HAL.report(tResourceType.kResourceType_Solenoid, channel + 1, m_module.getModuleNumber() + 1);
m_module.reportUsage("Solenoid[" + channel + "]", "Solenoid");
SendableRegistry.add(this, "Solenoid", m_module.getModuleNumber(), channel);
}

View File

@@ -7,8 +7,6 @@ package edu.wpi.first.wpilibj;
import static edu.wpi.first.units.Units.Seconds;
import edu.wpi.first.hal.DriverStationJNI;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.NotifierJNI;
import edu.wpi.first.units.measure.Time;
@@ -92,7 +90,7 @@ public class TimedRobot extends IterativeRobotBase {
addPeriodic(this::loopFunc, period);
NotifierJNI.setNotifierName(m_notifier, "TimedRobot");
HAL.report(tResourceType.kResourceType_Framework, tInstances.kFramework_Timed);
HAL.reportUsage("Framework", "TimedRobot");
}
@Override

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.wpilibj.counter;
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;
@@ -33,7 +32,7 @@ public class Tachometer implements Sendable, AutoCloseable {
public Tachometer(int channel, EdgeConfiguration configuration) {
m_handle = CounterJNI.initializeCounter(channel, configuration.rising);
HAL.report(tResourceType.kResourceType_Counter, channel + 1);
HAL.reportUsage("IO", channel, "Tachometer");
SendableRegistry.add(this, "Tachometer", channel);
}

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.wpilibj.counter;
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;
@@ -32,7 +31,7 @@ public class UpDownCounter implements Sendable, AutoCloseable {
reset();
HAL.report(tResourceType.kResourceType_Counter, channel);
HAL.reportUsage("IO", channel, "UpDownCounter");
SendableRegistry.add(this, "UpDown Counter", channel);
}

View File

@@ -6,8 +6,6 @@ package edu.wpi.first.wpilibj.drive;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
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.util.sendable.Sendable;
@@ -157,8 +155,7 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
*/
public void arcadeDrive(double xSpeed, double zRotation, boolean squareInputs) {
if (!m_reported) {
HAL.report(
tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive2_DifferentialArcade, 2);
HAL.reportUsage("RobotDrive", "DifferentialArcade");
m_reported = true;
}
@@ -189,8 +186,7 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
*/
public void curvatureDrive(double xSpeed, double zRotation, boolean allowTurnInPlace) {
if (!m_reported) {
HAL.report(
tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive2_DifferentialCurvature, 2);
HAL.reportUsage("RobotDrive", "DifferentialCurvature");
m_reported = true;
}
@@ -230,8 +226,7 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
*/
public void tankDrive(double leftSpeed, double rightSpeed, boolean squareInputs) {
if (!m_reported) {
HAL.report(
tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive2_DifferentialTank, 2);
HAL.reportUsage("RobotDrive", "DifferentialTank");
m_reported = true;
}

View File

@@ -6,8 +6,6 @@ package edu.wpi.first.wpilibj.drive;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
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.math.geometry.Rotation2d;
@@ -196,8 +194,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
*/
public void driveCartesian(double xSpeed, double ySpeed, double zRotation, Rotation2d gyroAngle) {
if (!m_reported) {
HAL.report(
tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive2_MecanumCartesian, 4);
HAL.reportUsage("RobotDrive", "MecanumCartesian");
m_reported = true;
}
@@ -232,7 +229,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
*/
public void drivePolar(double magnitude, Rotation2d angle, double zRotation) {
if (!m_reported) {
HAL.report(tResourceType.kResourceType_RobotDrive, tInstances.kRobotDrive2_MecanumPolar, 4);
HAL.reportUsage("RobotDrive", "MecanumPolar");
m_reported = true;
}

View File

@@ -4,7 +4,6 @@
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;
@@ -45,7 +44,7 @@ public class NidecBrushless extends MotorSafety
m_pwm = new PWM(pwmChannel);
SendableRegistry.addChild(this, m_pwm);
HAL.report(tResourceType.kResourceType_NidecBrushless, pwmChannel + 1);
HAL.reportUsage("IO[" + pwmChannel + "," + dioChannel + "]", "NidecBrushless");
SendableRegistry.add(this, "Nidec Brushless", pwmChannel);
}

View File

@@ -4,8 +4,6 @@
package edu.wpi.first.wpilibj.smartdashboard;
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.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
@@ -67,7 +65,7 @@ public final class SmartDashboard {
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public static synchronized void putData(String key, Sendable data) {
if (!m_reported) {
HAL.report(tResourceType.kResourceType_SmartDashboard, tInstances.kSmartDashboard_Instance);
HAL.reportUsage("SmartDashboard", "");
m_reported = true;
}
Sendable sddata = tablesToData.get(key);
@@ -121,7 +119,7 @@ public final class SmartDashboard {
*/
public static NetworkTableEntry getEntry(String key) {
if (!m_reported) {
HAL.report(tResourceType.kResourceType_SmartDashboard, tInstances.kSmartDashboard_Instance);
HAL.reportUsage("SmartDashboard", "");
m_reported = true;
}
return table.getEntry(key);