mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Enhance Command Sendable implementations (#4822)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "frc2/command/ConditionalCommand.h"
|
||||
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
ConditionalCommand::ConditionalCommand(std::unique_ptr<Command>&& onTrue,
|
||||
@@ -50,3 +52,21 @@ bool ConditionalCommand::IsFinished() {
|
||||
bool ConditionalCommand::RunsWhenDisabled() const {
|
||||
return m_runsWhenDisabled;
|
||||
}
|
||||
|
||||
void ConditionalCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"onTrue", [this] { return m_onTrue->GetName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
"onFalse", [this] { return m_onFalse->GetName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
"selected",
|
||||
[this] {
|
||||
if (m_selectedCommand) {
|
||||
return m_selectedCommand->GetName();
|
||||
} else {
|
||||
return std::string{"null"};
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user