mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Add GetName to Subsystem, use in Scheduler tracer epochs (#5836)
This commit is contained in:
@@ -261,7 +261,7 @@ public final class CommandScheduler implements Sendable, AutoCloseable {
|
||||
if (RobotBase.isSimulation()) {
|
||||
subsystem.simulationPeriodic();
|
||||
}
|
||||
m_watchdog.addEpoch(subsystem.getClass().getSimpleName() + ".periodic()");
|
||||
m_watchdog.addEpoch(subsystem.getName() + ".periodic()");
|
||||
}
|
||||
|
||||
// Cache the active instance to avoid concurrency problems if setActiveLoop() is called from
|
||||
|
||||
@@ -40,6 +40,15 @@ public interface Subsystem {
|
||||
*/
|
||||
default void simulationPeriodic() {}
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
default String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default {@link Command} of the subsystem. The default command will be automatically
|
||||
* scheduled when no other commands are scheduled that require the subsystem. Default commands
|
||||
|
||||
@@ -28,6 +28,7 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return SendableRegistry.getName(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user