SCRIPT Move java files

This commit is contained in:
PJ Reiniger
2025-11-07 19:55:40 -05:00
committed by Peter Johnson
parent 7ca1be9bae
commit c350c5f112
1486 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
// 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.wpilibj2.command;
import static edu.wpi.first.units.Units.Seconds;
import edu.wpi.first.units.measure.Time;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.util.sendable.SendableRegistry;
import edu.wpi.first.wpilibj.Timer;
/**
* A command that does nothing but takes a specified amount of time to finish.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class WaitCommand extends Command {
/** The timer used for waiting. */
protected Timer m_timer = new Timer();
private final double m_duration;
/**
* Creates a new WaitCommand. This command will do nothing, and end after the specified duration.
*
* @param seconds the time to wait, in seconds
*/
@SuppressWarnings("this-escape")
public WaitCommand(double seconds) {
m_duration = seconds;
SendableRegistry.setName(this, getName() + ": " + seconds + " seconds");
}
/**
* Creates a new WaitCommand. This command will do nothing, and end after the specified duration.
*
* @param time the time to wait
*/
public WaitCommand(Time time) {
this(time.in(Seconds));
}
@Override
public void initialize() {
m_timer.restart();
}
@Override
public void end(boolean interrupted) {
m_timer.stop();
}
@Override
public boolean isFinished() {
return m_timer.hasElapsed(m_duration);
}
@Override
public boolean runsWhenDisabled() {
return true;
}
@Override
public void initSendable(SendableBuilder builder) {
super.initSendable(builder);
builder.addDoubleProperty("duration", () -> m_duration, null);
}
}