Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Dec 20, 2024
1 parent 95a8ae5 commit 0d215d8
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public void initSendable(SendableBuilder builder) {
value -> {
if (value) {
if (!isScheduled()) {
schedule();
CommandScheduler.getInstance().schedule(this);
}
} else {
if (isScheduled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Trigger Trigger::OnChange(Command* command) {
Trigger Trigger::OnChange(CommandPtr&& command) {
AddBinding([command = std::move(command)](bool previous, bool current) {
if (previous != current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
});
return *this;
Expand All @@ -56,7 +56,7 @@ Trigger Trigger::OnTrue(Command* command) {
Trigger Trigger::OnTrue(CommandPtr&& command) {
AddBinding([command = std::move(command)](bool previous, bool current) {
if (!previous && current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
});
return *this;
Expand All @@ -74,7 +74,7 @@ Trigger Trigger::OnFalse(Command* command) {
Trigger Trigger::OnFalse(CommandPtr&& command) {
AddBinding([command = std::move(command)](bool previous, bool current) {
if (previous && !current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
});
return *this;
Expand All @@ -94,7 +94,7 @@ Trigger Trigger::WhileTrue(Command* command) {
Trigger Trigger::WhileTrue(CommandPtr&& command) {
AddBinding([command = std::move(command)](bool previous, bool current) {
if (!previous && current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
} else if (previous && !current) {
command.Cancel();
}
Expand All @@ -116,7 +116,7 @@ Trigger Trigger::WhileFalse(Command* command) {
Trigger Trigger::WhileFalse(CommandPtr&& command) {
AddBinding([command = std::move(command)](bool previous, bool current) {
if (!previous && current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
} else if (previous && !current) {
command.Cancel();
}
Expand All @@ -143,7 +143,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) {
if (command.IsScheduled()) {
command.Cancel();
} else {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}
});
Expand All @@ -169,7 +169,7 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
if (command.IsScheduled()) {
command.Cancel();
} else {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ class CommandPtr final {

/**
* Schedules this command.
*
* @deprecated Use CommandScheduler::GetInstance().Schedule() instead
*/
[[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]]
void Schedule() const&;

// Prevent calls on a temporary, as the returned pointer would be invalid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TEST_F(CommandSendableButtonTest, falseAndNotScheduledNoOp) {

TEST_F(CommandSendableButtonTest, falseAndScheduledCancel) {
// Scheduled and false -> cancel
frc2::CommandScheduler::GetInstance().Schedule(m_command);
frc2::CommandScheduler::GetInstance().Schedule(m_command.value());
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
EXPECT_TRUE(m_command->IsScheduled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_robot.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}

Expand Down

0 comments on commit 0d215d8

Please sign in to comment.